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.
Files changed (139) hide show
  1. x_ipe/app.py +25 -3
  2. x_ipe/handlers/terminal_handlers.py +6 -0
  3. x_ipe/handlers/voice_handlers.py +5 -0
  4. x_ipe/resources/copilot-instructions.md +19 -6
  5. x_ipe/resources/skills/lesson-learned/SKILL.md +208 -0
  6. x_ipe/resources/skills/lesson-learned/references/examples.md +238 -0
  7. x_ipe/resources/skills/project-quality-board-management/SKILL.md +135 -298
  8. x_ipe/resources/skills/project-quality-board-management/references/evaluation-principles.md +213 -0
  9. x_ipe/resources/skills/project-quality-board-management/references/evaluation-procedures.md +214 -0
  10. x_ipe/resources/skills/project-quality-board-management/templates/quality-report.md +70 -18
  11. x_ipe/resources/skills/task-execution-guideline/SKILL.md +2 -2
  12. x_ipe/resources/skills/task-execution-guideline/templates/task-record.yaml +1 -1
  13. x_ipe/resources/skills/task-type-code-implementation/SKILL.md +72 -270
  14. x_ipe/resources/skills/task-type-code-implementation/references/implementation-guidelines.md +432 -0
  15. x_ipe/resources/skills/task-type-code-refactor-v2/SKILL.md +127 -353
  16. x_ipe/resources/skills/task-type-code-refactor-v2/references/refactoring-techniques.md +373 -0
  17. x_ipe/resources/skills/task-type-feature-breakdown/SKILL.md +31 -243
  18. x_ipe/resources/skills/task-type-feature-breakdown/references/breakdown-guidelines.md +330 -0
  19. x_ipe/resources/skills/task-type-feature-refinement/SKILL.md +27 -180
  20. x_ipe/resources/skills/task-type-feature-refinement/references/specification-writing-guide.md +267 -0
  21. x_ipe/resources/skills/task-type-idea-mockup/SKILL.md +38 -276
  22. x_ipe/resources/skills/task-type-idea-mockup/references/mockup-guidelines.md +299 -0
  23. x_ipe/resources/skills/task-type-idea-to-architecture/SKILL.md +20 -218
  24. x_ipe/resources/skills/task-type-idea-to-architecture/references/architecture-patterns.md +342 -0
  25. x_ipe/resources/skills/task-type-ideation/SKILL.md +10 -266
  26. x_ipe/resources/skills/task-type-ideation/references/folder-naming-guide.md +55 -0
  27. x_ipe/resources/skills/task-type-ideation/references/tool-usage-guide.md +236 -0
  28. x_ipe/resources/skills/task-type-ideation-v2/SKILL.md +488 -0
  29. x_ipe/resources/skills/task-type-ideation-v2/references/examples.md +377 -0
  30. x_ipe/resources/skills/task-type-ideation-v2/references/folder-naming-guide.md +74 -0
  31. x_ipe/resources/skills/task-type-ideation-v2/references/tool-usage-guide.md +145 -0
  32. x_ipe/resources/skills/task-type-ideation-v2/references/visualization-guide.md +160 -0
  33. x_ipe/resources/skills/task-type-ideation-v2/templates/idea-summary.md +86 -0
  34. x_ipe/resources/skills/task-type-refactoring-analysis/SKILL.md +83 -145
  35. x_ipe/resources/skills/task-type-refactoring-analysis/references/output-schema.md +172 -0
  36. x_ipe/resources/skills/task-type-technical-design/SKILL.md +28 -214
  37. x_ipe/resources/skills/task-type-technical-design/references/design-templates.md +422 -0
  38. x_ipe/resources/skills/task-type-test-generation/SKILL.md +47 -332
  39. x_ipe/resources/skills/task-type-test-generation/references/test-patterns.md +368 -0
  40. x_ipe/resources/skills/tool-tracing-creator/SKILL.md +312 -0
  41. x_ipe/resources/skills/tool-tracing-creator/references/examples.md +324 -0
  42. x_ipe/resources/skills/tool-tracing-instrumentation/SKILL.md +373 -0
  43. x_ipe/resources/skills/tool-tracing-instrumentation/references/examples.md +264 -0
  44. x_ipe/resources/skills/x-ipe-skill-creator-v3/SKILL.md +486 -0
  45. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/10. example-gate-conditions.md +73 -0
  46. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/11. reference-quality-standards.md +127 -0
  47. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/2. reference-section-order.md +127 -0
  48. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/3. example-step-based-code-review.md +84 -0
  49. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/4. example-step-based-feature-implementation.md +113 -0
  50. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/5. example-function-based-validation.md +73 -0
  51. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/6. example-function-based-analysis.md +94 -0
  52. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/7. example-task-io-code-implementation.md +36 -0
  53. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/8. example-structured-summary.md +43 -0
  54. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/9. example-dor-dod.md +77 -0
  55. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/examples.md +429 -0
  56. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/skill-general-guidelines-v2.md +611 -0
  57. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-meta.md +153 -0
  58. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-task-based.md +324 -0
  59. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-task-category.md +109 -0
  60. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-tool.md +205 -0
  61. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-meta.md +334 -0
  62. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-task-based.md +279 -0
  63. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-tool.md +175 -0
  64. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-workflow-orchestration.md +329 -0
  65. x_ipe/resources/skills/x-ipe-task-based-ideation/SKILL.md +487 -0
  66. x_ipe/resources/skills/x-ipe-task-based-ideation/references/examples.md +377 -0
  67. x_ipe/resources/skills/x-ipe-task-based-ideation/references/folder-naming-guide.md +74 -0
  68. x_ipe/resources/skills/x-ipe-task-based-ideation/references/tool-usage-guide.md +145 -0
  69. x_ipe/resources/skills/x-ipe-task-based-ideation/references/visualization-guide.md +160 -0
  70. x_ipe/resources/skills/x-ipe-task-based-ideation/templates/idea-summary.md +86 -0
  71. x_ipe/routes/__init__.py +2 -0
  72. x_ipe/routes/ideas_routes.py +17 -0
  73. x_ipe/routes/kb_routes.py +80 -0
  74. x_ipe/routes/main_routes.py +18 -0
  75. x_ipe/routes/project_routes.py +7 -0
  76. x_ipe/routes/proxy_routes.py +2 -0
  77. x_ipe/routes/quality_evaluation_routes.py +193 -0
  78. x_ipe/routes/settings_routes.py +6 -0
  79. x_ipe/routes/tools_routes.py +6 -0
  80. x_ipe/routes/tracing_routes.py +232 -0
  81. x_ipe/routes/uiux_feedback_routes.py +30 -0
  82. x_ipe/services/__init__.py +5 -0
  83. x_ipe/services/config_service.py +6 -0
  84. x_ipe/services/file_service.py +20 -0
  85. x_ipe/services/homepage_service.py +160 -0
  86. x_ipe/services/ideas_service.py +19 -0
  87. x_ipe/services/kb_service.py +378 -0
  88. x_ipe/services/proxy_service.py +4 -0
  89. x_ipe/services/settings_service.py +13 -0
  90. x_ipe/services/skills_service.py +4 -0
  91. x_ipe/services/terminal_service.py +24 -0
  92. x_ipe/services/themes_service.py +4 -0
  93. x_ipe/services/tools_config_service.py +4 -0
  94. x_ipe/services/tracing_service.py +333 -0
  95. x_ipe/services/uiux_feedback_service.py +32 -0
  96. x_ipe/services/voice_input_service_v2.py +11 -0
  97. x_ipe/static/css/base.css +7 -0
  98. x_ipe/static/css/homepage-infinity.css +330 -0
  99. x_ipe/static/css/kb-core.css +301 -0
  100. x_ipe/static/css/quality-evaluation.css +345 -0
  101. x_ipe/static/css/sidebar.css +14 -4
  102. x_ipe/static/css/terminal.css +1 -0
  103. x_ipe/static/css/tracing-dashboard.css +796 -0
  104. x_ipe/static/css/workplace.css +20 -0
  105. x_ipe/static/img/homepage-infinity-loop.png +0 -0
  106. x_ipe/static/js/features/homepage-infinity.js +314 -0
  107. x_ipe/static/js/features/kb-core.js +371 -0
  108. x_ipe/static/js/features/quality-evaluation.js +387 -0
  109. x_ipe/static/js/features/sidebar.js +255 -12
  110. x_ipe/static/js/features/tracing-dashboard.js +855 -0
  111. x_ipe/static/js/features/tracing-graph.js +1031 -0
  112. x_ipe/static/js/features/tree-search.js +6 -2
  113. x_ipe/static/js/features/workplace.js +200 -6
  114. x_ipe/static/js/init.js +76 -0
  115. x_ipe/static/js/uiux-feedback.js +18 -2
  116. x_ipe/templates/base.html +19 -0
  117. x_ipe/templates/index.html +7 -1
  118. x_ipe/templates/knowledge-base.html +110 -0
  119. x_ipe/templates/workplace.html +4 -0
  120. x_ipe/tracing/__init__.py +37 -0
  121. x_ipe/tracing/buffer.py +135 -0
  122. x_ipe/tracing/context.py +125 -0
  123. x_ipe/tracing/decorator.py +288 -0
  124. x_ipe/tracing/middleware.py +197 -0
  125. x_ipe/tracing/parser.py +235 -0
  126. x_ipe/tracing/redactor.py +111 -0
  127. x_ipe/tracing/writer.py +122 -0
  128. {x_ipe-1.0.24.dist-info → x_ipe-1.0.25.dist-info}/METADATA +2 -2
  129. {x_ipe-1.0.24.dist-info → x_ipe-1.0.25.dist-info}/RECORD +132 -62
  130. x_ipe/resources/skills/x-ipe-skill-creator/SKILL.md +0 -329
  131. x_ipe/resources/skills/x-ipe-skill-creator/references/output-patterns.md +0 -169
  132. x_ipe/resources/skills/x-ipe-skill-creator/references/skill-structure.md +0 -162
  133. x_ipe/resources/skills/x-ipe-skill-creator/references/workflows.md +0 -110
  134. x_ipe/resources/skills/x-ipe-skill-creator/templates/references/examples.md +0 -113
  135. x_ipe/resources/skills/x-ipe-skill-creator/templates/skill-category-skill.md +0 -296
  136. x_ipe/resources/skills/x-ipe-skill-creator/templates/task-type-skill.md +0 -269
  137. {x_ipe-1.0.24.dist-info → x_ipe-1.0.25.dist-info}/WHEEL +0 -0
  138. {x_ipe-1.0.24.dist-info → x_ipe-1.0.25.dist-info}/entry_points.txt +0 -0
  139. {x_ipe-1.0.24.dist-info → x_ipe-1.0.25.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,324 @@
1
+ # Tracing Creator Skill Examples
2
+
3
+ ## Example 1: Python Project with Flask
4
+
5
+ **User Request:**
6
+ ```
7
+ Create tracing infrastructure for my Python Flask API project
8
+ ```
9
+
10
+ **Agent Execution:**
11
+
12
+ 1. **Check existing structure:**
13
+ ```
14
+ src/
15
+ ├── app.py
16
+ ├── routes/
17
+ └── services/
18
+ ```
19
+
20
+ 2. **Create tracing module:**
21
+ ```
22
+ src/tracing/
23
+ ├── __init__.py
24
+ ├── decorator.py
25
+ ├── context.py
26
+ ├── buffer.py
27
+ ├── writer.py
28
+ └── redactor.py
29
+ ```
30
+
31
+ 3. **Generated code:**
32
+
33
+ **decorator.py:**
34
+ ```python
35
+ import functools
36
+ import time
37
+ from .context import get_trace_id
38
+ from .buffer import TraceBuffer
39
+ from .redactor import Redactor
40
+
41
+ def x_ipe_tracing(level="INFO", redact=None):
42
+ """Decorator for tracing function calls."""
43
+ def decorator(func):
44
+ @functools.wraps(func)
45
+ def wrapper(*args, **kwargs):
46
+ trace_id = get_trace_id()
47
+ func_name = func.__name__
48
+
49
+ # Redact sensitive params
50
+ safe_kwargs = Redactor.redact_dict(kwargs, redact or [])
51
+
52
+ TraceBuffer.log(
53
+ trace_id=trace_id,
54
+ level=level,
55
+ event="start",
56
+ function=func_name,
57
+ input=safe_kwargs
58
+ )
59
+
60
+ start = time.perf_counter()
61
+ try:
62
+ result = func(*args, **kwargs)
63
+ duration = time.perf_counter() - start
64
+
65
+ TraceBuffer.log(
66
+ trace_id=trace_id,
67
+ level=level,
68
+ event="return",
69
+ function=func_name,
70
+ output=result,
71
+ duration_ms=duration * 1000
72
+ )
73
+ return result
74
+ except Exception as e:
75
+ duration = time.perf_counter() - start
76
+ TraceBuffer.log(
77
+ trace_id=trace_id,
78
+ level="ERROR",
79
+ event="exception",
80
+ function=func_name,
81
+ error=str(e),
82
+ duration_ms=duration * 1000
83
+ )
84
+ raise
85
+ return wrapper
86
+ return decorator
87
+ ```
88
+
89
+ 4. **Update requirements:**
90
+ - No additional dependencies needed
91
+
92
+ 5. **Report:**
93
+ ```
94
+ ## Tracing Infrastructure Created
95
+
96
+ Created 5 files in src/tracing/:
97
+ - decorator.py (x_ipe_tracing decorator)
98
+ - context.py (trace ID management)
99
+ - buffer.py (log buffering)
100
+ - writer.py (file/stdout output)
101
+ - redactor.py (sensitive data protection)
102
+
103
+ Import: `from tracing import x_ipe_tracing`
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Example 2: TypeScript/Node.js Project
109
+
110
+ **User Request:**
111
+ ```
112
+ Create tracing for my Node.js Express API
113
+ ```
114
+
115
+ **Agent Execution:**
116
+
117
+ 1. **Create tracing module:**
118
+ ```
119
+ src/tracing/
120
+ ├── index.ts
121
+ ├── decorator.ts
122
+ ├── context.ts
123
+ ├── buffer.ts
124
+ ├── writer.ts
125
+ └── redactor.ts
126
+ ```
127
+
128
+ 2. **Generated decorator.ts:**
129
+ ```typescript
130
+ import { getTraceId } from './context';
131
+ import { TraceBuffer } from './buffer';
132
+ import { Redactor } from './redactor';
133
+
134
+ export function xIpeTracing(options: {
135
+ level?: 'INFO' | 'DEBUG';
136
+ redact?: string[];
137
+ } = {}) {
138
+ const { level = 'INFO', redact = [] } = options;
139
+
140
+ return function(
141
+ target: any,
142
+ propertyKey: string,
143
+ descriptor: PropertyDescriptor
144
+ ) {
145
+ const originalMethod = descriptor.value;
146
+
147
+ descriptor.value = async function(...args: any[]) {
148
+ const traceId = getTraceId();
149
+ const funcName = propertyKey;
150
+
151
+ TraceBuffer.log({
152
+ traceId,
153
+ level,
154
+ event: 'start',
155
+ function: funcName,
156
+ input: Redactor.redact(args, redact)
157
+ });
158
+
159
+ const start = performance.now();
160
+ try {
161
+ const result = await originalMethod.apply(this, args);
162
+ const duration = performance.now() - start;
163
+
164
+ TraceBuffer.log({
165
+ traceId,
166
+ level,
167
+ event: 'return',
168
+ function: funcName,
169
+ output: result,
170
+ durationMs: duration
171
+ });
172
+
173
+ return result;
174
+ } catch (error) {
175
+ const duration = performance.now() - start;
176
+ TraceBuffer.log({
177
+ traceId,
178
+ level: 'ERROR',
179
+ event: 'exception',
180
+ function: funcName,
181
+ error: String(error),
182
+ durationMs: duration
183
+ });
184
+ throw error;
185
+ }
186
+ };
187
+
188
+ return descriptor;
189
+ };
190
+ }
191
+ ```
192
+
193
+ 3. **Report:**
194
+ ```
195
+ ## Tracing Infrastructure Created
196
+
197
+ Created 6 files in src/tracing/:
198
+ - index.ts (exports)
199
+ - decorator.ts (xIpeTracing decorator)
200
+ - context.ts (trace ID via AsyncLocalStorage)
201
+ - buffer.ts (log buffering)
202
+ - writer.ts (file/console output)
203
+ - redactor.ts (sensitive data protection)
204
+
205
+ Import: `import { xIpeTracing } from './tracing';`
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Example 3: Existing Project with Partial Tracing
211
+
212
+ **User Request:**
213
+ ```
214
+ My project has some tracing but it's incomplete. Set up proper infrastructure.
215
+ ```
216
+
217
+ **Agent Execution:**
218
+
219
+ 1. **Analyze existing tracing:**
220
+ ```
221
+ Found: src/utils/logger.py (basic logging only)
222
+ Missing: Proper tracing with context, buffering, redaction
223
+ ```
224
+
225
+ 2. **Create parallel structure:**
226
+ ```
227
+ src/tracing/ # NEW - full tracing
228
+ ├── __init__.py
229
+ ├── decorator.py
230
+ ...
231
+
232
+ src/utils/logger.py # KEEP - for general logging
233
+ ```
234
+
235
+ 3. **Migration guide:**
236
+ ```markdown
237
+ ## Migration Steps
238
+
239
+ 1. Replace `@log_function` with `@x_ipe_tracing`
240
+ 2. Add redact=[] for sensitive params
241
+ 3. Update imports: `from tracing import x_ipe_tracing`
242
+ ```
243
+
244
+ ---
245
+
246
+ ## Example 4: Project Without Package Structure
247
+
248
+ **User Request:**
249
+ ```
250
+ Add tracing to my simple Python script project
251
+ ```
252
+
253
+ **Agent Execution:**
254
+
255
+ 1. **Check structure:**
256
+ ```
257
+ app.py
258
+ utils.py
259
+ config.py
260
+ ```
261
+
262
+ 2. **Create minimal structure:**
263
+ ```
264
+ tracing.py # Single file with all tracing code
265
+ ```
266
+
267
+ 3. **Single-file tracing.py:**
268
+ ```python
269
+ """Minimal tracing decorator for simple projects."""
270
+ import functools
271
+ import time
272
+ import json
273
+ from datetime import datetime
274
+ from contextvars import ContextVar
275
+
276
+ _trace_id: ContextVar[str] = ContextVar('trace_id', default=None)
277
+
278
+ def set_trace_id(trace_id: str):
279
+ _trace_id.set(trace_id)
280
+
281
+ def get_trace_id() -> str:
282
+ return _trace_id.get()
283
+
284
+ def x_ipe_tracing(level="INFO", redact=None):
285
+ def decorator(func):
286
+ @functools.wraps(func)
287
+ def wrapper(*args, **kwargs):
288
+ trace_id = get_trace_id() or "no-trace"
289
+
290
+ # Simple redaction
291
+ safe_kwargs = {
292
+ k: "[REDACTED]" if k in (redact or []) else v
293
+ for k, v in kwargs.items()
294
+ }
295
+
296
+ print(f"[{datetime.now().isoformat()}] [{level}] → {func.__name__}: {safe_kwargs}")
297
+
298
+ start = time.perf_counter()
299
+ try:
300
+ result = func(*args, **kwargs)
301
+ duration = (time.perf_counter() - start) * 1000
302
+ print(f"[{datetime.now().isoformat()}] [{level}] ← {func.__name__}: {duration:.1f}ms")
303
+ return result
304
+ except Exception as e:
305
+ duration = (time.perf_counter() - start) * 1000
306
+ print(f"[{datetime.now().isoformat()}] [ERROR] ✗ {func.__name__}: {e} ({duration:.1f}ms)")
307
+ raise
308
+ return wrapper
309
+ return decorator
310
+ ```
311
+
312
+ 4. **Report:**
313
+ ```
314
+ ## Minimal Tracing Created
315
+
316
+ Created single file: tracing.py
317
+
318
+ Usage:
319
+ from tracing import x_ipe_tracing, set_trace_id
320
+
321
+ @x_ipe_tracing(level="INFO")
322
+ def my_function():
323
+ pass
324
+ ```
@@ -0,0 +1,373 @@
1
+ ---
2
+ name: tool-tracing-instrumentation
3
+ description: Add @x_ipe_tracing decorators to Python functions. Analyzes code, suggests levels (INFO/DEBUG), detects sensitive params for redaction, and applies decorators in batch. Triggers on "add tracing to", "instrument for tracing", "trace functions in".
4
+ ---
5
+
6
+ # Tool: Tracing Instrumentation
7
+
8
+ ## Purpose
9
+
10
+ Automatically instrument Python code with `@x_ipe_tracing` decorators by:
11
+ 1. Analyzing target file(s) for traceable functions
12
+ 2. Assigning appropriate tracing levels (INFO/DEBUG)
13
+ 3. Detecting sensitive parameters for redaction
14
+ 4. Proposing changes for human review
15
+ 5. Applying decorators to approved functions
16
+
17
+ ---
18
+
19
+ ## Trigger Patterns
20
+
21
+ Use this skill when human asks to:
22
+ - "add tracing to {file/module}"
23
+ - "instrument {file/module} for tracing"
24
+ - "add @x_ipe_tracing to {file}"
25
+ - "trace all functions in {path}"
26
+ - "add tracing decorators to {path}"
27
+
28
+ ---
29
+
30
+ ## Input Parameters
31
+
32
+ | Parameter | Type | Default | Description |
33
+ |-----------|------|---------|-------------|
34
+ | target | string | Required | File path or directory to instrument |
35
+ | level | string | "auto" | Force level: "INFO", "DEBUG", or "auto" (recommended) |
36
+ | include_private | bool | false | Include `_prefixed` functions |
37
+ | dry_run | bool | false | Only show proposed changes, don't apply |
38
+
39
+ ---
40
+
41
+ ## Execution Procedure
42
+
43
+ ### Step 1: Validate Target
44
+
45
+ 1. **Verify target path exists**
46
+ - If file: validate `.py` extension
47
+ - If directory: find all `.py` files recursively
48
+
49
+ 2. **Exclude patterns:**
50
+ - `__pycache__/`
51
+ - `.venv/`, `venv/`, `env/`
52
+ - `test_*.py`, `*_test.py` (test files)
53
+ - `conftest.py`
54
+
55
+ 3. **Report scope:**
56
+ ```
57
+ Found X Python files in {target}
58
+ ```
59
+
60
+ ---
61
+
62
+ ### Step 2: Analyze Each File
63
+
64
+ For each Python file, use Python AST to extract functions:
65
+
66
+ ```python
67
+ import ast
68
+
69
+ with open(filepath) as f:
70
+ tree = ast.parse(f.read())
71
+
72
+ for node in ast.walk(tree):
73
+ if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
74
+ # Process function
75
+ ```
76
+
77
+ **For each function, check:**
78
+
79
+ 1. **Already traced?**
80
+ - Look for `@x_ipe_tracing` in decorators
81
+ - If found → mark as "already traced", skip
82
+
83
+ 2. **Dunder method?**
84
+ - Name starts/ends with `__` (e.g., `__init__`, `__str__`)
85
+ - → Skip (don't trace dunder methods)
86
+
87
+ 3. **Private function?**
88
+ - Name starts with `_` but not `__`
89
+ - If `include_private=false` → Skip
90
+ - If `include_private=true` → Include with DEBUG level
91
+
92
+ 4. **Extract metadata:**
93
+ - Function name
94
+ - Parameters (names and type hints if available)
95
+ - Line number
96
+ - Is async (AsyncFunctionDef)
97
+ - Existing decorators
98
+
99
+ ---
100
+
101
+ ### Step 3: Determine Level
102
+
103
+ Apply rules in priority order:
104
+
105
+ | Priority | Condition | Level |
106
+ |----------|-----------|-------|
107
+ | 1 | Explicit `level` parameter != "auto" | Use explicit level |
108
+ | 2 | File in `routes/` or `api/` directory | INFO |
109
+ | 3 | Class name ends with `Service`, `Handler`, `Controller` | INFO |
110
+ | 4 | Function is public (no underscore prefix) | INFO |
111
+ | 5 | Function in `utils/`, `helpers/`, `internal/` directory | DEBUG |
112
+ | 6 | Protected function (`_prefix`) | DEBUG |
113
+ | 7 | Default fallback | INFO |
114
+
115
+ ---
116
+
117
+ ### Step 4: Detect Sensitive Parameters
118
+
119
+ Check each parameter name against these patterns:
120
+
121
+ **Exact matches (case-insensitive):**
122
+ ```
123
+ password, pwd, passwd, pass
124
+ secret, secret_key, secretkey
125
+ token, auth_token, api_token, access_token, refresh_token
126
+ key, api_key, apikey, private_key, privatekey
127
+ auth, authorization
128
+ credential, cred, credentials
129
+ ssn, social_security
130
+ pin, cvv, card_number
131
+ ```
132
+
133
+ **Suffix patterns:**
134
+ ```
135
+ *_password, *_pwd
136
+ *_secret, *_key
137
+ *_token, *_auth
138
+ *_credential
139
+ ```
140
+
141
+ **If match found:**
142
+ - Add parameter to `redact=["param_name"]` list
143
+ - Note: Built-in Redactor already handles these, but explicit is clearer
144
+
145
+ ---
146
+
147
+ ### Step 5: Present Proposal
148
+
149
+ Format output as markdown table:
150
+
151
+ ```markdown
152
+ ## Proposed Tracing Additions
153
+
154
+ ### File: src/x_ipe/services/ideas_service.py
155
+
156
+ | Function | Line | Level | Redact | Action |
157
+ |----------|------|-------|--------|--------|
158
+ | `get_all_ideas()` | 25 | INFO | - | Add |
159
+ | `create_idea(name, content)` | 42 | INFO | - | Add |
160
+ | `_validate_idea(data)` | 85 | DEBUG | - | Add |
161
+ | `update_idea(id, data)` | 58 | INFO | - | Add |
162
+ | `delete_idea(id)` | 72 | INFO | - | Add |
163
+
164
+ ### File: src/x_ipe/services/auth_service.py
165
+
166
+ | Function | Line | Level | Redact | Action |
167
+ |----------|------|-------|--------|--------|
168
+ | `login(email, password)` | 15 | INFO | password | Add |
169
+ | `validate_token(token)` | 35 | INFO | token | Add |
170
+ | `already_traced()` | 50 | - | - | Skip (already traced) |
171
+
172
+ ---
173
+
174
+ ### Summary
175
+
176
+ | Metric | Count |
177
+ |--------|-------|
178
+ | Files analyzed | 2 |
179
+ | Total functions | 8 |
180
+ | To instrument | 7 |
181
+ | Already traced | 1 |
182
+ | Excluded (dunder/private) | 0 |
183
+
184
+ ---
185
+
186
+ **Proceed with applying decorators?**
187
+ - Reply "Yes" to apply all
188
+ - Reply "Exclude: function1, function2" to skip specific functions
189
+ - Reply "No" to cancel
190
+ ```
191
+
192
+ ---
193
+
194
+ ### Step 6: Apply Decorators
195
+
196
+ After human approval:
197
+
198
+ #### 6.1 Add Import (if missing)
199
+
200
+ Check file for existing import:
201
+ ```python
202
+ from x_ipe.tracing import x_ipe_tracing
203
+ ```
204
+
205
+ If not present, add after other imports (before first function/class).
206
+
207
+ #### 6.2 Add Decorator to Each Function
208
+
209
+ **Simple case (no redaction):**
210
+ ```python
211
+ @x_ipe_tracing(level="INFO")
212
+ def my_function():
213
+ pass
214
+ ```
215
+
216
+ **With redaction:**
217
+ ```python
218
+ @x_ipe_tracing(level="INFO", redact=["password", "token"])
219
+ def login(email, password, token):
220
+ pass
221
+ ```
222
+
223
+ #### 6.3 Preserve Decorator Order
224
+
225
+ When function has existing decorators, add `@x_ipe_tracing` first (outermost):
226
+
227
+ ```python
228
+ # Before
229
+ @staticmethod
230
+ def my_function():
231
+ pass
232
+
233
+ # After
234
+ @x_ipe_tracing(level="INFO")
235
+ @staticmethod
236
+ def my_function():
237
+ pass
238
+ ```
239
+
240
+ #### 6.4 Handle Async Functions
241
+
242
+ Same syntax works for async:
243
+ ```python
244
+ @x_ipe_tracing(level="INFO")
245
+ async def async_function():
246
+ pass
247
+ ```
248
+
249
+ ---
250
+
251
+ ### Step 7: Report Results
252
+
253
+ After applying:
254
+
255
+ ```markdown
256
+ ## Instrumentation Complete ✅
257
+
258
+ ### Summary
259
+
260
+ | Metric | Count |
261
+ |--------|-------|
262
+ | Files modified | 2 |
263
+ | Functions instrumented | 7 |
264
+ | Import statements added | 1 |
265
+ | With redaction | 2 |
266
+
267
+ ### Changes Applied
268
+
269
+ | File | Functions | Notes |
270
+ |------|-----------|-------|
271
+ | `ideas_service.py` | 5 | - |
272
+ | `auth_service.py` | 2 | Added redaction for password, token |
273
+
274
+ ### Next Steps
275
+
276
+ 1. Run tests: `pytest tests/`
277
+ 2. Start tracing: Use Tracing Dashboard or API
278
+ 3. View traces: Check `instance/traces/` for logs
279
+ ```
280
+
281
+ ---
282
+
283
+ ## Edge Cases
284
+
285
+ ### EC-1: Already Traced Function
286
+ ```python
287
+ # Input
288
+ @x_ipe_tracing(level="DEBUG")
289
+ def my_function():
290
+ pass
291
+
292
+ # Action: SKIP
293
+ # Report: "already traced"
294
+ ```
295
+
296
+ ### EC-2: Multiple Decorators
297
+ ```python
298
+ # Input
299
+ @validate_input
300
+ @authorize
301
+ def my_function():
302
+ pass
303
+
304
+ # Output (add tracing first)
305
+ @x_ipe_tracing(level="INFO")
306
+ @validate_input
307
+ @authorize
308
+ def my_function():
309
+ pass
310
+ ```
311
+
312
+ ### EC-3: Class with Methods
313
+ ```python
314
+ # Input
315
+ class MyService:
316
+ def process(self, data):
317
+ pass
318
+
319
+ # Output
320
+ class MyService:
321
+ @x_ipe_tracing(level="INFO")
322
+ def process(self, data):
323
+ pass
324
+ ```
325
+
326
+ ### EC-4: Empty File / No Functions
327
+ ```
328
+ Report: "No traceable functions found in {filepath}"
329
+ ```
330
+
331
+ ### EC-5: Syntax Error in File
332
+ ```
333
+ Report: "Error parsing {filepath}: {error}"
334
+ Skip file, continue with others
335
+ ```
336
+
337
+ ---
338
+
339
+ ## Anti-Patterns
340
+
341
+ | Anti-Pattern | Why Bad | Do Instead |
342
+ |--------------|---------|------------|
343
+ | Trace `__init__` | Noisy, rarely useful | Skip all dunder methods |
344
+ | Trace test files | Tests shouldn't be traced | Exclude `test_*.py` |
345
+ | Force all INFO | DEBUG floods production logs | Use auto level assignment |
346
+ | Skip redaction check | Security risk | Always detect sensitive params |
347
+ | Modify without approval | Unexpected changes | Always show proposal first |
348
+
349
+ ---
350
+
351
+ ## Definition of Done
352
+
353
+ | # | Checkpoint | Required |
354
+ |---|------------|----------|
355
+ | 1 | Target path validated | Yes |
356
+ | 2 | Files analyzed with AST | Yes |
357
+ | 3 | Levels assigned per rules | Yes |
358
+ | 4 | Sensitive params detected | Yes |
359
+ | 5 | Proposal shown to human | Yes |
360
+ | 6 | Human approved changes | Yes |
361
+ | 7 | Decorators applied correctly | Yes |
362
+ | 8 | Imports added if needed | Yes |
363
+ | 9 | Results reported | Yes |
364
+
365
+ ---
366
+
367
+ ## Examples
368
+
369
+ See [references/examples.md](references/examples.md) for detailed examples including:
370
+ - Single file instrumentation
371
+ - Module/directory batch processing
372
+ - Auth service with sensitive params
373
+ - Excluding specific functions