drtrace 0.1.0 → 0.3.0

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 (43) hide show
  1. package/README.md +29 -0
  2. package/agents/CONTRIBUTING.md +296 -0
  3. package/agents/README.md +174 -0
  4. package/agents/daemon-method-selection.md +298 -0
  5. package/agents/integration-guides/cpp-best-practices.md +218 -0
  6. package/agents/integration-guides/cpp-ros-integration.md +88 -0
  7. package/agents/log-analysis.md +217 -0
  8. package/agents/log-help.md +226 -0
  9. package/agents/log-init.md +933 -0
  10. package/agents/log-it.md +1126 -0
  11. package/bin/init.js +4 -4
  12. package/dist/bin/init.js +31 -0
  13. package/dist/config-schema.d.ts +2 -2
  14. package/dist/init.d.ts +49 -4
  15. package/dist/init.js +494 -35
  16. package/dist/resources/agents/CONTRIBUTING.md +296 -0
  17. package/dist/resources/agents/README.md +174 -0
  18. package/dist/resources/agents/daemon-method-selection.md +298 -0
  19. package/dist/resources/agents/integration-guides/cpp-best-practices.md +218 -0
  20. package/dist/resources/agents/integration-guides/cpp-ros-integration.md +88 -0
  21. package/dist/resources/agents/log-analysis.md +217 -0
  22. package/dist/resources/agents/log-help.md +226 -0
  23. package/dist/resources/agents/log-init.md +933 -0
  24. package/dist/resources/agents/log-it.md +1126 -0
  25. package/dist/resources/cpp/drtrace_sink.hpp +1248 -0
  26. package/package.json +9 -2
  27. package/.eslintrc.js +0 -20
  28. package/jest.config.js +0 -11
  29. package/src/client.ts +0 -68
  30. package/src/config-schema.ts +0 -115
  31. package/src/config.ts +0 -326
  32. package/src/index.ts +0 -3
  33. package/src/init.ts +0 -410
  34. package/src/logger.ts +0 -56
  35. package/src/queue.ts +0 -105
  36. package/src/transport.ts +0 -60
  37. package/src/types.ts +0 -20
  38. package/tests/client.test.ts +0 -66
  39. package/tests/config-schema.test.ts +0 -198
  40. package/tests/config.test.ts +0 -456
  41. package/tests/queue.test.ts +0 -72
  42. package/tests/transport.test.ts +0 -52
  43. package/tsconfig.json +0 -18
package/README.md CHANGED
@@ -50,6 +50,35 @@ console.log('This is captured by DrTrace');
50
50
  console.error('Errors are also captured');
51
51
  ```
52
52
 
53
+ ## Starting the DrTrace Daemon
54
+
55
+ **Important**: The DrTrace daemon must be running before your application can send logs.
56
+
57
+ ### Option A: Docker Compose (Recommended)
58
+
59
+ ```bash
60
+ # From the DrTrace repository root
61
+ docker-compose up -d
62
+
63
+ # Verify it's running
64
+ curl http://localhost:8001/status
65
+ ```
66
+
67
+ ### Option B: Native Python Daemon
68
+
69
+ ```bash
70
+ # Set database URL (if using PostgreSQL)
71
+ export DRTRACE_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/drtrace"
72
+
73
+ # Start the daemon
74
+ uvicorn drtrace_service.api:app --host localhost --port 8001
75
+
76
+ # In another terminal, verify it's running
77
+ python -m drtrace_service status
78
+ ```
79
+
80
+ **Note**: The daemon runs on `http://localhost:8001` by default. Make sure this matches your `daemonUrl` in the config.
81
+
53
82
  ## Configuration
54
83
 
55
84
  Configuration is managed via `_drtrace/config.json` created during `npx drtrace init`.
