django-cfg 1.3.9__py3-none-any.whl → 1.3.11__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.
Files changed (187) hide show
  1. django_cfg/__init__.py +1 -1
  2. django_cfg/apps/payments/admin/networks_admin.py +12 -1
  3. django_cfg/apps/payments/admin/payments_admin.py +13 -0
  4. django_cfg/apps/payments/admin_interface/serializers/payment_serializers.py +62 -14
  5. django_cfg/apps/payments/admin_interface/templates/payments/components/payment_card.html +121 -0
  6. django_cfg/apps/payments/admin_interface/templates/payments/components/payment_qr_code.html +95 -0
  7. django_cfg/apps/payments/admin_interface/templates/payments/components/progress_bar.html +37 -0
  8. django_cfg/apps/payments/admin_interface/templates/payments/components/provider_stats.html +60 -0
  9. django_cfg/apps/payments/admin_interface/templates/payments/components/status_badge.html +41 -0
  10. django_cfg/apps/payments/admin_interface/templates/payments/components/status_overview.html +83 -0
  11. django_cfg/apps/payments/admin_interface/templates/payments/payment_detail.html +363 -0
  12. django_cfg/apps/payments/admin_interface/templates/payments/payment_form.html +33 -3
  13. django_cfg/apps/payments/admin_interface/views/api/payments.py +102 -0
  14. django_cfg/apps/payments/admin_interface/views/api/webhook_admin.py +96 -45
  15. django_cfg/apps/payments/admin_interface/views/forms.py +5 -1
  16. django_cfg/apps/payments/config/__init__.py +14 -15
  17. django_cfg/apps/payments/config/django_cfg_integration.py +59 -1
  18. django_cfg/apps/payments/config/helpers.py +8 -13
  19. django_cfg/apps/payments/migrations/0001_initial.py +33 -46
  20. django_cfg/apps/payments/migrations/0002_rename_payments_un_user_id_7f6e79_idx_payments_un_user_id_8ce187_idx_and_more.py +46 -0
  21. django_cfg/apps/payments/migrations/0003_universalpayment_status_changed_at.py +25 -0
  22. django_cfg/apps/payments/models/managers/payment_managers.py +142 -25
  23. django_cfg/apps/payments/models/payments.py +94 -0
  24. django_cfg/apps/payments/services/core/base.py +4 -4
  25. django_cfg/apps/payments/services/core/payment_service.py +265 -38
  26. django_cfg/apps/payments/services/providers/base.py +209 -3
  27. django_cfg/apps/payments/services/providers/models/__init__.py +2 -0
  28. django_cfg/apps/payments/services/providers/models/base.py +25 -2
  29. django_cfg/apps/payments/services/providers/nowpayments/models.py +2 -2
  30. django_cfg/apps/payments/services/providers/nowpayments/provider.py +57 -9
  31. django_cfg/apps/payments/services/providers/registry.py +5 -5
  32. django_cfg/apps/payments/services/types/requests.py +19 -7
  33. django_cfg/apps/payments/signals/payment_signals.py +31 -2
  34. django_cfg/apps/payments/static/payments/js/api-client.js +6 -1
  35. django_cfg/apps/payments/static/payments/js/payment-detail.js +167 -0
  36. django_cfg/apps/payments/static/payments/js/payment-form.js +35 -26
  37. django_cfg/apps/payments/templatetags/payment_tags.py +8 -0
  38. django_cfg/apps/payments/urls.py +3 -2
  39. django_cfg/apps/payments/views/api/currencies.py +3 -0
  40. django_cfg/apps/payments/views/serializers/currencies.py +18 -5
  41. django_cfg/apps/tasks/admin/tasks_admin.py +2 -2
  42. django_cfg/apps/tasks/static/tasks/css/dashboard.css +68 -217
  43. django_cfg/apps/tasks/static/tasks/js/api.js +40 -84
  44. django_cfg/apps/tasks/static/tasks/js/components/DataManager.js +24 -0
  45. django_cfg/apps/tasks/static/tasks/js/components/TabManager.js +85 -0
  46. django_cfg/apps/tasks/static/tasks/js/components/TaskRenderer.js +216 -0
  47. django_cfg/apps/tasks/static/tasks/js/dashboard/main.mjs +245 -0
  48. django_cfg/apps/tasks/static/tasks/js/dashboard/overview.mjs +123 -0
  49. django_cfg/apps/tasks/static/tasks/js/dashboard/queues.mjs +120 -0
  50. django_cfg/apps/tasks/static/tasks/js/dashboard/tasks.mjs +350 -0
  51. django_cfg/apps/tasks/static/tasks/js/dashboard/workers.mjs +169 -0
  52. django_cfg/apps/tasks/tasks/__init__.py +10 -0
  53. django_cfg/apps/tasks/tasks/demo_tasks.py +133 -0
  54. django_cfg/apps/tasks/templates/tasks/components/management_actions.html +42 -45
  55. django_cfg/apps/tasks/templates/tasks/components/{status_cards.html → overview_content.html} +30 -11
  56. django_cfg/apps/tasks/templates/tasks/components/queues_content.html +19 -0
  57. django_cfg/apps/tasks/templates/tasks/components/tab_navigation.html +16 -10
  58. django_cfg/apps/tasks/templates/tasks/components/tasks_content.html +51 -0
  59. django_cfg/apps/tasks/templates/tasks/components/workers_content.html +30 -0
  60. django_cfg/apps/tasks/templates/tasks/layout/base.html +117 -0
  61. django_cfg/apps/tasks/templates/tasks/pages/dashboard.html +82 -0
  62. django_cfg/apps/tasks/templates/tasks/partials/task_row_template.html +40 -0
  63. django_cfg/apps/tasks/templates/tasks/widgets/task_filters.html +37 -0
  64. django_cfg/apps/tasks/templates/tasks/widgets/task_footer.html +41 -0
  65. django_cfg/apps/tasks/templates/tasks/widgets/task_table.html +50 -0
  66. django_cfg/apps/tasks/urls.py +2 -2
  67. django_cfg/apps/tasks/urls_admin.py +2 -2
  68. django_cfg/apps/tasks/utils/__init__.py +1 -0
  69. django_cfg/apps/tasks/utils/simulator.py +356 -0
  70. django_cfg/apps/tasks/views/__init__.py +16 -0
  71. django_cfg/apps/tasks/views/api.py +569 -0
  72. django_cfg/apps/tasks/views/dashboard.py +58 -0
  73. django_cfg/core/integration/__init__.py +21 -0
  74. django_cfg/management/commands/rundramatiq_simulator.py +430 -0
  75. django_cfg/models/constance.py +0 -11
  76. django_cfg/models/payments.py +137 -3
  77. django_cfg/modules/django_tasks.py +54 -21
  78. django_cfg/registry/core.py +4 -9
  79. django_cfg/template_archive/django_sample.zip +0 -0
  80. {django_cfg-1.3.9.dist-info → django_cfg-1.3.11.dist-info}/METADATA +2 -2
  81. {django_cfg-1.3.9.dist-info → django_cfg-1.3.11.dist-info}/RECORD +84 -152
  82. django_cfg/apps/payments/config/constance/__init__.py +0 -22
  83. django_cfg/apps/payments/config/constance/config_service.py +0 -123
  84. django_cfg/apps/payments/config/constance/fields.py +0 -69
  85. django_cfg/apps/payments/config/constance/settings.py +0 -160
  86. django_cfg/apps/payments/migrations/0002_currency_usd_rate_currency_usd_rate_updated_at.py +0 -26
  87. django_cfg/apps/payments/migrations/0003_remove_provider_currency_fields.py +0 -28
  88. django_cfg/apps/payments/migrations/0004_add_reserved_usd_field.py +0 -30
  89. django_cfg/apps/tasks/static/tasks/js/dashboard.js +0 -614
  90. django_cfg/apps/tasks/static/tasks/js/modals.js +0 -452
  91. django_cfg/apps/tasks/static/tasks/js/notifications.js +0 -144
  92. django_cfg/apps/tasks/static/tasks/js/task-monitor.js +0 -454
  93. django_cfg/apps/tasks/static/tasks/js/theme.js +0 -77
  94. django_cfg/apps/tasks/templates/tasks/base.html +0 -96
  95. django_cfg/apps/tasks/templates/tasks/components/info_cards.html +0 -85
  96. django_cfg/apps/tasks/templates/tasks/components/overview_tab.html +0 -22
  97. django_cfg/apps/tasks/templates/tasks/components/queues_tab.html +0 -19
  98. django_cfg/apps/tasks/templates/tasks/components/task_details_modal.html +0 -103
  99. django_cfg/apps/tasks/templates/tasks/components/tasks_tab.html +0 -32
  100. django_cfg/apps/tasks/templates/tasks/components/workers_tab.html +0 -29
  101. django_cfg/apps/tasks/templates/tasks/dashboard.html +0 -29
  102. django_cfg/apps/tasks/views.py +0 -461
  103. django_cfg/management/commands/app_agent_diagnose.py +0 -470
  104. django_cfg/management/commands/app_agent_generate.py +0 -342
  105. django_cfg/management/commands/app_agent_info.py +0 -308
  106. django_cfg/management/commands/auto_generate.py +0 -486
  107. django_cfg/modules/django_app_agent/__init__.py +0 -87
  108. django_cfg/modules/django_app_agent/agents/__init__.py +0 -40
  109. django_cfg/modules/django_app_agent/agents/base/__init__.py +0 -24
  110. django_cfg/modules/django_app_agent/agents/base/agent.py +0 -354
  111. django_cfg/modules/django_app_agent/agents/base/context.py +0 -236
  112. django_cfg/modules/django_app_agent/agents/base/executor.py +0 -430
  113. django_cfg/modules/django_app_agent/agents/generation/__init__.py +0 -12
  114. django_cfg/modules/django_app_agent/agents/generation/app_generator/__init__.py +0 -15
  115. django_cfg/modules/django_app_agent/agents/generation/app_generator/config_validator.py +0 -147
  116. django_cfg/modules/django_app_agent/agents/generation/app_generator/main.py +0 -99
  117. django_cfg/modules/django_app_agent/agents/generation/app_generator/models.py +0 -32
  118. django_cfg/modules/django_app_agent/agents/generation/app_generator/prompt_manager.py +0 -290
  119. django_cfg/modules/django_app_agent/agents/interfaces.py +0 -376
  120. django_cfg/modules/django_app_agent/core/__init__.py +0 -33
  121. django_cfg/modules/django_app_agent/core/config.py +0 -300
  122. django_cfg/modules/django_app_agent/core/exceptions.py +0 -359
  123. django_cfg/modules/django_app_agent/models/__init__.py +0 -71
  124. django_cfg/modules/django_app_agent/models/base.py +0 -283
  125. django_cfg/modules/django_app_agent/models/context.py +0 -496
  126. django_cfg/modules/django_app_agent/models/enums.py +0 -481
  127. django_cfg/modules/django_app_agent/models/requests.py +0 -500
  128. django_cfg/modules/django_app_agent/models/responses.py +0 -585
  129. django_cfg/modules/django_app_agent/pytest.ini +0 -6
  130. django_cfg/modules/django_app_agent/services/__init__.py +0 -42
  131. django_cfg/modules/django_app_agent/services/app_generator/__init__.py +0 -30
  132. django_cfg/modules/django_app_agent/services/app_generator/ai_integration.py +0 -133
  133. django_cfg/modules/django_app_agent/services/app_generator/context.py +0 -40
  134. django_cfg/modules/django_app_agent/services/app_generator/main.py +0 -202
  135. django_cfg/modules/django_app_agent/services/app_generator/structure.py +0 -316
  136. django_cfg/modules/django_app_agent/services/app_generator/validation.py +0 -125
  137. django_cfg/modules/django_app_agent/services/base.py +0 -437
  138. django_cfg/modules/django_app_agent/services/context_builder/__init__.py +0 -34
  139. django_cfg/modules/django_app_agent/services/context_builder/code_extractor.py +0 -141
  140. django_cfg/modules/django_app_agent/services/context_builder/context_generator.py +0 -276
  141. django_cfg/modules/django_app_agent/services/context_builder/main.py +0 -272
  142. django_cfg/modules/django_app_agent/services/context_builder/models.py +0 -40
  143. django_cfg/modules/django_app_agent/services/context_builder/pattern_analyzer.py +0 -85
  144. django_cfg/modules/django_app_agent/services/project_scanner/__init__.py +0 -31
  145. django_cfg/modules/django_app_agent/services/project_scanner/app_discovery.py +0 -311
  146. django_cfg/modules/django_app_agent/services/project_scanner/main.py +0 -221
  147. django_cfg/modules/django_app_agent/services/project_scanner/models.py +0 -59
  148. django_cfg/modules/django_app_agent/services/project_scanner/pattern_detection.py +0 -94
  149. django_cfg/modules/django_app_agent/services/questioning_service/__init__.py +0 -28
  150. django_cfg/modules/django_app_agent/services/questioning_service/main.py +0 -273
  151. django_cfg/modules/django_app_agent/services/questioning_service/models.py +0 -111
  152. django_cfg/modules/django_app_agent/services/questioning_service/question_generator.py +0 -251
  153. django_cfg/modules/django_app_agent/services/questioning_service/response_processor.py +0 -347
  154. django_cfg/modules/django_app_agent/services/questioning_service/session_manager.py +0 -356
  155. django_cfg/modules/django_app_agent/services/report_service.py +0 -332
  156. django_cfg/modules/django_app_agent/services/template_manager/__init__.py +0 -18
  157. django_cfg/modules/django_app_agent/services/template_manager/jinja_engine.py +0 -236
  158. django_cfg/modules/django_app_agent/services/template_manager/main.py +0 -159
  159. django_cfg/modules/django_app_agent/services/template_manager/models.py +0 -36
  160. django_cfg/modules/django_app_agent/services/template_manager/template_loader.py +0 -100
  161. django_cfg/modules/django_app_agent/services/template_manager/templates/admin.py.j2 +0 -105
  162. django_cfg/modules/django_app_agent/services/template_manager/templates/apps.py.j2 +0 -31
  163. django_cfg/modules/django_app_agent/services/template_manager/templates/cfg_config.py.j2 +0 -44
  164. django_cfg/modules/django_app_agent/services/template_manager/templates/cfg_module.py.j2 +0 -81
  165. django_cfg/modules/django_app_agent/services/template_manager/templates/forms.py.j2 +0 -107
  166. django_cfg/modules/django_app_agent/services/template_manager/templates/models.py.j2 +0 -139
  167. django_cfg/modules/django_app_agent/services/template_manager/templates/serializers.py.j2 +0 -91
  168. django_cfg/modules/django_app_agent/services/template_manager/templates/tests.py.j2 +0 -195
  169. django_cfg/modules/django_app_agent/services/template_manager/templates/urls.py.j2 +0 -35
  170. django_cfg/modules/django_app_agent/services/template_manager/templates/views.py.j2 +0 -211
  171. django_cfg/modules/django_app_agent/services/template_manager/variable_processor.py +0 -200
  172. django_cfg/modules/django_app_agent/services/validation_service/__init__.py +0 -25
  173. django_cfg/modules/django_app_agent/services/validation_service/django_validator.py +0 -333
  174. django_cfg/modules/django_app_agent/services/validation_service/main.py +0 -242
  175. django_cfg/modules/django_app_agent/services/validation_service/models.py +0 -66
  176. django_cfg/modules/django_app_agent/services/validation_service/quality_validator.py +0 -352
  177. django_cfg/modules/django_app_agent/services/validation_service/security_validator.py +0 -272
  178. django_cfg/modules/django_app_agent/services/validation_service/syntax_validator.py +0 -203
  179. django_cfg/modules/django_app_agent/ui/__init__.py +0 -25
  180. django_cfg/modules/django_app_agent/ui/cli.py +0 -419
  181. django_cfg/modules/django_app_agent/ui/rich_components.py +0 -622
  182. django_cfg/modules/django_app_agent/utils/__init__.py +0 -38
  183. django_cfg/modules/django_app_agent/utils/logging.py +0 -360
  184. django_cfg/modules/django_app_agent/utils/validation.py +0 -417
  185. {django_cfg-1.3.9.dist-info → django_cfg-1.3.11.dist-info}/WHEEL +0 -0
  186. {django_cfg-1.3.9.dist-info → django_cfg-1.3.11.dist-info}/entry_points.txt +0 -0
  187. {django_cfg-1.3.9.dist-info → django_cfg-1.3.11.dist-info}/licenses/LICENSE +0 -0
