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
@@ -1,217 +1,217 @@
1
- import * as fs from "fs";
2
- import * as path from "path";
3
- import * as os from "os";
4
-
5
- // ============================================================================
6
- // Types for opencode.json structure
7
- // ============================================================================
8
-
9
- export interface ModelLimit {
10
- context: number;
11
- output: number;
12
- }
13
-
14
- export interface ModelModalities {
15
- input: string[];
16
- output: string[];
17
- }
18
-
19
- export interface ModelVariant {
20
- thinkingLevel?: string;
21
- thinkingConfig?: {
22
- thinkingBudget?: number;
23
- };
24
- }
25
-
26
- export interface ModelConfig {
27
- name: string;
28
- limit?: ModelLimit;
29
- modalities?: ModelModalities;
30
- variants?: Record<string, ModelVariant>;
31
- }
32
-
33
- export interface ProviderConfig {
34
- npm?: string;
35
- name?: string;
36
- options?: {
37
- baseURL?: string;
38
- apiKey?: string;
39
- };
40
- models: Record<string, ModelConfig>;
41
- }
42
-
43
- export interface McpServerConfig {
44
- type: "local" | "remote";
45
- command?: string[];
46
- url?: string;
47
- environment?: Record<string, string>;
48
- enabled?: boolean;
49
- }
50
-
51
- export interface OpencodeConfig {
52
- $schema?: string;
53
- plugin?: string[];
54
- mcp?: Record<string, McpServerConfig>;
55
- provider?: Record<string, ProviderConfig>;
56
- }
57
-
58
- // ============================================================================
59
- // Parsed/Display structures
60
- // ============================================================================
61
-
62
- export interface ProviderInfo {
63
- id: string;
64
- name: string;
65
- modelCount: number;
66
- models: string[];
67
- type: "builtin" | "custom";
68
- baseURL?: string;
69
- }
70
-
71
- export interface McpServerInfo {
72
- id: string;
73
- command: string;
74
- enabled: boolean;
75
- hasEnvVars: boolean;
76
- envVarCount: number;
77
- }
78
-
79
- export interface PluginInfo {
80
- name: string;
81
- version?: string;
82
- }
83
-
84
- export interface OpencodeInfo {
85
- configPath: string;
86
- exists: boolean;
87
- providers: ProviderInfo[];
88
- mcpServers: McpServerInfo[];
89
- plugins: PluginInfo[];
90
- totalModels: number;
91
- }
92
-
93
- // ============================================================================
94
- // Functions
95
- // ============================================================================
96
-
97
- /**
98
- * Get the path to opencode.json
99
- */
100
- export function getOpencodeConfigPath(): string {
101
- const home = os.homedir();
102
- // Check .config/opencode first (Unix-style)
103
- const unixPath = path.join(home, ".config", "opencode", "opencode.json");
104
- if (fs.existsSync(unixPath)) {
105
- return unixPath;
106
- }
107
- // Fallback to AppData on Windows
108
- const appData = process.env.APPDATA || path.join(home, "AppData", "Roaming");
109
- return path.join(appData, "opencode", "opencode.json");
110
- }
111
-
112
- /**
113
- * Read and parse opencode.json
114
- */
115
- export function readOpencodeConfig(configPath?: string): OpencodeConfig | null {
116
- const resolvedPath = configPath || getOpencodeConfigPath();
117
-
118
- if (!fs.existsSync(resolvedPath)) {
119
- return null;
120
- }
121
-
122
- try {
123
- const content = fs.readFileSync(resolvedPath, "utf-8");
124
- return JSON.parse(content) as OpencodeConfig;
125
- } catch {
126
- return null;
127
- }
128
- }
129
-
130
- /**
131
- * Parse opencode.json into display-friendly info
132
- */
133
- export function parseOpencodeInfo(configPath?: string): OpencodeInfo {
134
- const resolvedPath = configPath || getOpencodeConfigPath();
135
- const config = readOpencodeConfig(resolvedPath);
136
-
137
- const info: OpencodeInfo = {
138
- configPath: resolvedPath,
139
- exists: config !== null,
140
- providers: [],
141
- mcpServers: [],
142
- plugins: [],
143
- totalModels: 0,
144
- };
145
-
146
- if (!config) {
147
- return info;
148
- }
149
-
150
- // Parse plugins
151
- if (config.plugin) {
152
- info.plugins = config.plugin.map((p) => {
153
- const match = p.match(/^(.+?)(@(.+))?$/);
154
- return {
155
- name: match?.[1] || p,
156
- version: match?.[3],
157
- };
158
- });
159
- }
160
-
161
- // Parse MCP servers
162
- if (config.mcp) {
163
- info.mcpServers = Object.entries(config.mcp).map(([id, server]) => {
164
- const cmd = server.command?.join(" ") || server.url || "N/A";
165
- return {
166
- id,
167
- command: cmd,
168
- enabled: server.enabled !== false,
169
- hasEnvVars: !!server.environment,
170
- envVarCount: server.environment ? Object.keys(server.environment).length : 0,
171
- };
172
- });
173
- }
174
-
175
- // Parse providers
176
- if (config.provider) {
177
- info.providers = Object.entries(config.provider).map(([id, provider]) => {
178
- const modelIds = Object.keys(provider.models);
179
- const isBuiltin = id === "google" && !provider.npm;
180
-
181
- return {
182
- id,
183
- name: provider.name || id,
184
- modelCount: modelIds.length,
185
- models: modelIds,
186
- type: isBuiltin ? "builtin" : "custom",
187
- baseURL: provider.options?.baseURL,
188
- };
189
- });
190
-
191
- info.totalModels = info.providers.reduce((sum, p) => sum + p.modelCount, 0);
192
- }
193
-
194
- return info;
195
- }
196
-
197
- /**
198
- * Get summary stats
199
- */
200
- export function getConfigSummary(info: OpencodeInfo): {
201
- providers: number;
202
- models: number;
203
- mcpEnabled: number;
204
- mcpDisabled: number;
205
- plugins: number;
206
- } {
207
- const mcpEnabled = info.mcpServers.filter((m) => m.enabled).length;
208
- const mcpDisabled = info.mcpServers.length - mcpEnabled;
209
-
210
- return {
211
- providers: info.providers.length,
212
- models: info.totalModels,
213
- mcpEnabled,
214
- mcpDisabled,
215
- plugins: info.plugins.length,
216
- };
217
- }
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ import * as os from "os";
4
+
5
+ // ============================================================================
6
+ // Types for opencode.json structure
7
+ // ============================================================================
8
+
9
+ export interface ModelLimit {
10
+ context: number;
11
+ output: number;
12
+ }
13
+
14
+ export interface ModelModalities {
15
+ input: string[];
16
+ output: string[];
17
+ }
18
+
19
+ export interface ModelVariant {
20
+ thinkingLevel?: string;
21
+ thinkingConfig?: {
22
+ thinkingBudget?: number;
23
+ };
24
+ }
25
+
26
+ export interface ModelConfig {
27
+ name: string;
28
+ limit?: ModelLimit;
29
+ modalities?: ModelModalities;
30
+ variants?: Record<string, ModelVariant>;
31
+ }
32
+
33
+ export interface ProviderConfig {
34
+ npm?: string;
35
+ name?: string;
36
+ options?: {
37
+ baseURL?: string;
38
+ apiKey?: string;
39
+ };
40
+ models: Record<string, ModelConfig>;
41
+ }
42
+
43
+ export interface McpServerConfig {
44
+ type: "local" | "remote";
45
+ command?: string[];
46
+ url?: string;
47
+ environment?: Record<string, string>;
48
+ enabled?: boolean;
49
+ }
50
+
51
+ export interface OpencodeConfig {
52
+ $schema?: string;
53
+ plugin?: string[];
54
+ mcp?: Record<string, McpServerConfig>;
55
+ provider?: Record<string, ProviderConfig>;
56
+ }
57
+
58
+ // ============================================================================
59
+ // Parsed/Display structures
60
+ // ============================================================================
61
+
62
+ export interface ProviderInfo {
63
+ id: string;
64
+ name: string;
65
+ modelCount: number;
66
+ models: string[];
67
+ type: "builtin" | "custom";
68
+ baseURL?: string;
69
+ }
70
+
71
+ export interface McpServerInfo {
72
+ id: string;
73
+ command: string;
74
+ enabled: boolean;
75
+ hasEnvVars: boolean;
76
+ envVarCount: number;
77
+ }
78
+
79
+ export interface PluginInfo {
80
+ name: string;
81
+ version?: string;
82
+ }
83
+
84
+ export interface OpencodeInfo {
85
+ configPath: string;
86
+ exists: boolean;
87
+ providers: ProviderInfo[];
88
+ mcpServers: McpServerInfo[];
89
+ plugins: PluginInfo[];
90
+ totalModels: number;
91
+ }
92
+
93
+ // ============================================================================
94
+ // Functions
95
+ // ============================================================================
96
+
97
+ /**
98
+ * Get the path to opencode.json
99
+ */
100
+ export function getOpencodeConfigPath(): string {
101
+ const home = os.homedir();
102
+ // Check .config/opencode first (Unix-style)
103
+ const unixPath = path.join(home, ".config", "opencode", "opencode.json");
104
+ if (fs.existsSync(unixPath)) {
105
+ return unixPath;
106
+ }
107
+ // Fallback to AppData on Windows
108
+ const appData = process.env.APPDATA || path.join(home, "AppData", "Roaming");
109
+ return path.join(appData, "opencode", "opencode.json");
110
+ }
111
+
112
+ /**
113
+ * Read and parse opencode.json
114
+ */
115
+ export function readOpencodeConfig(configPath?: string): OpencodeConfig | null {
116
+ const resolvedPath = configPath || getOpencodeConfigPath();
117
+
118
+ if (!fs.existsSync(resolvedPath)) {
119
+ return null;
120
+ }
121
+
122
+ try {
123
+ const content = fs.readFileSync(resolvedPath, "utf-8");
124
+ return JSON.parse(content) as OpencodeConfig;
125
+ } catch {
126
+ return null;
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Parse opencode.json into display-friendly info
132
+ */
133
+ export function parseOpencodeInfo(configPath?: string): OpencodeInfo {
134
+ const resolvedPath = configPath || getOpencodeConfigPath();
135
+ const config = readOpencodeConfig(resolvedPath);
136
+
137
+ const info: OpencodeInfo = {
138
+ configPath: resolvedPath,
139
+ exists: config !== null,
140
+ providers: [],
141
+ mcpServers: [],
142
+ plugins: [],
143
+ totalModels: 0,
144
+ };
145
+
146
+ if (!config) {
147
+ return info;
148
+ }
149
+
150
+ // Parse plugins
151
+ if (config.plugin) {
152
+ info.plugins = config.plugin.map((p) => {
153
+ const match = p.match(/^(.+?)(@(.+))?$/);
154
+ return {
155
+ name: match?.[1] || p,
156
+ version: match?.[3],
157
+ };
158
+ });
159
+ }
160
+
161
+ // Parse MCP servers
162
+ if (config.mcp) {
163
+ info.mcpServers = Object.entries(config.mcp).map(([id, server]) => {
164
+ const cmd = server.command?.join(" ") || server.url || "N/A";
165
+ return {
166
+ id,
167
+ command: cmd,
168
+ enabled: server.enabled !== false,
169
+ hasEnvVars: !!server.environment,
170
+ envVarCount: server.environment ? Object.keys(server.environment).length : 0,
171
+ };
172
+ });
173
+ }
174
+
175
+ // Parse providers
176
+ if (config.provider) {
177
+ info.providers = Object.entries(config.provider).map(([id, provider]) => {
178
+ const modelIds = Object.keys(provider.models);
179
+ const isBuiltin = id === "google" && !provider.npm;
180
+
181
+ return {
182
+ id,
183
+ name: provider.name || id,
184
+ modelCount: modelIds.length,
185
+ models: modelIds,
186
+ type: isBuiltin ? "builtin" : "custom",
187
+ baseURL: provider.options?.baseURL,
188
+ };
189
+ });
190
+
191
+ info.totalModels = info.providers.reduce((sum, p) => sum + p.modelCount, 0);
192
+ }
193
+
194
+ return info;
195
+ }
196
+
197
+ /**
198
+ * Get summary stats
199
+ */
200
+ export function getConfigSummary(info: OpencodeInfo): {
201
+ providers: number;
202
+ models: number;
203
+ mcpEnabled: number;
204
+ mcpDisabled: number;
205
+ plugins: number;
206
+ } {
207
+ const mcpEnabled = info.mcpServers.filter((m) => m.enabled).length;
208
+ const mcpDisabled = info.mcpServers.length - mcpEnabled;
209
+
210
+ return {
211
+ providers: info.providers.length,
212
+ models: info.totalModels,
213
+ mcpEnabled,
214
+ mcpDisabled,
215
+ plugins: info.plugins.length,
216
+ };
217
+ }
package/src/core/paths.ts CHANGED
@@ -24,9 +24,13 @@ export function getAmFolderPath(): string {
24
24
  return path.join(os.homedir(), ".antigravity_tools");
25
25
  }
26
26
 
27
- export function getAmDbPath(customPath?: string): string {
28
- if (customPath && customPath.trim().length > 0) {
29
- return path.resolve(customPath);
30
- }
31
- return path.join(getConfigRoot(), "antigravity-manager", "accounts.db");
32
- }
27
+ export function getAmDbPath(customPath?: string): string {
28
+ if (customPath && customPath.trim().length > 0) {
29
+ return path.resolve(customPath);
30
+ }
31
+ return path.join(getConfigRoot(), "antigravity-manager", "accounts.db");
32
+ }
33
+
34
+ export function getAntigravityLogsPath(): string {
35
+ return path.join(getConfigRoot(), "opencode", "antigravity-logs");
36
+ }