Skip to content

Commit b807006

Browse files
committed
Bug Fix
1 parent 0a2a29c commit b807006

File tree

9 files changed

+76
-19
lines changed

9 files changed

+76
-19
lines changed

check_duplicate_versions.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@
1111

1212

1313
def get_file_hash(file_path: Path) -> str:
14-
"""Calculate MD5 hash of a file."""
15-
md5_hash = hashlib.md5()
16-
with open(file_path, 'rb') as f:
17-
for chunk in iter(lambda: f.read(4096), b''):
18-
md5_hash.update(chunk)
19-
return md5_hash.hexdigest()
14+
"""Calculate MD5 hash of a file.
15+
16+
Returns:
17+
Hash string on success, None on failure (logs error)
18+
"""
19+
try:
20+
md5_hash = hashlib.md5()
21+
with open(file_path, 'rb') as f:
22+
for chunk in iter(lambda: f.read(4096), b''):
23+
md5_hash.update(chunk)
24+
return md5_hash.hexdigest()
25+
except (OSError, IOError) as e:
26+
print(f"⚠️ Error reading file {file_path}: {e}")
27+
return None
2028

2129

2230
def find_duplicate_versions(prompts_dir: Path) -> Dict[str, Dict[str, List[str]]]:
@@ -43,7 +51,9 @@ def find_duplicate_versions(prompts_dir: Path) -> Dict[str, Dict[str, List[str]]
4351

4452
for version_file in version_files:
4553
file_hash = get_file_hash(version_file)
46-
hash_map[file_hash].append(version_file.name)
54+
# Skip files that couldn't be read
55+
if file_hash is not None:
56+
hash_map[file_hash].append(version_file.name)
4757

4858
# Only include agents with duplicates
4959
duplicates = {h: files for h, files in hash_map.items() if len(files) > 1}
@@ -79,9 +89,9 @@ def print_report(duplicates: Dict[str, Dict[str, List[str]]]):
7989

8090
def main():
8191
"""Main entry point."""
82-
# Find prompts directory
83-
script_dir = Path(__file__).parent
84-
prompts_dir = script_dir / "prompts"
92+
# Find prompts directory (at repository root)
93+
repo_root = Path(__file__).parent
94+
prompts_dir = repo_root / "prompts"
8595

8696
if not prompts_dir.exists():
8797
print(f"❌ Error: Prompts directory not found at {prompts_dir}")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
You are a code review assistant specialized in {{programming_language}}. Please review the following code snippet and provide feedback on {{review_focus}}:
2+
3+
```{{programming_language}}
4+
{{code_snippet}}
5+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
You are a code review assistant with active tools: {{active_tools}}. Specialized in {{programming_language}}. Review the code with {{severity}} scrutiny focusing on {{review_focus}}:
2+
3+
```{{programming_language}}
4+
{{code_snippet}}
5+
```
6+
7+
Provide feedback in: 'Summary', 'Critical Issues', 'Improvements', 'Positives'.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You are a helpful AI assistant named {{assistant_name}}. Your goal is to provide clear and concise answers to {{user_name}}'s questions.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
You are creating a {{content_type}} about {{theme}}.
2+
3+
{% if difficulty == 'beginner' %}
4+
Keep it simple and accessible for beginners.
5+
{% elif difficulty == 'intermediate' %}
6+
Include some advanced concepts but explain them clearly.
7+
{% else %}
8+
Don't hold back on technical details and advanced concepts.
9+
{% endif %}
10+
11+
{% if elements|length > 0 %}
12+
Be sure to include the following elements:
13+
{% for element in elements %}
14+
- {{element}}
15+
{% endfor %}
16+
{% endif %}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
You are a {{personality}} assistant specialized in {{domain}}.
2+
3+
Your role is to provide helpful, accurate, and engaging responses to user questions and requests. Always maintain a professional and friendly tone while adapting to the user's needs.
4+
5+
Key guidelines:
6+
- Be concise but thorough in your explanations
7+
- Ask clarifying questions when needed
8+
- Provide examples when helpful
9+
- Stay focused on the {{domain}} domain when specified
10+
11+
How can I help you today?

src/promptix/tools/cli.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,17 @@ def main():
457457
"""
458458
try:
459459
# Handle the case where user runs OpenAI commands directly
460-
if len(sys.argv) > 1 and sys.argv[1] not in ['studio', 'agent', 'openai', '--help', '--version']:
461-
# This looks like an OpenAI command, redirect
462-
Config.validate()
463-
sys.exit(openai_main())
460+
# Check if first arg is a flag (starts with '-') or a recognized top-level command
461+
if len(sys.argv) > 1:
462+
first_arg = sys.argv[1]
463+
# List of recognized top-level commands
464+
top_level_commands = ['studio', 'agent', 'openai', 'version', 'hooks']
465+
466+
# Don't redirect if it's a flag or a recognized command
467+
if not first_arg.startswith('-') and first_arg not in top_level_commands:
468+
# This looks like an OpenAI command, redirect
469+
Config.validate()
470+
sys.exit(openai_main())
464471

465472
cli()
466473

src/promptix/tools/hook_manager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,17 @@ def main():
309309
help='Overwrite existing hook')
310310

311311
# Uninstall command
312-
uninstall_cmd = subparsers.add_parser('uninstall', help='Uninstall pre-commit hook')
312+
subparsers.add_parser('uninstall', help='Uninstall pre-commit hook')
313313

314314
# Enable/disable commands
315-
enable_cmd = subparsers.add_parser('enable', help='Enable disabled hook')
316-
disable_cmd = subparsers.add_parser('disable', help='Disable hook temporarily')
315+
subparsers.add_parser('enable', help='Enable disabled hook')
316+
subparsers.add_parser('disable', help='Disable hook temporarily')
317317

318318
# Status command
319-
status_cmd = subparsers.add_parser('status', help='Show hook status')
319+
subparsers.add_parser('status', help='Show hook status')
320320

321321
# Test command
322-
test_cmd = subparsers.add_parser('test', help='Test hook without committing')
322+
subparsers.add_parser('test', help='Test hook without committing')
323323

324324
args = parser.parse_args()
325325

src/promptix/tools/version_manager.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)