hive-intelligence 0.1.0 → 0.3.0
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/LICENSE +21 -0
- package/README.md +112 -77
- package/bin/hive.js +25 -0
- package/build/alias-INGXWFCG.js +41 -0
- package/build/alias-INGXWFCG.js.map +1 -0
- package/build/auth-PVT4GTAD.js +233 -0
- package/build/auth-PVT4GTAD.js.map +1 -0
- package/build/cache-US4LSZPI.js +52 -0
- package/build/cache-US4LSZPI.js.map +1 -0
- package/build/chunk-FAFUYZQS.js +280 -0
- package/build/chunk-FAFUYZQS.js.map +1 -0
- package/build/chunk-IWBWPHYY.js +212 -0
- package/build/chunk-IWBWPHYY.js.map +1 -0
- package/build/chunk-LBTLYTZS.js +115 -0
- package/build/chunk-LBTLYTZS.js.map +1 -0
- package/build/chunk-N43VRMVB.js +3108 -0
- package/build/chunk-N43VRMVB.js.map +1 -0
- package/build/chunk-NEKSTV6P.js +911 -0
- package/build/chunk-NEKSTV6P.js.map +1 -0
- package/build/chunk-OK3LSM73.js +22 -0
- package/build/chunk-OK3LSM73.js.map +1 -0
- package/build/chunk-QMRVH5ZP.js +44 -0
- package/build/chunk-QMRVH5ZP.js.map +1 -0
- package/build/chunk-WKVZVQTG.js +66 -0
- package/build/chunk-WKVZVQTG.js.map +1 -0
- package/build/chunk-XQJ6PB2L.js +95 -0
- package/build/chunk-XQJ6PB2L.js.map +1 -0
- package/build/cli.js +3858 -0
- package/build/cli.js.map +1 -0
- package/build/completion-N35TWBLT.js +274 -0
- package/build/completion-N35TWBLT.js.map +1 -0
- package/build/config-2VDB2ZHE.js +100 -0
- package/build/config-2VDB2ZHE.js.map +1 -0
- package/build/config-dir-IEOID7Q6.js +31 -0
- package/build/config-dir-IEOID7Q6.js.map +1 -0
- package/build/doctor-GYP6IHPP.js +231 -0
- package/build/doctor-GYP6IHPP.js.map +1 -0
- package/build/errors-HRGXEUZR.js +17 -0
- package/build/errors-HRGXEUZR.js.map +1 -0
- package/build/format-4OIUGZKY.js +43 -0
- package/build/format-4OIUGZKY.js.map +1 -0
- package/build/init-YOJK6CH2.js +102 -0
- package/build/init-YOJK6CH2.js.map +1 -0
- package/build/namespace-GWTS6U6J.js +13 -0
- package/build/namespace-GWTS6U6J.js.map +1 -0
- package/build/open-FUXYIHFO.js +37 -0
- package/build/open-FUXYIHFO.js.map +1 -0
- package/build/output-6TJ3JTZ7.js +41 -0
- package/build/output-6TJ3JTZ7.js.map +1 -0
- package/build/server.js +14763 -0
- package/build/server.js.map +1 -0
- package/build/telemetry-KNWMQURH.js +18 -0
- package/build/telemetry-KNWMQURH.js.map +1 -0
- package/build/tools-4W3GGCUC.js +178 -0
- package/build/tools-4W3GGCUC.js.map +1 -0
- package/build/version-3TZ3U4IR.js +9 -0
- package/build/version-3TZ3U4IR.js.map +1 -0
- package/build/watch-P2QWGFYV.js +67 -0
- package/build/watch-P2QWGFYV.js.map +1 -0
- package/package.json +56 -15
- package/.env,example +0 -1
- package/dist/client.d.ts +0 -7
- package/dist/client.js +0 -52
- package/dist/errors.d.ts +0 -7
- package/dist/errors.js +0 -15
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -20
- package/dist/types.d.ts +0 -19
- package/dist/types.js +0 -2
- package/example.ts +0 -35
- package/jest.config.js +0 -7
- package/src/client.js +0 -52
- package/src/client.ts +0 -42
- package/src/errors.js +0 -15
- package/src/errors.ts +0 -11
- package/src/index.js +0 -20
- package/src/index.ts +0 -5
- package/src/types.js +0 -2
- package/src/types.ts +0 -21
- package/tests/client.test.js +0 -28
- package/tests/client.test.ts +0 -18
- package/tests/hive.test.js +0 -69
- package/tests/hive.test.ts +0 -63
- package/tsconfig.json +0 -117
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
NAMESPACE
|
|
4
|
+
} from "./chunk-NEKSTV6P.js";
|
|
5
|
+
import "./chunk-QMRVH5ZP.js";
|
|
6
|
+
|
|
7
|
+
// src/cli/completion.ts
|
|
8
|
+
import {
|
|
9
|
+
existsSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
appendFileSync,
|
|
12
|
+
writeFileSync,
|
|
13
|
+
mkdirSync
|
|
14
|
+
} from "fs";
|
|
15
|
+
import { join } from "path";
|
|
16
|
+
import { homedir } from "os";
|
|
17
|
+
function getTopLevel() {
|
|
18
|
+
return [
|
|
19
|
+
"serve",
|
|
20
|
+
"doctor",
|
|
21
|
+
"tools",
|
|
22
|
+
"config",
|
|
23
|
+
"init",
|
|
24
|
+
"completion",
|
|
25
|
+
"auth",
|
|
26
|
+
"status",
|
|
27
|
+
"open",
|
|
28
|
+
"watch",
|
|
29
|
+
"alias",
|
|
30
|
+
"telemetry",
|
|
31
|
+
...NAMESPACE.map((d) => d.name)
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
function getDomainSubs() {
|
|
35
|
+
const subs = {};
|
|
36
|
+
for (const domain of NAMESPACE) {
|
|
37
|
+
subs[domain.name] = domain.commands.map((c) => c.name);
|
|
38
|
+
}
|
|
39
|
+
return subs;
|
|
40
|
+
}
|
|
41
|
+
async function generateCompletion(shell) {
|
|
42
|
+
switch (shell) {
|
|
43
|
+
case "bash":
|
|
44
|
+
return generateBash();
|
|
45
|
+
case "zsh":
|
|
46
|
+
return generateZsh();
|
|
47
|
+
case "fish":
|
|
48
|
+
return generateFish();
|
|
49
|
+
case "powershell":
|
|
50
|
+
return generatePowerShell();
|
|
51
|
+
default:
|
|
52
|
+
console.error(
|
|
53
|
+
`Unsupported shell: ${shell}. Use: bash, zsh, fish, powershell`
|
|
54
|
+
);
|
|
55
|
+
process.exit(2);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function generateBash() {
|
|
59
|
+
const topLevel = getTopLevel();
|
|
60
|
+
const domainSubs = getDomainSubs();
|
|
61
|
+
const cases = Object.entries(domainSubs).map(
|
|
62
|
+
([domain, subs]) => ` ${domain}) COMPREPLY=($(compgen -W "${subs.join(" ")}" -- "$cur")); return ;;`
|
|
63
|
+
).join("\n");
|
|
64
|
+
console.log(`# Hive MCP bash completion
|
|
65
|
+
# Add to ~/.bashrc: eval "$(hive-mcp completion bash)"
|
|
66
|
+
_hive_mcp_completions() {
|
|
67
|
+
local cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
68
|
+
local prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
69
|
+
|
|
70
|
+
case "$prev" in
|
|
71
|
+
${cases}
|
|
72
|
+
tools) COMPREPLY=($(compgen -W "list search info call refresh" -- "$cur")); return ;;
|
|
73
|
+
config) COMPREPLY=($(compgen -W "claude-desktop cursor vscode claude-code http" -- "$cur")); return ;;
|
|
74
|
+
auth) COMPREPLY=($(compgen -W "login logout whoami profiles switch" -- "$cur")); return ;;
|
|
75
|
+
alias) COMPREPLY=($(compgen -W "set list remove" -- "$cur")); return ;;
|
|
76
|
+
telemetry) COMPREPLY=($(compgen -W "enable disable status" -- "$cur")); return ;;
|
|
77
|
+
open) COMPREPLY=($(compgen -W "dashboard docs status github" -- "$cur")); return ;;
|
|
78
|
+
completion) COMPREPLY=($(compgen -W "bash zsh fish powershell install" -- "$cur")); return ;;
|
|
79
|
+
esac
|
|
80
|
+
|
|
81
|
+
COMPREPLY=($(compgen -W "${topLevel.join(" ")}" -- "$cur"))
|
|
82
|
+
}
|
|
83
|
+
complete -F _hive_mcp_completions hive-mcp`);
|
|
84
|
+
}
|
|
85
|
+
function generateZsh() {
|
|
86
|
+
const domainEntries = NAMESPACE.map(
|
|
87
|
+
(d) => ` '${d.name}:${d.description}'`
|
|
88
|
+
).join("\n");
|
|
89
|
+
const subcommandCases = NAMESPACE.map((d) => {
|
|
90
|
+
const subs = d.commands.map((c) => ` '${c.name}:${c.description}'`).join("\n");
|
|
91
|
+
return ` ${d.name})
|
|
92
|
+
local -a subcmds
|
|
93
|
+
subcmds=(
|
|
94
|
+
${subs}
|
|
95
|
+
)
|
|
96
|
+
_describe 'subcommand' subcmds
|
|
97
|
+
;;`;
|
|
98
|
+
}).join("\n");
|
|
99
|
+
console.log(`# Hive MCP zsh completion
|
|
100
|
+
# Add to ~/.zshrc: eval "$(hive-mcp completion zsh)"
|
|
101
|
+
_hive_mcp() {
|
|
102
|
+
local -a commands
|
|
103
|
+
commands=(
|
|
104
|
+
'serve:Start the MCP server'
|
|
105
|
+
'doctor:Diagnose environment and connectivity'
|
|
106
|
+
'tools:Discover and execute tools'
|
|
107
|
+
'config:Generate MCP client configs'
|
|
108
|
+
'init:Interactive API key setup'
|
|
109
|
+
'completion:Generate shell completions'
|
|
110
|
+
'auth:Manage authentication profiles'
|
|
111
|
+
'status:Quick health and version check'
|
|
112
|
+
'open:Open Hive dashboard in browser'
|
|
113
|
+
'watch:Poll a tool on interval'
|
|
114
|
+
'alias:Manage command aliases'
|
|
115
|
+
'telemetry:Control anonymous usage telemetry'
|
|
116
|
+
${domainEntries}
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
if (( CURRENT == 2 )); then
|
|
120
|
+
_describe 'command' commands
|
|
121
|
+
elif (( CURRENT == 3 )); then
|
|
122
|
+
case "\${words[2]}" in
|
|
123
|
+
${subcommandCases}
|
|
124
|
+
tools)
|
|
125
|
+
local -a subcmds
|
|
126
|
+
subcmds=('list:List all tools' 'search:Search tools' 'info:Show tool info' 'call:Execute a tool' 'refresh:Refresh tool cache')
|
|
127
|
+
_describe 'subcommand' subcmds
|
|
128
|
+
;;
|
|
129
|
+
config)
|
|
130
|
+
local -a subcmds
|
|
131
|
+
subcmds=('claude-desktop:Claude Desktop config' 'cursor:Cursor config' 'vscode:VS Code config' 'claude-code:Claude Code config' 'http:HTTP remote config')
|
|
132
|
+
_describe 'subcommand' subcmds
|
|
133
|
+
;;
|
|
134
|
+
auth)
|
|
135
|
+
local -a subcmds
|
|
136
|
+
subcmds=('login:Log in with API key' 'logout:Remove credentials' 'whoami:Show current profile' 'profiles:List all profiles' 'switch:Switch active profile')
|
|
137
|
+
_describe 'subcommand' subcmds
|
|
138
|
+
;;
|
|
139
|
+
alias)
|
|
140
|
+
local -a subcmds
|
|
141
|
+
subcmds=('set:Create an alias' 'list:Show all aliases' 'remove:Delete an alias')
|
|
142
|
+
_describe 'subcommand' subcmds
|
|
143
|
+
;;
|
|
144
|
+
telemetry)
|
|
145
|
+
local -a subcmds
|
|
146
|
+
subcmds=('enable:Enable telemetry' 'disable:Disable telemetry' 'status:Show telemetry status')
|
|
147
|
+
_describe 'subcommand' subcmds
|
|
148
|
+
;;
|
|
149
|
+
open)
|
|
150
|
+
local -a subcmds
|
|
151
|
+
subcmds=('dashboard:Open dashboard' 'docs:Open documentation' 'status:Open status page' 'github:Open GitHub repo')
|
|
152
|
+
_describe 'subcommand' subcmds
|
|
153
|
+
;;
|
|
154
|
+
esac
|
|
155
|
+
fi
|
|
156
|
+
}
|
|
157
|
+
compdef _hive_mcp hive-mcp`);
|
|
158
|
+
}
|
|
159
|
+
function generateFish() {
|
|
160
|
+
const topLevel = getTopLevel();
|
|
161
|
+
const lines = [
|
|
162
|
+
"# Hive MCP fish completion",
|
|
163
|
+
"# Save to: ~/.config/fish/completions/hive-mcp.fish",
|
|
164
|
+
""
|
|
165
|
+
];
|
|
166
|
+
for (const cmd of topLevel) {
|
|
167
|
+
const desc = NAMESPACE.find((d) => d.name === cmd)?.description ?? cmd;
|
|
168
|
+
lines.push(
|
|
169
|
+
`complete -c hive-mcp -n '__fish_use_subcommand' -a '${cmd}' -d '${desc}'`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const domainSubs = getDomainSubs();
|
|
173
|
+
for (const [domain, subs] of Object.entries(domainSubs)) {
|
|
174
|
+
for (const sub of subs) {
|
|
175
|
+
const desc = NAMESPACE.find((d) => d.name === domain)?.commands.find(
|
|
176
|
+
(c) => c.name === sub
|
|
177
|
+
)?.description ?? sub;
|
|
178
|
+
lines.push(
|
|
179
|
+
`complete -c hive-mcp -n '__fish_seen_subcommand_from ${domain}' -a '${sub}' -d '${desc}'`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
for (const sub of ["list", "search", "info", "call", "refresh"]) {
|
|
184
|
+
lines.push(
|
|
185
|
+
`complete -c hive-mcp -n '__fish_seen_subcommand_from tools' -a '${sub}'`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
for (const sub of ["login", "logout", "whoami", "profiles", "switch"]) {
|
|
189
|
+
lines.push(
|
|
190
|
+
`complete -c hive-mcp -n '__fish_seen_subcommand_from auth' -a '${sub}'`
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
for (const sub of ["set", "list", "remove"]) {
|
|
194
|
+
lines.push(
|
|
195
|
+
`complete -c hive-mcp -n '__fish_seen_subcommand_from alias' -a '${sub}'`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
console.log(lines.join("\n"));
|
|
199
|
+
}
|
|
200
|
+
function generatePowerShell() {
|
|
201
|
+
const topLevel = getTopLevel();
|
|
202
|
+
console.log(`# Hive MCP PowerShell completion
|
|
203
|
+
# Add to your $PROFILE: . (hive-mcp completion powershell)
|
|
204
|
+
Register-ArgumentCompleter -Native -CommandName hive-mcp -ScriptBlock {
|
|
205
|
+
param($wordToComplete, $commandAst, $cursorPosition)
|
|
206
|
+
$commands = @(${topLevel.map((c) => `'${c}'`).join(", ")})
|
|
207
|
+
$commands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
|
|
208
|
+
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
|
|
209
|
+
}
|
|
210
|
+
}`);
|
|
211
|
+
}
|
|
212
|
+
async function installCompletion(shell) {
|
|
213
|
+
switch (shell) {
|
|
214
|
+
case "bash": {
|
|
215
|
+
const rcFile = join(homedir(), ".bashrc");
|
|
216
|
+
const line = 'eval "$(hive-mcp completion bash)"';
|
|
217
|
+
if (existsSync(rcFile) && readFileSync(rcFile, "utf-8").includes(line)) {
|
|
218
|
+
process.stderr.write("Bash completion already installed.\n");
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
appendFileSync(rcFile, `
|
|
222
|
+
# Hive MCP CLI completion
|
|
223
|
+
${line}
|
|
224
|
+
`);
|
|
225
|
+
process.stderr.write(
|
|
226
|
+
`Bash completion added to ${rcFile}. Restart your shell.
|
|
227
|
+
`
|
|
228
|
+
);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
case "zsh": {
|
|
232
|
+
const rcFile = join(homedir(), ".zshrc");
|
|
233
|
+
const line = 'eval "$(hive-mcp completion zsh)"';
|
|
234
|
+
if (existsSync(rcFile) && readFileSync(rcFile, "utf-8").includes(line)) {
|
|
235
|
+
process.stderr.write("Zsh completion already installed.\n");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
appendFileSync(rcFile, `
|
|
239
|
+
# Hive MCP CLI completion
|
|
240
|
+
${line}
|
|
241
|
+
`);
|
|
242
|
+
process.stderr.write(
|
|
243
|
+
`Zsh completion added to ${rcFile}. Restart your shell.
|
|
244
|
+
`
|
|
245
|
+
);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
case "fish": {
|
|
249
|
+
const dir = join(homedir(), ".config", "fish", "completions");
|
|
250
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
251
|
+
const filePath = join(dir, "hive-mcp.fish");
|
|
252
|
+
const { execFileSync } = await import("child_process");
|
|
253
|
+
const bin = process.argv[1] ?? "hive-mcp";
|
|
254
|
+
const output = execFileSync(bin, ["completion", "fish"], {
|
|
255
|
+
encoding: "utf-8"
|
|
256
|
+
});
|
|
257
|
+
writeFileSync(filePath, output);
|
|
258
|
+
process.stderr.write(`Fish completion written to ${filePath}.
|
|
259
|
+
`);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
default:
|
|
263
|
+
process.stderr.write(
|
|
264
|
+
`Unsupported shell for install: ${shell}. Use: bash, zsh, fish
|
|
265
|
+
`
|
|
266
|
+
);
|
|
267
|
+
process.exit(2);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
export {
|
|
271
|
+
generateCompletion,
|
|
272
|
+
installCompletion
|
|
273
|
+
};
|
|
274
|
+
//# sourceMappingURL=completion-N35TWBLT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/completion.ts"],"sourcesContent":["import {\n existsSync,\n readFileSync,\n appendFileSync,\n writeFileSync,\n mkdirSync,\n} from \"node:fs\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { NAMESPACE } from \"./namespace.js\";\n\nfunction getTopLevel(): string[] {\n return [\n \"serve\",\n \"doctor\",\n \"tools\",\n \"config\",\n \"init\",\n \"completion\",\n \"auth\",\n \"status\",\n \"open\",\n \"watch\",\n \"alias\",\n \"telemetry\",\n ...NAMESPACE.map((d) => d.name),\n ];\n}\n\nfunction getDomainSubs(): Record<string, string[]> {\n const subs: Record<string, string[]> = {};\n for (const domain of NAMESPACE) {\n subs[domain.name] = domain.commands.map((c) => c.name);\n }\n return subs;\n}\n\nexport async function generateCompletion(shell: string): Promise<void> {\n switch (shell) {\n case \"bash\":\n return generateBash();\n case \"zsh\":\n return generateZsh();\n case \"fish\":\n return generateFish();\n case \"powershell\":\n return generatePowerShell();\n default:\n console.error(\n `Unsupported shell: ${shell}. Use: bash, zsh, fish, powershell`,\n );\n process.exit(2);\n }\n}\n\nfunction generateBash(): void {\n const topLevel = getTopLevel();\n const domainSubs = getDomainSubs();\n\n const cases = Object.entries(domainSubs)\n .map(\n ([domain, subs]) =>\n ` ${domain}) COMPREPLY=($(compgen -W \"${subs.join(\" \")}\" -- \"$cur\")); return ;;`,\n )\n .join(\"\\n\");\n\n console.log(`# Hive MCP bash completion\n# Add to ~/.bashrc: eval \"$(hive-mcp completion bash)\"\n_hive_mcp_completions() {\n local cur=\"\\${COMP_WORDS[COMP_CWORD]}\"\n local prev=\"\\${COMP_WORDS[COMP_CWORD-1]}\"\n\n case \"$prev\" in\n${cases}\n tools) COMPREPLY=($(compgen -W \"list search info call refresh\" -- \"$cur\")); return ;;\n config) COMPREPLY=($(compgen -W \"claude-desktop cursor vscode claude-code http\" -- \"$cur\")); return ;;\n auth) COMPREPLY=($(compgen -W \"login logout whoami profiles switch\" -- \"$cur\")); return ;;\n alias) COMPREPLY=($(compgen -W \"set list remove\" -- \"$cur\")); return ;;\n telemetry) COMPREPLY=($(compgen -W \"enable disable status\" -- \"$cur\")); return ;;\n open) COMPREPLY=($(compgen -W \"dashboard docs status github\" -- \"$cur\")); return ;;\n completion) COMPREPLY=($(compgen -W \"bash zsh fish powershell install\" -- \"$cur\")); return ;;\n esac\n\n COMPREPLY=($(compgen -W \"${topLevel.join(\" \")}\" -- \"$cur\"))\n}\ncomplete -F _hive_mcp_completions hive-mcp`);\n}\n\nfunction generateZsh(): void {\n const domainEntries = NAMESPACE.map(\n (d) => ` '${d.name}:${d.description}'`,\n ).join(\"\\n\");\n\n const subcommandCases = NAMESPACE.map((d) => {\n const subs = d.commands\n .map((c) => ` '${c.name}:${c.description}'`)\n .join(\"\\n\");\n return ` ${d.name})\n local -a subcmds\n subcmds=(\n${subs}\n )\n _describe 'subcommand' subcmds\n ;;`;\n }).join(\"\\n\");\n\n console.log(`# Hive MCP zsh completion\n# Add to ~/.zshrc: eval \"$(hive-mcp completion zsh)\"\n_hive_mcp() {\n local -a commands\n commands=(\n 'serve:Start the MCP server'\n 'doctor:Diagnose environment and connectivity'\n 'tools:Discover and execute tools'\n 'config:Generate MCP client configs'\n 'init:Interactive API key setup'\n 'completion:Generate shell completions'\n 'auth:Manage authentication profiles'\n 'status:Quick health and version check'\n 'open:Open Hive dashboard in browser'\n 'watch:Poll a tool on interval'\n 'alias:Manage command aliases'\n 'telemetry:Control anonymous usage telemetry'\n${domainEntries}\n )\n\n if (( CURRENT == 2 )); then\n _describe 'command' commands\n elif (( CURRENT == 3 )); then\n case \"\\${words[2]}\" in\n${subcommandCases}\n tools)\n local -a subcmds\n subcmds=('list:List all tools' 'search:Search tools' 'info:Show tool info' 'call:Execute a tool' 'refresh:Refresh tool cache')\n _describe 'subcommand' subcmds\n ;;\n config)\n local -a subcmds\n subcmds=('claude-desktop:Claude Desktop config' 'cursor:Cursor config' 'vscode:VS Code config' 'claude-code:Claude Code config' 'http:HTTP remote config')\n _describe 'subcommand' subcmds\n ;;\n auth)\n local -a subcmds\n subcmds=('login:Log in with API key' 'logout:Remove credentials' 'whoami:Show current profile' 'profiles:List all profiles' 'switch:Switch active profile')\n _describe 'subcommand' subcmds\n ;;\n alias)\n local -a subcmds\n subcmds=('set:Create an alias' 'list:Show all aliases' 'remove:Delete an alias')\n _describe 'subcommand' subcmds\n ;;\n telemetry)\n local -a subcmds\n subcmds=('enable:Enable telemetry' 'disable:Disable telemetry' 'status:Show telemetry status')\n _describe 'subcommand' subcmds\n ;;\n open)\n local -a subcmds\n subcmds=('dashboard:Open dashboard' 'docs:Open documentation' 'status:Open status page' 'github:Open GitHub repo')\n _describe 'subcommand' subcmds\n ;;\n esac\n fi\n}\ncompdef _hive_mcp hive-mcp`);\n}\n\nfunction generateFish(): void {\n const topLevel = getTopLevel();\n const lines: string[] = [\n \"# Hive MCP fish completion\",\n \"# Save to: ~/.config/fish/completions/hive-mcp.fish\",\n \"\",\n ];\n\n for (const cmd of topLevel) {\n const desc = NAMESPACE.find((d) => d.name === cmd)?.description ?? cmd;\n lines.push(\n `complete -c hive-mcp -n '__fish_use_subcommand' -a '${cmd}' -d '${desc}'`,\n );\n }\n\n const domainSubs = getDomainSubs();\n for (const [domain, subs] of Object.entries(domainSubs)) {\n for (const sub of subs) {\n const desc =\n NAMESPACE.find((d) => d.name === domain)?.commands.find(\n (c) => c.name === sub,\n )?.description ?? sub;\n lines.push(\n `complete -c hive-mcp -n '__fish_seen_subcommand_from ${domain}' -a '${sub}' -d '${desc}'`,\n );\n }\n }\n\n for (const sub of [\"list\", \"search\", \"info\", \"call\", \"refresh\"]) {\n lines.push(\n `complete -c hive-mcp -n '__fish_seen_subcommand_from tools' -a '${sub}'`,\n );\n }\n for (const sub of [\"login\", \"logout\", \"whoami\", \"profiles\", \"switch\"]) {\n lines.push(\n `complete -c hive-mcp -n '__fish_seen_subcommand_from auth' -a '${sub}'`,\n );\n }\n for (const sub of [\"set\", \"list\", \"remove\"]) {\n lines.push(\n `complete -c hive-mcp -n '__fish_seen_subcommand_from alias' -a '${sub}'`,\n );\n }\n\n console.log(lines.join(\"\\n\"));\n}\n\nfunction generatePowerShell(): void {\n const topLevel = getTopLevel();\n console.log(`# Hive MCP PowerShell completion\n# Add to your $PROFILE: . (hive-mcp completion powershell)\nRegister-ArgumentCompleter -Native -CommandName hive-mcp -ScriptBlock {\n param($wordToComplete, $commandAst, $cursorPosition)\n $commands = @(${topLevel.map((c) => `'${c}'`).join(\", \")})\n $commands | Where-Object { $_ -like \"$wordToComplete*\" } | ForEach-Object {\n [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n }\n}`);\n}\n\nexport async function installCompletion(shell: string): Promise<void> {\n switch (shell) {\n case \"bash\": {\n const rcFile = join(homedir(), \".bashrc\");\n const line = 'eval \"$(hive-mcp completion bash)\"';\n if (existsSync(rcFile) && readFileSync(rcFile, \"utf-8\").includes(line)) {\n process.stderr.write(\"Bash completion already installed.\\n\");\n return;\n }\n appendFileSync(rcFile, `\\n# Hive MCP CLI completion\\n${line}\\n`);\n process.stderr.write(\n `Bash completion added to ${rcFile}. Restart your shell.\\n`,\n );\n return;\n }\n case \"zsh\": {\n const rcFile = join(homedir(), \".zshrc\");\n const line = 'eval \"$(hive-mcp completion zsh)\"';\n if (existsSync(rcFile) && readFileSync(rcFile, \"utf-8\").includes(line)) {\n process.stderr.write(\"Zsh completion already installed.\\n\");\n return;\n }\n appendFileSync(rcFile, `\\n# Hive MCP CLI completion\\n${line}\\n`);\n process.stderr.write(\n `Zsh completion added to ${rcFile}. Restart your shell.\\n`,\n );\n return;\n }\n case \"fish\": {\n const dir = join(homedir(), \".config\", \"fish\", \"completions\");\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n const filePath = join(dir, \"hive-mcp.fish\");\n const { execFileSync } = await import(\"node:child_process\");\n const bin = process.argv[1] ?? \"hive-mcp\";\n const output = execFileSync(bin, [\"completion\", \"fish\"], {\n encoding: \"utf-8\",\n });\n writeFileSync(filePath, output);\n process.stderr.write(`Fish completion written to ${filePath}.\\n`);\n return;\n }\n default:\n process.stderr.write(\n `Unsupported shell for install: ${shell}. Use: bash, zsh, fish\\n`,\n );\n process.exit(2);\n }\n}\n"],"mappings":";;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,YAAY;AACrB,SAAS,eAAe;AAGxB,SAAS,cAAwB;AAC/B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG,UAAU,IAAI,CAAC,MAAM,EAAE,IAAI;AAAA,EAChC;AACF;AAEA,SAAS,gBAA0C;AACjD,QAAM,OAAiC,CAAC;AACxC,aAAW,UAAU,WAAW;AAC9B,SAAK,OAAO,IAAI,IAAI,OAAO,SAAS,IAAI,CAAC,MAAM,EAAE,IAAI;AAAA,EACvD;AACA,SAAO;AACT;AAEA,eAAsB,mBAAmB,OAA8B;AACrE,UAAQ,OAAO;AAAA,IACb,KAAK;AACH,aAAO,aAAa;AAAA,IACtB,KAAK;AACH,aAAO,YAAY;AAAA,IACrB,KAAK;AACH,aAAO,aAAa;AAAA,IACtB,KAAK;AACH,aAAO,mBAAmB;AAAA,IAC5B;AACE,cAAQ;AAAA,QACN,sBAAsB,KAAK;AAAA,MAC7B;AACA,cAAQ,KAAK,CAAC;AAAA,EAClB;AACF;AAEA,SAAS,eAAqB;AAC5B,QAAM,WAAW,YAAY;AAC7B,Q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AA,MACzC;AACA,cAAQ,KAAK,CAAC;AAAA,EAClB;AACF;","names":[]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import "./chunk-QMRVH5ZP.js";
|
|
3
|
+
|
|
4
|
+
// src/cli/config.ts
|
|
5
|
+
import { homedir, platform } from "os";
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
function getEnvBlock() {
|
|
8
|
+
const envs = {};
|
|
9
|
+
const keys = [
|
|
10
|
+
"COINGECKO_PRO_API_KEY",
|
|
11
|
+
"COINGECKO_DEMO_API_KEY",
|
|
12
|
+
"DEBANK_API_KEY",
|
|
13
|
+
"GOPLUS_APP_KEY",
|
|
14
|
+
"GOPLUS_APP_SECRET",
|
|
15
|
+
"LUNARCRUSH_API_KEY",
|
|
16
|
+
"CODEX_API_KEY",
|
|
17
|
+
"GOLDRUSH_API_KEY",
|
|
18
|
+
"FINNHUB_API_KEY",
|
|
19
|
+
"FRED_API_KEY"
|
|
20
|
+
];
|
|
21
|
+
for (const key of keys) {
|
|
22
|
+
if (process.env[key]) envs[key] = process.env[key];
|
|
23
|
+
}
|
|
24
|
+
return envs;
|
|
25
|
+
}
|
|
26
|
+
function configClaudeDesktop() {
|
|
27
|
+
const env = getEnvBlock();
|
|
28
|
+
const config = {
|
|
29
|
+
"hive-mcp": {
|
|
30
|
+
command: "npx",
|
|
31
|
+
args: ["-y", "hive-mcp"],
|
|
32
|
+
env
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const p = platform() === "darwin" ? join(
|
|
36
|
+
homedir(),
|
|
37
|
+
"Library",
|
|
38
|
+
"Application Support",
|
|
39
|
+
"Claude",
|
|
40
|
+
"claude_desktop_config.json"
|
|
41
|
+
) : platform() === "win32" ? join(
|
|
42
|
+
homedir(),
|
|
43
|
+
"AppData",
|
|
44
|
+
"Roaming",
|
|
45
|
+
"Claude",
|
|
46
|
+
"claude_desktop_config.json"
|
|
47
|
+
) : join(homedir(), ".config", "claude", "claude_desktop_config.json");
|
|
48
|
+
console.log(
|
|
49
|
+
'\nAdd this to your claude_desktop_config.json under "mcpServers":\n'
|
|
50
|
+
);
|
|
51
|
+
console.log(`Config file: ${p}
|
|
52
|
+
`);
|
|
53
|
+
console.log(JSON.stringify(config, null, 2));
|
|
54
|
+
}
|
|
55
|
+
function configCursor() {
|
|
56
|
+
const env = getEnvBlock();
|
|
57
|
+
const config = {
|
|
58
|
+
mcpServers: {
|
|
59
|
+
"hive-mcp": { command: "npx", args: ["-y", "hive-mcp"], env }
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
console.log("\nAdd to .cursor/mcp.json:\n");
|
|
63
|
+
console.log(JSON.stringify(config, null, 2));
|
|
64
|
+
}
|
|
65
|
+
function configVscode() {
|
|
66
|
+
const env = getEnvBlock();
|
|
67
|
+
const config = {
|
|
68
|
+
servers: {
|
|
69
|
+
"hive-mcp": {
|
|
70
|
+
type: "stdio",
|
|
71
|
+
command: "npx",
|
|
72
|
+
args: ["-y", "hive-mcp"],
|
|
73
|
+
env
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
console.log("\nAdd to .vscode/mcp.json:\n");
|
|
78
|
+
console.log(JSON.stringify(config, null, 2));
|
|
79
|
+
}
|
|
80
|
+
function configClaudeCode() {
|
|
81
|
+
const envFlags = Object.entries(getEnvBlock()).map(([k, v]) => `-e ${k}=${v}`).join(" ");
|
|
82
|
+
console.log("\nRun this command:\n");
|
|
83
|
+
console.log(`claude mcp add ${envFlags} hive-mcp -- npx -y hive-mcp`);
|
|
84
|
+
}
|
|
85
|
+
function configHttpUrl(url) {
|
|
86
|
+
console.log(`
|
|
87
|
+
Remote MCP server URL: ${url}/mcp`);
|
|
88
|
+
console.log("\nFor Claude Code:");
|
|
89
|
+
console.log(` claude mcp add --transport http hive-mcp ${url}/mcp`);
|
|
90
|
+
console.log("\nFor clients without HTTP support:");
|
|
91
|
+
console.log(` npx mcp-remote ${url}/mcp`);
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
configClaudeCode,
|
|
95
|
+
configClaudeDesktop,
|
|
96
|
+
configCursor,
|
|
97
|
+
configHttpUrl,
|
|
98
|
+
configVscode
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=config-2VDB2ZHE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/config.ts"],"sourcesContent":["import { homedir, platform } from \"node:os\";\nimport { join } from \"node:path\";\n\nfunction getEnvBlock(): Record<string, string> {\n const envs: Record<string, string> = {};\n const keys = [\n \"COINGECKO_PRO_API_KEY\",\n \"COINGECKO_DEMO_API_KEY\",\n \"DEBANK_API_KEY\",\n \"GOPLUS_APP_KEY\",\n \"GOPLUS_APP_SECRET\",\n \"LUNARCRUSH_API_KEY\",\n \"CODEX_API_KEY\",\n \"GOLDRUSH_API_KEY\",\n \"FINNHUB_API_KEY\",\n \"FRED_API_KEY\",\n ];\n for (const key of keys) {\n if (process.env[key]) envs[key] = process.env[key]!;\n }\n return envs;\n}\n\nexport function configClaudeDesktop(): void {\n const env = getEnvBlock();\n const config = {\n \"hive-mcp\": {\n command: \"npx\",\n args: [\"-y\", \"hive-mcp\"],\n env,\n },\n };\n const p =\n platform() === \"darwin\"\n ? join(\n homedir(),\n \"Library\",\n \"Application Support\",\n \"Claude\",\n \"claude_desktop_config.json\",\n )\n : platform() === \"win32\"\n ? join(\n homedir(),\n \"AppData\",\n \"Roaming\",\n \"Claude\",\n \"claude_desktop_config.json\",\n )\n : join(homedir(), \".config\", \"claude\", \"claude_desktop_config.json\");\n console.log(\n '\\nAdd this to your claude_desktop_config.json under \"mcpServers\":\\n',\n );\n console.log(`Config file: ${p}\\n`);\n console.log(JSON.stringify(config, null, 2));\n}\n\nexport function configCursor(): void {\n const env = getEnvBlock();\n const config = {\n mcpServers: {\n \"hive-mcp\": { command: \"npx\", args: [\"-y\", \"hive-mcp\"], env },\n },\n };\n console.log(\"\\nAdd to .cursor/mcp.json:\\n\");\n console.log(JSON.stringify(config, null, 2));\n}\n\nexport function configVscode(): void {\n const env = getEnvBlock();\n const config = {\n servers: {\n \"hive-mcp\": {\n type: \"stdio\",\n command: \"npx\",\n args: [\"-y\", \"hive-mcp\"],\n env,\n },\n },\n };\n console.log(\"\\nAdd to .vscode/mcp.json:\\n\");\n console.log(JSON.stringify(config, null, 2));\n}\n\nexport function configClaudeCode(): void {\n const envFlags = Object.entries(getEnvBlock())\n .map(([k, v]) => `-e ${k}=${v}`)\n .join(\" \");\n console.log(\"\\nRun this command:\\n\");\n console.log(`claude mcp add ${envFlags} hive-mcp -- npx -y hive-mcp`);\n}\n\nexport function configHttpUrl(url: string): void {\n console.log(`\\nRemote MCP server URL: ${url}/mcp`);\n console.log(\"\\nFor Claude Code:\");\n console.log(` claude mcp add --transport http hive-mcp ${url}/mcp`);\n console.log(\"\\nFor clients without HTTP support:\");\n console.log(` npx mcp-remote ${url}/mcp`);\n}\n"],"mappings":";;;;AAAA,SAAS,SAAS,gBAAgB;AAClC,SAAS,YAAY;AAErB,SAAS,cAAsC;AAC7C,QAAM,OAA+B,CAAC;AACtC,QAAM,OAAO;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,aAAW,OAAO,MAAM;AACtB,QAAI,QAAQ,IAAI,GAAG,EAAG,MAAK,GAAG,IAAI,QAAQ,IAAI,GAAG;AAAA,EACnD;AACA,SAAO;AACT;AAEO,SAAS,sBAA4B;AAC1C,QAAM,MAAM,YAAY;AACxB,QAAM,SAAS;AAAA,IACb,YAAY;AAAA,MACV,SAAS;AAAA,MACT,MAAM,CAAC,MAAM,UAAU;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AACA,QAAM,IACJ,SAAS,MAAM,WACX;AAAA,IACE,QAAQ;AAAA,IACR;AAAA,IACA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CAA8C,GAAG,MAAM;AACnE,UAAQ,IAAI,qCAAqC;AACjD,UAAQ,IAAI,oBAAoB,GAAG,MAAM;AAC3C;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
ensureConfigDir,
|
|
4
|
+
getConfig,
|
|
5
|
+
getConfigDir,
|
|
6
|
+
getCredentials,
|
|
7
|
+
getNoRetry,
|
|
8
|
+
readJsonFile,
|
|
9
|
+
resolveApiKey,
|
|
10
|
+
resolveApiUrl,
|
|
11
|
+
saveConfig,
|
|
12
|
+
saveCredentials,
|
|
13
|
+
setCliFlags,
|
|
14
|
+
writeJsonFile
|
|
15
|
+
} from "./chunk-XQJ6PB2L.js";
|
|
16
|
+
import "./chunk-QMRVH5ZP.js";
|
|
17
|
+
export {
|
|
18
|
+
ensureConfigDir,
|
|
19
|
+
getConfig,
|
|
20
|
+
getConfigDir,
|
|
21
|
+
getCredentials,
|
|
22
|
+
getNoRetry,
|
|
23
|
+
readJsonFile,
|
|
24
|
+
resolveApiKey,
|
|
25
|
+
resolveApiUrl,
|
|
26
|
+
saveConfig,
|
|
27
|
+
saveCredentials,
|
|
28
|
+
setCliFlags,
|
|
29
|
+
writeJsonFile
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=config-dir-IEOID7Q6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
fetchToolCatalog
|
|
4
|
+
} from "./chunk-LBTLYTZS.js";
|
|
5
|
+
import {
|
|
6
|
+
debug,
|
|
7
|
+
info,
|
|
8
|
+
shouldOutputJson,
|
|
9
|
+
successEnvelope,
|
|
10
|
+
writeOutput
|
|
11
|
+
} from "./chunk-FAFUYZQS.js";
|
|
12
|
+
import "./chunk-XQJ6PB2L.js";
|
|
13
|
+
import "./chunk-QMRVH5ZP.js";
|
|
14
|
+
|
|
15
|
+
// src/cli/doctor.ts
|
|
16
|
+
var DEFAULT_API_URL = "https://mcp.hiveintelligence.xyz";
|
|
17
|
+
function getApiUrl() {
|
|
18
|
+
return process.env.HIVE_API_URL || DEFAULT_API_URL;
|
|
19
|
+
}
|
|
20
|
+
async function runDoctor(opts) {
|
|
21
|
+
const checks = [];
|
|
22
|
+
const apiKey = process.env.HIVE_API_KEY;
|
|
23
|
+
checks.push({
|
|
24
|
+
check: "HIVE_API_KEY",
|
|
25
|
+
status: apiKey ? "PASS" : "INFO",
|
|
26
|
+
detail: apiKey ? `Set (${apiKey.slice(0, 4)}...)` : "Not set (optional \u2014 API is currently free)"
|
|
27
|
+
});
|
|
28
|
+
const apiUrl = process.env.HIVE_API_URL;
|
|
29
|
+
checks.push({
|
|
30
|
+
check: "HIVE_API_URL",
|
|
31
|
+
status: "PASS",
|
|
32
|
+
detail: apiUrl ? `Custom: ${apiUrl}` : `Default: ${DEFAULT_API_URL}`
|
|
33
|
+
});
|
|
34
|
+
const healthUrl = `${getApiUrl()}/ping`;
|
|
35
|
+
debug(`GET ${healthUrl}`);
|
|
36
|
+
try {
|
|
37
|
+
const controller = new AbortController();
|
|
38
|
+
const timer = setTimeout(() => controller.abort(), 1e4);
|
|
39
|
+
const resp = await fetch(healthUrl, {
|
|
40
|
+
headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
|
|
41
|
+
signal: controller.signal
|
|
42
|
+
});
|
|
43
|
+
clearTimeout(timer);
|
|
44
|
+
if (resp.ok) {
|
|
45
|
+
const body = await resp.json().catch(() => null);
|
|
46
|
+
const serverStatus = body && typeof body === "object" && "status" in body ? String(body.status) : "ok";
|
|
47
|
+
checks.push({
|
|
48
|
+
check: "Server health",
|
|
49
|
+
status: "PASS",
|
|
50
|
+
detail: `${resp.status} \u2014 ${serverStatus}`
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
checks.push({
|
|
54
|
+
check: "Server health",
|
|
55
|
+
status: "FAIL",
|
|
56
|
+
detail: `HTTP ${resp.status} ${resp.statusText}`
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {
|
|
60
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
61
|
+
const isTimeout = err instanceof Error && err.name === "AbortError";
|
|
62
|
+
checks.push({
|
|
63
|
+
check: "Server health",
|
|
64
|
+
status: "FAIL",
|
|
65
|
+
detail: isTimeout ? `Timeout connecting to ${getApiUrl()}` : `Connection failed: ${msg}`
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
{
|
|
69
|
+
debug("Fetching tool catalog...");
|
|
70
|
+
try {
|
|
71
|
+
const catalog = await fetchToolCatalog();
|
|
72
|
+
const toolsData = catalog.data;
|
|
73
|
+
const toolCount = Array.isArray(toolsData) ? toolsData.length : typeof toolsData === "object" && toolsData !== null && "totalCount" in toolsData ? toolsData.totalCount : 0;
|
|
74
|
+
if (catalog.ok) {
|
|
75
|
+
checks.push({
|
|
76
|
+
check: "Tool catalog",
|
|
77
|
+
status: toolCount > 0 ? "PASS" : "WARN",
|
|
78
|
+
detail: `${toolCount} tools available`
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
const errMsg = catalog.error && typeof catalog.error === "object" && "message" in catalog.error ? String(catalog.error.message) : "Unknown error";
|
|
82
|
+
checks.push({
|
|
83
|
+
check: "Tool catalog",
|
|
84
|
+
status: "FAIL",
|
|
85
|
+
detail: errMsg
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
} catch (err) {
|
|
89
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
90
|
+
checks.push({
|
|
91
|
+
check: "Tool catalog",
|
|
92
|
+
status: "FAIL",
|
|
93
|
+
detail: `Failed to fetch: ${msg}`
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (opts.probe) {
|
|
98
|
+
const probeUrl = `${getApiUrl()}/health?run=true`;
|
|
99
|
+
debug(`Probe: GET ${probeUrl}`);
|
|
100
|
+
try {
|
|
101
|
+
const controller = new AbortController();
|
|
102
|
+
const timer = setTimeout(() => controller.abort(), 3e4);
|
|
103
|
+
const resp = await fetch(probeUrl, {
|
|
104
|
+
headers: {
|
|
105
|
+
...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
|
|
106
|
+
},
|
|
107
|
+
signal: controller.signal
|
|
108
|
+
});
|
|
109
|
+
clearTimeout(timer);
|
|
110
|
+
if (resp.ok) {
|
|
111
|
+
const body = await resp.json().catch(() => null);
|
|
112
|
+
if (body && typeof body === "object" && "providers" in body) {
|
|
113
|
+
const providers = body.providers;
|
|
114
|
+
if (Array.isArray(providers)) {
|
|
115
|
+
for (const p of providers) {
|
|
116
|
+
const pObj = p;
|
|
117
|
+
const name = String(pObj.name ?? pObj.provider ?? "unknown");
|
|
118
|
+
const status = String(pObj.status ?? "unknown");
|
|
119
|
+
const pass = status === "healthy" || status === "passed" || status === "partial";
|
|
120
|
+
checks.push({
|
|
121
|
+
check: `Probe: ${name}`,
|
|
122
|
+
status: pass ? "PASS" : status === "inactive" ? "SKIP" : "FAIL",
|
|
123
|
+
detail: status
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
checks.push({
|
|
129
|
+
check: "Probe",
|
|
130
|
+
status: "PASS",
|
|
131
|
+
detail: `Server responded ${resp.status}`
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
checks.push({
|
|
136
|
+
check: "Probe",
|
|
137
|
+
status: "FAIL",
|
|
138
|
+
detail: `HTTP ${resp.status} ${resp.statusText}`
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
143
|
+
checks.push({
|
|
144
|
+
check: "Probe",
|
|
145
|
+
status: "FAIL",
|
|
146
|
+
detail: `Failed: ${msg}`
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const fails = checks.filter((c) => c.status === "FAIL").length;
|
|
151
|
+
const warns = checks.filter((c) => c.status === "WARN").length;
|
|
152
|
+
const data = {
|
|
153
|
+
checks,
|
|
154
|
+
summary: {
|
|
155
|
+
total: checks.length,
|
|
156
|
+
pass: checks.filter((c) => c.status === "PASS").length,
|
|
157
|
+
fail: fails,
|
|
158
|
+
warn: warns
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
if (shouldOutputJson()) {
|
|
162
|
+
await writeOutput(successEnvelope(data, {}));
|
|
163
|
+
if (fails > 0) process.exit(1);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const { table } = await import("./format-4OIUGZKY.js");
|
|
167
|
+
info("\nHive MCP Doctor\n");
|
|
168
|
+
info(
|
|
169
|
+
table(
|
|
170
|
+
["Check", "Status", "Detail"],
|
|
171
|
+
checks.map((c) => [c.check, c.status, c.detail])
|
|
172
|
+
)
|
|
173
|
+
);
|
|
174
|
+
info(
|
|
175
|
+
`
|
|
176
|
+
${fails === 0 ? "All checks passed" : `${fails} issues found`}${warns ? ` (${warns} warnings)` : ""}
|
|
177
|
+
`
|
|
178
|
+
);
|
|
179
|
+
if (fails > 0) process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
async function runStatus() {
|
|
182
|
+
const { CLI_VERSION: SERVER_VERSION } = await import("./version-3TZ3U4IR.js");
|
|
183
|
+
const { resolveApiKey, resolveApiUrl } = await import("./config-dir-IEOID7Q6.js");
|
|
184
|
+
const { getActiveProfile, maskKey } = await import("./auth-PVT4GTAD.js");
|
|
185
|
+
const apiUrl = resolveApiUrl();
|
|
186
|
+
const apiKey = resolveApiKey();
|
|
187
|
+
const profile = getActiveProfile();
|
|
188
|
+
let apiStatus = "unknown";
|
|
189
|
+
try {
|
|
190
|
+
const controller = new AbortController();
|
|
191
|
+
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
192
|
+
const resp = await fetch(`${apiUrl}/ping`, {
|
|
193
|
+
headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
|
|
194
|
+
signal: controller.signal
|
|
195
|
+
});
|
|
196
|
+
clearTimeout(timer);
|
|
197
|
+
apiStatus = resp.ok ? "healthy" : `HTTP ${resp.status}`;
|
|
198
|
+
} catch {
|
|
199
|
+
apiStatus = "unreachable";
|
|
200
|
+
}
|
|
201
|
+
if (shouldOutputJson()) {
|
|
202
|
+
await writeOutput(
|
|
203
|
+
successEnvelope(
|
|
204
|
+
{
|
|
205
|
+
version: SERVER_VERSION,
|
|
206
|
+
profile: profile?.name ?? "(none)",
|
|
207
|
+
apiUrl,
|
|
208
|
+
apiStatus,
|
|
209
|
+
hasKey: !!apiKey
|
|
210
|
+
},
|
|
211
|
+
{}
|
|
212
|
+
)
|
|
213
|
+
);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
process.stderr.write(`
|
|
217
|
+
Hive CLI v${SERVER_VERSION}
|
|
218
|
+
`);
|
|
219
|
+
process.stderr.write(
|
|
220
|
+
`Profile: ${profile ? `${profile.name} (${maskKey(profile.apiKey)})` : "(not logged in)"}
|
|
221
|
+
`
|
|
222
|
+
);
|
|
223
|
+
process.stderr.write(`API: ${apiUrl} (${apiStatus})
|
|
224
|
+
|
|
225
|
+
`);
|
|
226
|
+
}
|
|
227
|
+
export {
|
|
228
|
+
runDoctor,
|
|
229
|
+
runStatus
|
|
230
|
+
};
|
|
231
|
+
//# sourceMappingURL=doctor-GYP6IHPP.js.map
|