@@ -1,585 +0,0 @@
1
- """
2
- Response models for Django App Agent Module.
3
-
4
- This module defines all response models with:
5
- - Complete result structures
6
- - Quality metrics and validation
7
- - File generation results
8
- - Error handling information
9
- """
10
-
11
- from typing import List, Optional, Dict, Any, Set
12
- from pathlib import Path
13
- from datetime import datetime, timezone
14
- from pydantic import Field, field_validator, computed_field
15
-
16
- from .base import BaseAgentModel, TimestampedModel, MetricsModel, ErrorModel, ValidationMixin
17
- from .enums import GenerationStage, ValidationSeverity, FileType, AppFeature
18
- from .requests import ContextualQuestion, QuestionResponse
19
-
20
-
21
- class QualityMetrics(MetricsModel):
22
- """Quality metrics for generated code."""
23
-
24
- overall_score: float = Field(
25
- ge=0.0,
26
- le=10.0,
27
- description="Overall quality score (0-10)"
28
- )
29
-
30
- type_safety_score: float = Field(
31
- ge=0.0,
32
- le=10.0,
33
- description="Type safety score (0-10)"
34
- )
35
-
36
- pattern_consistency: float = Field(
37
- ge=0.0,
38
- le=10.0,
39
- description="Architectural pattern consistency score (0-10)"
40
- )
41
-
42
- code_complexity: float = Field(
43
- ge=0.0,
44
- le=10.0,
45
- description="Code complexity score (lower is better, 0-10)"
46
- )
47
-
48
- test_coverage: float = Field(
49
- ge=0.0,
50
- le=100.0,
51
- description="Test coverage percentage (0-100)"
52
- )
53
-
54
- documentation_coverage: float = Field(
55
- ge=0.0,
56
- le=100.0,
57
- description="Documentation coverage percentage (0-100)"
58
- )
59
-
60
- performance_score: float = Field(
61
- ge=0.0,
62
- le=10.0,
63
- description="Performance optimization score (0-10)"
64
- )
65
-
66
- security_score: float = Field(
67
- ge=0.0,
68
- le=10.0,
69
- description="Security best practices score (0-10)"
70
- )
71
-
72
- maintainability_score: float = Field(
73
- ge=0.0,
74
- le=10.0,
75
- description="Code maintainability score (0-10)"
76
- )
77
-
78
- @computed_field
79
- @property
80
- def is_production_ready(self) -> bool:
81
- """Check if quality metrics indicate production readiness."""
82
- return (
83
- self.overall_score >= 8.0 and
84
- self.type_safety_score >= 9.0 and
85
- self.security_score >= 8.0 and
86
- self.test_coverage >= 80.0
87
- )
88
-
89
- @computed_field
90
- @property
91
- def quality_grade(self) -> str:
92
- """Get letter grade for overall quality."""
93
- if self.overall_score >= 9.0:
94
- return "A"
95
- elif self.overall_score >= 8.0:
96
- return "B"
97
- elif self.overall_score >= 7.0:
98
- return "C"
99
- elif self.overall_score >= 6.0:
100
- return "D"
101
- else:
102
- return "F"
103
-
104
- def get_improvement_areas(self) -> List[str]:
105
- """Get list of areas that need improvement."""
106
- areas = []
107
-
108
- if self.type_safety_score < 9.0:
109
- areas.append("Type safety needs improvement")
110
-
111
- if self.pattern_consistency < 8.0:
112
- areas.append("Architectural pattern consistency")
113
-
114
- if self.test_coverage < 80.0:
115
- areas.append("Test coverage is insufficient")
116
-
117
- if self.security_score < 8.0:
118
- areas.append("Security best practices")
119
-
120
- if self.performance_score < 7.0:
121
- areas.append("Performance optimization")
122
-
123
- if self.documentation_coverage < 70.0:
124
- areas.append("Documentation coverage")
125
-
126
- return areas
127
-
128
-
129
- class ValidationIssue(BaseAgentModel):
130
- """A validation issue found in generated code."""
131
-
132
- severity: ValidationSeverity = Field(
133
- description="Severity level of the issue"
134
- )
135
-
136
- message: str = Field(
137
- description="Human-readable description of the issue",
138
- min_length=1,
139
- max_length=500
140
- )
141
-
142
- file_path: Optional[str] = Field(
143
- default=None,
144
- description="File path where the issue was found"
145
- )
146
-
147
- line_number: Optional[int] = Field(
148
- default=None,
149
- ge=1,
150
- description="Line number where the issue occurs"
151
- )
152
-
153
- rule_id: Optional[str] = Field(
154
- default=None,
155
- description="ID of the validation rule that was violated"
156
- )
157
-
158
- suggestion: Optional[str] = Field(
159
- default=None,
160
- max_length=500,
161
- description="Suggested fix for the issue"
162
- )
163
-
164
- auto_fixable: bool = Field(
165
- default=False,
166
- description="Whether this issue can be automatically fixed"
167
- )
168
-
169
- @computed_field
170
- @property
171
- def is_blocking(self) -> bool:
172
- """Check if this issue blocks generation."""
173
- return self.severity.is_blocking()
174
-
175
-
176
- class GeneratedFile(BaseAgentModel):
177
- """Information about a generated file."""
178
-
179
- relative_path: str = Field(
180
- description="Relative path of the file within the app"
181
- )
182
-
183
- absolute_path: Path = Field(
184
- description="Absolute path where the file will be created"
185
- )
186
-
187
- content: str = Field(
188
- description="Generated file content"
189
- )
190
-
191
- line_count: int = Field(
192
- ge=0,
193
- description="Number of lines in the file"
194
- )
195
-
196
- file_type: FileType = Field(
197
- description="Type of the generated file"
198
- )
199
-
200
- type_safety_score: float = Field(
201
- ge=0.0,
202
- le=10.0,
203
- description="Type safety score for this file"
204
- )
205
-
206
- complexity_score: float = Field(
207
- ge=0.0,
208
- le=10.0,
209
- description="Complexity score for this file"
210
- )
211
-
212
- patterns_used: List[str] = Field(
213
- default_factory=list,
214
- description="Architectural patterns used in this file"
215
- )
216
-
217
- description: str = Field(
218
- description="Human-readable description of the file's purpose"
219
- )
220
-
221
- follows_conventions: bool = Field(
222
- default=True,
223
- description="Whether the file follows coding conventions"
224
- )
225
-
226
- imports: List[str] = Field(
227
- default_factory=list,
228
- description="List of imports used in the file"
229
- )
230
-
231
- exports: List[str] = Field(
232
- default_factory=list,
233
- description="List of classes/functions exported by the file"
234
- )
235
-
236
- dependencies: List[str] = Field(
237
- default_factory=list,
238
- description="External dependencies required by this file"
239
- )
240
-
241
- @field_validator('line_count', mode='before')
242
- @classmethod
243
- def calculate_line_count(cls, v: int, info) -> int:
244
- """Calculate line count from content if not provided."""
245
- if v == 0 and 'content' in info.data:
246
- return len(info.data['content'].splitlines())
247
- return v
248
-
249
- @computed_field
250
- @property
251
- def size_bytes(self) -> int:
252
- """Get file size in bytes."""
253
- return len(self.content.encode('utf-8'))
254
-
255
- @computed_field
256
- @property
257
- def is_large_file(self) -> bool:
258
- """Check if file exceeds size limits."""
259
- return self.line_count > 500 # Based on technical requirements
260
-
261
- def get_quality_summary(self) -> Dict[str, Any]:
262
- """Get quality summary for this file."""
263
- return {
264
- "type_safety_score": self.type_safety_score,
265
- "complexity_score": self.complexity_score,
266
- "follows_conventions": self.follows_conventions,
267
- "line_count": self.line_count,
268
- "patterns_count": len(self.patterns_used),
269
- "dependencies_count": len(self.dependencies)
270
- }
271
-
272
-
273
- class AppGenerationResult(TimestampedModel):
274
- """Result of application generation process."""
275
-
276
- # Basic result information
277
- app_name: str = Field(description="Name of the generated application")
278
- generation_id: str = Field(description="Unique identifier for this generation")
279
- success: bool = Field(description="Whether generation completed successfully")
280
-
281
- # Timing information
282
- total_execution_time_seconds: float = Field(
283
- ge=0.0,
284
- description="Total time taken for generation in seconds"
285
- )
286
-
287
- # Generation statistics
288
- files_count: int = Field(
289
- ge=0,
290
- description="Number of files generated"
291
- )
292
-
293
- lines_of_code: int = Field(
294
- ge=0,
295
- description="Total lines of code generated"
296
- )
297
-
298
- # Quality metrics
299
- quality_score: float = Field(
300
- ge=0.0,
301
- le=10.0,
302
- description="Overall quality score"
303
- )
304
-
305
- type_safety_score: float = Field(
306
- ge=0.0,
307
- le=10.0,
308
- description="Type safety score"
309
- )
310
-
311
- pattern_consistency_score: float = Field(
312
- ge=0.0,
313
- le=10.0,
314
- description="Pattern consistency score"
315
- )
316
-
317
- test_coverage_percentage: float = Field(
318
- ge=0.0,
319
- le=100.0,
320
- description="Test coverage percentage"
321
- )
322
-
323
- # Integration information
324
- integration_successful: bool = Field(
325
- description="Whether integration with existing project was successful"
326
- )
327
-
328
- # Generated content
329
- generated_files: List[GeneratedFile] = Field(
330
- default_factory=list,
331
- description="List of generated files"
332
- )
333
-
334
- patterns_followed: List[str] = Field(
335
- default_factory=list,
336
- description="Architectural patterns that were followed"
337
- )
338
-
339
- dependencies_resolved: List[str] = Field(
340
- default_factory=list,
341
- description="Dependencies that were resolved and added"
342
- )
343
-
344
- # Issues and warnings
345
- errors: List[ValidationIssue] = Field(
346
- default_factory=list,
347
- description="Errors encountered during generation"
348
- )
349
-
350
- warnings: List[ValidationIssue] = Field(
351
- default_factory=list,
352
- description="Warnings from validation"
353
- )
354
-
355
- # Output paths
356
- report_directory: Path = Field(
357
- description="Directory containing generation reports"
358
- )
359
-
360
- generation_report_path: Path = Field(
361
- description="Path to the detailed generation report"
362
- )
363
-
364
- @computed_field
365
- @property
366
- def has_critical_errors(self) -> bool:
367
- """Check if there are any critical errors."""
368
- return any(error.severity == ValidationSeverity.CRITICAL for error in self.errors)
369
-
370
- @computed_field
371
- @property
372
- def blocking_issues_count(self) -> int:
373
- """Count of issues that block deployment."""
374
- return sum(1 for error in self.errors if error.is_blocking)
375
-
376
- @computed_field
377
- @property
378
- def quality_metrics(self) -> QualityMetrics:
379
- """Get comprehensive quality metrics."""
380
- return QualityMetrics(
381
- overall_score=self.quality_score,
382
- type_safety_score=self.type_safety_score,
383
- pattern_consistency=self.pattern_consistency_score,
384
- test_coverage=self.test_coverage_percentage,
385
- # Calculate other metrics from generated files
386
- code_complexity=self._calculate_average_complexity(),
387
- documentation_coverage=self._calculate_documentation_coverage(),
388
- performance_score=8.0, # Default for now
389
- security_score=8.5, # Default for now
390
- maintainability_score=self._calculate_maintainability_score()
391
- )
392
-
393
- def _calculate_average_complexity(self) -> float:
394
- """Calculate average complexity across all files."""
395
- if not self.generated_files:
396
- return 0.0
397
-
398
- total_complexity = sum(f.complexity_score for f in self.generated_files)
399
- return total_complexity / len(self.generated_files)
400
-
401
- def _calculate_documentation_coverage(self) -> float:
402
- """Calculate documentation coverage percentage."""
403
- if not self.generated_files:
404
- return 0.0
405
-
406
- # Simple heuristic: files with docstrings
407
- documented_files = sum(
408
- 1 for f in self.generated_files
409
- if '"""' in f.content or "'''" in f.content
410
- )
411
-
412
- return (documented_files / len(self.generated_files)) * 100
413
-
414
- def _calculate_maintainability_score(self) -> float:
415
- """Calculate maintainability score."""
416
- if not self.generated_files:
417
- return 0.0
418
-
419
- # Factors: follows conventions, reasonable complexity, good patterns
420
- convention_score = sum(1 for f in self.generated_files if f.follows_conventions)
421
- convention_ratio = convention_score / len(self.generated_files)
422
-
423
- avg_complexity = self._calculate_average_complexity()
424
- complexity_score = max(0, 10 - avg_complexity) # Lower complexity = higher score
425
-
426
- pattern_score = min(10, len(self.patterns_followed))
427
-
428
- return (convention_ratio * 4 + complexity_score * 3 + pattern_score * 3) / 10
429
-
430
- def get_files_by_type(self, file_type: FileType) -> List[GeneratedFile]:
431
- """Get all generated files of a specific type."""
432
- return [f for f in self.generated_files if f.file_type == file_type]
433
-
434
- def get_summary(self) -> Dict[str, Any]:
435
- """Get a summary of the generation result."""
436
- return {
437
- "app_name": self.app_name,
438
- "success": self.success,
439
- "execution_time_seconds": self.total_execution_time_seconds,
440
- "files_generated": self.files_count,
441
- "lines_of_code": self.lines_of_code,
442
- "quality_score": self.quality_score,
443
- "type_safety_score": self.type_safety_score,
444
- "test_coverage": self.test_coverage_percentage,
445
- "errors_count": len(self.errors),
446
- "warnings_count": len(self.warnings),
447
- "critical_errors": self.has_critical_errors,
448
- "patterns_used": len(self.patterns_followed),
449
- "dependencies_added": len(self.dependencies_resolved)
450
- }
451
-
452
-
453
- class QuestioningResult(TimestampedModel):
454
- """Result of an intelligent questioning session."""
455
-
456
- session_id: str = Field(description="Unique session identifier")
457
- success: bool = Field(description="Whether questioning completed successfully")
458
-
459
- questions_asked: List[ContextualQuestion] = Field(
460
- default_factory=list,
461
- description="Questions that were asked"
462
- )
463
-
464
- responses_received: List[QuestionResponse] = Field(
465
- default_factory=list,
466
- description="Responses received from user"
467
- )
468
-
469
- session_duration_seconds: float = Field(
470
- ge=0.0,
471
- description="Duration of questioning session in seconds"
472
- )
473
-
474
- completion_percentage: float = Field(
475
- ge=0.0,
476
- le=100.0,
477
- description="Percentage of questions completed"
478
- )
479
-
480
- context_quality_score: float = Field(
481
- ge=0.0,
482
- le=10.0,
483
- description="Quality of context gathered (0-10)"
484
- )
485
-
486
- architectural_insights: List[str] = Field(
487
- default_factory=list,
488
- description="Key architectural insights discovered"
489
- )
490
-
491
- integration_requirements: List[str] = Field(
492
- default_factory=list,
493
- description="Integration requirements identified"
494
- )
495
-
496
- @computed_field
497
- @property
498
- def response_rate(self) -> float:
499
- """Calculate response rate (responses / questions)."""
500
- if not self.questions_asked:
501
- return 0.0
502
- return len(self.responses_received) / len(self.questions_asked)
503
-
504
- def get_unanswered_questions(self) -> List[ContextualQuestion]:
505
- """Get questions that were not answered."""
506
- answered_ids = {r.question_id for r in self.responses_received}
507
- return [q for q in self.questions_asked if q.id not in answered_ids]
508
-
509
-
510
- class DiagnosticResult(TimestampedModel):
511
- """Result of diagnostic analysis."""
512
-
513
- analysis_id: str = Field(description="Unique analysis identifier")
514
- success: bool = Field(description="Whether diagnostic completed successfully")
515
-
516
- problems_identified: List[str] = Field(
517
- default_factory=list,
518
- description="Problems identified in the codebase"
519
- )
520
-
521
- root_causes: List[str] = Field(
522
- default_factory=list,
523
- description="Potential root causes of issues"
524
- )
525
-
526
- solution_suggestions: List[str] = Field(
527
- default_factory=list,
528
- description="Suggested solutions"
529
- )
530
-
531
- confidence_score: float = Field(
532
- ge=0.0,
533
- le=1.0,
534
- description="Confidence in the diagnostic results"
535
- )
536
-
537
- analysis_duration_seconds: float = Field(
538
- ge=0.0,
539
- description="Time taken for analysis in seconds"
540
- )
541
-
542
- files_analyzed: int = Field(
543
- ge=0,
544
- description="Number of files analyzed"
545
- )
546
-
547
- @computed_field
548
- @property
549
- def severity_level(self) -> str:
550
- """Get overall severity level of identified problems."""
551
- if len(self.problems_identified) >= 5:
552
- return "high"
553
- elif len(self.problems_identified) >= 2:
554
- return "medium"
555
- elif len(self.problems_identified) >= 1:
556
- return "low"
557
- else:
558
- return "none"
559
-
560
-
561
- class TemplateResult(BaseAgentModel):
562
- """Result of template rendering operation."""
563
-
564
- rendered_content: str = Field(
565
- description="The rendered template content"
566
- )
567
-
568
- template_name: str = Field(
569
- description="Name of the template that was rendered"
570
- )
571
-
572
- variables_used: List[str] = Field(
573
- default_factory=list,
574
- description="List of variables that were used in rendering"
575
- )
576
-
577
- missing_variables: List[str] = Field(
578
- default_factory=list,
579
- description="List of variables that were referenced but not provided"
580
- )
581
-
582
- template_metadata: Dict[str, Any] = Field(
583
- default_factory=dict,
584
- description="Metadata about the template rendering process"
585
- )
@@ -1,6 +0,0 @@
1
- [tool:pytest]
2
- filterwarnings =
3
- ignore::DeprecationWarning:pydantic
4
- ignore::DeprecationWarning:pydantic.fields
5
- ignore::pydantic.warnings.PydanticDeprecatedSince20
6
- ignore:.*asyncio_default_fixture_loop_scope.*:pytest.PytestDeprecationWarning
@@ -1,42 +0,0 @@
1
- """
2
- Service Layer for Django App Agent Module.
3
-
4
- This module provides business logic services for:
5
- - Application generation and management
6
- - Project structure analysis and scanning
7
- - Template management and code generation
8
- - Context building for AI agents
9
- - Validation and quality assurance
10
- - Reporting and documentation generation
11
-
12
- Services follow the base service pattern with:
13
- - Dependency injection via configuration
14
- - Structured logging and error handling
15
- - Async operations for performance
16
- - Type safety with Pydantic v2
17
- """
18
-
19
- from .base import BaseService, ServiceResult, ServiceError
20
- from .project_scanner import ProjectScannerService
21
- from .app_generator import AppGeneratorService
22
- from .context_builder import ContextBuilderService
23
- from .template_manager import TemplateManagerService
24
- from .validation_service import ValidationService
25
- from .questioning_service import QuestioningService
26
- from .report_service import ReportService
27
-
28
- __all__ = [
29
- # Base service infrastructure
30
- "BaseService",
31
- "ServiceResult",
32
- "ServiceError",
33
-
34
- # Core services
35
- "ProjectScannerService",
36
- "AppGeneratorService",
37
- "ContextBuilderService",
38
- "TemplateManagerService",
39
- "ValidationService",
40
- "QuestioningService",
41
- "ReportService",
42
- ]
@@ -1,30 +0,0 @@
1
- """
2
- Application Generator Module for Django App Agent.
3
-
4
- This module provides a decomposed, modular approach to Django application generation
5
- with AI assistance. The module is split into logical components for better maintainability.
6
-
7
- Components:
8
- - context: Generation context management
9
- - validation: Requirements and code validation
10
- - structure: Basic app structure and template generation
11
- - ai_integration: AI-powered code generation
12
- - main: Main orchestration service
13
- """
14
-
15
- from .main import AppGeneratorService
16
- from .context import GenerationContext
17
- from .validation import GenerationValidator
18
- from .structure import StructureGenerator
19
- from .ai_integration import AIGenerationManager
20
-
21
- __all__ = [
22
- # Main service
23
- "AppGeneratorService",
24
-
25
- # Core components
26
- "GenerationContext",
27
- "GenerationValidator",
28
- "StructureGenerator",
29
- "AIGenerationManager",
30
- ]