devstuff 2.8.0__py3-none-any.whl → 2.10.0__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.
- dev_setup/agent/approval.py +6 -6
- dev_setup/agent/loop.py +5 -2
- dev_setup/agent/session.py +33 -11
- dev_setup/commands/add_cmd.py +2 -2
- dev_setup/commands/configure_cmd.py +7 -4
- dev_setup/commands/docs_cmd.py +1 -1
- dev_setup/commands/doctor_cmd.py +21 -7
- dev_setup/commands/functions_cmd.py +12 -8
- dev_setup/commands/help_cmd.py +36 -10
- dev_setup/commands/install_cmd.py +1 -1
- dev_setup/commands/list_cmd.py +17 -16
- dev_setup/configure/starship/icons.py +166 -0
- dev_setup/configure/starship/model.py +22 -2
- dev_setup/configure/starship/render.py +39 -24
- dev_setup/configure/starship/wizard.py +309 -0
- dev_setup/ui.py +118 -27
- {devstuff-2.8.0.dist-info → devstuff-2.10.0.dist-info}/METADATA +2 -2
- {devstuff-2.8.0.dist-info → devstuff-2.10.0.dist-info}/RECORD +20 -19
- {devstuff-2.8.0.dist-info → devstuff-2.10.0.dist-info}/WHEEL +0 -0
- {devstuff-2.8.0.dist-info → devstuff-2.10.0.dist-info}/entry_points.txt +0 -0
dev_setup/agent/approval.py
CHANGED
|
@@ -21,7 +21,7 @@ def _write_file_preview(args: dict[str, Any], ws: Workspace) -> Panel:
|
|
|
21
21
|
except SandboxError:
|
|
22
22
|
# The sandbox will reject this before it runs; show the raw request rather
|
|
23
23
|
# than crashing the prompt.
|
|
24
|
-
return Panel(str(args.get("path", "")), title="write_file", border_style=
|
|
24
|
+
return Panel(str(args.get("path", "")), title="write_file", border_style=ui.AMBER)
|
|
25
25
|
|
|
26
26
|
new = args.get("content", "")
|
|
27
27
|
old = path.read_text(encoding="utf-8", errors="replace") if path.exists() else ""
|
|
@@ -29,7 +29,7 @@ def _write_file_preview(args: dict[str, Any], ws: Workspace) -> Panel:
|
|
|
29
29
|
|
|
30
30
|
if not path.exists():
|
|
31
31
|
body = Syntax(new, "text", theme="monokai", line_numbers=False, word_wrap=True)
|
|
32
|
-
return Panel(body, title=f"create {label}", border_style=
|
|
32
|
+
return Panel(body, title=f"create {label}", border_style=ui.GREEN)
|
|
33
33
|
|
|
34
34
|
diff = "".join(
|
|
35
35
|
difflib.unified_diff(
|
|
@@ -41,11 +41,11 @@ def _write_file_preview(args: dict[str, Any], ws: Workspace) -> Panel:
|
|
|
41
41
|
)
|
|
42
42
|
)
|
|
43
43
|
if not diff:
|
|
44
|
-
return Panel("(no change)", title=f"write {label}", border_style=
|
|
44
|
+
return Panel("(no change)", title=f"write {label}", border_style=ui.BORDER)
|
|
45
45
|
return Panel(
|
|
46
46
|
Syntax(diff, "diff", theme="monokai", line_numbers=False),
|
|
47
47
|
title=f"edit {label}",
|
|
48
|
-
border_style=
|
|
48
|
+
border_style=ui.AMBER,
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
|
|
@@ -59,11 +59,11 @@ def preview(tool: AgentTool, args: dict[str, Any], ws: Workspace) -> Panel:
|
|
|
59
59
|
return Panel(
|
|
60
60
|
Syntax(str(args.get("command", "")), "bash", theme="monokai", line_numbers=False),
|
|
61
61
|
title=f"run in {ws.display(ws.cwd)}",
|
|
62
|
-
border_style=
|
|
62
|
+
border_style=ui.AMBER,
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
rendered = "\n".join(f"{k}: {v}" for k, v in args.items()) or "(no arguments)"
|
|
66
|
-
return Panel(rendered, title=tool.key, border_style=
|
|
66
|
+
return Panel(rendered, title=tool.key, border_style=ui.AMBER)
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
class ApprovalPolicy:
|
dev_setup/agent/loop.py
CHANGED
|
@@ -67,7 +67,8 @@ def execute(session, call: ToolCall) -> ToolOutcome:
|
|
|
67
67
|
call.name, False, "the user declined this action. Ask what they would prefer."
|
|
68
68
|
)
|
|
69
69
|
else:
|
|
70
|
-
|
|
70
|
+
preview = ", ".join(f"{k}={v!r}" for k, v in args.items())[:120]
|
|
71
|
+
ui.console.print(f" [{ui.CYAN}]▸[/] [{ui.GRAY}]{call.name}({preview})[/]")
|
|
71
72
|
|
|
72
73
|
try:
|
|
73
74
|
output = _dispatch(session, tool, args)
|
|
@@ -122,7 +123,9 @@ def run_turn(session, user_text: str) -> Message | None:
|
|
|
122
123
|
}
|
|
123
124
|
)
|
|
124
125
|
if not outcome.ok:
|
|
125
|
-
ui.
|
|
126
|
+
ui.console.print(
|
|
127
|
+
f" [{ui.AMBER}]▸[/] [{ui.GRAY}]{outcome.content.splitlines()[0][:120]}[/]"
|
|
128
|
+
)
|
|
126
129
|
|
|
127
130
|
ui.warn(f"Stopped after {session.config.max_iterations} tool calls without a final answer.")
|
|
128
131
|
ui.dim("Ask again with a narrower request, or /reset to start over.")
|
dev_setup/agent/session.py
CHANGED
|
@@ -91,16 +91,19 @@ def render(reply: Message | None) -> None:
|
|
|
91
91
|
return
|
|
92
92
|
if reply.content.strip():
|
|
93
93
|
ui.console.print()
|
|
94
|
-
ui.console.print(Markdown(reply.content.strip()))
|
|
94
|
+
ui.console.print(ui.gutter(Markdown(reply.content.strip())))
|
|
95
95
|
ui.console.print()
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
def _print_banner(session: AgentSession) -> None:
|
|
99
99
|
ui.section("devstuff agent")
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
for key, value in (
|
|
101
|
+
("model", session.model),
|
|
102
|
+
("host", session.client.host),
|
|
103
|
+
("workspace", str(session.workspace.root)),
|
|
104
|
+
("tools", f"{len(session.tools)} available"),
|
|
105
|
+
):
|
|
106
|
+
ui.console.print(f" [{ui.PURPLE}]{key:<10}[/] [{ui.GRAY}]{value}[/]")
|
|
104
107
|
if session.policy.yolo:
|
|
105
108
|
ui.console.print()
|
|
106
109
|
ui.warn("--yolo: mutating tools run without confirmation (the denylist still applies).")
|
|
@@ -121,7 +124,7 @@ def _print_slash_help() -> None:
|
|
|
121
124
|
|
|
122
125
|
def _print_tools(session: AgentSession) -> None:
|
|
123
126
|
for key, tool in sorted(session.tools.items()):
|
|
124
|
-
marker = "[
|
|
127
|
+
marker = f"[{ui.AMBER}]![/]" if tool.mutating else " "
|
|
125
128
|
ui.console.print(f" {marker} [bold cyan]{key:<18}[/] [dim]{tool.description[:70]}[/]")
|
|
126
129
|
ui.console.print()
|
|
127
130
|
ui.dim("! = mutating, asks for confirmation before running")
|
|
@@ -151,15 +154,15 @@ def _summarise(message: dict[str, Any]) -> str | None:
|
|
|
151
154
|
if role == "system":
|
|
152
155
|
return None
|
|
153
156
|
if role == "user":
|
|
154
|
-
return f"[bold]you[/]
|
|
157
|
+
return f"[{ui.PURPLE} bold]you[/] {str(message.get('content', ''))[:80]}"
|
|
155
158
|
if role == "tool":
|
|
156
159
|
first = str(message.get("content", "")).splitlines()[:1]
|
|
157
|
-
return f"[
|
|
160
|
+
return f"[{ui.GRAY}]tool[/] {message.get('tool_name', '?')} → {(first[0] if first else '')[:60]}"
|
|
158
161
|
calls = message.get("tool_calls") or []
|
|
159
162
|
if calls:
|
|
160
163
|
names = ", ".join(c["function"]["name"] for c in calls)
|
|
161
|
-
return f"[
|
|
162
|
-
return f"[
|
|
164
|
+
return f"[{ui.CYAN}]agent[/] calls {names}"
|
|
165
|
+
return f"[{ui.CYAN}]agent[/] {str(message.get('content', ''))[:80]}"
|
|
163
166
|
|
|
164
167
|
|
|
165
168
|
def _print_history(session: AgentSession) -> None:
|
|
@@ -282,6 +285,22 @@ def _continuation(width: int, line_number: int, is_soft_wrap: bool) -> str:
|
|
|
282
285
|
return " " * max(0, width - 2) + "› "
|
|
283
286
|
|
|
284
287
|
|
|
288
|
+
def _prompt_style():
|
|
289
|
+
"""prompt_toolkit theme: violet prompt glyph, dark-violet completion menu."""
|
|
290
|
+
from prompt_toolkit.styles import Style as PTStyle
|
|
291
|
+
|
|
292
|
+
return PTStyle.from_dict({
|
|
293
|
+
"prompt": f"{ui.PURPLE} bold",
|
|
294
|
+
"completion-menu": "bg:#26223B #DDD6FE",
|
|
295
|
+
"completion-menu.completion": "bg:#26223B #DDD6FE",
|
|
296
|
+
"completion-menu.completion.current": f"bg:{ui.VIOLET} #FFFFFF bold",
|
|
297
|
+
"completion-menu.meta.completion": f"bg:#26223B {ui.GRAY}",
|
|
298
|
+
"completion-menu.meta.completion.current": "bg:#7C3AED #DDD6FE",
|
|
299
|
+
"scrollbar.background": "bg:#26223B",
|
|
300
|
+
"scrollbar.button": "bg:#4B4568",
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
|
|
285
304
|
def build_prompt_session(session: AgentSession, **overrides):
|
|
286
305
|
"""Split out from run_repl so the input behaviour can be driven by tests with a
|
|
287
306
|
pipe input rather than only exercised by hand."""
|
|
@@ -297,6 +316,7 @@ def build_prompt_session(session: AgentSession, **overrides):
|
|
|
297
316
|
"multiline": True,
|
|
298
317
|
"key_bindings": _key_bindings(),
|
|
299
318
|
"prompt_continuation": _continuation,
|
|
319
|
+
"style": _prompt_style(),
|
|
300
320
|
}
|
|
301
321
|
kwargs.update(overrides)
|
|
302
322
|
return PromptSession(**kwargs)
|
|
@@ -308,9 +328,11 @@ def run_repl(session: AgentSession) -> None:
|
|
|
308
328
|
|
|
309
329
|
_print_banner(session)
|
|
310
330
|
|
|
331
|
+
from prompt_toolkit.formatted_text import HTML
|
|
332
|
+
|
|
311
333
|
while True:
|
|
312
334
|
try:
|
|
313
|
-
line = prompt_session.prompt("you
|
|
335
|
+
line = prompt_session.prompt(HTML("<prompt>you ❯</prompt> ")).strip()
|
|
314
336
|
except KeyboardInterrupt:
|
|
315
337
|
continue # Ctrl-C clears the current line, like a shell
|
|
316
338
|
except EOFError:
|
dev_setup/commands/add_cmd.py
CHANGED
|
@@ -124,11 +124,11 @@ def add_cmd() -> None:
|
|
|
124
124
|
)
|
|
125
125
|
|
|
126
126
|
ui.console.print()
|
|
127
|
-
ui.
|
|
127
|
+
ui.heading("Summary")
|
|
128
128
|
for k, v in kwargs.items():
|
|
129
129
|
if v:
|
|
130
130
|
display = _truncate_script(v) if k.endswith("_script") else v
|
|
131
|
-
ui.console.print(f" [
|
|
131
|
+
ui.console.print(f" [{ui.PURPLE}]{k:<18}[/] {display}")
|
|
132
132
|
ui.console.print()
|
|
133
133
|
|
|
134
134
|
if not ui.confirm("Save this package?"):
|
|
@@ -101,11 +101,14 @@ def _is_installed(key: str) -> bool:
|
|
|
101
101
|
|
|
102
102
|
def _print_list() -> None:
|
|
103
103
|
ui.console.print()
|
|
104
|
-
ui.
|
|
105
|
-
width =
|
|
104
|
+
tbl = ui.table(title="[bold]configurable tools[/]")
|
|
105
|
+
tbl.add_column("", width=2, justify="center")
|
|
106
|
+
tbl.add_column("Tool", style="bold cyan", no_wrap=True)
|
|
107
|
+
tbl.add_column("Description", ratio=1)
|
|
106
108
|
for spec in configure.CONFIGURATORS.values():
|
|
107
|
-
mark = "[
|
|
108
|
-
|
|
109
|
+
mark = f"[{ui.GREEN}]●[/]" if _is_installed(spec.key) else f"[{ui.GRAY}]○[/]"
|
|
110
|
+
tbl.add_row(mark, spec.key, spec.description)
|
|
111
|
+
ui.console.print(tbl)
|
|
109
112
|
ui.console.print()
|
|
110
113
|
ui.dim(" devstuff configure <tool>")
|
|
111
114
|
ui.console.print()
|
dev_setup/commands/docs_cmd.py
CHANGED
|
@@ -25,7 +25,7 @@ def docs_cmd(package: str) -> None:
|
|
|
25
25
|
sys.exit(1)
|
|
26
26
|
|
|
27
27
|
ui.console.print(f"\n [bold]{tool.name}[/] docs")
|
|
28
|
-
ui.console.print(f" [cyan]{tool.docs_url}[/]\n")
|
|
28
|
+
ui.console.print(f" [cyan underline link={tool.docs_url}]{tool.docs_url}[/]\n")
|
|
29
29
|
|
|
30
30
|
opened = webbrowser.open(tool.docs_url)
|
|
31
31
|
if opened:
|
dev_setup/commands/doctor_cmd.py
CHANGED
|
@@ -7,11 +7,12 @@ import click
|
|
|
7
7
|
from dev_setup import doctor, ui
|
|
8
8
|
|
|
9
9
|
_STATUS_ICON = {
|
|
10
|
-
doctor.PASS: "[
|
|
11
|
-
doctor.WARN: "[
|
|
12
|
-
doctor.FAIL: "[
|
|
10
|
+
doctor.PASS: f"[{ui.GREEN} bold]✔[/]",
|
|
11
|
+
doctor.WARN: f"[{ui.AMBER} bold]⚠[/]",
|
|
12
|
+
doctor.FAIL: f"[{ui.RED} bold]✖[/]",
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
# pass needs no text label — the icon carries it. warn/fail get one for scanability.
|
|
15
|
+
_STATUS_LABEL = {doctor.WARN: ui.AMBER, doctor.FAIL: ui.RED}
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
@click.command("doctor")
|
|
@@ -32,8 +33,11 @@ def doctor_cmd(auto_fix: bool, check_only: bool) -> None:
|
|
|
32
33
|
fixable: list[doctor.CheckResult] = []
|
|
33
34
|
for r in results:
|
|
34
35
|
icon = _STATUS_ICON.get(r.status, "[dim]?[/]")
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
line = f" {icon} [bold]{r.name}[/] {r.message}"
|
|
37
|
+
color = _STATUS_LABEL.get(r.status)
|
|
38
|
+
if color:
|
|
39
|
+
line += f" [{color} bold]{r.status.upper()}[/]"
|
|
40
|
+
ui.console.print(line)
|
|
37
41
|
if r.detail:
|
|
38
42
|
ui.dim(f" {r.detail}")
|
|
39
43
|
if r.status != doctor.PASS and r.fix is not None:
|
|
@@ -42,9 +46,19 @@ def doctor_cmd(auto_fix: bool, check_only: bool) -> None:
|
|
|
42
46
|
passed = sum(1 for r in results if r.status == doctor.PASS)
|
|
43
47
|
warned = sum(1 for r in results if r.status == doctor.WARN)
|
|
44
48
|
failed = sum(1 for r in results if r.status == doctor.FAIL)
|
|
49
|
+
|
|
50
|
+
def _count(n: int, color: str, word: str) -> str:
|
|
51
|
+
style = color if n else ui.GRAY
|
|
52
|
+
return f"[{style}]{n} {word}[/]"
|
|
53
|
+
|
|
45
54
|
ui.console.print()
|
|
46
55
|
ui.console.print(
|
|
47
|
-
|
|
56
|
+
" "
|
|
57
|
+
+ " · ".join([
|
|
58
|
+
_count(passed, ui.GREEN, "passed"),
|
|
59
|
+
_count(warned, ui.AMBER, "warnings"),
|
|
60
|
+
_count(failed, ui.RED, "failed"),
|
|
61
|
+
])
|
|
48
62
|
)
|
|
49
63
|
|
|
50
64
|
if check_only or not fixable:
|
|
@@ -26,17 +26,21 @@ def list_cmd() -> None:
|
|
|
26
26
|
for f in fns:
|
|
27
27
|
by_cat.setdefault(f.category, []).append(f)
|
|
28
28
|
|
|
29
|
-
key_width = max((len(f.key) for f in fns), default=12) + 2
|
|
30
29
|
for cat in sorted(by_cat, key=lambda c: (c == "custom", c)):
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
entries = sorted(by_cat[cat], key=lambda f: f.key)
|
|
31
|
+
tbl = ui.table(
|
|
32
|
+
title=f"[bold]{cat}[/] [{ui.GRAY}]{len(entries)} function(s)[/]"
|
|
33
|
+
)
|
|
34
|
+
tbl.add_column("Function", style="bold cyan", no_wrap=True)
|
|
35
|
+
tbl.add_column("Type", style=ui.CYAN, no_wrap=True)
|
|
36
|
+
tbl.add_column("Args", style=ui.GRAY, no_wrap=True)
|
|
37
|
+
tbl.add_column("Description", ratio=1)
|
|
38
|
+
for f in entries:
|
|
33
39
|
mode = f.type if f.type == "script" else f"{f.type} ({f.register})"
|
|
34
|
-
ui.console.print(
|
|
35
|
-
f" [bold cyan]{f.key:<{key_width}}[/] [dim]{mode:<22}[/] {f.description}"
|
|
36
|
-
)
|
|
37
40
|
params = " ".join(f"<{p.name}>" for p in f.params)
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
tbl.add_row(f.key, mode, params, f.description)
|
|
42
|
+
ui.console.print(tbl)
|
|
43
|
+
ui.console.print()
|
|
40
44
|
|
|
41
45
|
|
|
42
46
|
@functions_cmd.command("enable")
|
dev_setup/commands/help_cmd.py
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
from rich.columns import Columns
|
|
2
|
+
from rich.text import Text
|
|
3
|
+
|
|
1
4
|
from dev_setup import ui
|
|
2
5
|
from dev_setup.catalog import USER_CATALOG_PATH
|
|
3
6
|
|
|
7
|
+
_CATEGORY_DESC = {
|
|
8
|
+
"core": "Always-installed tools (Docker, NVM, uv)",
|
|
9
|
+
"tools": "Optional utilities (lazygit, htop, bat)",
|
|
10
|
+
"ai-tools": "AI coding agents and assistants",
|
|
11
|
+
"customization": "Prompt and shell customization",
|
|
12
|
+
"languages": "Programming language runtimes",
|
|
13
|
+
"custom": "User-added packages",
|
|
14
|
+
}
|
|
15
|
+
|
|
4
16
|
|
|
5
17
|
def print_help() -> None:
|
|
6
18
|
ui.print_banner()
|
|
@@ -26,10 +38,15 @@ def print_help() -> None:
|
|
|
26
38
|
("agent", "[--setup] [--dir] [--model]", "Chat with a local tool-using model"),
|
|
27
39
|
("version", "", "Show version"),
|
|
28
40
|
]
|
|
41
|
+
tbl = ui.table(bordered=False, show_header=False)
|
|
42
|
+
tbl.add_column("cmd", style="bold cyan", no_wrap=True)
|
|
43
|
+
tbl.add_column("args", style=ui.GRAY, no_wrap=True)
|
|
44
|
+
tbl.add_column("desc", ratio=1)
|
|
29
45
|
for cmd, args, desc in rows:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)
|
|
46
|
+
# args goes in as Text: strings like "[category]" are valid Rich markup
|
|
47
|
+
# tags and would be silently swallowed from a plain str cell.
|
|
48
|
+
tbl.add_row(f" {cmd}", Text(args), desc)
|
|
49
|
+
ui.console.print(tbl)
|
|
33
50
|
|
|
34
51
|
ui.console.print()
|
|
35
52
|
ui.console.print("[bold]EXAMPLES[/]")
|
|
@@ -58,15 +75,24 @@ def print_help() -> None:
|
|
|
58
75
|
'devstuff agent --print "what node tools are available?"',
|
|
59
76
|
"ssh-agent-key ~/.ssh/id_ed25519",
|
|
60
77
|
]
|
|
61
|
-
|
|
62
|
-
|
|
78
|
+
items = [
|
|
79
|
+
Text.assemble((" $ ", ui.GRAY), (ex, "green")) for ex in examples
|
|
80
|
+
]
|
|
81
|
+
ui.console.print(Columns(items, column_first=True, padding=(0, 3)))
|
|
82
|
+
|
|
83
|
+
from dev_setup import registry
|
|
63
84
|
|
|
64
85
|
ui.console.print()
|
|
65
86
|
ui.console.print("[bold]CATEGORIES[/]")
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
87
|
+
_ORDER = {"core": 0, "tools": 1, "custom": 999}
|
|
88
|
+
cats = sorted(
|
|
89
|
+
{t.category for t in registry.all_tools()},
|
|
90
|
+
key=lambda c: (_ORDER.get(c, 500), c),
|
|
91
|
+
)
|
|
92
|
+
for cat in cats:
|
|
93
|
+
desc = _CATEGORY_DESC.get(cat, "")
|
|
94
|
+
ui.console.print(f" [cyan]{cat:<14}[/] [{ui.GRAY}]{desc}[/]")
|
|
70
95
|
|
|
96
|
+
ui.console.print()
|
|
71
97
|
ui.console.print("[bold]CONFIG[/]")
|
|
72
|
-
ui.console.print(f" User catalog: [
|
|
98
|
+
ui.console.print(f" User catalog: [{ui.GRAY}]{USER_CATALOG_PATH}[/]\n")
|
|
@@ -106,7 +106,7 @@ def _install_interactive() -> None:
|
|
|
106
106
|
else:
|
|
107
107
|
disabled = None
|
|
108
108
|
title = [
|
|
109
|
-
("class:check", "
|
|
109
|
+
("class:check", "● " if is_inst else " "),
|
|
110
110
|
("class:text", f"{t.key:<{key_width}}{desc}"),
|
|
111
111
|
]
|
|
112
112
|
choices.append(questionary.Choice(
|
dev_setup/commands/list_cmd.py
CHANGED
|
@@ -3,7 +3,6 @@ from __future__ import annotations
|
|
|
3
3
|
from concurrent.futures import ThreadPoolExecutor
|
|
4
4
|
|
|
5
5
|
import click
|
|
6
|
-
from rich.table import Table
|
|
7
6
|
|
|
8
7
|
from dev_setup import registry, ui
|
|
9
8
|
from dev_setup.base import Tool
|
|
@@ -53,24 +52,26 @@ def list_cmd(show_filter: str, category: str) -> None:
|
|
|
53
52
|
if not entries:
|
|
54
53
|
continue
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
ui.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
tbl.add_column("", width=2)
|
|
61
|
-
tbl.add_column("Package", style="bold",
|
|
62
|
-
tbl.add_column("Description",
|
|
63
|
-
tbl.add_column("Type", style=
|
|
64
|
-
tbl.add_column("Version", style="
|
|
55
|
+
n_inst = sum(1 for _, is_inst, _ in entries if is_inst)
|
|
56
|
+
tbl = ui.table(
|
|
57
|
+
title=f"[bold]{cat}[/] [{ui.GRAY}]{n_inst}/{len(entries)} installed[/]"
|
|
58
|
+
)
|
|
59
|
+
tbl.add_column("", width=2, justify="center")
|
|
60
|
+
tbl.add_column("Package", style="bold", no_wrap=True)
|
|
61
|
+
tbl.add_column("Description", ratio=1)
|
|
62
|
+
tbl.add_column("Type", style=ui.CYAN, no_wrap=True)
|
|
63
|
+
tbl.add_column("Version", style=ui.GRAY, no_wrap=True, max_width=28, overflow="ellipsis")
|
|
65
64
|
|
|
66
65
|
for tool, is_inst, version in entries:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
tbl.add_row(icon, tool.key, tool.description, tool.install_type, version)
|
|
66
|
+
icon = f"[{ui.GREEN}]●[/]" if is_inst else f"[{ui.GRAY}]○[/]"
|
|
67
|
+
desc = tool.description
|
|
70
68
|
if tool.help_cmd:
|
|
71
|
-
|
|
72
|
-
if
|
|
73
|
-
|
|
69
|
+
desc += f"\n[{ui.GRAY}] ↳ {tool.help_cmd}[/]"
|
|
70
|
+
if not is_inst:
|
|
71
|
+
missing = registry.missing_requires(tool)
|
|
72
|
+
if missing:
|
|
73
|
+
desc += f"\n[{ui.AMBER}] ⚠ requires: {', '.join(missing)}[/]"
|
|
74
|
+
tbl.add_row(icon, tool.key, desc, tool.install_type, version)
|
|
74
75
|
|
|
75
76
|
ui.console.print(tbl)
|
|
76
77
|
ui.console.print()
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""A curated catalog of Nerd Font glyphs and emoji for the icon picker.
|
|
2
|
+
|
|
3
|
+
Every entry has a stable ``key``, a human-readable ``label`` (what the filterable
|
|
4
|
+
picker searches against), the ``glyph`` string that gets emitted into the config,
|
|
5
|
+
and one or more ``categories`` so the picker can group them. Glyphs are written as
|
|
6
|
+
escapes with their Nerd Font names so the source stays reviewable without the font
|
|
7
|
+
installed — the same convention as ``model.py``'s section icons.
|
|
8
|
+
|
|
9
|
+
The catalog is deliberately not exhaustive: it covers the domains the wizard's
|
|
10
|
+
sections live in (languages, cloud, git, shell, general) with a handful of
|
|
11
|
+
alternatives each, plus a set of generic shapes that work for anything. A user
|
|
12
|
+
who wants a glyph not listed here can type one into the picker's free-text input.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from dataclasses import dataclass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class Icon:
|
|
22
|
+
key: str
|
|
23
|
+
label: str
|
|
24
|
+
glyph: str
|
|
25
|
+
categories: tuple[str, ...] = ()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Category constants — keep in sync with the wizard's grouping.
|
|
29
|
+
CAT_LANG = "Languages"
|
|
30
|
+
CAT_CLOUD = "Cloud & Infrastructure"
|
|
31
|
+
CAT_GIT = "Git"
|
|
32
|
+
CAT_SHELL = "Shell"
|
|
33
|
+
CAT_GENERAL = "General"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
ICONS: tuple[Icon, ...] = (
|
|
37
|
+
# -- General -----------------------------------------------------------------
|
|
38
|
+
Icon("folder", "Folder", "\uf07b ", (CAT_GENERAL,)), # nf-fa-folder
|
|
39
|
+
Icon("folder_open", "Open folder", "\uf07c ", (CAT_GENERAL,)), # nf-fa-folder_open
|
|
40
|
+
Icon("package", "Package", "\U000f03d7 ", (CAT_GENERAL,)), # nf-md-package_variant_closed
|
|
41
|
+
Icon("package_box", "Package box", "\uf1b6 ", (CAT_GENERAL,)), # nf-fa-inbox
|
|
42
|
+
Icon("container", "Container", "\U000f021b ", (CAT_GENERAL,)), # nf-md-container
|
|
43
|
+
Icon("cube", "Cube", "\uf1b2 ", (CAT_GENERAL,)), # nf-fa-cube
|
|
44
|
+
Icon("gear", "Gear", "\uf013 ", (CAT_GENERAL,)), # nf-fa-cog
|
|
45
|
+
Icon("wrench", "Wrench", "\uf0ad ", (CAT_GENERAL,)), # nf-fa-wrench
|
|
46
|
+
Icon("rocket", "Rocket", "\uf135 ", (CAT_GENERAL,)), # nf-fa-rocket
|
|
47
|
+
Icon("star", "Star", "\uf005 ", (CAT_GENERAL,)), # nf-fa-star
|
|
48
|
+
Icon("heart", "Heart", "\uf004 ", (CAT_GENERAL,)), # nf-fa-heart
|
|
49
|
+
Icon("check", "Check mark", "\uf00c ", (CAT_GENERAL,)), # nf-fa-check
|
|
50
|
+
Icon("x", "X mark", "\uf00d ", (CAT_GENERAL,)), # nf-fa-times
|
|
51
|
+
Icon("lightbulb", "Light bulb", "\uf0eb ", (CAT_GENERAL,)), # nf-fa-lightbulb_o
|
|
52
|
+
Icon("fire", "Fire", "\uf06d ", (CAT_GENERAL,)), # nf-fa-fire
|
|
53
|
+
Icon("bolt", "Lightning bolt", "\uf0e7 ", (CAT_GENERAL,)), # nf-fa-bolt
|
|
54
|
+
Icon("terminal", "Terminal", "\uf120 ", (CAT_GENERAL,)), # nf-fa-terminal
|
|
55
|
+
Icon("keyboard", "Keyboard", "\uf11c ", (CAT_GENERAL,)), # nf-fa-keyboard_o
|
|
56
|
+
Icon("clock", "Clock", "\uf017 ", (CAT_GENERAL,)), # nf-fa-clock_o
|
|
57
|
+
Icon("hourglass", "Hourglass", "\uf252 ", (CAT_GENERAL,)), # nf-fa-hourglass_half
|
|
58
|
+
Icon("chart", "Bar chart", "\uf080 ", (CAT_GENERAL,)), # nf-fa-bar_chart
|
|
59
|
+
Icon("database", "Database", "\uf1c0 ", (CAT_GENERAL,)), # nf-fa-database
|
|
60
|
+
Icon("server", "Server", "\uf233 ", (CAT_GENERAL,)), # nf-fa-server
|
|
61
|
+
Icon("globe", "Globe", "\uf0ac ", (CAT_GENERAL,)), # nf-fa-globe
|
|
62
|
+
Icon("link", "Link", "\uf0c1 ", (CAT_GENERAL,)), # nf-fa-link
|
|
63
|
+
|
|
64
|
+
# -- Git ---------------------------------------------------------------------
|
|
65
|
+
Icon("git_branch", "Git branch", "\ue0a0 ", (CAT_GIT,)), # nf-pl-branch
|
|
66
|
+
Icon("git_branch_alt", "Git branch (alt)", "\uf126 ", (CAT_GIT,)), # nf-fa-code_fork
|
|
67
|
+
Icon("git_commit", "Git commit", "\ue0a1 ", (CAT_GIT,)), # nf-pl-narrow
|
|
68
|
+
Icon("git_merge", "Git merge", "\ue0a3 ", (CAT_GIT,)), # nf-pl-branch
|
|
69
|
+
Icon("git_pull", "Git pull request", "\uf09b ", (CAT_GIT,)), # nf-fa-github_alt
|
|
70
|
+
Icon("fork", "Fork", "\uf126 ", (CAT_GIT,)), # nf-fa-code_fork
|
|
71
|
+
Icon("diff", "Diff", "\ue728 ", (CAT_GIT,)), # nf-seti-git
|
|
72
|
+
|
|
73
|
+
# -- Languages ---------------------------------------------------------------
|
|
74
|
+
Icon("nodejs_small", "Node.js small", "\ue718 ", (CAT_LANG,)), # nf-dev-nodejs_small
|
|
75
|
+
Icon("nodejs", "Node.js", "\ue74e ", (CAT_LANG,)), # nf-dev-nodejs_large
|
|
76
|
+
Icon("js", "JavaScript", "\ue74e ", (CAT_LANG,)),
|
|
77
|
+
Icon("js_square", "JavaScript (square)", "\ue781 ", (CAT_LANG,)), # nf-dev-javascript
|
|
78
|
+
Icon("typescript", "TypeScript", "\ue628 ", (CAT_LANG,)), # nf-seti-file_type_ts
|
|
79
|
+
Icon("deno", "Deno", "\ue70c ", (CAT_LANG,)), # nf-seti-file_type_deno
|
|
80
|
+
Icon("deno_robot", "Deno (robot)", "\U000f06a9 ", (CAT_LANG,)), # nf-md-robot
|
|
81
|
+
Icon("bun", "Bun (croissant)", "\U000f07f0 ", (CAT_LANG,)), # nf-md-food_croissant
|
|
82
|
+
Icon("python", "Python", "\ue73c ", (CAT_LANG,)), # nf-dev-python
|
|
83
|
+
Icon("python_alt", "Python (alt)", "\ue235 ", (CAT_LANG,)), # nf-fa-python
|
|
84
|
+
Icon("rust", "Rust", "\ue7a8 ", (CAT_LANG,)), # nf-dev-rust
|
|
85
|
+
Icon("rust_crab", "Rust (crab)", "\U000f0f80 ", (CAT_LANG,)), # nf-md-crab
|
|
86
|
+
Icon("go", "Go", "\ue627 ", (CAT_LANG,)), # nf-seti-go
|
|
87
|
+
Icon("go_gopher", "Go (gopher)", "\ue626 ", (CAT_LANG,)), # nf-seti-go
|
|
88
|
+
Icon("java", "Java", "\ue256 ", (CAT_LANG,)), # nf-dev-java
|
|
89
|
+
Icon("java_cup", "Java (cup)", "\uf266 ", (CAT_LANG,)), # nf-fa-java
|
|
90
|
+
Icon("php", "PHP", "\ue73d ", (CAT_LANG,)), # nf-dev-php
|
|
91
|
+
Icon("php_elephant", "PHP (elephant)", "\ue608 ", (CAT_LANG,)), # nf-seti-php
|
|
92
|
+
Icon("ruby", "Ruby", "\ue791 ", (CAT_LANG,)), # nf-dev-ruby
|
|
93
|
+
Icon("ruby_gem", "Ruby (gem)", "\uf219 ", (CAT_LANG,)), # nf-fa-ruby
|
|
94
|
+
Icon("elixir", "Elixir (droplet)", "\U000f078b ", (CAT_LANG,)), # nf-md-droplet
|
|
95
|
+
Icon("elixir_alt", "Elixir", "\ue62d ", (CAT_LANG,)), # nf-seti-elixir
|
|
96
|
+
Icon("dotnet", ".NET", "\U000f071e ", (CAT_LANG,)), # nf-md-microsoft_dot_net
|
|
97
|
+
Icon("csharp", "C#", "\U000f031b ", (CAT_LANG,)), # nf-md-language_csharp
|
|
98
|
+
Icon("cpp", "C++", "\U000f061b ", (CAT_LANG,)), # nf-md-language_cpp
|
|
99
|
+
Icon("c", "C", "\U000f061c ", (CAT_LANG,)), # nf-md-language_c
|
|
100
|
+
Icon("swift", "Swift", "\ue755 ", (CAT_LANG,)), # nf-dev-swift
|
|
101
|
+
Icon("kotlin", "Kotlin", "\ue634 ", (CAT_LANG,)), # nf-seti-file_type_kotlin
|
|
102
|
+
Icon("scala", "Scala", "\ue737 ", (CAT_LANG,)), # nf-dev-scala
|
|
103
|
+
Icon("haskell", "Haskell", "\ue77f ", (CAT_LANG,)), # nf-dev-haskell
|
|
104
|
+
Icon("lua", "Lua", "\ue620 ", (CAT_LANG,)), # nf-seti-file_type_lua
|
|
105
|
+
Icon("perl", "Perl", "\ue769 ", (CAT_LANG,)), # nf-dev-perl
|
|
106
|
+
Icon("clojure", "Clojure", "\ue76a ", (CAT_LANG,)), # nf-dev-clojure
|
|
107
|
+
Icon("zig", "Zig", "\U000f071f ", (CAT_LANG,)), # nf-md-language_zig
|
|
108
|
+
|
|
109
|
+
# -- Cloud & Infrastructure --------------------------------------------------
|
|
110
|
+
Icon("docker", "Docker", "\U000f0868 ", (CAT_CLOUD,)), # nf-md-docker
|
|
111
|
+
Icon("docker_whale", "Docker (whale)", "\uf308 ", (CAT_CLOUD,)), # nf-fa-docker
|
|
112
|
+
Icon("kubernetes", "Kubernetes", "\U000f10fe ", (CAT_CLOUD,)), # nf-md-kubernetes
|
|
113
|
+
Icon("kubernetes_alt", "Kubernetes (alt)", "\ue0b6 ", (CAT_CLOUD,)),
|
|
114
|
+
Icon("aws", "AWS", "\ue7ad ", (CAT_CLOUD,)), # nf-dev-aws
|
|
115
|
+
Icon("aws_alt", "AWS (alt)", "\uf270 ", (CAT_CLOUD,)), # nf-fa-aws
|
|
116
|
+
Icon("gcp", "Google Cloud", "\ue7b3 ", (CAT_CLOUD,)), # nf-dev-google_cloud_platform
|
|
117
|
+
Icon("gcp_cloud", "Google Cloud (cloud)", "\uf0c2 ", (CAT_CLOUD,)), # nf-fa-cloud
|
|
118
|
+
Icon("azure", "Azure", "\U000f0825 ", (CAT_CLOUD,)), # nf-md-microsoft_azure
|
|
119
|
+
Icon("terraform", "Terraform", "\U000f1062 ", (CAT_CLOUD,)), # nf-md-terraform
|
|
120
|
+
Icon("terraform_alt", "Terraform (alt)", "\ue0a3 ", (CAT_CLOUD,)),
|
|
121
|
+
Icon("nix", "Nix", "\U000f1105 ", (CAT_CLOUD,)), # nf-md-nix
|
|
122
|
+
Icon("ansible", "Ansible", "\uf195 ", (CAT_CLOUD,)), # nf-fa-building
|
|
123
|
+
Icon("helm", "Helm", "\uf298 ", (CAT_CLOUD,)), # nf-fa-ship
|
|
124
|
+
Icon("cloud", "Cloud", "\uf0c2 ", (CAT_CLOUD,)), # nf-fa-cloud
|
|
125
|
+
Icon("server_alt", "Server (alt)", "\U000f051b ", (CAT_CLOUD,)), # nf-md-server
|
|
126
|
+
Icon("shield", "Shield", "\uf132 ", (CAT_CLOUD,)), # nf-fa-shield
|
|
127
|
+
|
|
128
|
+
# -- Shell -------------------------------------------------------------------
|
|
129
|
+
Icon("prompt_arrow", "Prompt arrow", "\u276f ", (CAT_SHELL,)), # ❯ — standard Unicode, not Nerd Font
|
|
130
|
+
Icon("prompt_dollar", "Dollar sign", "$ ", (CAT_SHELL,)),
|
|
131
|
+
Icon("prompt_lambda", "Lambda", "\u03bb ", (CAT_SHELL,)), # λ — standard Unicode
|
|
132
|
+
Icon("prompt_star", "Star prompt", "\uf005 ", (CAT_SHELL,)), # nf-fa-star
|
|
133
|
+
Icon("prompt_bang", "Bang", "! ", (CAT_SHELL,)),
|
|
134
|
+
Icon("jobs", "Background jobs (sparkle)", "\uf005 ", (CAT_SHELL,)), # nf-fa-star
|
|
135
|
+
Icon("jobs_alt", "Background jobs (gear)", "\uf013 ", (CAT_SHELL,)), # nf-fa-cog
|
|
136
|
+
Icon("error_x", "Error (X)", "\uf00d ", (CAT_SHELL,)), # nf-fa-times
|
|
137
|
+
Icon("error_x_circle", "Error (X in circle)", "\uf057 ", (CAT_SHELL,)), # nf-fa-times_circle
|
|
138
|
+
Icon("error_bang", "Error (warning)", "\uf071 ", (CAT_SHELL,)), # nf-fa-warning
|
|
139
|
+
Icon("error_skull", "Error (skull)", "\U000f05dc ", (CAT_SHELL,)), # nf-md-skull
|
|
140
|
+
Icon("shell_depth", "Shell depth (arrows)", "\uf0aa ", (CAT_SHELL,)), # nf-fa-angle_double_up
|
|
141
|
+
Icon("clock_alt", "Clock (alarm)", "\uf017 ", (CAT_SHELL,)),
|
|
142
|
+
Icon("user", "User", "\uf007 ", (CAT_SHELL,)), # nf-fa-user
|
|
143
|
+
Icon("host", "Host / server", "\uf233 ", (CAT_SHELL,)), # nf-fa-server
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
ICONS_BY_KEY: dict[str, Icon] = {i.key: i for i in ICONS}
|
|
147
|
+
ICON_CATEGORIES: tuple[str, ...] = (CAT_GENERAL, CAT_GIT, CAT_LANG, CAT_CLOUD, CAT_SHELL)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def icons_by_category() -> dict[str, list[Icon]]:
|
|
151
|
+
"""Group icons by category, preserving declaration order within each group."""
|
|
152
|
+
grouped: dict[str, list[Icon]] = {cat: [] for cat in ICON_CATEGORIES}
|
|
153
|
+
for icon in ICONS:
|
|
154
|
+
for cat in icon.categories:
|
|
155
|
+
if cat in grouped:
|
|
156
|
+
grouped[cat].append(icon)
|
|
157
|
+
return grouped
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def find_icon_by_glyph(glyph: str) -> Icon | None:
|
|
161
|
+
"""The icon whose glyph matches, or None. Used to mark the current choice in
|
|
162
|
+
the picker — a section's default icon is a raw glyph, not a catalog key."""
|
|
163
|
+
for icon in ICONS:
|
|
164
|
+
if icon.glyph == glyph:
|
|
165
|
+
return icon
|
|
166
|
+
return None
|
|
@@ -788,6 +788,13 @@ class StarshipConfig:
|
|
|
788
788
|
# Off gives starship's own "no runtime versions" look: the language sections still
|
|
789
789
|
# say *which* toolchain a project uses, without the number nobody reads.
|
|
790
790
|
show_versions: bool = True
|
|
791
|
+
# Per-section overrides chosen in the wizard's "Customize" steps. A colour
|
|
792
|
+
# override is a literal starship colour (hex or ANSI name) that replaces the
|
|
793
|
+
# section's palette role; an icon override is a glyph/text string that replaces
|
|
794
|
+
# the section's default symbol. Both are keyed by section key and empty dicts
|
|
795
|
+
# mean "use the palette/section defaults" — the common path.
|
|
796
|
+
color_overrides: dict[str, str] = field(default_factory=dict)
|
|
797
|
+
icon_overrides: dict[str, str] = field(default_factory=dict)
|
|
791
798
|
|
|
792
799
|
# -- resolved views the emitter and previews share ----------------------
|
|
793
800
|
|
|
@@ -818,14 +825,27 @@ class StarshipConfig:
|
|
|
818
825
|
return left, right
|
|
819
826
|
|
|
820
827
|
def symbol(self, section: Section) -> str:
|
|
821
|
-
"""The glyph for this section under the current preset
|
|
822
|
-
|
|
828
|
+
"""The glyph for this section under the current preset, honouring any
|
|
829
|
+
per-section icon override from the wizard's "Customize icons" step."""
|
|
830
|
+
if section.key in self.icon_overrides:
|
|
831
|
+
symbol = self.icon_overrides[section.key]
|
|
832
|
+
else:
|
|
833
|
+
symbol = section.icon if self.preset_spec.nerd_font else section.plain
|
|
823
834
|
if section.takes_version and not self.show_versions:
|
|
824
835
|
# Every versioned body is `$symbol$version`, so with the version gone the
|
|
825
836
|
# symbol's trailing space would sit at the end of the segment.
|
|
826
837
|
symbol = symbol.rstrip()
|
|
827
838
|
return symbol
|
|
828
839
|
|
|
840
|
+
def section_color(self, section: Section) -> str:
|
|
841
|
+
"""The colour this section renders in — a per-section override if one was
|
|
842
|
+
set in the wizard, otherwise the section's palette role name (which
|
|
843
|
+
starship resolves against the emitted ``[palettes.<name>]`` table). Both
|
|
844
|
+
forms are valid in a starship style string, so the emitter and the offline
|
|
845
|
+
preview can use this uniformly."""
|
|
846
|
+
override = self.color_overrides.get(section.key)
|
|
847
|
+
return override if override is not None else section.role
|
|
848
|
+
|
|
829
849
|
def body(self, section: Section) -> str:
|
|
830
850
|
"""The module's format body under the current preset — what goes inside
|
|
831
851
|
`[…]($style)`. The emitter and the offline preview both derive from this, so
|