proagents 1.6.17 → 1.6.19

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 (185) hide show
  1. package/.claude/settings.local.json +169 -0
  2. package/.proagents/AGENTS.md +2 -0
  3. package/.proagents/AI_INSTRUCTIONS.md +13 -0
  4. package/.proagents/ANTIGRAVITY.md +2 -0
  5. package/.proagents/BOLT.md +2 -0
  6. package/.proagents/CHATGPT.md +2 -0
  7. package/.proagents/CLAUDE.md +2 -0
  8. package/.proagents/GEMINI.md +2 -0
  9. package/.proagents/GROQ.md +2 -0
  10. package/.proagents/KIRO.md +2 -0
  11. package/.proagents/LOVABLE.md +2 -0
  12. package/.proagents/PROAGENTS.md +2 -0
  13. package/.proagents/REPLIT.md +2 -0
  14. package/.proagents/prompts/00-project-setup.md +878 -0
  15. package/.proagents/prompts/04-planning.md +38 -0
  16. package/.proagents/prompts/12-rnd.md +957 -0
  17. package/.proagents/workflow-modes/entry-modes.md +27 -0
  18. package/.proagents/worklog/_context.template.md +47 -0
  19. package/COMMANDS.md +654 -0
  20. package/README.md +16 -24
  21. package/package.json +2 -7
  22. package/.proagents/ai-models/README.md +0 -141
  23. package/.proagents/ai-models/cost-management.md +0 -362
  24. package/.proagents/ai-models/fallbacks.md +0 -342
  25. package/.proagents/ai-models/model-config.md +0 -318
  26. package/.proagents/ai-models/task-routing.md +0 -503
  27. package/.proagents/ai-training/README.md +0 -155
  28. package/.proagents/ai-training/continuous-learning.md +0 -413
  29. package/.proagents/ai-training/domain-knowledge.md +0 -378
  30. package/.proagents/ai-training/pattern-learning.md +0 -455
  31. package/.proagents/ai-training/training-data.md +0 -337
  32. package/.proagents/ai-training/user-preferences.md +0 -346
  33. package/.proagents/approval-workflows/README.md +0 -146
  34. package/.proagents/approval-workflows/approval-config.md +0 -332
  35. package/.proagents/approval-workflows/approval-stages.md +0 -503
  36. package/.proagents/approval-workflows/emergency-bypass.md +0 -351
  37. package/.proagents/approval-workflows/examples.md +0 -859
  38. package/.proagents/approval-workflows/notifications.md +0 -320
  39. package/.proagents/compliance/README.md +0 -206
  40. package/.proagents/compliance/access-control.md +0 -310
  41. package/.proagents/compliance/audit-logging.md +0 -444
  42. package/.proagents/compliance/compliance-frameworks.md +0 -429
  43. package/.proagents/compliance/reports.md +0 -491
  44. package/.proagents/compliance/retention-policies.md +0 -454
  45. package/.proagents/config-versioning/README.md +0 -120
  46. package/.proagents/config-versioning/changelog.md +0 -300
  47. package/.proagents/config-versioning/rollback.md +0 -283
  48. package/.proagents/config-versioning/versioning.md +0 -330
  49. package/.proagents/contract-testing/README.md +0 -223
  50. package/.proagents/contract-testing/contract-testing.md +0 -614
  51. package/.proagents/contract-testing/pact-integration.md +0 -507
  52. package/.proagents/contract-testing/schema-validation.md +0 -565
  53. package/.proagents/dependency-management/README.md +0 -140
  54. package/.proagents/dependency-management/automation.md +0 -363
  55. package/.proagents/dependency-management/compatibility.md +0 -319
  56. package/.proagents/dependency-management/security-scanning.md +0 -413
  57. package/.proagents/dependency-management/update-policies.md +0 -374
  58. package/.proagents/disaster-recovery/README.md +0 -247
  59. package/.proagents/disaster-recovery/automation.md +0 -366
  60. package/.proagents/disaster-recovery/backup-recovery.md +0 -571
  61. package/.proagents/disaster-recovery/incident-response.md +0 -565
  62. package/.proagents/disaster-recovery/rollback-procedures.md +0 -499
  63. package/.proagents/disaster-recovery/runbooks.md +0 -603
  64. package/.proagents/disaster-recovery/scenarios.md +0 -892
  65. package/.proagents/disaster-recovery/testing.md +0 -438
  66. package/.proagents/environments/README.md +0 -244
  67. package/.proagents/environments/configuration.md +0 -437
  68. package/.proagents/environments/promotion.md +0 -434
  69. package/.proagents/environments/setup.md +0 -420
  70. package/.proagents/examples/README.md +0 -55
  71. package/.proagents/examples/backend-nodejs/README.md +0 -188
  72. package/.proagents/examples/backend-nodejs/complete-conversation.md +0 -601
  73. package/.proagents/examples/backend-nodejs/proagents.config.yaml +0 -415
  74. package/.proagents/examples/backend-nodejs/workflow-example.md +0 -909
  75. package/.proagents/examples/fullstack-nextjs/README.md +0 -155
  76. package/.proagents/examples/fullstack-nextjs/complete-conversation.md +0 -604
  77. package/.proagents/examples/fullstack-nextjs/proagents.config.yaml +0 -287
  78. package/.proagents/examples/fullstack-nextjs/workflow-example.md +0 -553
  79. package/.proagents/examples/mobile-react-native/README.md +0 -171
  80. package/.proagents/examples/mobile-react-native/complete-conversation.md +0 -825
  81. package/.proagents/examples/mobile-react-native/proagents.config.yaml +0 -330
  82. package/.proagents/examples/mobile-react-native/workflow-example.md +0 -723
  83. package/.proagents/examples/web-frontend-react/README.md +0 -125
  84. package/.proagents/examples/web-frontend-react/complete-conversation.md +0 -556
  85. package/.proagents/examples/web-frontend-react/proagents.config.yaml +0 -183
  86. package/.proagents/examples/web-frontend-react/workflow-example.md +0 -603
  87. package/.proagents/existing-projects/README.md +0 -65
  88. package/.proagents/existing-projects/challenges.md +0 -861
  89. package/.proagents/existing-projects/coexistence-mode.md +0 -483
  90. package/.proagents/existing-projects/compatibility-assessment.md +0 -541
  91. package/.proagents/existing-projects/gradual-adoption.md +0 -515
  92. package/.proagents/existing-projects/migration-strategies.md +0 -788
  93. package/.proagents/existing-projects/pattern-reconciliation.md +0 -489
  94. package/.proagents/existing-projects/team-onboarding.md +0 -617
  95. package/.proagents/existing-projects/technical-debt-handling.md +0 -644
  96. package/.proagents/feature-flags/README.md +0 -263
  97. package/.proagents/feature-flags/ab-testing.md +0 -413
  98. package/.proagents/feature-flags/configuration.md +0 -420
  99. package/.proagents/feature-flags/kill-switches.md +0 -444
  100. package/.proagents/feature-flags/rollout-strategies.md +0 -392
  101. package/.proagents/history.log +0 -12
  102. package/.proagents/i18n/README.md +0 -133
  103. package/.proagents/i18n/extraction.md +0 -433
  104. package/.proagents/i18n/tms-integration.md +0 -332
  105. package/.proagents/i18n/translation-workflow.md +0 -413
  106. package/.proagents/i18n/validation.md +0 -355
  107. package/.proagents/logging/README.md +0 -276
  108. package/.proagents/logging/aggregation.md +0 -475
  109. package/.proagents/logging/log-levels.md +0 -376
  110. package/.proagents/logging/sensitive-data.md +0 -423
  111. package/.proagents/logging/structured-logging.md +0 -406
  112. package/.proagents/metrics/README.md +0 -69
  113. package/.proagents/metrics/code-quality-kpis.md +0 -461
  114. package/.proagents/metrics/deployment-metrics.md +0 -517
  115. package/.proagents/metrics/developer-productivity.md +0 -368
  116. package/.proagents/metrics/learning-effectiveness.md +0 -478
  117. package/.proagents/migrations/README.md +0 -77
  118. package/.proagents/migrations/from-claude-projects.md +0 -313
  119. package/.proagents/migrations/from-cursor-rules.md +0 -345
  120. package/.proagents/migrations/from-custom-workflows.md +0 -410
  121. package/.proagents/monitoring/README.md +0 -308
  122. package/.proagents/monitoring/alerting.md +0 -449
  123. package/.proagents/monitoring/dashboards.md +0 -454
  124. package/.proagents/monitoring/health-checks.md +0 -436
  125. package/.proagents/monitoring/metrics.md +0 -434
  126. package/.proagents/multi-project/README.md +0 -170
  127. package/.proagents/multi-project/coordinated-deploy.md +0 -510
  128. package/.proagents/multi-project/cross-project-deps.md +0 -395
  129. package/.proagents/multi-project/unified-changelog.md +0 -477
  130. package/.proagents/multi-project/walkthroughs/monorepo-setup.md +0 -787
  131. package/.proagents/multi-project/workspace-config.md +0 -408
  132. package/.proagents/notifications/README.md +0 -151
  133. package/.proagents/notifications/channels.md +0 -457
  134. package/.proagents/notifications/preferences.md +0 -415
  135. package/.proagents/notifications/routing.md +0 -449
  136. package/.proagents/notifications/scheduling.md +0 -425
  137. package/.proagents/notifications/templates.md +0 -446
  138. package/.proagents/offline-mode/README.md +0 -145
  139. package/.proagents/offline-mode/caching.md +0 -344
  140. package/.proagents/offline-mode/offline-operations.md +0 -312
  141. package/.proagents/offline-mode/queue-specifications.md +0 -679
  142. package/.proagents/offline-mode/sync.md +0 -475
  143. package/.proagents/parallel-features/README.md +0 -85
  144. package/.proagents/parallel-features/conflict-detection.md +0 -226
  145. package/.proagents/parallel-features/dependency-management.md +0 -392
  146. package/.proagents/parallel-features/merge-coordination.md +0 -506
  147. package/.proagents/parallel-features/tracking-system.md +0 -416
  148. package/.proagents/performance/README.md +0 -59
  149. package/.proagents/performance/bundle-analysis.md +0 -375
  150. package/.proagents/performance/load-testing.md +0 -563
  151. package/.proagents/performance/runtime-metrics.md +0 -489
  152. package/.proagents/performance/web-vitals.md +0 -425
  153. package/.proagents/plugins/README.md +0 -139
  154. package/.proagents/plugins/creating-plugins.md +0 -504
  155. package/.proagents/plugins/plugin-api.md +0 -467
  156. package/.proagents/plugins/plugin-registry.md +0 -276
  157. package/.proagents/reporting/README.md +0 -158
  158. package/.proagents/reporting/dashboards.md +0 -366
  159. package/.proagents/reporting/exports.md +0 -524
  160. package/.proagents/reporting/quality-metrics.md +0 -385
  161. package/.proagents/reporting/templates/README.md +0 -56
  162. package/.proagents/reporting/templates/dashboard-config.json +0 -187
  163. package/.proagents/reporting/templates/metrics-queries.md +0 -427
  164. package/.proagents/reporting/templates/react-dashboard.tsx +0 -544
  165. package/.proagents/reporting/templates/widgets.md +0 -451
  166. package/.proagents/reporting/velocity-metrics.md +0 -340
  167. package/.proagents/reverse-engineering/README.md +0 -151
  168. package/.proagents/reverse-engineering/architecture-extraction.md +0 -325
  169. package/.proagents/reverse-engineering/code-analysis.md +0 -377
  170. package/.proagents/reverse-engineering/dependency-mapping.md +0 -567
  171. package/.proagents/reverse-engineering/diagram-generation.md +0 -586
  172. package/.proagents/reverse-engineering/documentation-generation.md +0 -468
  173. package/.proagents/reverse-engineering/pattern-detection.md +0 -569
  174. package/.proagents/reverse-engineering/quality-assessment.md +0 -733
  175. package/.proagents/secrets/README.md +0 -278
  176. package/.proagents/secrets/access-control.md +0 -443
  177. package/.proagents/secrets/rotation.md +0 -403
  178. package/.proagents/secrets/scanning.md +0 -487
  179. package/.proagents/secrets/storage.md +0 -394
  180. package/.proagents/webhooks/README.md +0 -126
  181. package/.proagents/webhooks/endpoints.md +0 -298
  182. package/.proagents/webhooks/events.md +0 -316
  183. package/.proagents/webhooks/payloads.md +0 -325
  184. package/.proagents/webhooks/reliability.md +0 -363
  185. package/.proagents/webhooks/security.md +0 -380
