x-ipe 1.0.24__py3-none-any.whl → 1.0.25__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.
- x_ipe/app.py +25 -3
- x_ipe/handlers/terminal_handlers.py +6 -0
- x_ipe/handlers/voice_handlers.py +5 -0
- x_ipe/resources/copilot-instructions.md +19 -6
- x_ipe/resources/skills/lesson-learned/SKILL.md +208 -0
- x_ipe/resources/skills/lesson-learned/references/examples.md +238 -0
- x_ipe/resources/skills/project-quality-board-management/SKILL.md +135 -298
- x_ipe/resources/skills/project-quality-board-management/references/evaluation-principles.md +213 -0
- x_ipe/resources/skills/project-quality-board-management/references/evaluation-procedures.md +214 -0
- x_ipe/resources/skills/project-quality-board-management/templates/quality-report.md +70 -18
- x_ipe/resources/skills/task-execution-guideline/SKILL.md +2 -2
- x_ipe/resources/skills/task-execution-guideline/templates/task-record.yaml +1 -1
- x_ipe/resources/skills/task-type-code-implementation/SKILL.md +72 -270
- x_ipe/resources/skills/task-type-code-implementation/references/implementation-guidelines.md +432 -0
- x_ipe/resources/skills/task-type-code-refactor-v2/SKILL.md +127 -353
- x_ipe/resources/skills/task-type-code-refactor-v2/references/refactoring-techniques.md +373 -0
- x_ipe/resources/skills/task-type-feature-breakdown/SKILL.md +31 -243
- x_ipe/resources/skills/task-type-feature-breakdown/references/breakdown-guidelines.md +330 -0
- x_ipe/resources/skills/task-type-feature-refinement/SKILL.md +27 -180
- x_ipe/resources/skills/task-type-feature-refinement/references/specification-writing-guide.md +267 -0
- x_ipe/resources/skills/task-type-idea-mockup/SKILL.md +38 -276
- x_ipe/resources/skills/task-type-idea-mockup/references/mockup-guidelines.md +299 -0
- x_ipe/resources/skills/task-type-idea-to-architecture/SKILL.md +20 -218
- x_ipe/resources/skills/task-type-idea-to-architecture/references/architecture-patterns.md +342 -0
- x_ipe/resources/skills/task-type-ideation/SKILL.md +10 -266
- x_ipe/resources/skills/task-type-ideation/references/folder-naming-guide.md +55 -0
- x_ipe/resources/skills/task-type-ideation/references/tool-usage-guide.md +236 -0
- x_ipe/resources/skills/task-type-ideation-v2/SKILL.md +488 -0
- x_ipe/resources/skills/task-type-ideation-v2/references/examples.md +377 -0
- x_ipe/resources/skills/task-type-ideation-v2/references/folder-naming-guide.md +74 -0
- x_ipe/resources/skills/task-type-ideation-v2/references/tool-usage-guide.md +145 -0
- x_ipe/resources/skills/task-type-ideation-v2/references/visualization-guide.md +160 -0
- x_ipe/resources/skills/task-type-ideation-v2/templates/idea-summary.md +86 -0
- x_ipe/resources/skills/task-type-refactoring-analysis/SKILL.md +83 -145
- x_ipe/resources/skills/task-type-refactoring-analysis/references/output-schema.md +172 -0
- x_ipe/resources/skills/task-type-technical-design/SKILL.md +28 -214
- x_ipe/resources/skills/task-type-technical-design/references/design-templates.md +422 -0
- x_ipe/resources/skills/task-type-test-generation/SKILL.md +47 -332
- x_ipe/resources/skills/task-type-test-generation/references/test-patterns.md +368 -0
- x_ipe/resources/skills/tool-tracing-creator/SKILL.md +312 -0
- x_ipe/resources/skills/tool-tracing-creator/references/examples.md +324 -0
- x_ipe/resources/skills/tool-tracing-instrumentation/SKILL.md +373 -0
- x_ipe/resources/skills/tool-tracing-instrumentation/references/examples.md +264 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/SKILL.md +486 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/10. example-gate-conditions.md +73 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/11. reference-quality-standards.md +127 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/2. reference-section-order.md +127 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/3. example-step-based-code-review.md +84 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/4. example-step-based-feature-implementation.md +113 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/5. example-function-based-validation.md +73 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/6. example-function-based-analysis.md +94 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/7. example-task-io-code-implementation.md +36 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/8. example-structured-summary.md +43 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/9. example-dor-dod.md +77 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/examples.md +429 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/references/skill-general-guidelines-v2.md +611 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-meta.md +153 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-task-based.md +324 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-task-category.md +109 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-tool.md +205 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-meta.md +334 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-task-based.md +279 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-tool.md +175 -0
- x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-workflow-orchestration.md +329 -0
- x_ipe/resources/skills/x-ipe-task-based-ideation/SKILL.md +487 -0
- x_ipe/resources/skills/x-ipe-task-based-ideation/references/examples.md +377 -0
- x_ipe/resources/skills/x-ipe-task-based-ideation/references/folder-naming-guide.md +74 -0
- x_ipe/resources/skills/x-ipe-task-based-ideation/references/tool-usage-guide.md +145 -0
- x_ipe/resources/skills/x-ipe-task-based-ideation/references/visualization-guide.md +160 -0
- x_ipe/resources/skills/x-ipe-task-based-ideation/templates/idea-summary.md +86 -0
- x_ipe/routes/__init__.py +2 -0
- x_ipe/routes/ideas_routes.py +17 -0
- x_ipe/routes/kb_routes.py +80 -0
- x_ipe/routes/main_routes.py +18 -0
- x_ipe/routes/project_routes.py +7 -0
- x_ipe/routes/proxy_routes.py +2 -0
- x_ipe/routes/quality_evaluation_routes.py +193 -0
- x_ipe/routes/settings_routes.py +6 -0
- x_ipe/routes/tools_routes.py +6 -0
- x_ipe/routes/tracing_routes.py +232 -0
- x_ipe/routes/uiux_feedback_routes.py +30 -0
- x_ipe/services/__init__.py +5 -0
- x_ipe/services/config_service.py +6 -0
- x_ipe/services/file_service.py +20 -0
- x_ipe/services/homepage_service.py +160 -0
- x_ipe/services/ideas_service.py +19 -0
- x_ipe/services/kb_service.py +378 -0
- x_ipe/services/proxy_service.py +4 -0
- x_ipe/services/settings_service.py +13 -0
- x_ipe/services/skills_service.py +4 -0
- x_ipe/services/terminal_service.py +24 -0
- x_ipe/services/themes_service.py +4 -0
- x_ipe/services/tools_config_service.py +4 -0
- x_ipe/services/tracing_service.py +333 -0
- x_ipe/services/uiux_feedback_service.py +32 -0
- x_ipe/services/voice_input_service_v2.py +11 -0
- x_ipe/static/css/base.css +7 -0
- x_ipe/static/css/homepage-infinity.css +330 -0
- x_ipe/static/css/kb-core.css +301 -0
- x_ipe/static/css/quality-evaluation.css +345 -0
- x_ipe/static/css/sidebar.css +14 -4
- x_ipe/static/css/terminal.css +1 -0
- x_ipe/static/css/tracing-dashboard.css +796 -0
- x_ipe/static/css/workplace.css +20 -0
- x_ipe/static/img/homepage-infinity-loop.png +0 -0
- x_ipe/static/js/features/homepage-infinity.js +314 -0
- x_ipe/static/js/features/kb-core.js +371 -0
- x_ipe/static/js/features/quality-evaluation.js +387 -0
- x_ipe/static/js/features/sidebar.js +255 -12
- x_ipe/static/js/features/tracing-dashboard.js +855 -0
- x_ipe/static/js/features/tracing-graph.js +1031 -0
- x_ipe/static/js/features/tree-search.js +6 -2
- x_ipe/static/js/features/workplace.js +200 -6
- x_ipe/static/js/init.js +76 -0
- x_ipe/static/js/uiux-feedback.js +18 -2
- x_ipe/templates/base.html +19 -0
- x_ipe/templates/index.html +7 -1
- x_ipe/templates/knowledge-base.html +110 -0
- x_ipe/templates/workplace.html +4 -0
- x_ipe/tracing/__init__.py +37 -0
- x_ipe/tracing/buffer.py +135 -0
- x_ipe/tracing/context.py +125 -0
- x_ipe/tracing/decorator.py +288 -0
- x_ipe/tracing/middleware.py +197 -0
- x_ipe/tracing/parser.py +235 -0
- x_ipe/tracing/redactor.py +111 -0
- x_ipe/tracing/writer.py +122 -0
- {x_ipe-1.0.24.dist-info → x_ipe-1.0.25.dist-info}/METADATA +2 -2
- {x_ipe-1.0.24.dist-info → x_ipe-1.0.25.dist-info}/RECORD +132 -62
- x_ipe/resources/skills/x-ipe-skill-creator/SKILL.md +0 -329
- x_ipe/resources/skills/x-ipe-skill-creator/references/output-patterns.md +0 -169
- x_ipe/resources/skills/x-ipe-skill-creator/references/skill-structure.md +0 -162
- x_ipe/resources/skills/x-ipe-skill-creator/references/workflows.md +0 -110
- x_ipe/resources/skills/x-ipe-skill-creator/templates/references/examples.md +0 -113
- x_ipe/resources/skills/x-ipe-skill-creator/templates/skill-category-skill.md +0 -296
- x_ipe/resources/skills/x-ipe-skill-creator/templates/task-type-skill.md +0 -269
- {x_ipe-1.0.24.dist-info → x_ipe-1.0.25.dist-info}/WHEEL +0 -0
- {x_ipe-1.0.24.dist-info → x_ipe-1.0.25.dist-info}/entry_points.txt +0 -0
- {x_ipe-1.0.24.dist-info → x_ipe-1.0.25.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
# Test Generation Patterns Reference
|
|
2
|
+
|
|
3
|
+
## Test Case Templates
|
|
4
|
+
|
|
5
|
+
### Unit Test Template (Arrange-Act-Assert)
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
def test_<function>_<scenario>_<expected_result>(self):
|
|
9
|
+
"""AC: <Acceptance Criteria being tested>"""
|
|
10
|
+
# ARRANGE (Given)
|
|
11
|
+
# Set up test data and dependencies
|
|
12
|
+
email = "user@test.com"
|
|
13
|
+
password = "ValidPass123"
|
|
14
|
+
|
|
15
|
+
# ACT (When)
|
|
16
|
+
# Execute the function under test
|
|
17
|
+
result = auth_service.authenticate(email, password)
|
|
18
|
+
|
|
19
|
+
# ASSERT (Then)
|
|
20
|
+
# Verify expected outcomes
|
|
21
|
+
assert result.access_token is not None
|
|
22
|
+
assert result.token_type == "Bearer"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Integration Test Template
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
class TestAuthIntegration:
|
|
29
|
+
"""Integration tests for authentication flow."""
|
|
30
|
+
|
|
31
|
+
@pytest.fixture
|
|
32
|
+
def setup_db(self):
|
|
33
|
+
"""Set up test database with fixtures."""
|
|
34
|
+
db = create_test_database()
|
|
35
|
+
yield db
|
|
36
|
+
db.cleanup()
|
|
37
|
+
|
|
38
|
+
def test_full_auth_flow_success(self, setup_db):
|
|
39
|
+
"""Test complete authentication from request to token storage."""
|
|
40
|
+
# Test end-to-end flow
|
|
41
|
+
user = create_test_user(setup_db)
|
|
42
|
+
result = auth_service.authenticate(user.email, "password")
|
|
43
|
+
stored_token = token_repo.get_by_user(user.id)
|
|
44
|
+
|
|
45
|
+
assert result.success
|
|
46
|
+
assert stored_token is not None
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### API Test Template
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
class TestAuthAPI:
|
|
53
|
+
"""API tests for authentication endpoints."""
|
|
54
|
+
|
|
55
|
+
def test_login_endpoint_success(self, client):
|
|
56
|
+
"""POST /api/auth/login returns 200 with valid credentials."""
|
|
57
|
+
response = client.post("/api/auth/login", json={
|
|
58
|
+
"email": "test@example.com",
|
|
59
|
+
"password": "ValidPass123"
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
assert response.status_code == 200
|
|
63
|
+
assert "access_token" in response.json()
|
|
64
|
+
assert response.json()["token_type"] == "Bearer"
|
|
65
|
+
|
|
66
|
+
def test_login_endpoint_invalid_credentials(self, client):
|
|
67
|
+
"""POST /api/auth/login returns 401 with invalid credentials."""
|
|
68
|
+
response = client.post("/api/auth/login", json={
|
|
69
|
+
"email": "test@example.com",
|
|
70
|
+
"password": "WrongPassword"
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
assert response.status_code == 401
|
|
74
|
+
assert "error" in response.json()
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Parameterized Test Template
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
@pytest.mark.parametrize("input_data,expected", [
|
|
81
|
+
({"email": "valid@test.com", "name": "Test"}, True),
|
|
82
|
+
({"email": "invalid-email", "name": "Test"}, False),
|
|
83
|
+
({"email": "", "name": "Test"}, False),
|
|
84
|
+
({"email": "valid@test.com", "name": ""}, False),
|
|
85
|
+
])
|
|
86
|
+
def test_user_validation(input_data, expected):
|
|
87
|
+
"""Test user data validation with various inputs."""
|
|
88
|
+
result = validate_user(input_data)
|
|
89
|
+
assert result.is_valid == expected
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Test Naming Conventions
|
|
95
|
+
|
|
96
|
+
### Pattern
|
|
97
|
+
```
|
|
98
|
+
test_<function>_<scenario>_<expected_result>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Examples by Category
|
|
102
|
+
|
|
103
|
+
| Category | Example Name |
|
|
104
|
+
|----------|--------------|
|
|
105
|
+
| Happy path | `test_authenticate_valid_credentials_returns_token` |
|
|
106
|
+
| Invalid input | `test_authenticate_invalid_email_raises_error` |
|
|
107
|
+
| Edge case | `test_authenticate_expired_token_returns_401` |
|
|
108
|
+
| Boundary | `test_password_minimum_length_accepted` |
|
|
109
|
+
| Error handling | `test_database_connection_failure_handled_gracefully` |
|
|
110
|
+
| State | `test_logout_clears_session_data` |
|
|
111
|
+
|
|
112
|
+
### Language-Specific Conventions
|
|
113
|
+
|
|
114
|
+
**Python (pytest):**
|
|
115
|
+
```python
|
|
116
|
+
def test_function_scenario_expected():
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
class TestClassName:
|
|
120
|
+
def test_method_scenario_expected(self):
|
|
121
|
+
pass
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**JavaScript (Jest):**
|
|
125
|
+
```javascript
|
|
126
|
+
describe('ClassName', () => {
|
|
127
|
+
describe('methodName', () => {
|
|
128
|
+
it('should return expected when scenario', () => {});
|
|
129
|
+
it('should throw error when invalid input', () => {});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Go:**
|
|
135
|
+
```go
|
|
136
|
+
func TestFunctionName_Scenario_ExpectedResult(t *testing.T) {}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Mock and Stub Examples
|
|
142
|
+
|
|
143
|
+
### Python (pytest-mock)
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
def test_service_calls_repository(mocker):
|
|
147
|
+
"""Verify service delegates to repository."""
|
|
148
|
+
# Create mock
|
|
149
|
+
mock_repo = mocker.Mock()
|
|
150
|
+
mock_repo.find_by_id.return_value = User(id=1, name="Test")
|
|
151
|
+
|
|
152
|
+
# Inject mock
|
|
153
|
+
service = UserService(repository=mock_repo)
|
|
154
|
+
|
|
155
|
+
# Execute
|
|
156
|
+
result = service.get_user(1)
|
|
157
|
+
|
|
158
|
+
# Verify
|
|
159
|
+
mock_repo.find_by_id.assert_called_once_with(1)
|
|
160
|
+
assert result.name == "Test"
|
|
161
|
+
|
|
162
|
+
def test_external_api_mocked(mocker):
|
|
163
|
+
"""Mock external API calls."""
|
|
164
|
+
mocker.patch(
|
|
165
|
+
'services.external_api.fetch_data',
|
|
166
|
+
return_value={"status": "success"}
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
result = my_service.process()
|
|
170
|
+
assert result.success
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Stub for Database
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
@pytest.fixture
|
|
177
|
+
def stub_repository():
|
|
178
|
+
"""Stub repository with predefined responses."""
|
|
179
|
+
class StubRepository:
|
|
180
|
+
def find_by_id(self, id):
|
|
181
|
+
return {"1": User(id=1, name="Alice")}.get(str(id))
|
|
182
|
+
|
|
183
|
+
def save(self, entity):
|
|
184
|
+
entity.id = 999 # Simulate generated ID
|
|
185
|
+
return entity
|
|
186
|
+
|
|
187
|
+
return StubRepository()
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Mock for HTTP Responses
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
@pytest.fixture
|
|
194
|
+
def mock_http_client(mocker):
|
|
195
|
+
"""Mock HTTP client for external service calls."""
|
|
196
|
+
mock = mocker.patch('httpx.Client')
|
|
197
|
+
mock.return_value.__enter__ = mocker.Mock(return_value=mock)
|
|
198
|
+
mock.return_value.__exit__ = mocker.Mock(return_value=False)
|
|
199
|
+
|
|
200
|
+
# Configure responses
|
|
201
|
+
mock.get.return_value = mocker.Mock(
|
|
202
|
+
status_code=200,
|
|
203
|
+
json=lambda: {"data": "mocked"}
|
|
204
|
+
)
|
|
205
|
+
return mock
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### JavaScript Mocks (Jest)
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
// Mock module
|
|
212
|
+
jest.mock('./database', () => ({
|
|
213
|
+
findUser: jest.fn().mockResolvedValue({ id: 1, name: 'Test' }),
|
|
214
|
+
saveUser: jest.fn().mockResolvedValue({ id: 1 }),
|
|
215
|
+
}));
|
|
216
|
+
|
|
217
|
+
// Spy on method
|
|
218
|
+
const spy = jest.spyOn(userService, 'validate');
|
|
219
|
+
await userService.create(userData);
|
|
220
|
+
expect(spy).toHaveBeenCalledWith(userData);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Coverage Requirements
|
|
226
|
+
|
|
227
|
+
### Coverage Thresholds by Test Type
|
|
228
|
+
|
|
229
|
+
| Test Level | Minimum Coverage | Target Coverage |
|
|
230
|
+
|------------|------------------|-----------------|
|
|
231
|
+
| Unit Tests | 80% | 90%+ |
|
|
232
|
+
| Integration Tests | 60% | 75%+ |
|
|
233
|
+
| API Tests | 100% endpoints | 100% endpoints |
|
|
234
|
+
| Overall | 75% | 85%+ |
|
|
235
|
+
|
|
236
|
+
### What Must Be Covered
|
|
237
|
+
|
|
238
|
+
| Component Type | Coverage Requirement |
|
|
239
|
+
|----------------|---------------------|
|
|
240
|
+
| Public methods | 100% |
|
|
241
|
+
| Data models | All field validations |
|
|
242
|
+
| API endpoints | All success + error responses |
|
|
243
|
+
| Error handlers | All error paths |
|
|
244
|
+
| Business rules | All conditions |
|
|
245
|
+
|
|
246
|
+
### What Can Be Excluded
|
|
247
|
+
|
|
248
|
+
- Private helper methods (covered via public interface)
|
|
249
|
+
- Boilerplate code (getters/setters)
|
|
250
|
+
- Configuration files
|
|
251
|
+
- Third-party library code
|
|
252
|
+
|
|
253
|
+
### Coverage Documentation Template
|
|
254
|
+
|
|
255
|
+
```markdown
|
|
256
|
+
| Component | Unit Tests | Integration | API Tests | Coverage |
|
|
257
|
+
|-----------|------------|-------------|-----------|----------|
|
|
258
|
+
| AuthService | 8 | 2 | - | 92% |
|
|
259
|
+
| TokenManager | 5 | - | - | 88% |
|
|
260
|
+
| UserRepository | 4 | 3 | - | 85% |
|
|
261
|
+
| /login endpoint | - | - | 4 | 100% |
|
|
262
|
+
| /logout endpoint | - | - | 3 | 100% |
|
|
263
|
+
| **TOTAL** | **17** | **5** | **7** | **89%** |
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Test Data Strategies
|
|
269
|
+
|
|
270
|
+
### Fixtures vs Factories
|
|
271
|
+
|
|
272
|
+
**Use Fixtures when:**
|
|
273
|
+
- Static test data that doesn't change
|
|
274
|
+
- Shared across multiple tests
|
|
275
|
+
- Database seeding
|
|
276
|
+
|
|
277
|
+
**Use Factories when:**
|
|
278
|
+
- Need dynamic/unique data
|
|
279
|
+
- Tests require variations
|
|
280
|
+
- Complex object creation
|
|
281
|
+
|
|
282
|
+
### Factory Pattern Example
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
class UserFactory:
|
|
286
|
+
_counter = 0
|
|
287
|
+
|
|
288
|
+
@classmethod
|
|
289
|
+
def create(cls, **overrides):
|
|
290
|
+
cls._counter += 1
|
|
291
|
+
defaults = {
|
|
292
|
+
"id": cls._counter,
|
|
293
|
+
"email": f"user{cls._counter}@test.com",
|
|
294
|
+
"name": f"Test User {cls._counter}",
|
|
295
|
+
"active": True,
|
|
296
|
+
}
|
|
297
|
+
defaults.update(overrides)
|
|
298
|
+
return User(**defaults)
|
|
299
|
+
|
|
300
|
+
# Usage
|
|
301
|
+
user1 = UserFactory.create()
|
|
302
|
+
user2 = UserFactory.create(name="Custom Name")
|
|
303
|
+
inactive_user = UserFactory.create(active=False)
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Tracing Test Patterns
|
|
309
|
+
|
|
310
|
+
### Decorator Presence Test
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
def test_service_functions_have_tracing():
|
|
314
|
+
"""Verify service functions have @x_ipe_tracing decorators."""
|
|
315
|
+
import inspect
|
|
316
|
+
from x_ipe.services.my_service import MyService
|
|
317
|
+
|
|
318
|
+
traced_functions = ['create', 'update', 'delete', 'get']
|
|
319
|
+
for func_name in traced_functions:
|
|
320
|
+
func = getattr(MyService, func_name, None)
|
|
321
|
+
if func:
|
|
322
|
+
source = inspect.getsource(func)
|
|
323
|
+
assert "@x_ipe_tracing" in source, f"{func_name} missing tracing"
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Sensitive Data Redaction Test
|
|
327
|
+
|
|
328
|
+
```python
|
|
329
|
+
def test_password_redacted_in_traces(mocker, captured_logs):
|
|
330
|
+
"""Verify password is not logged in trace output."""
|
|
331
|
+
service.login(email="test@test.com", password="secret123")
|
|
332
|
+
for log in captured_logs:
|
|
333
|
+
assert "secret123" not in log
|
|
334
|
+
assert "[REDACTED]" in log or "password" not in log.lower()
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Trace Context Propagation Test
|
|
338
|
+
|
|
339
|
+
```python
|
|
340
|
+
def test_trace_context_propagates():
|
|
341
|
+
"""Verify trace_id propagates through nested calls."""
|
|
342
|
+
from x_ipe.tracing import get_current_trace_id
|
|
343
|
+
with trace_context("test-trace-123"):
|
|
344
|
+
result = service.nested_operation()
|
|
345
|
+
assert result.trace_id == "test-trace-123"
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Test File Structure
|
|
351
|
+
|
|
352
|
+
```
|
|
353
|
+
tests/
|
|
354
|
+
├── unit/ # Unit tests (isolated)
|
|
355
|
+
│ ├── services/
|
|
356
|
+
│ │ └── auth_service_test.py
|
|
357
|
+
│ ├── models/
|
|
358
|
+
│ │ └── user_test.py
|
|
359
|
+
│ └── utils/
|
|
360
|
+
│ └── token_utils_test.py
|
|
361
|
+
├── integration/ # Integration tests
|
|
362
|
+
│ └── auth_flow_test.py
|
|
363
|
+
├── api/ # API tests
|
|
364
|
+
│ └── auth_api_test.py
|
|
365
|
+
├── fixtures/ # Shared test data
|
|
366
|
+
│ └── users.py
|
|
367
|
+
└── conftest.py # Test configuration
|
|
368
|
+
```
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tool-tracing-creator
|
|
3
|
+
description: Creates tracing utility infrastructure for a target project/language. Generates decorator templates, log writers, and configuration. Use when setting up tracing for a new project or adding tracing support to existing project. Triggers on "create tracing utility", "set up tracing for", "add tracing infrastructure".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tool: Tracing Creator
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Create tracing utility infrastructure for a project by:
|
|
11
|
+
1. Detecting target language (Python/TypeScript)
|
|
12
|
+
2. Generating tracing decorator/wrapper code
|
|
13
|
+
3. Creating log writer and buffer modules
|
|
14
|
+
4. Setting up configuration files
|
|
15
|
+
5. Adding sensitive data redaction
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Trigger Patterns
|
|
20
|
+
|
|
21
|
+
Use this skill when human asks to:
|
|
22
|
+
- "create tracing utility for {project}"
|
|
23
|
+
- "set up tracing for {language} project"
|
|
24
|
+
- "add tracing infrastructure to {path}"
|
|
25
|
+
- "generate tracing decorators for {project}"
|
|
26
|
+
- "initialize tracing system"
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Input Parameters
|
|
31
|
+
|
|
32
|
+
| Parameter | Type | Default | Description |
|
|
33
|
+
|-----------|------|---------|-------------|
|
|
34
|
+
| target_path | string | Required | Project root or source directory |
|
|
35
|
+
| language | string | "auto" | Target language: "python", "typescript", or "auto" |
|
|
36
|
+
| log_path | string | "instance/traces/" | Directory for trace log files |
|
|
37
|
+
| retention_hours | int | 24 | Hours to retain log files |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Execution Procedure
|
|
42
|
+
|
|
43
|
+
### Step 1: Detect Language
|
|
44
|
+
|
|
45
|
+
If `language="auto"`:
|
|
46
|
+
1. Check for `pyproject.toml`, `setup.py`, `requirements.txt` → Python
|
|
47
|
+
2. Check for `package.json`, `tsconfig.json` → TypeScript
|
|
48
|
+
3. If both exist, ask human to specify
|
|
49
|
+
|
|
50
|
+
### Step 2: Create Directory Structure
|
|
51
|
+
|
|
52
|
+
**For Python:**
|
|
53
|
+
```
|
|
54
|
+
{target_path}/
|
|
55
|
+
├── tracing/
|
|
56
|
+
│ ├── __init__.py # Exports decorator and utilities
|
|
57
|
+
│ ├── decorator.py # @x_ipe_tracing decorator
|
|
58
|
+
│ ├── context.py # TraceContext for request tracking
|
|
59
|
+
│ ├── buffer.py # In-memory trace buffer
|
|
60
|
+
│ ├── writer.py # Log file writer
|
|
61
|
+
│ └── redactor.py # Sensitive data redaction
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**For TypeScript:**
|
|
65
|
+
```
|
|
66
|
+
{target_path}/
|
|
67
|
+
├── tracing/
|
|
68
|
+
│ ├── index.ts # Exports decorator and utilities
|
|
69
|
+
│ ├── decorator.ts # @xIpeTracing decorator
|
|
70
|
+
│ ├── context.ts # TraceContext for request tracking
|
|
71
|
+
│ ├── buffer.ts # In-memory trace buffer
|
|
72
|
+
│ ├── writer.ts # Log file writer
|
|
73
|
+
│ └── redactor.ts # Sensitive data redaction
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Step 3: Generate Core Files
|
|
77
|
+
|
|
78
|
+
#### 3.1 Decorator (Python)
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
# tracing/decorator.py
|
|
82
|
+
"""
|
|
83
|
+
Tracing decorator for automatic function instrumentation.
|
|
84
|
+
"""
|
|
85
|
+
import functools
|
|
86
|
+
import time
|
|
87
|
+
import asyncio
|
|
88
|
+
from typing import Callable, List, Optional
|
|
89
|
+
|
|
90
|
+
from .context import TraceContext
|
|
91
|
+
from .redactor import Redactor
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def x_ipe_tracing(
|
|
95
|
+
level: str = "INFO",
|
|
96
|
+
redact: Optional[List[str]] = None
|
|
97
|
+
) -> Callable:
|
|
98
|
+
"""
|
|
99
|
+
Decorator for automatic function tracing.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
level: Log level - "INFO", "DEBUG", or "SKIP"
|
|
103
|
+
redact: List of parameter names to redact
|
|
104
|
+
|
|
105
|
+
Usage:
|
|
106
|
+
@x_ipe_tracing(level="INFO", redact=["password"])
|
|
107
|
+
def login(email: str, password: str) -> dict:
|
|
108
|
+
...
|
|
109
|
+
"""
|
|
110
|
+
if level == "SKIP":
|
|
111
|
+
return lambda fn: fn
|
|
112
|
+
|
|
113
|
+
redactor = Redactor(custom_fields=redact)
|
|
114
|
+
|
|
115
|
+
def decorator(func: Callable) -> Callable:
|
|
116
|
+
@functools.wraps(func)
|
|
117
|
+
def sync_wrapper(*args, **kwargs):
|
|
118
|
+
ctx = TraceContext.get_current()
|
|
119
|
+
if not ctx:
|
|
120
|
+
return func(*args, **kwargs)
|
|
121
|
+
return _trace_call(ctx, func, args, kwargs, level, redactor)
|
|
122
|
+
|
|
123
|
+
@functools.wraps(func)
|
|
124
|
+
async def async_wrapper(*args, **kwargs):
|
|
125
|
+
ctx = TraceContext.get_current()
|
|
126
|
+
if not ctx:
|
|
127
|
+
return await func(*args, **kwargs)
|
|
128
|
+
return await _trace_async(ctx, func, args, kwargs, level, redactor)
|
|
129
|
+
|
|
130
|
+
if asyncio.iscoroutinefunction(func):
|
|
131
|
+
return async_wrapper
|
|
132
|
+
return sync_wrapper
|
|
133
|
+
|
|
134
|
+
return decorator
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### 3.2 Decorator (TypeScript)
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// tracing/decorator.ts
|
|
141
|
+
import { TraceContext } from './context';
|
|
142
|
+
import { Redactor } from './redactor';
|
|
143
|
+
|
|
144
|
+
interface TracingOptions {
|
|
145
|
+
level?: 'INFO' | 'DEBUG' | 'SKIP';
|
|
146
|
+
redact?: string[];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function xIpeTracing(options: TracingOptions = {}) {
|
|
150
|
+
const { level = 'INFO', redact = [] } = options;
|
|
151
|
+
|
|
152
|
+
if (level === 'SKIP') {
|
|
153
|
+
return (target: any, key: string, descriptor: PropertyDescriptor) => descriptor;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const redactor = new Redactor(redact);
|
|
157
|
+
|
|
158
|
+
return function (target: any, key: string, descriptor: PropertyDescriptor) {
|
|
159
|
+
const original = descriptor.value;
|
|
160
|
+
|
|
161
|
+
descriptor.value = async function (...args: any[]) {
|
|
162
|
+
const ctx = TraceContext.getCurrent();
|
|
163
|
+
if (!ctx) {
|
|
164
|
+
return original.apply(this, args);
|
|
165
|
+
}
|
|
166
|
+
return traceCall(ctx, original, this, args, key, level, redactor);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
return descriptor;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Step 4: Generate Support Files
|
|
175
|
+
|
|
176
|
+
Create these additional modules:
|
|
177
|
+
- **context.py/ts**: TraceContext with thread-local/async-local storage
|
|
178
|
+
- **buffer.py/ts**: TraceBuffer for in-memory log accumulation
|
|
179
|
+
- **writer.py/ts**: TraceLogWriter for file output
|
|
180
|
+
- **redactor.py/ts**: Redactor with sensitive pattern matching
|
|
181
|
+
|
|
182
|
+
### Step 5: Create Configuration
|
|
183
|
+
|
|
184
|
+
Add to project configuration:
|
|
185
|
+
|
|
186
|
+
**Python (pyproject.toml or .env):**
|
|
187
|
+
```toml
|
|
188
|
+
[tool.tracing]
|
|
189
|
+
enabled = true
|
|
190
|
+
log_path = "instance/traces/"
|
|
191
|
+
retention_hours = 24
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**TypeScript (package.json or .env):**
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"tracing": {
|
|
198
|
+
"enabled": true,
|
|
199
|
+
"logPath": "traces/",
|
|
200
|
+
"retentionHours": 24
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Step 6: Create __init__.py / index.ts
|
|
206
|
+
|
|
207
|
+
Export public API:
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
# tracing/__init__.py
|
|
211
|
+
from .decorator import x_ipe_tracing
|
|
212
|
+
from .context import TraceContext
|
|
213
|
+
from .writer import TraceLogWriter
|
|
214
|
+
|
|
215
|
+
__all__ = ['x_ipe_tracing', 'TraceContext', 'TraceLogWriter']
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// tracing/index.ts
|
|
220
|
+
export { xIpeTracing } from './decorator';
|
|
221
|
+
export { TraceContext } from './context';
|
|
222
|
+
export { TraceLogWriter } from './writer';
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Step 7: Report Results
|
|
226
|
+
|
|
227
|
+
```markdown
|
|
228
|
+
## Tracing Utility Created ✅
|
|
229
|
+
|
|
230
|
+
### Files Generated
|
|
231
|
+
|
|
232
|
+
| File | Purpose |
|
|
233
|
+
|------|---------|
|
|
234
|
+
| `tracing/__init__.py` | Public exports |
|
|
235
|
+
| `tracing/decorator.py` | @x_ipe_tracing decorator |
|
|
236
|
+
| `tracing/context.py` | Request context tracking |
|
|
237
|
+
| `tracing/buffer.py` | In-memory trace buffer |
|
|
238
|
+
| `tracing/writer.py` | Log file writer |
|
|
239
|
+
| `tracing/redactor.py` | Sensitive data redaction |
|
|
240
|
+
|
|
241
|
+
### Configuration
|
|
242
|
+
|
|
243
|
+
- Log path: `instance/traces/`
|
|
244
|
+
- Retention: 24 hours
|
|
245
|
+
- Sensitive patterns: password, token, secret, key, auth
|
|
246
|
+
|
|
247
|
+
### Usage
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
from tracing import x_ipe_tracing
|
|
251
|
+
|
|
252
|
+
@x_ipe_tracing(level="INFO")
|
|
253
|
+
def my_function():
|
|
254
|
+
pass
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Next Steps
|
|
258
|
+
|
|
259
|
+
1. Add tracing to API routes using `tool-tracing-instrumentation` skill
|
|
260
|
+
2. Configure retention in project settings
|
|
261
|
+
3. View traces in Tracing Dashboard
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Sensitive Data Patterns
|
|
267
|
+
|
|
268
|
+
The generated redactor includes these patterns:
|
|
269
|
+
|
|
270
|
+
| Category | Patterns |
|
|
271
|
+
|----------|----------|
|
|
272
|
+
| Passwords | password, pwd, passwd, pass |
|
|
273
|
+
| Secrets | secret, secret_key, secretkey |
|
|
274
|
+
| Tokens | token, auth_token, api_token, access_token |
|
|
275
|
+
| Keys | key, api_key, apikey, private_key |
|
|
276
|
+
| Auth | auth, authorization, credential |
|
|
277
|
+
| Financial | card_number, cvv, ssn |
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Reference Implementation
|
|
282
|
+
|
|
283
|
+
The skill uses X-IPE's own tracing implementation as reference:
|
|
284
|
+
- `src/x_ipe/tracing/decorator.py`
|
|
285
|
+
- `src/x_ipe/tracing/context.py`
|
|
286
|
+
- `src/x_ipe/tracing/buffer.py`
|
|
287
|
+
- `src/x_ipe/tracing/writer.py`
|
|
288
|
+
- `src/x_ipe/tracing/redactor.py`
|
|
289
|
+
|
|
290
|
+
When creating tracing for a new project, adapt these patterns to the target language.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Definition of Done
|
|
295
|
+
|
|
296
|
+
| # | Checkpoint | Required |
|
|
297
|
+
|---|------------|----------|
|
|
298
|
+
| 1 | Language detected or specified | Yes |
|
|
299
|
+
| 2 | Directory structure created | Yes |
|
|
300
|
+
| 3 | Decorator file generated | Yes |
|
|
301
|
+
| 4 | Context file generated | Yes |
|
|
302
|
+
| 5 | Buffer file generated | Yes |
|
|
303
|
+
| 6 | Writer file generated | Yes |
|
|
304
|
+
| 7 | Redactor file generated | Yes |
|
|
305
|
+
| 8 | Configuration added | Yes |
|
|
306
|
+
| 9 | Usage instructions provided | Yes |
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## Examples
|
|
311
|
+
|
|
312
|
+
See [references/examples.md](references/examples.md) for detailed examples.
|