coding-client 1.21.2__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 (109) hide show
  1. coding_client/__init__.py +1 -0
  2. coding_client/api/__init__.py +19 -0
  3. coding_client/api/exception_handlers.py +158 -0
  4. coding_client/api/logging_setup.py +44 -0
  5. coding_client/api/metrics.py +40 -0
  6. coding_client/api/openapi_config.py +124 -0
  7. coding_client/api/request_logging.py +60 -0
  8. coding_client/api/validation.py +150 -0
  9. coding_client/auth/__init__.py +78 -0
  10. coding_client/auth/_default_tenant.py +132 -0
  11. coding_client/auth/_header_trust.py +98 -0
  12. coding_client/auth/_onbehalf.py +315 -0
  13. coding_client/auth/_trusted_networks.py +94 -0
  14. coding_client/auth/dependencies.py +61 -0
  15. coding_client/auth/middleware.py +445 -0
  16. coding_client/auth/models.py +83 -0
  17. coding_client/auth/outbound.py +137 -0
  18. coding_client/auth/rbac.py +21 -0
  19. coding_client/auth/rbac_coding.py +5 -0
  20. coding_client/auth/tenant.py +650 -0
  21. coding_client/auth/websocket.py +148 -0
  22. coding_client/clients/__init__.py +24 -0
  23. coding_client/clients/base.py +131 -0
  24. coding_client/clients/coding_ai.py +33 -0
  25. coding_client/clients/coding_analysis.py +36 -0
  26. coding_client/clients/coding_containers.py +45 -0
  27. coding_client/clients/coding_github.py +127 -0
  28. coding_client/clients/coding_realtime.py +127 -0
  29. coding_client/clients/coding_security.py +51 -0
  30. coding_client/clients/coding_testing.py +31 -0
  31. coding_client/clients/coding_workspaces.py +265 -0
  32. coding_client/config/__init__.py +12 -0
  33. coding_client/config/base_settings.py +61 -0
  34. coding_client/config/yaml_config_loader.py +172 -0
  35. coding_client/db/__init__.py +42 -0
  36. coding_client/db/db_types.py +122 -0
  37. coding_client/db/exceptions.py +59 -0
  38. coding_client/db/postgres_connection.py +572 -0
  39. coding_client/db/tenant_query_helper.py +417 -0
  40. coding_client/db_init.py +49 -0
  41. coding_client/exceptions/__init__.py +67 -0
  42. coding_client/exceptions/api_exceptions.py +395 -0
  43. coding_client/exceptions/pydantic_ai_exceptions.py +533 -0
  44. coding_client/interfaces/__init__.py +22 -0
  45. coding_client/interfaces/cache_interface.py +179 -0
  46. coding_client/interfaces/container_interface.py +49 -0
  47. coding_client/interfaces/docker_interface.py +283 -0
  48. coding_client/interfaces/graph_interface.py +28 -0
  49. coding_client/interfaces/security_interface.py +72 -0
  50. coding_client/interfaces/webhook_interface.py +67 -0
  51. coding_client/llm/__init__.py +54 -0
  52. coding_client/llm/base_agent.py +195 -0
  53. coding_client/llm/context.py +121 -0
  54. coding_client/llm/responses.py +102 -0
  55. coding_client/llm/routing.py +82 -0
  56. coding_client/llm/settings.py +102 -0
  57. coding_client/models/__init__.py +62 -0
  58. coding_client/models/agent.py +38 -0
  59. coding_client/models/ai_test_failure.py +745 -0
  60. coding_client/models/analysis.py +330 -0
  61. coding_client/models/architecture.py +685 -0
  62. coding_client/models/bug.py +128 -0
  63. coding_client/models/code_graph.py +317 -0
  64. coding_client/models/container.py +241 -0
  65. coding_client/models/core.py +878 -0
  66. coding_client/models/docker_container.py +104 -0
  67. coding_client/models/github.py +293 -0
  68. coding_client/models/logging.py +29 -0
  69. coding_client/models/package_manager.py +257 -0
  70. coding_client/models/pr_validation.py +440 -0
  71. coding_client/models/pydantic_ai.py +395 -0
  72. coding_client/models/repo_scanner.py +249 -0
  73. coding_client/models/responses.py +431 -0
  74. coding_client/models/security.py +185 -0
  75. coding_client/models/static_analysis.py +508 -0
  76. coding_client/models/system.py +48 -0
  77. coding_client/models/test_executor.py +204 -0
  78. coding_client/models/testing.py +673 -0
  79. coding_client/models/testing_config.py +200 -0
  80. coding_client/models/validation.py +127 -0
  81. coding_client/models_init.py +272 -0
  82. coding_client/telemetry.py +195 -0
  83. coding_client/testing.py +180 -0
  84. coding_client/types/__init__.py +130 -0
  85. coding_client/types/constraint_types.py +276 -0
  86. coding_client/types/core_types.py +112 -0
  87. coding_client/types/state_machine.py +443 -0
  88. coding_client/utils/__init__.py +86 -0
  89. coding_client/utils/archive_utils.py +387 -0
  90. coding_client/utils/ast_debug.py +45 -0
  91. coding_client/utils/async_timeout.py +364 -0
  92. coding_client/utils/constants.py +518 -0
  93. coding_client/utils/content_processing.py +326 -0
  94. coding_client/utils/database.py +916 -0
  95. coding_client/utils/encoding_helper.py +222 -0
  96. coding_client/utils/enum_helpers.py +166 -0
  97. coding_client/utils/file_operations.py +177 -0
  98. coding_client/utils/filesystem_ops.py +528 -0
  99. coding_client/utils/http_client.py +562 -0
  100. coding_client/utils/path_utils.py +471 -0
  101. coding_client/utils/profiling.py +421 -0
  102. coding_client/utils/response_builder.py +240 -0
  103. coding_client/utils/retry_helper.py +712 -0
  104. coding_client/utils/security_validation.py +423 -0
  105. coding_client-1.21.2.dist-info/METADATA +234 -0
  106. coding_client-1.21.2.dist-info/RECORD +109 -0
  107. coding_client-1.21.2.dist-info/WHEEL +5 -0
  108. coding_client-1.21.2.dist-info/licenses/LICENSE +201 -0
  109. coding_client-1.21.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,330 @@
