hud-python 0.4.1__py3-none-any.whl → 0.4.3__py3-none-any.whl
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.
Potentially problematic release.
This version of hud-python might be problematic. Click here for more details.
- hud/__init__.py +22 -22
- hud/agents/__init__.py +13 -15
- hud/agents/base.py +599 -599
- hud/agents/claude.py +373 -373
- hud/agents/langchain.py +261 -250
- hud/agents/misc/__init__.py +7 -7
- hud/agents/misc/response_agent.py +82 -80
- hud/agents/openai.py +352 -352
- hud/agents/openai_chat_generic.py +154 -154
- hud/agents/tests/__init__.py +1 -1
- hud/agents/tests/test_base.py +742 -742
- hud/agents/tests/test_claude.py +324 -324
- hud/agents/tests/test_client.py +363 -363
- hud/agents/tests/test_openai.py +237 -237
- hud/cli/__init__.py +617 -617
- hud/cli/__main__.py +8 -8
- hud/cli/analyze.py +371 -371
- hud/cli/analyze_metadata.py +230 -230
- hud/cli/build.py +498 -427
- hud/cli/clone.py +185 -185
- hud/cli/cursor.py +92 -92
- hud/cli/debug.py +392 -392
- hud/cli/docker_utils.py +83 -83
- hud/cli/init.py +280 -281
- hud/cli/interactive.py +353 -353
- hud/cli/mcp_server.py +764 -756
- hud/cli/pull.py +330 -336
- hud/cli/push.py +404 -370
- hud/cli/remote_runner.py +311 -311
- hud/cli/runner.py +160 -160
- hud/cli/tests/__init__.py +3 -3
- hud/cli/tests/test_analyze.py +284 -284
- hud/cli/tests/test_cli_init.py +265 -265
- hud/cli/tests/test_cli_main.py +27 -27
- hud/cli/tests/test_clone.py +142 -142
- hud/cli/tests/test_cursor.py +253 -253
- hud/cli/tests/test_debug.py +453 -453
- hud/cli/tests/test_mcp_server.py +139 -139
- hud/cli/tests/test_utils.py +388 -388
- hud/cli/utils.py +263 -263
- hud/clients/README.md +143 -143
- hud/clients/__init__.py +16 -16
- hud/clients/base.py +378 -379
- hud/clients/fastmcp.py +222 -222
- hud/clients/mcp_use.py +298 -278
- hud/clients/tests/__init__.py +1 -1
- hud/clients/tests/test_client_integration.py +111 -111
- hud/clients/tests/test_fastmcp.py +342 -342
- hud/clients/tests/test_protocol.py +188 -188
- hud/clients/utils/__init__.py +1 -1
- hud/clients/utils/retry_transport.py +160 -160
- hud/datasets.py +327 -322
- hud/misc/__init__.py +1 -1
- hud/misc/claude_plays_pokemon.py +292 -292
- hud/otel/__init__.py +35 -35
- hud/otel/collector.py +142 -142
- hud/otel/config.py +164 -164
- hud/otel/context.py +536 -536
- hud/otel/exporters.py +366 -366
- hud/otel/instrumentation.py +97 -97
- hud/otel/processors.py +118 -118
- hud/otel/tests/__init__.py +1 -1
- hud/otel/tests/test_processors.py +197 -197
- hud/server/__init__.py +5 -5
- hud/server/context.py +114 -114
- hud/server/helper/__init__.py +5 -5
- hud/server/low_level.py +132 -132
- hud/server/server.py +170 -166
- hud/server/tests/__init__.py +3 -3
- hud/settings.py +73 -73
- hud/shared/__init__.py +5 -5
- hud/shared/exceptions.py +180 -180
- hud/shared/requests.py +264 -264
- hud/shared/tests/test_exceptions.py +157 -157
- hud/shared/tests/test_requests.py +275 -275
- hud/telemetry/__init__.py +25 -25
- hud/telemetry/instrument.py +379 -379
- hud/telemetry/job.py +309 -309
- hud/telemetry/replay.py +74 -74
- hud/telemetry/trace.py +83 -83
- hud/tools/__init__.py +33 -33
- hud/tools/base.py +365 -365
- hud/tools/bash.py +161 -161
- hud/tools/computer/__init__.py +15 -15
- hud/tools/computer/anthropic.py +437 -437
- hud/tools/computer/hud.py +376 -376
- hud/tools/computer/openai.py +295 -295
- hud/tools/computer/settings.py +82 -82
- hud/tools/edit.py +314 -314
- hud/tools/executors/__init__.py +30 -30
- hud/tools/executors/base.py +539 -539
- hud/tools/executors/pyautogui.py +621 -621
- hud/tools/executors/tests/__init__.py +1 -1
- hud/tools/executors/tests/test_base_executor.py +338 -338
- hud/tools/executors/tests/test_pyautogui_executor.py +165 -165
- hud/tools/executors/xdo.py +511 -511
- hud/tools/playwright.py +412 -412
- hud/tools/tests/__init__.py +3 -3
- hud/tools/tests/test_base.py +282 -282
- hud/tools/tests/test_bash.py +158 -158
- hud/tools/tests/test_bash_extended.py +197 -197
- hud/tools/tests/test_computer.py +425 -425
- hud/tools/tests/test_computer_actions.py +34 -34
- hud/tools/tests/test_edit.py +259 -259
- hud/tools/tests/test_init.py +27 -27
- hud/tools/tests/test_playwright_tool.py +183 -183
- hud/tools/tests/test_tools.py +145 -145
- hud/tools/tests/test_utils.py +156 -156
- hud/tools/types.py +72 -72
- hud/tools/utils.py +50 -50
- hud/types.py +136 -136
- hud/utils/__init__.py +10 -10
- hud/utils/async_utils.py +65 -65
- hud/utils/design.py +236 -168
- hud/utils/mcp.py +55 -55
- hud/utils/progress.py +149 -149
- hud/utils/telemetry.py +66 -66
- hud/utils/tests/test_async_utils.py +173 -173
- hud/utils/tests/test_init.py +17 -17
- hud/utils/tests/test_progress.py +261 -261
- hud/utils/tests/test_telemetry.py +82 -82
- hud/utils/tests/test_version.py +8 -8
- hud/version.py +7 -7
- {hud_python-0.4.1.dist-info → hud_python-0.4.3.dist-info}/METADATA +10 -8
- hud_python-0.4.3.dist-info/RECORD +131 -0
- {hud_python-0.4.1.dist-info → hud_python-0.4.3.dist-info}/licenses/LICENSE +21 -21
- hud/agents/art.py +0 -101
- hud_python-0.4.1.dist-info/RECORD +0 -132
- {hud_python-0.4.1.dist-info → hud_python-0.4.3.dist-info}/WHEEL +0 -0
- {hud_python-0.4.1.dist-info → hud_python-0.4.3.dist-info}/entry_points.txt +0 -0
hud/cli/clone.py
CHANGED
|
@@ -1,185 +1,185 @@
|
|
|
1
|
-
"""Git clone wrapper with quiet mode and rich output.
|
|
2
|
-
|
|
3
|
-
This module provides a CLI command that wraps 'git clone' to provide a better user experience:
|
|
4
|
-
- Runs git clone quietly (no verbose output)
|
|
5
|
-
- Displays a rich formatted success message
|
|
6
|
-
- Shows optional tutorial/getting started messages from the cloned repository
|
|
7
|
-
|
|
8
|
-
Usage:
|
|
9
|
-
hud clone https://github.com/user/repo.git
|
|
10
|
-
|
|
11
|
-
The clone command will look for a [tool.hud.clone] section in the cloned repository's
|
|
12
|
-
pyproject.toml file. If found, it will display the configured message after cloning.
|
|
13
|
-
|
|
14
|
-
Configuration in pyproject.toml:
|
|
15
|
-
[tool.hud.clone]
|
|
16
|
-
title = "🚀 My Project" # Optional title for the message panel
|
|
17
|
-
style = "blue" # Optional border style (any Rich color)
|
|
18
|
-
|
|
19
|
-
# Option 1: Plain text message with Rich markup support
|
|
20
|
-
message = "[bold]Welcome![/bold] Run [cyan]pip install -e .[/cyan] to start."
|
|
21
|
-
|
|
22
|
-
# Option 2: Markdown formatted message
|
|
23
|
-
markdown = "## Welcome\\n\\nThis supports **markdown** formatting."
|
|
24
|
-
|
|
25
|
-
# Option 3: Step-by-step instructions
|
|
26
|
-
steps = [
|
|
27
|
-
"Install dependencies: [green]pip install -e .[/green]",
|
|
28
|
-
"Run tests: [green]pytest[/green]",
|
|
29
|
-
"Start coding!"
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
Rich Markup Examples:
|
|
33
|
-
- Colors: [red]text[/red], [green]text[/green], [blue]text[/blue], [cyan]text[/cyan]
|
|
34
|
-
- Styles: [bold]text[/bold], [italic]text[/italic], [underline]text[/underline]
|
|
35
|
-
- Combined: [bold cyan]text[/bold cyan]
|
|
36
|
-
- Background: [on red]text[/on red]
|
|
37
|
-
- Links: [link=https://example.com]clickable[/link]
|
|
38
|
-
|
|
39
|
-
See Rich documentation for more markup options: https://rich.readthedocs.io/en/stable/markup.html
|
|
40
|
-
"""
|
|
41
|
-
|
|
42
|
-
from __future__ import annotations
|
|
43
|
-
|
|
44
|
-
import logging
|
|
45
|
-
import subprocess
|
|
46
|
-
import tomllib
|
|
47
|
-
from pathlib import Path
|
|
48
|
-
from typing import Any
|
|
49
|
-
|
|
50
|
-
from rich.console import Console
|
|
51
|
-
from rich.markdown import Markdown
|
|
52
|
-
from rich.panel import Panel
|
|
53
|
-
from rich.text import Text
|
|
54
|
-
|
|
55
|
-
logger = logging.getLogger(__name__)
|
|
56
|
-
|
|
57
|
-
console = Console()
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def clone_repository(url: str) -> tuple[bool, str]:
|
|
61
|
-
"""
|
|
62
|
-
Clone a git repository quietly and return status.
|
|
63
|
-
|
|
64
|
-
Args:
|
|
65
|
-
url: Git repository URL
|
|
66
|
-
|
|
67
|
-
Returns:
|
|
68
|
-
Tuple of (success, directory_path or error_message)
|
|
69
|
-
"""
|
|
70
|
-
# Extract repo name from URL
|
|
71
|
-
repo_name = Path(url).stem
|
|
72
|
-
if repo_name.endswith(".git"):
|
|
73
|
-
repo_name = repo_name[:-4]
|
|
74
|
-
|
|
75
|
-
# Build git clone command (simple, no options)
|
|
76
|
-
cmd = ["git", "clone", "--quiet", url]
|
|
77
|
-
|
|
78
|
-
try:
|
|
79
|
-
# Run git clone with quiet flag
|
|
80
|
-
subprocess.run( # noqa: S603
|
|
81
|
-
cmd,
|
|
82
|
-
capture_output=True,
|
|
83
|
-
text=True,
|
|
84
|
-
check=True,
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
# Get the absolute path of the cloned directory
|
|
88
|
-
clone_path = Path(repo_name).resolve()
|
|
89
|
-
|
|
90
|
-
return True, str(clone_path)
|
|
91
|
-
|
|
92
|
-
except subprocess.CalledProcessError as e:
|
|
93
|
-
error_msg = (
|
|
94
|
-
e.stderr.strip() if e.stderr else f"Git clone failed with exit code {e.returncode}"
|
|
95
|
-
)
|
|
96
|
-
return False, error_msg
|
|
97
|
-
except Exception as e:
|
|
98
|
-
return False, f"Unexpected error: {e!s}"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def get_clone_message(clone_path: str) -> dict[str, Any] | None:
|
|
102
|
-
"""
|
|
103
|
-
Look for a clone message configuration in the repository's pyproject.toml or .hud.toml.
|
|
104
|
-
|
|
105
|
-
Checks for:
|
|
106
|
-
1. [tool.hud.clone] section in pyproject.toml
|
|
107
|
-
2. [clone] section in .hud.toml
|
|
108
|
-
|
|
109
|
-
Args:
|
|
110
|
-
clone_path: Path to the cloned repository
|
|
111
|
-
|
|
112
|
-
Returns:
|
|
113
|
-
Dictionary with message configuration or None
|
|
114
|
-
"""
|
|
115
|
-
repo_path = Path(clone_path)
|
|
116
|
-
|
|
117
|
-
# Check pyproject.toml first
|
|
118
|
-
pyproject_path = repo_path / "pyproject.toml"
|
|
119
|
-
if pyproject_path.exists():
|
|
120
|
-
try:
|
|
121
|
-
with open(pyproject_path, "rb") as f:
|
|
122
|
-
data = tomllib.load(f)
|
|
123
|
-
if "tool" in data and "hud" in data["tool"] and "clone" in data["tool"]["hud"]:
|
|
124
|
-
return data["tool"]["hud"]["clone"]
|
|
125
|
-
except Exception:
|
|
126
|
-
logger.warning("Failed to load clone config from %s", pyproject_path)
|
|
127
|
-
|
|
128
|
-
# Check .hud.toml as fallback
|
|
129
|
-
hud_toml_path = repo_path / ".hud.toml"
|
|
130
|
-
if hud_toml_path.exists():
|
|
131
|
-
try:
|
|
132
|
-
with open(hud_toml_path, "rb") as f:
|
|
133
|
-
data = tomllib.load(f)
|
|
134
|
-
if "clone" in data:
|
|
135
|
-
return data["clone"]
|
|
136
|
-
except Exception:
|
|
137
|
-
logger.warning("Failed to load clone config from %s", hud_toml_path)
|
|
138
|
-
|
|
139
|
-
return None
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def print_tutorial(clone_config: dict[str, Any] | None = None) -> None:
|
|
143
|
-
"""Print a rich formatted success message with optional tutorial."""
|
|
144
|
-
# Display custom message if configured
|
|
145
|
-
if clone_config:
|
|
146
|
-
# Handle different message formats
|
|
147
|
-
if "message" in clone_config:
|
|
148
|
-
# Message with Rich markup support
|
|
149
|
-
console.print(
|
|
150
|
-
Panel(
|
|
151
|
-
clone_config["message"], # Rich will parse markup automatically
|
|
152
|
-
title=clone_config.get("title", "📋 Getting Started"),
|
|
153
|
-
border_style=clone_config.get("style", "blue"),
|
|
154
|
-
padding=(1, 2),
|
|
155
|
-
)
|
|
156
|
-
)
|
|
157
|
-
elif "markdown" in clone_config:
|
|
158
|
-
# Markdown message
|
|
159
|
-
console.print(
|
|
160
|
-
Panel(
|
|
161
|
-
Markdown(clone_config["markdown"]),
|
|
162
|
-
title=clone_config.get("title", "📋 Getting Started"),
|
|
163
|
-
border_style=clone_config.get("style", "blue"),
|
|
164
|
-
padding=(1, 2),
|
|
165
|
-
)
|
|
166
|
-
)
|
|
167
|
-
elif "steps" in clone_config:
|
|
168
|
-
# Step-by-step instructions
|
|
169
|
-
title = clone_config.get("title", "📋 Getting Started")
|
|
170
|
-
console.print(f"\n[bold]{title}[/bold]\n")
|
|
171
|
-
for i, step in enumerate(clone_config["steps"], 1):
|
|
172
|
-
console.print(f" {i}. {step}")
|
|
173
|
-
console.print()
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
def print_error(error_msg: str) -> None:
|
|
177
|
-
"""Print a rich formatted error message."""
|
|
178
|
-
console.print(
|
|
179
|
-
Panel(
|
|
180
|
-
Text(f"❌ {error_msg}", style="red"),
|
|
181
|
-
title="[bold red]Clone Failed[/bold red]",
|
|
182
|
-
border_style="red",
|
|
183
|
-
padding=(1, 2),
|
|
184
|
-
)
|
|
185
|
-
)
|
|
1
|
+
"""Git clone wrapper with quiet mode and rich output.
|
|
2
|
+
|
|
3
|
+
This module provides a CLI command that wraps 'git clone' to provide a better user experience:
|
|
4
|
+
- Runs git clone quietly (no verbose output)
|
|
5
|
+
- Displays a rich formatted success message
|
|
6
|
+
- Shows optional tutorial/getting started messages from the cloned repository
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
hud clone https://github.com/user/repo.git
|
|
10
|
+
|
|
11
|
+
The clone command will look for a [tool.hud.clone] section in the cloned repository's
|
|
12
|
+
pyproject.toml file. If found, it will display the configured message after cloning.
|
|
13
|
+
|
|
14
|
+
Configuration in pyproject.toml:
|
|
15
|
+
[tool.hud.clone]
|
|
16
|
+
title = "🚀 My Project" # Optional title for the message panel
|
|
17
|
+
style = "blue" # Optional border style (any Rich color)
|
|
18
|
+
|
|
19
|
+
# Option 1: Plain text message with Rich markup support
|
|
20
|
+
message = "[bold]Welcome![/bold] Run [cyan]pip install -e .[/cyan] to start."
|
|
21
|
+
|
|
22
|
+
# Option 2: Markdown formatted message
|
|
23
|
+
markdown = "## Welcome\\n\\nThis supports **markdown** formatting."
|
|
24
|
+
|
|
25
|
+
# Option 3: Step-by-step instructions
|
|
26
|
+
steps = [
|
|
27
|
+
"Install dependencies: [green]pip install -e .[/green]",
|
|
28
|
+
"Run tests: [green]pytest[/green]",
|
|
29
|
+
"Start coding!"
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
Rich Markup Examples:
|
|
33
|
+
- Colors: [red]text[/red], [green]text[/green], [blue]text[/blue], [cyan]text[/cyan]
|
|
34
|
+
- Styles: [bold]text[/bold], [italic]text[/italic], [underline]text[/underline]
|
|
35
|
+
- Combined: [bold cyan]text[/bold cyan]
|
|
36
|
+
- Background: [on red]text[/on red]
|
|
37
|
+
- Links: [link=https://example.com]clickable[/link]
|
|
38
|
+
|
|
39
|
+
See Rich documentation for more markup options: https://rich.readthedocs.io/en/stable/markup.html
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
from __future__ import annotations
|
|
43
|
+
|
|
44
|
+
import logging
|
|
45
|
+
import subprocess
|
|
46
|
+
import tomllib
|
|
47
|
+
from pathlib import Path
|
|
48
|
+
from typing import Any
|
|
49
|
+
|
|
50
|
+
from rich.console import Console
|
|
51
|
+
from rich.markdown import Markdown
|
|
52
|
+
from rich.panel import Panel
|
|
53
|
+
from rich.text import Text
|
|
54
|
+
|
|
55
|
+
logger = logging.getLogger(__name__)
|
|
56
|
+
|
|
57
|
+
console = Console()
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def clone_repository(url: str) -> tuple[bool, str]:
|
|
61
|
+
"""
|
|
62
|
+
Clone a git repository quietly and return status.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
url: Git repository URL
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
Tuple of (success, directory_path or error_message)
|
|
69
|
+
"""
|
|
70
|
+
# Extract repo name from URL
|
|
71
|
+
repo_name = Path(url).stem
|
|
72
|
+
if repo_name.endswith(".git"):
|
|
73
|
+
repo_name = repo_name[:-4]
|
|
74
|
+
|
|
75
|
+
# Build git clone command (simple, no options)
|
|
76
|
+
cmd = ["git", "clone", "--quiet", url]
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
# Run git clone with quiet flag
|
|
80
|
+
subprocess.run( # noqa: S603
|
|
81
|
+
cmd,
|
|
82
|
+
capture_output=True,
|
|
83
|
+
text=True,
|
|
84
|
+
check=True,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# Get the absolute path of the cloned directory
|
|
88
|
+
clone_path = Path(repo_name).resolve()
|
|
89
|
+
|
|
90
|
+
return True, str(clone_path)
|
|
91
|
+
|
|
92
|
+
except subprocess.CalledProcessError as e:
|
|
93
|
+
error_msg = (
|
|
94
|
+
e.stderr.strip() if e.stderr else f"Git clone failed with exit code {e.returncode}"
|
|
95
|
+
)
|
|
96
|
+
return False, error_msg
|
|
97
|
+
except Exception as e:
|
|
98
|
+
return False, f"Unexpected error: {e!s}"
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def get_clone_message(clone_path: str) -> dict[str, Any] | None:
|
|
102
|
+
"""
|
|
103
|
+
Look for a clone message configuration in the repository's pyproject.toml or .hud.toml.
|
|
104
|
+
|
|
105
|
+
Checks for:
|
|
106
|
+
1. [tool.hud.clone] section in pyproject.toml
|
|
107
|
+
2. [clone] section in .hud.toml
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
clone_path: Path to the cloned repository
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
Dictionary with message configuration or None
|
|
114
|
+
"""
|
|
115
|
+
repo_path = Path(clone_path)
|
|
116
|
+
|
|
117
|
+
# Check pyproject.toml first
|
|
118
|
+
pyproject_path = repo_path / "pyproject.toml"
|
|
119
|
+
if pyproject_path.exists():
|
|
120
|
+
try:
|
|
121
|
+
with open(pyproject_path, "rb") as f:
|
|
122
|
+
data = tomllib.load(f)
|
|
123
|
+
if "tool" in data and "hud" in data["tool"] and "clone" in data["tool"]["hud"]:
|
|
124
|
+
return data["tool"]["hud"]["clone"]
|
|
125
|
+
except Exception:
|
|
126
|
+
logger.warning("Failed to load clone config from %s", pyproject_path)
|
|
127
|
+
|
|
128
|
+
# Check .hud.toml as fallback
|
|
129
|
+
hud_toml_path = repo_path / ".hud.toml"
|
|
130
|
+
if hud_toml_path.exists():
|
|
131
|
+
try:
|
|
132
|
+
with open(hud_toml_path, "rb") as f:
|
|
133
|
+
data = tomllib.load(f)
|
|
134
|
+
if "clone" in data:
|
|
135
|
+
return data["clone"]
|
|
136
|
+
except Exception:
|
|
137
|
+
logger.warning("Failed to load clone config from %s", hud_toml_path)
|
|
138
|
+
|
|
139
|
+
return None
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def print_tutorial(clone_config: dict[str, Any] | None = None) -> None:
|
|
143
|
+
"""Print a rich formatted success message with optional tutorial."""
|
|
144
|
+
# Display custom message if configured
|
|
145
|
+
if clone_config:
|
|
146
|
+
# Handle different message formats
|
|
147
|
+
if "message" in clone_config:
|
|
148
|
+
# Message with Rich markup support
|
|
149
|
+
console.print(
|
|
150
|
+
Panel(
|
|
151
|
+
clone_config["message"], # Rich will parse markup automatically
|
|
152
|
+
title=clone_config.get("title", "📋 Getting Started"),
|
|
153
|
+
border_style=clone_config.get("style", "blue"),
|
|
154
|
+
padding=(1, 2),
|
|
155
|
+
)
|
|
156
|
+
)
|
|
157
|
+
elif "markdown" in clone_config:
|
|
158
|
+
# Markdown message
|
|
159
|
+
console.print(
|
|
160
|
+
Panel(
|
|
161
|
+
Markdown(clone_config["markdown"]),
|
|
162
|
+
title=clone_config.get("title", "📋 Getting Started"),
|
|
163
|
+
border_style=clone_config.get("style", "blue"),
|
|
164
|
+
padding=(1, 2),
|
|
165
|
+
)
|
|
166
|
+
)
|
|
167
|
+
elif "steps" in clone_config:
|
|
168
|
+
# Step-by-step instructions
|
|
169
|
+
title = clone_config.get("title", "📋 Getting Started")
|
|
170
|
+
console.print(f"\n[bold]{title}[/bold]\n")
|
|
171
|
+
for i, step in enumerate(clone_config["steps"], 1):
|
|
172
|
+
console.print(f" {i}. {step}")
|
|
173
|
+
console.print()
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def print_error(error_msg: str) -> None:
|
|
177
|
+
"""Print a rich formatted error message."""
|
|
178
|
+
console.print(
|
|
179
|
+
Panel(
|
|
180
|
+
Text(f"❌ {error_msg}", style="red"),
|
|
181
|
+
title="[bold red]Clone Failed[/bold red]",
|
|
182
|
+
border_style="red",
|
|
183
|
+
padding=(1, 2),
|
|
184
|
+
)
|
|
185
|
+
)
|
hud/cli/cursor.py
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
"""Cursor config parsing utilities."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import json
|
|
6
|
-
import os
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def parse_cursor_config(server_name: str) -> tuple[list[str] | None, str | None]:
|
|
11
|
-
"""
|
|
12
|
-
Parse cursor config to get command for a server.
|
|
13
|
-
|
|
14
|
-
Args:
|
|
15
|
-
server_name: Name of the server in Cursor config
|
|
16
|
-
|
|
17
|
-
Returns:
|
|
18
|
-
Tuple of (command_list, error_message). If successful, error_message is None.
|
|
19
|
-
If failed, command_list is None and error_message contains the error.
|
|
20
|
-
"""
|
|
21
|
-
# Find cursor config
|
|
22
|
-
cursor_config_path = Path.home() / ".cursor" / "mcp.json"
|
|
23
|
-
if not cursor_config_path.exists():
|
|
24
|
-
# Try Windows path
|
|
25
|
-
cursor_config_path = Path(os.environ.get("USERPROFILE", "")) / ".cursor" / "mcp.json"
|
|
26
|
-
|
|
27
|
-
if not cursor_config_path.exists():
|
|
28
|
-
return None, f"Cursor config not found at {cursor_config_path}"
|
|
29
|
-
|
|
30
|
-
try:
|
|
31
|
-
with open(cursor_config_path) as f:
|
|
32
|
-
config = json.load(f)
|
|
33
|
-
|
|
34
|
-
servers = config.get("mcpServers", {})
|
|
35
|
-
if server_name not in servers:
|
|
36
|
-
available = ", ".join(servers.keys())
|
|
37
|
-
return None, f"Server '{server_name}' not found. Available: {available}"
|
|
38
|
-
|
|
39
|
-
server_config = servers[server_name]
|
|
40
|
-
command = server_config.get("command", "")
|
|
41
|
-
args = server_config.get("args", [])
|
|
42
|
-
_ = server_config.get("env", {})
|
|
43
|
-
|
|
44
|
-
# Combine command and args
|
|
45
|
-
full_command = [command, *args]
|
|
46
|
-
|
|
47
|
-
# Handle reloaderoo wrapper
|
|
48
|
-
if command == "npx" and "reloaderoo" in args and "--" in args:
|
|
49
|
-
# Extract the actual command after --
|
|
50
|
-
dash_index = args.index("--")
|
|
51
|
-
full_command = args[dash_index + 1 :]
|
|
52
|
-
|
|
53
|
-
return full_command, None
|
|
54
|
-
|
|
55
|
-
except Exception as e:
|
|
56
|
-
return None, f"Error reading config: {e}"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def list_cursor_servers() -> tuple[list[str] | None, str | None]:
|
|
60
|
-
"""
|
|
61
|
-
List all available servers in Cursor config.
|
|
62
|
-
|
|
63
|
-
Returns:
|
|
64
|
-
Tuple of (server_list, error_message). If successful, error_message is None.
|
|
65
|
-
"""
|
|
66
|
-
# Find cursor config
|
|
67
|
-
cursor_config_path = Path.home() / ".cursor" / "mcp.json"
|
|
68
|
-
if not cursor_config_path.exists():
|
|
69
|
-
# Try Windows path
|
|
70
|
-
cursor_config_path = Path(os.environ.get("USERPROFILE", "")) / ".cursor" / "mcp.json"
|
|
71
|
-
|
|
72
|
-
if not cursor_config_path.exists():
|
|
73
|
-
return None, f"Cursor config not found at {cursor_config_path}"
|
|
74
|
-
|
|
75
|
-
try:
|
|
76
|
-
with open(cursor_config_path) as f:
|
|
77
|
-
config = json.load(f)
|
|
78
|
-
|
|
79
|
-
servers = config.get("mcpServers", {})
|
|
80
|
-
return list(servers.keys()), None
|
|
81
|
-
|
|
82
|
-
except Exception as e:
|
|
83
|
-
return None, f"Error reading config: {e}"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def get_cursor_config_path() -> Path:
|
|
87
|
-
"""Get the path to Cursor's MCP config file."""
|
|
88
|
-
cursor_config_path = Path.home() / ".cursor" / "mcp.json"
|
|
89
|
-
if not cursor_config_path.exists():
|
|
90
|
-
# Try Windows path
|
|
91
|
-
cursor_config_path = Path(os.environ.get("USERPROFILE", "")) / ".cursor" / "mcp.json"
|
|
92
|
-
return cursor_config_path
|
|
1
|
+
"""Cursor config parsing utilities."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def parse_cursor_config(server_name: str) -> tuple[list[str] | None, str | None]:
|
|
11
|
+
"""
|
|
12
|
+
Parse cursor config to get command for a server.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
server_name: Name of the server in Cursor config
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
Tuple of (command_list, error_message). If successful, error_message is None.
|
|
19
|
+
If failed, command_list is None and error_message contains the error.
|
|
20
|
+
"""
|
|
21
|
+
# Find cursor config
|
|
22
|
+
cursor_config_path = Path.home() / ".cursor" / "mcp.json"
|
|
23
|
+
if not cursor_config_path.exists():
|
|
24
|
+
# Try Windows path
|
|
25
|
+
cursor_config_path = Path(os.environ.get("USERPROFILE", "")) / ".cursor" / "mcp.json"
|
|
26
|
+
|
|
27
|
+
if not cursor_config_path.exists():
|
|
28
|
+
return None, f"Cursor config not found at {cursor_config_path}"
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
with open(cursor_config_path) as f:
|
|
32
|
+
config = json.load(f)
|
|
33
|
+
|
|
34
|
+
servers = config.get("mcpServers", {})
|
|
35
|
+
if server_name not in servers:
|
|
36
|
+
available = ", ".join(servers.keys())
|
|
37
|
+
return None, f"Server '{server_name}' not found. Available: {available}"
|
|
38
|
+
|
|
39
|
+
server_config = servers[server_name]
|
|
40
|
+
command = server_config.get("command", "")
|
|
41
|
+
args = server_config.get("args", [])
|
|
42
|
+
_ = server_config.get("env", {})
|
|
43
|
+
|
|
44
|
+
# Combine command and args
|
|
45
|
+
full_command = [command, *args]
|
|
46
|
+
|
|
47
|
+
# Handle reloaderoo wrapper
|
|
48
|
+
if command == "npx" and "reloaderoo" in args and "--" in args:
|
|
49
|
+
# Extract the actual command after --
|
|
50
|
+
dash_index = args.index("--")
|
|
51
|
+
full_command = args[dash_index + 1 :]
|
|
52
|
+
|
|
53
|
+
return full_command, None
|
|
54
|
+
|
|
55
|
+
except Exception as e:
|
|
56
|
+
return None, f"Error reading config: {e}"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def list_cursor_servers() -> tuple[list[str] | None, str | None]:
|
|
60
|
+
"""
|
|
61
|
+
List all available servers in Cursor config.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
Tuple of (server_list, error_message). If successful, error_message is None.
|
|
65
|
+
"""
|
|
66
|
+
# Find cursor config
|
|
67
|
+
cursor_config_path = Path.home() / ".cursor" / "mcp.json"
|
|
68
|
+
if not cursor_config_path.exists():
|
|
69
|
+
# Try Windows path
|
|
70
|
+
cursor_config_path = Path(os.environ.get("USERPROFILE", "")) / ".cursor" / "mcp.json"
|
|
71
|
+
|
|
72
|
+
if not cursor_config_path.exists():
|
|
73
|
+
return None, f"Cursor config not found at {cursor_config_path}"
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
with open(cursor_config_path) as f:
|
|
77
|
+
config = json.load(f)
|
|
78
|
+
|
|
79
|
+
servers = config.get("mcpServers", {})
|
|
80
|
+
return list(servers.keys()), None
|
|
81
|
+
|
|
82
|
+
except Exception as e:
|
|
83
|
+
return None, f"Error reading config: {e}"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def get_cursor_config_path() -> Path:
|
|
87
|
+
"""Get the path to Cursor's MCP config file."""
|
|
88
|
+
cursor_config_path = Path.home() / ".cursor" / "mcp.json"
|
|
89
|
+
if not cursor_config_path.exists():
|
|
90
|
+
# Try Windows path
|
|
91
|
+
cursor_config_path = Path(os.environ.get("USERPROFILE", "")) / ".cursor" / "mcp.json"
|
|
92
|
+
return cursor_config_path
|