ds-agent-cli 0.1.0 → 0.1.1
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/ds_agent/__init__.py +1 -1
- package/package.json +2 -2
- package/setup.py +1 -1
- package/src/cli.py +85 -26
package/ds_agent/__init__.py
CHANGED
package/package.json
CHANGED
package/setup.py
CHANGED
package/src/cli.py
CHANGED
|
@@ -9,6 +9,8 @@ from rich.panel import Panel
|
|
|
9
9
|
from rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn
|
|
10
10
|
from rich.live import Live
|
|
11
11
|
from rich import print as rprint
|
|
12
|
+
from rich import box
|
|
13
|
+
from rich.text import Text
|
|
12
14
|
from pathlib import Path
|
|
13
15
|
import json
|
|
14
16
|
import sys
|
|
@@ -16,7 +18,7 @@ import os
|
|
|
16
18
|
import io
|
|
17
19
|
import contextlib
|
|
18
20
|
import importlib.util
|
|
19
|
-
from typing import Optional
|
|
21
|
+
from typing import Optional, Tuple
|
|
20
22
|
|
|
21
23
|
# Add src to path
|
|
22
24
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__)))
|
|
@@ -40,35 +42,85 @@ app.add_typer(sessions_app, name="sessions")
|
|
|
40
42
|
console = Console()
|
|
41
43
|
|
|
42
44
|
|
|
45
|
+
def _hex_to_rgb(hex_color: str) -> Tuple[int, int, int]:
|
|
46
|
+
value = hex_color.lstrip("#")
|
|
47
|
+
return int(value[0:2], 16), int(value[2:4], 16), int(value[4:6], 16)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _rgb_to_hex(r: int, g: int, b: int) -> str:
|
|
51
|
+
return f"#{r:02x}{g:02x}{b:02x}"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _gradient_text(content: str, start_color: str, end_color: str, *, bold: bool = True) -> Text:
|
|
55
|
+
"""Render per-character color interpolation for a more futuristic terminal banner."""
|
|
56
|
+
start_r, start_g, start_b = _hex_to_rgb(start_color)
|
|
57
|
+
end_r, end_g, end_b = _hex_to_rgb(end_color)
|
|
58
|
+
|
|
59
|
+
visible_count = sum(1 for ch in content if ch != "\n")
|
|
60
|
+
steps = max(visible_count - 1, 1)
|
|
61
|
+
current = 0
|
|
62
|
+
|
|
63
|
+
out = Text()
|
|
64
|
+
for ch in content:
|
|
65
|
+
if ch == "\n":
|
|
66
|
+
out.append("\n")
|
|
67
|
+
continue
|
|
68
|
+
|
|
69
|
+
t = current / steps
|
|
70
|
+
r = int(start_r + (end_r - start_r) * t)
|
|
71
|
+
g = int(start_g + (end_g - start_g) * t)
|
|
72
|
+
b = int(start_b + (end_b - start_b) * t)
|
|
73
|
+
weight = "bold " if bold else ""
|
|
74
|
+
out.append(ch, style=f"{weight}{_rgb_to_hex(r, g, b)}")
|
|
75
|
+
current += 1
|
|
76
|
+
|
|
77
|
+
return out
|
|
78
|
+
|
|
79
|
+
|
|
43
80
|
def _print_cli_home():
|
|
44
81
|
"""Render a first-run friendly home screen for users running the CLI without arguments."""
|
|
45
|
-
banner = r"""
|
|
82
|
+
banner = r"""
|
|
46
83
|
____ ____ _ ____ _____ _ _ _____
|
|
47
84
|
| _ \/ ___| / \ / ___| ____| \ | |_ _|
|
|
48
85
|
| | | \___ \ / _ \| | _| _| | \| | | |
|
|
49
86
|
| |_| |___) | / ___ \ |_| | |___| |\ | | |
|
|
50
87
|
|____/|____/ /_/ \_\____|_____|_| \_| |_|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
""".strip("\n")
|
|
89
|
+
|
|
90
|
+
hero_content = Text()
|
|
91
|
+
hero_content.append_text(_gradient_text(banner, "#ff8d63", "#66f0ff", bold=True))
|
|
92
|
+
hero_content.append("\n\n")
|
|
93
|
+
hero_content.append_text(_gradient_text("A stylish, one-command data science command center", "#ffd4be", "#9ef7ff", bold=False))
|
|
94
|
+
|
|
95
|
+
hero = Panel(
|
|
96
|
+
hero_content,
|
|
97
|
+
border_style="#7bd7ff",
|
|
98
|
+
box=box.ROUNDED,
|
|
99
|
+
padding=(1, 2),
|
|
100
|
+
title="[bold #ff9b72]DS-AGENT[/bold #ff9b72]",
|
|
101
|
+
subtitle="[bold #7bd7ff]Neon CLI[/bold #7bd7ff]"
|
|
102
|
+
)
|
|
103
|
+
console.print(hero)
|
|
104
|
+
|
|
105
|
+
quick = Table(box=box.SIMPLE_HEAVY, show_header=True, header_style="bold #7bd7ff")
|
|
106
|
+
quick.add_column("Command", style="bold white", width=54, no_wrap=True)
|
|
107
|
+
quick.add_column("Use Case", style="#d0c9bc")
|
|
108
|
+
|
|
109
|
+
quick.add_row("ds-agent quickstart", "Copy-paste examples for every core workflow")
|
|
110
|
+
quick.add_row("ds-agent analyze <file>", "Run complete ML workflow with one command")
|
|
111
|
+
quick.add_row("ds-agent chat [file]", "Interactive assistant with session memory")
|
|
112
|
+
quick.add_row("ds-agent report <file>", "Generate beautiful HTML profiling reports")
|
|
113
|
+
quick.add_row("ds-agent train <file> --target <col>", "Train baseline models quickly")
|
|
114
|
+
quick.add_row("ds-agent tune <file> --target <col>", "Optimize models with Optuna")
|
|
115
|
+
quick.add_row("ds-agent plot <file>", "Create plots and visual diagnostics")
|
|
116
|
+
quick.add_row("ds-agent forecast <file> --time <col> --target <col>", "Time-series forecasting")
|
|
117
|
+
quick.add_row("ds-agent sessions list", "View, resume, or clean saved sessions")
|
|
118
|
+
quick.add_row("ds-agent --help", "Full command and options reference")
|
|
69
119
|
|
|
70
|
-
console.print(
|
|
71
|
-
console.print(
|
|
120
|
+
console.print()
|
|
121
|
+
console.print(quick)
|
|
122
|
+
console.print("\n[bold #7bd7ff]Start here:[/bold #7bd7ff] [white]ds-agent quickstart[/white]")
|
|
123
|
+
console.print("[dim]Tip: add --help to any command for detailed usage, examples, and flags.[/dim]")
|
|
72
124
|
|
|
73
125
|
|
|
74
126
|
@app.callback(invoke_without_command=True)
|
|
@@ -93,9 +145,15 @@ def root_callback(
|
|
|
93
145
|
@app.command()
|
|
94
146
|
def quickstart():
|
|
95
147
|
"""Show beginner-friendly command guide with copy-paste examples."""
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
148
|
+
console.print(Panel.fit(
|
|
149
|
+
"[bold #7bd7ff]Quickstart Command Deck[/bold #7bd7ff]\n[dim]Run these exactly as shown and replace file paths.[/dim]",
|
|
150
|
+
border_style="#7bd7ff",
|
|
151
|
+
box=box.ROUNDED
|
|
152
|
+
))
|
|
153
|
+
|
|
154
|
+
guide = Table(box=box.SIMPLE_HEAVY, show_header=True, header_style="bold #7bd7ff")
|
|
155
|
+
guide.add_column("Workflow", style="bold white", width=24, no_wrap=True)
|
|
156
|
+
guide.add_column("Command", style="#d0c9bc", no_wrap=True)
|
|
99
157
|
|
|
100
158
|
guide.add_row("Analyze", "ds-agent analyze data.csv --target price --task \"predict price\"")
|
|
101
159
|
guide.add_row("Chat", "ds-agent chat data.csv")
|
|
@@ -110,7 +168,8 @@ def quickstart():
|
|
|
110
168
|
|
|
111
169
|
console.print()
|
|
112
170
|
console.print(guide)
|
|
113
|
-
console.print("\n[
|
|
171
|
+
console.print("\n[bold #7bd7ff]Need details?[/bold #7bd7ff] [white]ds-agent <command> --help[/white]")
|
|
172
|
+
console.print("[dim]Example: ds-agent report --help | ds-agent forecast --help[/dim]")
|
|
114
173
|
|
|
115
174
|
|
|
116
175
|
def _load_module_from_src(module_name: str, relative_path: str):
|