1
+ """Analysis models for deep code analysis and improvement generation.
2
+
3
+ This module provides Pydantic models for the analysis API endpoints, supporting
4
+ deep static code analysis, bug hunting, and automated code improvement workflows.
5
+ The models facilitate comprehensive code quality assessment and remediation
6
+ through AI-powered analysis and GitHub integration.
7
+
8
+ The analysis system supports:
9
+ - Deep static analysis with multi-dimensional quality assessment
10
+ - Bug hunting from error logs with automated remediation
11
+ - Code improvement suggestions with confidence scoring
12
+ - GitHub integration for automated PR creation
13
+ - Validation of proposed code changes
14
+ - Comprehensive reporting with actionable insights
15
+
16
+ Key Model Categories:
17
+ Request Models: DeepAnalysisRequest, BugHuntingRequest, ImprovementRequest
18
+ Response Models: DeepAnalysisResponse, BugHuntingResponse for analysis results
19
+ Data Models: ImprovementItem, CodeValidationRequest for change representation
20
+ Integration Models: GitHub token and repository handling for PR creation
21
+
22
+ Analysis Types:
23
+ - Security vulnerability detection
24
+ - Performance issue identification
25
+ - Code complexity analysis
26
+ - Code smell detection
27
+ - Architectural analysis
28
+ - Documentation quality assessment
29
+ - Bug risk analysis
30
+
31
+ Example:
32
+ ```python
33
+ from analysis_models import DeepAnalysisRequest, BugHuntingRequest, ImprovementItem
34
+
35
+ # Deep analysis request
36
+ analysis_request = DeepAnalysisRequest(
37
+ include_security=True,
38
+ include_performance=True,
39
+ include_complexity=True,
40
+ include_code_smells=True,
41
+ include_architecture=True,
42
+ include_documentation=True,
43
+ include_bug_risks=True
44
+ )
45
+
46
+ # Bug hunting request
47
+ bug_request = BugHuntingRequest(
48
+ error_logs="Traceback: ImportError: No module named 'requests'",
49
+ create_pr=True,
50
+ github_repo="owner/repository",
51
+ GITHUB_ACCESS_TOKEN="ghp_token"
52
+ )
53
+
54
+ # Improvement item
55
+ improvement = ImprovementItem(
56
+ file_path="src/main.py",
57
+ fixed_code=(
58
+ "import requests\\n\\ndef fetch_data():\\n "
59
+ "response = requests.get('https://api.example.com/data')\\n return response.json()"
60
+ ),
61
+ original_code="def fetch_data():\\n # TODO: implement data fetching\\n pass",
62
+ description="Implement data fetching functionality",
63
+ confidence=0.9,
64
+ fix_type="implementation"
65
+ )
66
+ ```
67
+ """
68
+
69
+ from __future__ import annotations
70
+
71
+ import logging
72
+ from typing import TypedDict
73
+
74
+ from pydantic import BaseModel, Field, model_validator
75
+
76
+ # Configure logging for analysis models
77
+ logger = logging.getLogger(__name__)
78
+
79
+
80
+ class BugHuntingContextDict(TypedDict, total=False):
81
+ """Type definition for bug hunting context information.
82
+
83
+ This dictionary structure provides context for bug hunting analysis,
84
+ including repository metadata, environment details, and execution context.
85
+ """
86
+
87
+ container_name: str
88
+ repository_path: str
89
+ branch: str
90
+ commit_hash: str
91
+ environment: str
92
+ runtime_version: str
93
+ error_timestamp: str
94
+ user_id: str
95
+ session_id: str
96
+ error_type: str
97
+ stack_trace: str
98
+ affected_files: list[str]
99
+ recent_changes: list[str]
100
+ system_info: dict[str, str]
101
+
102
+
103
+ class AnalysisMetricsDict(TypedDict):
104
+ """Type definition for analysis metrics data.
105
+
106
+ Comprehensive metrics for code quality assessment including
107
+ maintainability, security, performance, and coverage indicators.
108
+ """
109
+
110
+ lines_of_code: int
111
+ cyclomatic_complexity: float
112
+ maintainability_index: float
113
+ test_coverage: float
114
+ code_duplication: float
115
+ security_score: float
116
+ performance_score: float
117
+ documentation_coverage: float
118
+ technical_debt_ratio: float
119
+ complexity_violations: int
120
+ security_vulnerabilities: int
121
+ performance_issues: int
122
+ code_smells: int
123
+ test_failures: int
124
+
125
+
126
+ class AnalysisIssueDict(TypedDict):
127
+ """Type definition for individual analysis issues.
128
+
129
+ Structured representation of code quality issues with
130
+ location, severity, and remediation information.
131
+ """
132
+
133
+ id: str
134
+ severity: str # "critical", "high", "medium", "low"
135
+ type: str # "security", "performance", "complexity", "maintainability"
136
+ category: str
137
+ file_path: str
138
+ line_number: int
139
+ column_number: int
140
+ message: str
141
+ description: str
142
+ fix_suggestion: str
143
+ confidence: float
144
+ rule_id: str
145
+ tool_name: str
146
+ impact: str
147
+ effort: str
148
+
149
+
150
+ class ErrorDetailDict(TypedDict):
151
+ """Type definition for error analysis details.
152
+
153
+ Structured representation of parsed error information
154
+ with context and classification data.
155
+ """
156
+
157
+ error_id: str
158
+ error_type: str
159
+ error_message: str
160
+ stack_trace: str
161
+ file_path: str
162
+ line_number: int
163
+ function_name: str
164
+ error_category: str
165
+ severity: str
166
+ timestamp: str
167
+ frequency: int
168
+ impact_score: float
169
+ suggested_fix: str
170
+ related_errors: list[str]
171
+
172
+
173
+ class FixDetailDict(TypedDict):
174
+ """Type definition for bug fix details.
175
+
176
+ Structured representation of proposed fixes with
177
+ implementation details and risk assessment.
178
+ """
179
+
180
+ fix_id: str
181
+ fix_type: str
182
+ file_path: str
183
+ line_number: int
184
+ original_code: str
185
+ fixed_code: str
186
+ description: str
187
+ confidence: float
188
+ risk_level: str
189
+ test_impact: str
190
+ dependencies: list[str]
191
+ validation_steps: list[str]
192
+ rollback_plan: str
193
+
194
+
195
+ class PullRequestDict(TypedDict):
196
+ """Type definition for pull request information.
197
+
198
+ Structured representation of GitHub pull request data
199
+ with creation and status details.
200
+ """
201
+
202
+ pr_number: int
203
+ pr_url: str
204
+ pr_title: str
205
+ pr_description: str
206
+ branch_name: str
207
+ commit_hash: str
208
+ status: str
209
+ created_at: str
210
+ updated_at: str
211
+ mergeable: bool
212
+ conflicts: list[str]
213
+ checks_passed: bool
214
+ review_required: bool
215
+ files_changed: list[str]
216
+
217
+
218
+ class DeepAnalysisRequest(BaseModel):
219
+ """Request for deep static code analysis."""
220
+
221
+ include_security: bool = Field(True, description="Include security vulnerability analysis")
222
+ include_performance: bool = Field(True, description="Include performance issue analysis")
223
+ include_complexity: bool = Field(True, description="Include code complexity analysis")
224
+ include_code_smells: bool = Field(True, description="Include code smell detection")
225
+ include_architecture: bool = Field(True, description="Include architectural analysis")
226
+ include_documentation: bool = Field(True, description="Include documentation quality analysis")
227
+ include_bug_risks: bool = Field(True, description="Include potential bug risk analysis")
228
+
229
+
230
+ class BugHuntingRequest(BaseModel):
231
+ """Request for bug hunting from error logs."""
232
+
233
+ error_logs: str | None = Field(
234
+ "",
235
+ description=(
236
+ "Console logs, error output, or deep analysis results to analyze. "
237
+ "If empty, will scan codebase for potential issues."
238
+ ),
239
+ )
240
+ error_logs_base64: str | None = Field(
241
+ None,
242
+ description="Base64-encoded console logs or error output. Decoded before analysis.",
243
+ )
244
+ context: BugHuntingContextDict | None = Field(
245
+ None, description="Additional context information for bug hunting"
246
+ )
247
+ create_pr: bool = Field(False, description="Whether to create a pull request with resolves")
248
+ github_repo: str | None = Field(
249
+ None, description="GitHub repository (owner/repo) for PR creation"
250
+ )
251
+ GITHUB_ACCESS_TOKEN: str | None = Field(None, description="GitHub token for PR creation")
252
+
253
+
254
+ class DeepAnalysisResponse(BaseModel):
255
+ """Response for deep static code analysis."""
256
+
257
+ overall_score: float = Field(description="Overall code quality score (0-10)")
258
+ total_issues: int = Field(description="Total number of issues found")
259
+ issues_by_severity: dict[str, int] = Field(description="Issues grouped by severity")
260
+ issues_by_type: dict[str, int] = Field(description="Issues grouped by type")
261
+ metrics: AnalysisMetricsDict = Field(description="Comprehensive codebase quality metrics")
262
+ recommendations: list[str] = Field(description="High-level recommendations")
263
+ issues: list[AnalysisIssueDict] = Field(description="Detailed list of code quality issues")
264
+ analysis_time: float = Field(description="Time taken for analysis (seconds)")
265
+
266
+
267
+ class BugHuntingResponse(BaseModel):
268
+ """Response for bug hunting analysis."""
269
+
270
+ errors_found: int = Field(description="Number of errors identified")
271
+ fixes_generated: int = Field(description="Number of resolves generated")
272
+ root_cause_analysis: str = Field(description="Analysis of root causes")
273
+ fix_summary: str = Field(description="Summary of proposed resolves")
274
+ estimated_effort: str = Field(description="Estimated effort to implement resolves")
275
+ risk_assessment: str = Field(description="Risk assessment of proposed resolves")
276
+ errors: list[ErrorDetailDict] = Field(description="Parsed error details with context")
277
+ resolves: list[FixDetailDict] = Field(description="Generated fix proposals")
278
+ pull_request: PullRequestDict | None = Field(
279
+ None, description="Pull request information if created"
280
+ )
281
+ analysis_time: float = Field(description="Time taken for analysis (seconds)")
282
+
283
+
284
+ class ImprovementItem(BaseModel):
285
+ """Individual update item model."""
286
+
287
+ file_path: str = Field(..., description="Path to the file to be updated", min_length=1)
288
+ fixed_code: str | None = Field(None, description="The updated code content")
289
+ code: str | None = Field(None, description="Alternative field name for code content")
290
+ original_code: str | None = Field(None, description="The original code content")
291
+ line_number: int | None = Field(None, description="Line number of the change")
292
+ description: str | None = Field(None, description="Description of the update")
293
+ confidence: float | None = Field(0.8, description="Confidence score for the update")
294
+ fix_type: str | None = Field("augmentation", description="Type of resolve/update")
295
+
296
+ @model_validator(mode="after")
297
+ def check_code_or_fixed_code(self) -> ImprovementItem:
298
+ """Validate that at least one of fixed_code or code is provided in the model.
299
+
300
+ Raises:
301
+ ValueError: If neither fixed_code nor code is present.
302
+ """
303
+ logger.debug(f"Validating ImprovementItem for file: {self.file_path}")
304
+ if not self.fixed_code and not self.code:
305
+ logger.error(f"Missing code content for improvement item: {self.file_path}")
306
+ raise ValueError("At least one of fixed_code or code must be provided")
307
+ # Log validation success
308
+ logger.debug(f"ImprovementItem validation successful for {self.file_path}")
309
+ return self
310
+
311
+
312
+ class ImprovementRequest(BaseModel):
313
+ """Request model for creating update PR."""
314
+
315
+ github_repo: str = Field(..., description="GitHub repository (owner/repo)", min_length=1)
316
+ GITHUB_ACCESS_TOKEN: str = Field(..., description="GitHub token for API access", min_length=1)
317
+ updates: list[ImprovementItem] = Field(..., description="List of code updates", min_length=1)
318
+ pr_title: str | None = Field(None, description="Pull request title")
319
+ pr_description: str | None = Field(None, description="Pull request description")
320
+
321
+
322
+ class CodeValidationRequest(BaseModel):
323
+ """Request model for validating proposed code changes."""
324
+
325
+ code: str = Field(..., description="The proposed code changes", min_length=1)
326
+ filename: str = Field(..., description="The filename of the code", min_length=1)
327
+ relative_path: str | None = Field(None, description="The relative path to the original file")
328
+ language: str = Field(..., description="The programming language of the code", min_length=1)
329
+ author: str = Field(..., description="The author of the code", min_length=1)
330
+ description: str = Field(..., description="A brief description of the changes", min_length=1)