@@ -1,355 +0,0 @@
1
- # Translation Validation
2
-
3
- Quality checks and validation rules for translations.
4
-
5
- ---
6
-
7
- ## Validation Overview
8
-
9
- ```
10
- ┌─────────────────────────────────────────────────────────────┐
11
- │ Validation Pipeline │
12
- ├─────────────────────────────────────────────────────────────┤
13
- │ │
14
- │ Source String Translation │
15
- │ ┌─────────────┐ ┌─────────────┐ │
16
- │ │ "Hello, │ │ "Hola, │ │
17
- │ │ {{name}}!" │ → │ {{name}}!" │ │
18
- │ └──────┬──────┘ └──────┬──────┘ │
19
- │ │ │ │
20
- │ └──────────┬───────────┘ │
21
- │ │ │
22
- │ ▼ │
23
- │ ┌─────────────────────┐ │
24
- │ │ Validators │ │
25
- │ ├─────────────────────┤ │
26
- │ │ ✓ Placeholders │ │
27
- │ │ ✓ Formatting │ │
28
- │ │ ✓ Length │ │
29
- │ │ ✓ Glossary │ │
30
- │ │ ✓ Plurals │ │
31
- │ └─────────────────────┘ │
32
- │ │ │
33
- │ [PASS/FAIL] │
34
- │ │
35
- └─────────────────────────────────────────────────────────────┘
36
- ```
37
-
38
- ---
39
-
40
- ## Validation Rules
41
-
42
- ### Placeholder Validation
43
-
44
- ```yaml
45
- i18n:
46
- validation:
47
- placeholders:
48
- enabled: true
49
- severity: "error"
50
-
51
- rules:
52
- # All source placeholders must exist in translation
53
- missing: "error"
54
-
55
- # Extra placeholders not in source
56
- extra: "warning"
57
-
58
- # Placeholder format must match
59
- format_mismatch: "error"
60
-
61
- # Placeholder patterns
62
- patterns:
63
- - "{{\\w+}}" # {{name}}
64
- - "%[sd]" # %s, %d
65
- - "\\{\\d+\\}" # {0}, {1}
66
- ```
67
-
68
- ### Length Validation
69
-
70
- ```yaml
71
- i18n:
72
- validation:
73
- length:
74
- enabled: true
75
- severity: "warning"
76
-
77
- rules:
78
- # Maximum expansion allowed
79
- max_expansion: 1.5 # Translation can be 50% longer
80
-
81
- # Minimum length (catch empty translations)
82
- min_length: 1
83
-
84
- # Per-context limits
85
- contexts:
86
- button:
87
- max_chars: 20
88
- title:
89
- max_chars: 50
90
- description:
91
- max_chars: 200
92
- ```
93
-
94
- ### Formatting Validation
95
-
96
- ```yaml
97
- i18n:
98
- validation:
99
- formatting:
100
- enabled: true
101
-
102
- rules:
103
- # HTML tags must match
104
- html_tags:
105
- enabled: true
106
- severity: "error"
107
-
108
- # Markdown must be preserved
109
- markdown:
110
- enabled: true
111
- severity: "warning"
112
-
113
- # Line breaks
114
- line_breaks:
115
- preserve: true
116
- severity: "warning"
117
-
118
- # Leading/trailing whitespace
119
- whitespace:
120
- check: true
121
- severity: "info"
122
- ```
123
-
124
- ### Glossary Validation
125
-
126
- ```yaml
127
- i18n:
128
- validation:
129
- glossary:
130
- enabled: true
131
- severity: "warning"
132
-
133
- # Glossary file
134
- file: "i18n/glossary.csv"
135
-
136
- rules:
137
- # Terms must be translated consistently
138
- consistency: true
139
-
140
- # Terms must not be translated (brand names)
141
- do_not_translate:
142
- - "ProAgents"
143
- - "GitHub"
144
- - "API"
145
- ```
146
-
147
- ### Plural Validation
148
-
149
- ```yaml
150
- i18n:
151
- validation:
152
- plurals:
153
- enabled: true
154
- severity: "error"
155
-
156
- rules:
157
- # All plural forms required
158
- all_forms_required: true
159
-
160
- # Forms per language
161
- forms:
162
- en: ["one", "other"]
163
- ru: ["one", "few", "many", "other"]
164
- ar: ["zero", "one", "two", "few", "many", "other"]
165
- zh: ["other"] # No plurals
166
- ```
167
-
168
- ---
169
-
170
- ## Running Validation
171
-
172
- ### Command Line
173
-
174
- ```bash
175
- # Validate all translations
176
- proagents i18n validate
177
-
178
- # Validate specific language
179
- proagents i18n validate --lang es
180
-
181
- # Validate specific file
182
- proagents i18n validate --file src/locales/es/common.json
183
-
184
- # Output format
185
- proagents i18n validate --format json
186
- ```
187
-
188
- ### Validation Output
189
-
190
- ```
191
- ┌─────────────────────────────────────────────────────────────┐
192
- │ Translation Validation Results │
193
- ├─────────────────────────────────────────────────────────────┤
194
- │ │
195
- │ Validated: 5 languages, 450 keys │
196
- │ │
197
- │ Errors (3): │
198
- │ ┌─────────────────────────────────────────────────────────┐│
199
- │ │ es/common.json:greeting ││
200
- │ │ Missing placeholder: {{name}} ││
201
- │ │ Source: "Hello, {{name}}!" ││
202
- │ │ Translation: "¡Hola!" ││
203
- │ └─────────────────────────────────────────────────────────┘│
204
- │ ┌─────────────────────────────────────────────────────────┐│
205
- │ │ fr/errors.json:validation_error ││
206
- │ │ Mismatched HTML tags ││
207
- │ │ Source: "<strong>Error:</strong> {{message}}" ││
208
- │ │ Translation: "<b>Erreur:</b> {{message}}" ││
209
- │ └─────────────────────────────────────────────────────────┘│
210
- │ │
211
- │ Warnings (5): │
212
- │ • de/common.json:long_text - exceeds 150% expansion │
213
- │ • ja/ui.json:button_submit - exceeds 20 char limit │
214
- │ • ... 3 more │
215
- │ │
216
- │ Result: FAILED (3 errors, 5 warnings) │
217
- │ │
218
- └─────────────────────────────────────────────────────────────┘
219
- ```
220
-
221
- ---
222
-
223
- ## CI Integration
224
-
225
- ### Pre-Commit Hook
226
-
227
- ```yaml
228
- # .proagents/hooks/pre-commit
229
- i18n:
230
- validation:
231
- hooks:
232
- pre_commit:
233
- enabled: true
234
- fail_on: "error"
235
- languages: "all"
236
- ```
237
-
238
- ### CI Pipeline
239
-
240
- ```yaml
241
- # GitHub Actions
242
- name: i18n Validation
243
-
244
- on:
245
- pull_request:
246
- paths:
247
- - 'src/locales/**'
248
-
249
- jobs:
250
- validate:
251
- runs-on: ubuntu-latest
252
- steps:
253
- - uses: actions/checkout@v4
254
-
255
- - name: Validate translations
256
- run: proagents i18n validate --ci --fail-on error
257
-
258
- - name: Upload report
259
- uses: actions/upload-artifact@v3
260
- with:
261
- name: i18n-validation-report
262
- path: i18n-validation.json
263
- ```
264
-
265
- ### Block Merge
266
-
267
- ```yaml
268
- i18n:
269
- validation:
270
- ci:
271
- # Block PR merge on
272
- block_on:
273
- errors: true
274
- warnings: false
275
-
276
- # Required checks
277
- required_checks:
278
- - "placeholder_validation"
279
- - "plural_validation"
280
- ```
281
-
282
- ---
283
-
284
- ## Custom Validators
285
-
286
- ### Define Custom Rule
287
-
288
- ```yaml
289
- i18n:
290
- validation:
291
- custom:
292
- # No profanity
293
- - name: "no_profanity"
294
- type: "regex"
295
- pattern: "\\b(badword1|badword2)\\b"
296
- severity: "error"
297
- message: "Translation contains inappropriate language"
298
-
299
- # Brand name capitalization
300
- - name: "brand_caps"
301
- type: "regex"
302
- pattern: "proagents"
303
- severity: "warning"
304
- message: "Brand name should be 'ProAgents'"
305
-
306
- # Custom script
307
- - name: "custom_check"
308
- type: "script"
309
- script: "scripts/validate-i18n.js"
310
- severity: "error"
311
- ```
312
-
313
- ---
314
-
315
- ## Auto-Fix
316
-
317
- ### Fixable Issues
318
-
319
- ```yaml
320
- i18n:
321
- validation:
322
- auto_fix:
323
- enabled: true
324
-
325
- # What can be auto-fixed
326
- fixable:
327
- - "trailing_whitespace"
328
- - "leading_whitespace"
329
- - "double_spaces"
330
- - "smart_quotes" # Convert to standard quotes
331
-
332
- # Confirmation
333
- confirm: true
334
- ```
335
-
336
- ### Fix Command
337
-
338
- ```bash
339
- # Auto-fix issues
340
- proagents i18n validate --fix
341
-
342
- # Preview fixes
343
- proagents i18n validate --fix --dry-run
344
- ```
345
-
346
- ---
347
-
348
- ## Best Practices
349
-
350
- 1. **Run in CI**: Validate on every PR
351
- 2. **Block on Errors**: Don't merge with validation errors
352
- 3. **Use Glossary**: Ensure consistent terminology
353
- 4. **Check Plurals**: Verify all plural forms
354
- 5. **Test UI**: Visual testing catches length issues
355
- 6. **Review Warnings**: Don't ignore warnings
@@ -1,276 +0,0 @@
1
- # Logging Best Practices
2
-
3
- Structured logging for debugging, monitoring, and compliance.
4
-
5
- ---
6
-
7
- ## Overview
8
-
9
- Consistent, structured logging that supports debugging, monitoring, and audit requirements.
10
-
11
- ## Documentation
12
-
13
- | Document | Description |
14
- |----------|-------------|
15
- | [Log Levels](./log-levels.md) | When to use each level |
16
- | [Structured Logging](./structured-logging.md) | JSON log format |
17
- | [Log Aggregation](./aggregation.md) | Centralized logging |
18
- | [Sensitive Data](./sensitive-data.md) | Protecting PII in logs |
19
-
20
- ---
21
-
22
- ## Log Levels
23
-
24
- | Level | When to Use | Example |
25
- |-------|-------------|---------|
26
- | `error` | Application errors requiring attention | Database connection failed |
27
- | `warn` | Unexpected but handled situations | Retry attempt, deprecation |
28
- | `info` | Normal operations, milestones | Request completed, user logged in |
29
- | `debug` | Detailed debugging information | Variable values, flow tracking |
30
- | `trace` | Very detailed tracing | Function entry/exit |
31
-
32
- ---
33
-
34
- ## Structured Logging
35
-
36
- ### JSON Log Format
37
-
38
- ```typescript
39
- // src/utils/logger.ts
40
- import pino from 'pino';
41
-
42
- export const logger = pino({
43
- level: process.env.LOG_LEVEL || 'info',
44
- formatters: {
45
- level: (label) => ({ level: label }),
46
- },
47
- timestamp: () => `,"timestamp":"${new Date().toISOString()}"`,
48
- });
49
-
50
- // Usage
51
- logger.info({
52
- event: 'user_login',
53
- userId: user.id,
54
- ip: req.ip,
55
- userAgent: req.headers['user-agent'],
56
- });
57
- ```
58
-
59
- ### Log Output
60
-
61
- ```json
62
- {
63
- "level": "info",
64
- "timestamp": "2024-01-15T10:30:00.000Z",
65
- "event": "user_login",
66
- "userId": "user-123",
67
- "ip": "192.168.1.1",
68
- "userAgent": "Mozilla/5.0..."
69
- }
70
- ```
71
-
72
- ---
73
-
74
- ## Request Logging
75
-
76
- ### HTTP Request Logger
77
-
78
- ```typescript
79
- // src/middleware/request-logger.ts
80
- export function requestLogger(req, res, next) {
81
- const start = Date.now();
82
-
83
- res.on('finish', () => {
84
- const duration = Date.now() - start;
85
-
86
- logger.info({
87
- event: 'http_request',
88
- method: req.method,
89
- path: req.path,
90
- statusCode: res.statusCode,
91
- duration,
92
- requestId: req.id,
93
- userId: req.user?.id,
94
- });
95
- });
96
-
97
- next();
98
- }
99
- ```
100
-
101
- ### Request ID Tracking
102
-
103
- ```typescript
104
- // Add unique ID to each request
105
- import { v4 as uuid } from 'uuid';
106
-
107
- app.use((req, res, next) => {
108
- req.id = req.headers['x-request-id'] || uuid();
109
- res.setHeader('x-request-id', req.id);
110
- next();
111
- });
112
- ```
113
-
114
- ---
115
-
116
- ## Configuration
117
-
118
- ```yaml
119
- # proagents.config.yaml
120
- logging:
121
- level: "info" # error, warn, info, debug, trace
122
-
123
- format: "json" # json, pretty
124
-
125
- # Include in all logs
126
- default_fields:
127
- service: "my-app"
128
- version: "${APP_VERSION}"
129
- environment: "${NODE_ENV}"
130
-
131
- # Output destinations
132
- outputs:
133
- - type: "stdout"
134
- - type: "file"
135
- path: "logs/app.log"
136
- rotate: "daily"
137
-
138
- # Aggregation
139
- aggregation:
140
- provider: "datadog" # datadog, cloudwatch, elasticsearch
141
- ```
142
-
143
- ---
144
-
145
- ## Log Aggregation
146
-
147
- ### Send to Aggregator
148
-
149
- ```typescript
150
- // DataDog example
151
- import { createLogger, format, transports } from 'winston';
152
-
153
- const logger = createLogger({
154
- transports: [
155
- new transports.Console(),
156
- new transports.Http({
157
- host: 'http-intake.logs.datadoghq.com',
158
- path: `/api/v2/logs?dd-api-key=${process.env.DD_API_KEY}`,
159
- ssl: true,
160
- }),
161
- ],
162
- });
163
- ```
164
-
165
- ### Log Search
166
-
167
- ```
168
- ┌─────────────────────────────────────────────────────────────┐
169
- │ Log Search: service:my-app level:error │
170
- ├─────────────────────────────────────────────────────────────┤
171
- │ │
172
- │ 10:30:15 ERROR Database connection failed │
173
- │ requestId: abc-123 │
174
- │ error: ECONNREFUSED │
175
- │ host: db.example.com │
176
- │ │
177
- │ 10:28:42 ERROR Payment processing failed │
178
- │ requestId: def-456 │
179
- │ userId: user-789 │
180
- │ error: Card declined │
181
- │ │
182
- │ 10:25:10 ERROR API rate limit exceeded │
183
- │ requestId: ghi-789 │
184
- │ endpoint: /api/users │
185
- │ │
186
- └─────────────────────────────────────────────────────────────┘
187
- ```
188
-
189
- ---
190
-
191
- ## Sensitive Data Protection
192
-
193
- ### What NOT to Log
194
-
195
- ```typescript
196
- // ❌ Never log these
197
- logger.info({ password: user.password }); // Credentials
198
- logger.info({ ssn: user.ssn }); // PII
199
- logger.info({ creditCard: payment.card }); // Financial
200
- logger.info({ token: auth.token }); // Secrets
201
-
202
- // ✅ Safe alternatives
203
- logger.info({ userId: user.id });
204
- logger.info({ last4: payment.card.slice(-4) });
205
- ```
206
-
207
- ### Automatic Redaction
208
-
209
- ```typescript
210
- const logger = pino({
211
- redact: {
212
- paths: [
213
- 'password',
214
- 'secret',
215
- 'token',
216
- '*.password',
217
- 'user.email',
218
- 'creditCard',
219
- ],
220
- censor: '[REDACTED]',
221
- },
222
- });
223
-
224
- // Input
225
- logger.info({ user: { email: 'user@example.com', password: 'secret123' } });
226
-
227
- // Output
228
- { "user": { "email": "[REDACTED]", "password": "[REDACTED]" } }
229
- ```
230
-
231
- ---
232
-
233
- ## Performance Logging
234
-
235
- ### Timing Operations
236
-
237
- ```typescript
238
- // Track operation duration
239
- async function processOrder(orderId: string) {
240
- const start = Date.now();
241
-
242
- try {
243
- const result = await doProcessing(orderId);
244
-
245
- logger.info({
246
- event: 'order_processed',
247
- orderId,
248
- duration: Date.now() - start,
249
- status: 'success',
250
- });
251
-
252
- return result;
253
- } catch (error) {
254
- logger.error({
255
- event: 'order_processing_failed',
256
- orderId,
257
- duration: Date.now() - start,
258
- error: error.message,
259
- });
260
- throw error;
261
- }
262
- }
263
- ```
264
-
265
- ---
266
-
267
- ## Best Practices
268
-
269
- 1. **Use Structured Logs**: JSON format for machine parsing
270
- 2. **Include Request IDs**: Trace requests across services
271
- 3. **Log at Right Level**: Don't overuse error/debug
272
- 4. **Add Context**: Include relevant business context
273
- 5. **Protect Sensitive Data**: Redact PII and secrets
274
- 6. **Aggregate Logs**: Use centralized logging
275
- 7. **Monitor Log Volume**: High volume may indicate issues
276
- 8. **Rotate Log Files**: Prevent disk exhaustion