@@ -0,0 +1,296 @@
1
+ # Contributing to DrTrace Agents
2
+
3
+ Thank you for your interest in contributing to DrTrace agents! This guide explains how to create, test, and submit new agents or improvements.
4
+
5
+ ## Creating a New Agent
6
+
7
+ ### 1. File Structure
8
+
9
+ Create a new agent file named `<agent-name>.md` in this directory:
10
+
11
+ ```
12
+ agents/
13
+ ├── <agent-name>.md
14
+ ├── log-analysis.md
15
+ ├── log-it.md
16
+ ├── log-init.md
17
+ ├── log-help.md
18
+ └── README.md
19
+ ```
20
+
21
+ ### 2. File Format
22
+
23
+ Use the standardized markdown format with embedded XML:
24
+
25
+ ```markdown
26
+ ---
27
+ name: "<agent-name>"
28
+ description: "Brief description of the agent's purpose"
29
+ ---
30
+
31
+ You must fully embody this agent's persona and follow all activation instructions exactly as specified. NEVER break character until given an exit command.
32
+
33
+ \`\`\`xml
34
+ <agent id="<agent-name>.agent.yaml" name="drtrace" title="Agent Title" icon="emoji">
35
+ <activation critical="MANDATORY">
36
+ <step n="1">First activation step</step>
37
+ <step n="2">Second activation step</step>
38
+ ...
39
+ <rules>
40
+ <r>Behavior rule 1</r>
41
+ <r>Behavior rule 2</r>
42
+ </rules>
43
+ </activation>
44
+
45
+ <persona>
46
+ <role>Agent Role</role>
47
+ <identity>Who the agent is</identity>
48
+ <communication_style>How the agent communicates</communication_style>
49
+ <principles>
50
+ - Principle 1
51
+ - Principle 2
52
+ </principles>
53
+ </persona>
54
+
55
+ <menu title="Menu title">
56
+ <item cmd="X" hotkey="X" name="Option name">
57
+ Description of what this option does
58
+ </item>
59
+ </menu>
60
+ \`\`\`
61
+
62
+ [Implementation content - patterns, frameworks, examples, etc.]
63
+ ```
64
+
65
+ ### 3. Key Components
66
+
67
+ **Activation Steps** (required):
68
+ - Define how the agent initializes
69
+ - Set persona and rules
70
+ - Display greeting and menu
71
+ - Wait for user input
72
+ - Process commands
73
+
74
+ **Persona** (required):
75
+ - Role: What the agent does
76
+ - Identity: Who/what the agent is
77
+ - Communication style: Tone and format
78
+ - Principles: Core behavioral guidelines
79
+
80
+ **Menu** (optional):
81
+ - Interactive commands users can choose
82
+ - Each item has cmd, hotkey, name, description
83
+ - Focus on actionable options, not auto-execution
84
+
85
+ **Implementation**:
86
+ - Patterns, examples, frameworks
87
+ - Language-specific guidance
88
+ - Copy-paste ready code snippets
89
+ - Decision trees and validation logic
90
+
91
+ ### 4. Multi-Language Support
92
+
93
+ Agents must support all five languages:
94
+ - Python (stdlib logging, structlog)
95
+ - JavaScript/TypeScript (winston, pino, bunyan)
96
+ - Java (SLF4J, Logback)
97
+ - Go (slog, logrus)
98
+ - C++ (spdlog)
99
+
100
+ For each language, provide:
101
+ - Pattern examples
102
+ - Library-specific guidance
103
+ - Syntax highlighting
104
+ - Copy-paste ready code
105
+
106
+ **Example:**
107
+ ```markdown
108
+ ## Python Pattern
109
+ \`\`\`python
110
+ import logging
111
+ logger = logging.getLogger(__name__)
112
+ logger.info("message")
113
+ \`\`\`
114
+
115
+ ## JavaScript Pattern
116
+ \`\`\`javascript
117
+ const winston = require('winston');
118
+ const logger = winston.createLogger({...});
119
+ logger.info("message");
120
+ \`\`\`
121
+ ```
122
+
123
+ ## Testing Your Agent
124
+
125
+ ### 1. Manual Testing
126
+
127
+ **In Python:**
128
+ ```bash
129
+ cd /path/to/project
130
+ python -m drtrace_service init-agent --agent <agent-name>
131
+ cat _drtrace/agents/<agent-name>.md
132
+ ```
133
+
134
+ **In JavaScript:**
135
+ ```bash
136
+ cd /path/to/project
137
+ npx drtrace init-agent --agent <agent-name>
138
+ cat _drtrace/agents/<agent-name>.md
139
+ ```
140
+
141
+ **In C++:**
142
+ ```bash
143
+ cd /path/to/project
144
+ drtrace init-agent --agent <agent-name>
145
+ cat _drtrace/agents/<agent-name>.md
146
+ ```
147
+
148
+ ### 2. Activation Testing
149
+
150
+ Load the agent in your preferred AI chat or IDE:
151
+ 1. Copy the entire agent file content
152
+ 2. Paste into the chat interface
153
+ 3. Wait for the greeting and menu
154
+ 4. Verify all menu options work
155
+ 5. Test core workflows
156
+
157
+ ### 3. Edge Cases
158
+
159
+ Test your agent with:
160
+ - Empty input
161
+ - Malformed code
162
+ - Very large code samples
163
+ - Multiple programming languages
164
+ - Missing context (ask for clarification)
165
+ - Ambiguous requests (offer options)
166
+
167
+ ### 4. Automated Testing
168
+
169
+ Agents are tested via:
170
+ - **Unit tests**: Agent spec syntax validation
171
+ - **Integration tests**: Agent loading across ecosystems
172
+ - **E2E tests**: Agent activation and menu interaction
173
+
174
+ ## Updating Existing Agents
175
+
176
+ When updating an existing agent:
177
+
178
+ 1. **Backward Compatibility**: Maintain the same persona and core menu items
179
+ 2. **Documentation**: Update `agents/README.md` if functionality changes
180
+ 3. **Testing**: Run full test suite before submitting
181
+ 4. **Version Notes**: Add comment in agent file about what changed
182
+
183
+ Example:
184
+ ```markdown
185
+ ---
186
+ name: "log-analysis"
187
+ description: "Log Analysis Agent"
188
+ version: "1.1.0"
189
+ updated: "2025-12-22"
190
+ changelog: "Added support for cross-service log correlation"
191
+ ---
192
+ ```
193
+
194
+ ## Submission Checklist
195
+
196
+ Before submitting your agent:
197
+
198
+ - [ ] File named `<agent-name>.md`
199
+ - [ ] YAML frontmatter with name and description
200
+ - [ ] XML activation block with 9+ steps
201
+ - [ ] Persona definition (role, identity, communication_style, principles)
202
+ - [ ] Interactive menu with 3+ options
203
+ - [ ] Examples for all 5 supported languages
204
+ - [ ] Copy-paste ready code snippets
205
+ - [ ] Tested in Python, JavaScript, C++ ecosystems
206
+ - [ ] No hardcoded file paths or system-specific code
207
+ - [ ] Error handling for edge cases
208
+ - [ ] Markdown syntax verified (no broken links)
209
+ - [ ] README.md updated (if adding new agent)
210
+
211
+ ## Code Guidelines
212
+
213
+ ### Do's ✅
214
+ - Use lazy string formatting (f-strings, template literals)
215
+ - Validate user input before processing
216
+ - Ask for clarification if context is unclear
217
+ - Provide helpful error messages
218
+ - Include multiple examples
219
+ - Support natural language queries
220
+ - Offer copy-paste ready code
221
+
222
+ ### Don'ts ❌
223
+ - Don't hardcode system paths
224
+ - Don't assume user's environment
225
+ - Don't execute code automatically (wait for confirmation)
226
+ - Don't log sensitive data
227
+ - Don't make breaking changes to existing agents
228
+ - Don't use platform-specific syntax
229
+ - Don't skip error handling
230
+
231
+ ## File Size Guidelines
232
+
233
+ Agent files should be:
234
+ - **Minimal**: 200-500 lines for simple agents
235
+ - **Comprehensive**: 800-1500 lines for complex agents
236
+ - **Maximum**: 2000 lines (split into multiple agents if larger)
237
+
238
+ Avoid:
239
+ - Excessive repetition
240
+ - Redundant examples
241
+ - Over-documentation
242
+ - Unnecessary complexity
243
+
244
+ ## Directory Structure
245
+
246
+ After your contribution:
247
+
248
+ ```
249
+ agents/
250
+ ├── <agent-name>.md ← Your new agent
251
+ ├── log-analysis.md ← Existing
252
+ ├── log-it.md ← Existing
253
+ ├── log-init.md ← Existing
254
+ ├── log-help.md ← Existing
255
+ ├── README.md ← Updated
256
+ └── CONTRIBUTING.md ← This file
257
+ ```
258
+
259
+ ## Distribution Pipeline
260
+
261
+ 1. **Development**: Agent file created in `agents/`
262
+ 2. **Testing**: Tested across ecosystems
263
+ 3. **Packaging**: Included in PyPI, npm, C++ releases
264
+ 4. **Deployment**: Users get agent via `pip install drtrace`, `npm install drtrace`, etc.
265
+ 5. **Activation**: Users run `drtrace init-agent --agent <name>`
266
+
267
+ ## Questions?
268
+
269
+ Refer to:
270
+ - [log-analysis.md](log-analysis.md) — Complete working example
271
+ - [log-it.md](log-it.md) — Another example with 5-criteria validation
272
+ - [Agent Implementation Guide](../_bmad-output/implementation-artifacts/log-it-agent-implementation-guide.md)
273
+ - [Agent Refactoring Plan](../_bmad-output/implementation-artifacts/agent-files-shared-resource-refactoring-plan.md)
274
+
275
+ ## Review Process
276
+
277
+ 1. **Submit**: Create PR with new/updated agent file
278
+ 2. **Review**: Architecture team reviews for:
279
+ - Correctness and completeness
280
+ - Multi-language support
281
+ - Edge case handling
282
+ - Documentation quality
283
+ 3. **Feedback**: Comments provided; iterate as needed
284
+ 4. **Approval**: Merged to main branch
285
+ 5. **Release**: Published with next version
286
+
287
+ ---
288
+
289
+ **Agent Quality Standards**
290
+ - All agents must be production-ready
291
+ - Must support all 5 programming languages
292
+ - Must include comprehensive documentation
293
+ - Must handle edge cases gracefully
294
+ - Must provide value to developers
295
+
296
+ Thank you for contributing to DrTrace! 🚀
@@ -0,0 +1,174 @@
1
+ # DrTrace Agent Library
2
+
3
+ Central repository for all DrTrace interactive agents. These agents guide developers through code analysis, logging decisions, and troubleshooting workflows.
4
+
5
+ ## Agents
6
+
7
+ ### log-analysis (Log Analysis Specialist)
8
+ Analyzes application logs and provides root-cause explanations for errors.
9
+
10
+ - **Purpose**: Help developers understand why errors occurred with AI-powered analysis
11
+ - **Input**: Natural language queries about log data and time windows
12
+ - **Output**: Structured markdown reports with summaries, root causes, evidence, and suggested fixes
13
+ - **Availability**: All ecosystems (Python, JavaScript, C++)
14
+
15
+ **Activate:**
16
+ ```bash
17
+ # Python
18
+ python -m drtrace_service init-agent --agent log-analysis
19
+
20
+ # JavaScript
21
+ npx drtrace init-agent --agent log-analysis
22
+
23
+ # C++
24
+ drtrace init-agent --agent log-analysis
25
+ ```
26
+
27
+ ### log-it (Strategic Logging Assistant)
28
+ Helps developers add efficient, strategic logging to their code.
29
+
30
+ - **Purpose**: Guide developers through logging decisions using 5-criteria validation
31
+ - **Input**: Function or file code to analyze
32
+ - **Output**: Strategic logging suggestions with line numbers, log levels, and copy-paste ready code
33
+ - **Availability**: All ecosystems (Python, JavaScript, Java, Go, C++)
34
+
35
+ **Activate:**
36
+ ```bash
37
+ # Python
38
+ python -m drtrace_service init-agent --agent log-it
39
+
40
+ # JavaScript
41
+ npx drtrace init-agent --agent log-it
42
+
43
+ # C++
44
+ drtrace init-agent --agent log-it
45
+ ```
46
+
47
+ ### log-init (DrTrace Setup Assistant)
48
+ Analyzes your project structure and suggests language-specific DrTrace setup.
49
+
50
+ - **Purpose**: Inspect real project files (Python, C++, JS/TS) and recommend minimal, best‑practice integration points.
51
+ - **Input**: Project root path and/or key files (e.g., `main.py`, `CMakeLists.txt`, `package.json`).
52
+ - **Output**: Markdown suggestions with integration points, code snippets, config changes, and verification steps.
53
+
54
+ **Activate:**
55
+
56
+ ```bash
57
+ # Python
58
+ python -m drtrace_service init-agent --agent log-init
59
+
60
+ # JavaScript
61
+ npx drtrace init-agent --agent log-init
62
+
63
+ # C++
64
+ drtrace init-agent --agent log-init
65
+ ```
66
+
67
+ See `docs/log-init-agent-guide.md` for detailed usage, examples, and how it works with `init-project`.
68
+
69
+ ### log-help (DrTrace Setup Guide)
70
+ Provides interactive, step-by-step guidance and troubleshooting for DrTrace setup.
71
+
72
+ - **Purpose**: Walk you through setup steps for each language and help debug common issues.
73
+ - **Input**: Natural language requests (e.g., “start Python setup guide”, “I’m stuck – daemon not connecting”).
74
+ - **Output**: Guided checklists, progress tracking, and troubleshooting instructions.
75
+
76
+ **Activate:**
77
+
78
+ ```bash
79
+ # Python
80
+ python -m drtrace_service init-agent --agent log-help
81
+
82
+ # JavaScript
83
+ npx drtrace init-agent --agent log-help
84
+
85
+ # C++
86
+ drtrace init-agent --agent log-help
87
+ ```
88
+
89
+ See `docs/log-help-agent-guide.md` for guidance on step-by-step usage and troubleshooting patterns.
90
+
91
+ ## Usage
92
+
93
+ 1. **Bootstrap an agent into your project:**
94
+ ```bash
95
+ drtrace init-agent --agent <agent-name>
96
+ ```
97
+ This creates `_drtrace/agents/<agent-name>.md` in your project.
98
+
99
+ 2. **Activate an agent in your chat/IDE:**
100
+ - Load the agent file from `_drtrace/agents/<agent-name>.md`
101
+ - Or use `@agent-name` shorthand if supported by your host
102
+
103
+ 3. **Interact with the agent:**
104
+ - Follow the agent's menu options
105
+ - Provide code or query details as requested
106
+ - Use the agent's structured responses for your work
107
+
108
+ ## Supported Languages
109
+
110
+ All agents support analysis and suggestions for:
111
+ - **Python** (stdlib logging, structlog)
112
+ - **JavaScript/TypeScript** (winston, pino, bunyan)
113
+ - **Java** (SLF4J, Logback)
114
+ - **Go** (slog, logrus)
115
+ - **C++** (spdlog)
116
+
117
+ ## File Format
118
+
119
+ Agents use a standardized markdown format with embedded XML configuration:
120
+
121
+ ```
122
+ ---
123
+ name: "agent-name"
124
+ description: "Agent description"
125
+ ---
126
+
127
+ [XML activation instructions and persona definition]
128
+
129
+ [Agent implementation content]
130
+ ```
131
+
132
+ Key sections:
133
+ - `<agent>` tag: Identifies the agent and its capabilities
134
+ - `<activation>`: Step-by-step instructions for activation
135
+ - `<rules>`: Behavioral guidelines
136
+ - `<persona>`: Role definition and communication style
137
+ - `<menu>`: Interactive menu items (optional)
138
+
139
+ See [log-analysis.md](log-analysis.md) or [log-it.md](log-it.md) for complete examples.
140
+
141
+ ## Distribution
142
+
143
+ Agents are distributed with each ecosystem:
144
+
145
+ - **Python**: Packaged in `drtrace_service.resources.agents` via pip
146
+ - **JavaScript**: Copied to `node_modules/drtrace/agents/` via npm
147
+ - **C++**: Installed alongside library via package manager
148
+
149
+ When you run `drtrace init-agent`, the agent spec is copied from the installed package location to your local project at `_drtrace/agents/`.
150
+
151
+ ## Contributing
152
+
153
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on:
154
+ - Creating new agents
155
+ - Testing agents across ecosystems
156
+ - Updating existing agents
157
+ - Documentation requirements
158
+
159
+ ## Maintenance
160
+
161
+ - **Version sync**: Agent files are versioned with each DrTrace release
162
+ - **Updates**: Agents are updated in main branch; new versions published with releases
163
+ - **Compatibility**: All agents must work across Python, JavaScript, and C++ ecosystems
164
+
165
+ ## References
166
+
167
+ - [Agent Implementation Guide](../_bmad-output/implementation-artifacts/log-it-agent-implementation-guide.md)
168
+ - [Agent Refactoring Plan](../_bmad-output/implementation-artifacts/agent-files-shared-resource-refactoring-plan.md)
169
+ - [DrTrace Documentation](../docs/overview.md)
170
+
171
+ ---
172
+
173
+ **Last Updated**: December 29, 2025
174
+ **Maintainer**: DrTrace Architecture Team