Skip to content

Commit 99056ca

Browse files
committed
fix(hooks): remove unused subproc import in welcome hook
1 parent 70fec4d commit 99056ca

1 file changed

Lines changed: 31 additions & 10 deletions

File tree

.gemini/hooks/welcome.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
It fetches project info from pyproject.toml and current git status.
77
"""
88
import json
9-
import subprocess
109
import sys
1110
import os
1211
import tomllib
@@ -30,6 +29,30 @@ def get_project_info():
3029
except Exception:
3130
return "Unknown", "No description available."
3231

32+
def get_commands():
33+
"""
34+
Reads the .gemini/commands/ directory and extracts descriptions from .toml files.
35+
"""
36+
commands_dir = os.path.join(".gemini", "commands")
37+
if not os.path.isdir(commands_dir):
38+
return []
39+
40+
commands = []
41+
for filename in sorted(os.listdir(commands_dir)):
42+
if filename.endswith(".toml"):
43+
command_name = filename[:-5]
44+
file_path = os.path.join(commands_dir, filename)
45+
try:
46+
with open(file_path, "r", encoding="utf-8") as f:
47+
first_line = f.readline().strip()
48+
if "description =" in first_line:
49+
# Extract description from "description = '...'" or "description = \"...\""
50+
desc = first_line.split("=", 1)[1].strip().strip('"').strip("'")
51+
commands.append((command_name, desc))
52+
except Exception:
53+
continue
54+
return commands
55+
3356
def main():
3457
"""
3558
Main entry point for the welcome message hook.
@@ -50,6 +73,9 @@ def main():
5073
else:
5174
status_msg = "✅ Working tree is clean."
5275

76+
commands = get_commands()
77+
command_lines = [f"- `/{cmd_name}`: {desc}" for cmd_name, desc in commands if cmd_name != "onboard"]
78+
5379
message_lines = [
5480
f"🚀 Welcome to Gemini CLI for `{name}`",
5581
f"📝 {description}",
@@ -58,17 +84,12 @@ def main():
5884
status_msg,
5985
" ",
6086
"🛠️ Available Commands:",
61-
"- `/scaffold`: Scaffold a new project.",
62-
"- `/task`: Manage tasks, create, update, or work.",
63-
"- `/commit`: Prepare and commit changes.",
64-
"- `/maintainance`: Project maintenance tasks.",
65-
"- `/docs`: Update project documentation.",
66-
"- `/release`: Run release workflow.",
67-
"- `/issues`: Manage project issues with GitHub CLI.",
68-
"- `/research`: Perform deep research on a topic.",
87+
*command_lines,
6988
" ",
70-
"💡 Tip: Run `/onboard` for a brief explanation of the project.",
7189
]
90+
91+
if any(cmd[0] == "onboard" for cmd in commands):
92+
message_lines.append("💡 Tip: Run `/onboard` for a brief explanation of the project.")
7293

7394
system_message = "\n".join(message_lines)
7495

0 commit comments

Comments
 (0)