wrd 0.1.41__py3-none-any.whl → 1.0.1__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.
wrd/__init__.py ADDED
File without changes
wrd/__main__.py ADDED
@@ -0,0 +1,518 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ WRD (Word) - Python Package
4
+ Narzędzie inspirowane workflow opisanym przez użytkownika Claude Code
5
+
6
+ Funkcjonalności:
7
+ - Zarządzanie projektami Claude Code
8
+ - Automatyzacja dokumentacji
9
+ - Integracja z różnymi AI tools
10
+ - Workflow optimization
11
+ """
12
+
13
+ import os
14
+ import sys
15
+ import json
16
+ import argparse
17
+ import subprocess
18
+ import datetime
19
+ import shutil
20
+ from pathlib import Path
21
+ from typing import Dict, List, Optional, Any
22
+ import logging
23
+
24
+ # Konfiguracja logowania
25
+ logging.basicConfig(
26
+ level=logging.INFO,
27
+ format='%(asctime)s - %(levelname)s - %(message)s',
28
+ handlers=[
29
+ logging.FileHandler('wrd.log'),
30
+ logging.StreamHandler()
31
+ ]
32
+ )
33
+ logger = logging.getLogger(__name__)
34
+
35
+
36
+ class WRDConfig:
37
+ """Konfiguracja WRD"""
38
+
39
+ def __init__(self):
40
+ self.home_dir = Path.home()
41
+ self.wrd_dir = self.home_dir / '.wrd'
42
+ self.config_file = self.wrd_dir / 'config.json'
43
+ self.projects_dir = self.home_dir / 'claude-projects'
44
+ self.templates_dir = self.projects_dir / 'templates'
45
+
46
+ self.ensure_directories()
47
+ self.load_config()
48
+
49
+ def ensure_directories(self):
50
+ """Tworzenie niezbędnych katalogów"""
51
+ dirs = [
52
+ self.wrd_dir,
53
+ self.projects_dir,
54
+ self.templates_dir,
55
+ self.projects_dir / 'scripts',
56
+ self.projects_dir / 'docs',
57
+ self.projects_dir / 'archive'
58
+ ]
59
+
60
+ for dir_path in dirs:
61
+ dir_path.mkdir(parents=True, exist_ok=True)
62
+
63
+ def load_config(self):
64
+ """Wczytanie konfiguracji"""
65
+ default_config = {
66
+ 'ai_tools': {
67
+ 'claude_code': {'enabled': True, 'priority': 1},
68
+ 'gemini_cli': {'enabled': False, 'priority': 2},
69
+ 'cursor': {'enabled': False, 'priority': 3}
70
+ },
71
+ 'workflows': {
72
+ 'documentation_auto': True,
73
+ 'commit_auto_describe': True,
74
+ 'project_templates': True
75
+ },
76
+ 'limits': {
77
+ 'session_duration': 5, # hours
78
+ 'max_concurrent_projects': 3
79
+ }
80
+ }
81
+
82
+ if self.config_file.exists():
83
+ with open(self.config_file, 'r') as f:
84
+ self.config = json.load(f)
85
+ else:
86
+ self.config = default_config
87
+ self.save_config()
88
+
89
+ def save_config(self):
90
+ """Zapisanie konfiguracji"""
91
+ with open(self.config_file, 'w') as f:
92
+ json.dump(self.config, f, indent=2)
93
+
94
+
95
+ class WRDProject:
96
+ """Klasa reprezentująca projekt WRD"""
97
+
98
+ def __init__(self, name: str, project_type: str = 'python'):
99
+ self.name = name
100
+ self.project_type = project_type
101
+ self.config = WRDConfig()
102
+ self.project_dir = self.config.projects_dir / name
103
+ self.claude_md_file = self.project_dir / 'CLAUDE.md'
104
+
105
+ def create(self, description: str = ""):
106
+ """Tworzenie nowego projektu"""
107
+ if self.project_dir.exists():
108
+ logger.warning(f"Projekt {self.name} już istnieje")
109
+ return False
110
+
111
+ # Tworzenie struktury katalogów
112
+ dirs = ['src', 'tests', 'docs', 'scripts', 'config']
113
+ for dir_name in dirs:
114
+ (self.project_dir / dir_name).mkdir(parents=True)
115
+
116
+ # Tworzenie plików bazowych
117
+ self._create_readme(description)
118
+ self._create_claude_md(description)
119
+ self._create_requirements_txt()
120
+ self._create_gitignore()
121
+
122
+ # Inicjalizacja git
123
+ subprocess.run(['git', 'init'], cwd=self.project_dir, capture_output=True)
124
+
125
+ logger.info(f"Projekt {self.name} został utworzony w {self.project_dir}")
126
+ return True
127
+
128
+ def _create_readme(self, description: str):
129
+ """Tworzenie README.md"""
130
+ readme_content = f"""# {self.name}
131
+
132
+ {description}
133
+
134
+ ## Opis projektu
135
+ Projekt typu: {self.project_type}
136
+ Utworzony: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M')}
137
+
138
+ ## Instalacja
139
+ ```bash
140
+ cd {self.name}
141
+ python -m venv venv
142
+ source venv/bin/activate # Linux/Mac
143
+ pip install -r requirements.txt
144
+ ```
145
+
146
+ ## Użycie
147
+ ```bash
148
+ python src/main.py
149
+ ```
150
+
151
+ ## Rozwój
152
+ Ten projekt został utworzony z użyciem WRD (Word) - narzędzia do zarządzania projektami Claude Code.
153
+
154
+ ## Dokumentacja
155
+ Szczegółowa dokumentacja znajduje się w pliku CLAUDE.md
156
+ """
157
+
158
+ with open(self.project_dir / 'README.md', 'w') as f:
159
+ f.write(readme_content)
160
+
161
+ def _create_claude_md(self, description: str):
162
+ """Tworzenie CLAUDE.md dla Claude Code"""
163
+ claude_content = f"""# Claude Code Project: {self.name}
164
+
165
+ ## Przegląd projektu
166
+ - **Nazwa**: {self.name}
167
+ - **Typ**: {self.project_type}
168
+ - **Opis**: {description}
169
+ - **Utworzony**: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M')}
170
+ - **Narzędzie**: WRD (Word) v1.0
171
+
172
+ ## Środowisko deweloperskie
173
+ - **OS**: Fedora Linux
174
+ - **Python**: {sys.version.split()[0]}
175
+ - **Virtual Environment**: venv/
176
+ - **Narzędzia**: Claude Code, WRD
177
+
178
+ ## Struktura projektu
179
+ ```
180
+ {self.name}/
181
+ ├── src/ # Kod źródłowy
182
+ ├── tests/ # Testy
183
+ ├── docs/ # Dokumentacja
184
+ ├── scripts/ # Skrypty pomocnicze
185
+ ├── config/ # Konfiguracja
186
+ ├── venv/ # Środowisko wirtualne
187
+ ├── README.md # Podstawowa dokumentacja
188
+ ├── CLAUDE.md # Ten plik - dokumentacja dla Claude Code
189
+ ├── requirements.txt # Zależności Python
190
+ └── .gitignore # Git ignore
191
+ ```
192
+
193
+ ## Workflow z Claude Code
194
+ 1. **Planowanie** (Gemini 2.5 Pro/Claude.ai)
195
+ - Architektura rozwiązania
196
+ - Specyfikacja funkcjonalności
197
+ - Planowanie iteracji
198
+
199
+ 2. **Implementacja** (Claude Code)
200
+ - Kodowanie w 5-godzinnych sesjach
201
+ - Automatyczne commity z opisami
202
+ - Iteracyjny rozwój
203
+
204
+ 3. **Dokumentacja** (Automatyczna)
205
+ - WRD automatycznie dokumentuje proces
206
+ - Śledzenie błędów i rozwiązań
207
+ - Historia zmian
208
+
209
+ ## Postęp prac
210
+ ### {datetime.datetime.now().strftime('%Y-%m-%d')}
211
+ - ✅ Inicjalizacja projektu
212
+ - ✅ Struktura katalogów
213
+ - ⏳ Implementacja podstawowej funkcjonalności
214
+
215
+ ## Błędy i rozwiązania
216
+ <!-- Automatycznie aktualizowane przez WRD -->
217
+
218
+ ## Notatki techniczne
219
+ <!-- Miejsce na notatki specyficzne dla Claude Code -->
220
+
221
+ ## Optymalizacje wydajności
222
+ <!-- Dokumentacja optymalizacji -->
223
+
224
+ ## Deployment
225
+ <!-- Instrukcje wdrożenia -->
226
+
227
+ ---
228
+ *Dokumentacja generowana przez WRD (Word) - narzędzie workflow dla Claude Code*
229
+ """
230
+
231
+ with open(self.claude_md_file, 'w') as f:
232
+ f.write(claude_content)
233
+
234
+ def _create_requirements_txt(self):
235
+ """Tworzenie requirements.txt"""
236
+ requirements = [
237
+ "requests>=2.28.0",
238
+ "click>=8.0.0",
239
+ "rich>=12.0.0",
240
+ "pydantic>=1.9.0",
241
+ "python-dotenv>=0.19.0"
242
+ ]
243
+
244
+ if self.project_type == 'fastapi':
245
+ requirements.extend([
246
+ "fastapi>=0.95.0",
247
+ "uvicorn>=0.20.0"
248
+ ])
249
+ elif self.project_type == 'data':
250
+ requirements.extend([
251
+ "pandas>=1.5.0",
252
+ "numpy>=1.24.0",
253
+ "matplotlib>=3.6.0"
254
+ ])
255
+
256
+ with open(self.project_dir / 'requirements.txt', 'w') as f:
257
+ f.write('\n'.join(requirements))
258
+
259
+ def _create_gitignore(self):
260
+ """Tworzenie .gitignore"""
261
+ gitignore_content = """# WRD Generated .gitignore
262
+
263
+ # Python
264
+ __pycache__/
265
+ *.py[cod]
266
+ *$py.class
267
+ *.so
268
+ .Python
269
+ build/
270
+ develop-eggs/
271
+ dist/
272
+ downloads/
273
+ eggs/
274
+ .eggs/
275
+ lib/
276
+ lib64/
277
+ parts/
278
+ sdist/
279
+ var/
280
+ wheels/
281
+ *.egg-info/
282
+ .installed.cfg
283
+ *.egg
284
+
285
+ # Virtual Environment
286
+ venv/
287
+ env/
288
+ ENV/
289
+
290
+ # IDE
291
+ .vscode/
292
+ .idea/
293
+ *.swp
294
+ *.swo
295
+
296
+ # OS
297
+ .DS_Store
298
+ Thumbs.db
299
+
300
+ # Logs
301
+ *.log
302
+ logs/
303
+
304
+ # Environment variables
305
+ .env
306
+ .env.local
307
+
308
+ # WRD
309
+ .wrd/
310
+ wrd.log
311
+ """
312
+
313
+ with open(self.project_dir / '.gitignore', 'w') as f:
314
+ f.write(gitignore_content)
315
+
316
+ def update_progress(self, message: str, task_type: str = "progress"):
317
+ """Aktualizacja postępu w CLAUDE.md"""
318
+ if not self.claude_md_file.exists():
319
+ return
320
+
321
+ # Wczytanie zawartości
322
+ with open(self.claude_md_file, 'r') as f:
323
+ content = f.read()
324
+
325
+ # Dodanie wpisu
326
+ timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
327
+ progress_entry = f"### {timestamp}\n- {task_type.upper()}: {message}\n\n"
328
+
329
+ # Wstawianie po sekcji "Postęp prac"
330
+ progress_marker = "## Postęp prac\n"
331
+ if progress_marker in content:
332
+ parts = content.split(progress_marker, 1)
333
+ content = parts[0] + progress_marker + progress_entry + parts[1]
334
+
335
+ # Zapisanie
336
+ with open(self.claude_md_file, 'w') as f:
337
+ f.write(content)
338
+
339
+ logger.info(f"Zaktualizowano postęp: {message}")
340
+
341
+
342
+ class WRDManager:
343
+ """Główny manager WRD"""
344
+
345
+ def __init__(self):
346
+ self.config = WRDConfig()
347
+
348
+ def list_projects(self) -> List[str]:
349
+ """Lista projektów"""
350
+ projects = []
351
+ if self.config.projects_dir.exists():
352
+ for item in self.config.projects_dir.iterdir():
353
+ if item.is_dir() and not item.name.startswith('.'):
354
+ exclude_dirs = {'templates', 'scripts', 'docs', 'archive', 'venv'}
355
+ if item.name not in exclude_dirs:
356
+ projects.append(item.name)
357
+ return sorted(projects)
358
+
359
+ def create_project(self, name: str, project_type: str = 'python', description: str = ""):
360
+ """Tworzenie nowego projektu"""
361
+ project = WRDProject(name, project_type)
362
+ return project.create(description)
363
+
364
+ def auto_commit(self, project_name: str, message: str = ""):
365
+ """Automatyczny commit z opisem"""
366
+ project_dir = self.config.projects_dir / project_name
367
+ if not project_dir.exists():
368
+ logger.error(f"Projekt {project_name} nie istnieje")
369
+ return False
370
+
371
+ # Auto-generated commit message if not provided
372
+ if not message:
373
+ timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
374
+ message = f"WRD auto-commit: {timestamp}"
375
+
376
+ try:
377
+ # Git add
378
+ subprocess.run(['git', 'add', '.'], cwd=project_dir, check=True)
379
+
380
+ # Git commit
381
+ subprocess.run(['git', 'commit', '-m', message], cwd=project_dir, check=True)
382
+
383
+ # Update progress
384
+ project = WRDProject(project_name)
385
+ project.update_progress(f"Commit: {message}", "git")
386
+
387
+ logger.info(f"Commit wykonany: {message}")
388
+ return True
389
+
390
+ except subprocess.CalledProcessError as e:
391
+ logger.error(f"Błąd podczas commit: {e}")
392
+ return False
393
+
394
+ def backup_projects(self):
395
+ """Backup wszystkich projektów"""
396
+ backup_name = f"wrd-backup-{datetime.datetime.now().strftime('%Y%m%d-%H%M%S')}"
397
+ archive_dir = self.config.projects_dir / 'archive'
398
+ backup_path = archive_dir / f"{backup_name}.tar.gz"
399
+
400
+ try:
401
+ subprocess.run([
402
+ 'tar', '-czf', str(backup_path),
403
+ '-C', str(self.config.projects_dir),
404
+ '--exclude=archive',
405
+ '--exclude=venv',
406
+ '.'
407
+ ], check=True)
408
+
409
+ logger.info(f"Backup utworzony: {backup_path}")
410
+ return True
411
+
412
+ except subprocess.CalledProcessError as e:
413
+ logger.error(f"Błąd podczas tworzenia backup: {e}")
414
+ return False
415
+
416
+ def status(self):
417
+ """Status WRD"""
418
+ projects = self.list_projects()
419
+
420
+ print(f"🔧 WRD (Word) Status")
421
+ print(f"📁 Workspace: {self.config.projects_dir}")
422
+ print(f"📊 Aktywne projekty: {len(projects)}")
423
+
424
+ if projects:
425
+ print("\n🚀 Projekty:")
426
+ for project in projects[:10]: # Limit to 10
427
+ project_dir = self.config.projects_dir / project
428
+ if (project_dir / '.git').exists():
429
+ status = "🔄 Git repo"
430
+ else:
431
+ status = "📁 Folder"
432
+ print(f" - {project} {status}")
433
+
434
+ print(f"\n⚙️ Konfiguracja:")
435
+ print(f" - Claude Code: {'✅' if self.config.config['ai_tools']['claude_code']['enabled'] else '❌'}")
436
+ print(f" - Auto dokumentacja: {'✅' if self.config.config['workflows']['documentation_auto'] else '❌'}")
437
+ print(f" - Auto commit opisy: {'✅' if self.config.config['workflows']['commit_auto_describe'] else '❌'}")
438
+
439
+
440
+ def main():
441
+ """Main CLI interface"""
442
+ parser = argparse.ArgumentParser(description='WRD (Word) - Narzędzie workflow dla Claude Code')
443
+ subparsers = parser.add_subparsers(dest='command', help='Dostępne komendy')
444
+
445
+ # Status
446
+ subparsers.add_parser('status', help='Pokaż status WRD')
447
+
448
+ # List projects
449
+ subparsers.add_parser('list', help='Lista projektów')
450
+
451
+ # Create project
452
+ create_parser = subparsers.add_parser('create', help='Utwórz nowy projekt')
453
+ create_parser.add_argument('name', help='Nazwa projektu')
454
+ create_parser.add_argument('--type', default='python',
455
+ choices=['python', 'javascript', 'rust', 'go', 'fastapi', 'data'], help='Typ projektu')
456
+ create_parser.add_argument('--description', default='', help='Opis projektu')
457
+
458
+ # Commit
459
+ commit_parser = subparsers.add_parser('commit', help='Auto commit projektu')
460
+ commit_parser.add_argument('project', help='Nazwa projektu')
461
+ commit_parser.add_argument('--message', help='Wiadomość commit')
462
+
463
+ # Backup
464
+ subparsers.add_parser('backup', help='Backup wszystkich projektów')
465
+
466
+ # Progress update
467
+ progress_parser = subparsers.add_parser('progress', help='Aktualizuj postęp projektu')
468
+ progress_parser.add_argument('project', help='Nazwa projektu')
469
+ progress_parser.add_argument('message', help='Wiadomość o postępie')
470
+
471
+ args = parser.parse_args()
472
+
473
+ if not args.command:
474
+ parser.print_help()
475
+ return
476
+
477
+ manager = WRDManager()
478
+
479
+ if args.command == 'status':
480
+ manager.status()
481
+
482
+ elif args.command == 'list':
483
+ projects = manager.list_projects()
484
+ print("📁 Projekty WRD:")
485
+ for project in projects:
486
+ print(f" - {project}")
487
+ if not projects:
488
+ print(" (brak projektów)")
489
+
490
+ elif args.command == 'create':
491
+ success = manager.create_project(args.name, args.type, args.description)
492
+ if success:
493
+ print(f"✅ Projekt '{args.name}' został utworzony")
494
+ else:
495
+ print(f"❌ Nie udało się utworzyć projektu '{args.name}'")
496
+
497
+ elif args.command == 'commit':
498
+ success = manager.auto_commit(args.project, args.message or "")
499
+ if success:
500
+ print(f"✅ Commit wykonany dla projektu '{args.project}'")
501
+ else:
502
+ print(f"❌ Nie udało się wykonać commit dla projektu '{args.project}'")
503
+
504
+ elif args.command == 'backup':
505
+ success = manager.backup_projects()
506
+ if success:
507
+ print("✅ Backup projektów wykonany")
508
+ else:
509
+ print("❌ Nie udało się wykonać backup")
510
+
511
+ elif args.command == 'progress':
512
+ project = WRDProject(args.project)
513
+ project.update_progress(args.message)
514
+ print(f"✅ Postęp zaktualizowany dla projektu '{args.project}'")
515
+
516
+
517
+ if __name__ == '__main__':
518
+ main()