drtrace 0.3.0 → 0.5.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 (51) hide show
  1. package/README.md +45 -4
  2. package/agents/CONTRIBUTING.md +0 -0
  3. package/agents/README.md +0 -0
  4. package/agents/daemon-method-selection.md +126 -227
  5. package/agents/integration-guides/cpp-best-practices.md +0 -0
  6. package/agents/integration-guides/cpp-ros-integration.md +0 -0
  7. package/agents/log-analysis.md +3 -89
  8. package/agents/log-help.md +6 -79
  9. package/agents/log-init.md +4 -0
  10. package/agents/log-it.md +4 -0
  11. package/bin/cli.js +98 -0
  12. package/bin/init.js +0 -0
  13. package/dist/bin/cli.js +98 -0
  14. package/dist/browser.d.ts +28 -0
  15. package/dist/browser.js +91 -0
  16. package/dist/cli/grep.d.ts +27 -0
  17. package/dist/cli/grep.js +251 -0
  18. package/dist/cli/status.d.ts +11 -0
  19. package/dist/cli/status.js +78 -0
  20. package/dist/client.d.ts +0 -0
  21. package/dist/client.js +0 -0
  22. package/dist/config-schema.d.ts +0 -0
  23. package/dist/config-schema.js +0 -0
  24. package/dist/config.d.ts +0 -0
  25. package/dist/config.js +0 -0
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +2 -2
  28. package/dist/init.d.ts +2 -0
  29. package/dist/init.js +23 -18
  30. package/dist/logger.d.ts +7 -0
  31. package/dist/logger.js +30 -4
  32. package/dist/node.d.ts +13 -0
  33. package/dist/node.js +67 -0
  34. package/dist/queue.d.ts +0 -0
  35. package/dist/queue.js +0 -0
  36. package/dist/resources/agents/CONTRIBUTING.md +0 -0
  37. package/dist/resources/agents/README.md +0 -0
  38. package/dist/resources/agents/daemon-method-selection.md +126 -227
  39. package/dist/resources/agents/integration-guides/cpp-best-practices.md +0 -0
  40. package/dist/resources/agents/integration-guides/cpp-ros-integration.md +0 -0
  41. package/dist/resources/agents/log-analysis.md +3 -89
  42. package/dist/resources/agents/log-help.md +6 -79
  43. package/dist/resources/agents/log-init.md +4 -0
  44. package/dist/resources/agents/log-it.md +4 -0
  45. package/dist/resources/cpp/drtrace_sink.hpp +1 -0
  46. package/dist/transport.d.ts +0 -0
  47. package/dist/transport.js +5 -1
  48. package/dist/types.d.ts +8 -2
  49. package/dist/types.js +0 -0
  50. package/package.json +22 -5
  51. package/dist/bin/init.js +0 -31
@@ -1,83 +1,97 @@
1
1
  # Daemon Method Selection Guide
2
-
3
2
  **Purpose**: Guide for AI agents to choose the right method for daemon interaction.
3
+ **Key Principle**: For AI agents, prefer interaction with daemon in this order (most preferred to least, if a method is unavailable, fall back to the next):
4
+ - **CLI**: if available on client machine (check `## CLI Approach` below).
5
+ - **HTTP/curl**: for complex interactions without dependencies (check `## HTTP/curl Approach` below).
6
+ - **Python code**: when rich queries are needed (check `## Python code Approach` below).
7
+ ## CLI Approach
8
+ If `drtrace` CLI is installed on the client machine:
9
+ - Check with: `drtrace --version`
10
+ - Prefer CLI commands: `drtrace grep`, `drtrace tail`, `drtrace status`
11
+ - Benefit: no HTTP overhead and faster queries
12
+ ### Query Filter Rule: Mutually Exclusive
13
+ When querying logs, use **either** `message_contains` **or** `message_regex`, **NOT both**.
14
+
15
+ | Filter | Use Case | Example |
16
+ | ------------------ | ---------------- | --------------------------------------------- |
17
+ | `message_contains` | Substring search | "timeout" matches "Connection timeout error" |
18
+ | `message_regex` | Regex patterns | "(db\|cache).*timeout" matches service errors |
19
+ **Error if both used**: API returns 400 "Cannot use both filters".
20
+ ### Examples
21
+ **CLI - Substring Search**:
22
+ ```bash
23
+ drtrace grep "timeout" --since 1h
24
+ ```
25
+ **CLI - Regex Search** (with `-E`):
26
+ ```bash
27
+ drtrace grep -E "(db|cache).*timeout" --since 1h
28
+ ```
29
+ ## HTTP/curl Approach
30
+ ### Check Daemon Status
4
31
 
5
- **Key Principle**: For AI agents, prefer **HTTP/curl first** (simpler, no dependencies), then Python, then CLI.
6
-
7
- ---
8
-
9
- ## Priority Order for AI Agents
10
-
11
- | Priority | Method | When to Use |
12
- |----------|--------|-------------|
13
- | **1st** | HTTP/curl | Default - works without dependencies |
14
- | **2nd** | Python code | When rich SDK features needed |
15
- | **3rd** | CLI commands | Last resort - requires subprocess |
16
-
17
- ### Why HTTP-First for AI Agents?
18
-
19
- - **No dependencies**: Just HTTP requests - works in any environment
20
- - **Simpler**: curl commands are self-contained and portable
21
- - **Faster**: No import overhead or Python interpreter startup
22
- - **Universal**: Works from any language or tool
23
-
24
- ---
25
-
26
- ## Discovery First: OpenAPI Schema
27
-
32
+ ```bash
33
+ curl http://localhost:8001/status
34
+ ```
35
+ ### Discovery API via OpenAPI Schema
28
36
  **CRITICAL**: Before making any API call, fetch `/openapi.json` to discover:
29
37
  - Available endpoints
30
38
  - Correct field names (e.g., `ts` not `timestamp`)
31
39
  - Request/response schemas
32
-
33
40
  ```bash
34
41
  # Always fetch schema first
35
42
  curl http://localhost:8001/openapi.json
36
43
  ```
37
-
38
- ```python
39
- import requests
40
-
41
- base_url = "http://localhost:8001"
42
-
43
- # Fetch schema to discover endpoints and field names
44
- schema = requests.get(f"{base_url}/openapi.json", timeout=5).json()
45
- paths = schema.get("paths", {})
46
- components = schema.get("components", {}).get("schemas", {})
47
-
48
- # Use discovered field names, not hardcoded ones
44
+ ### Common Endpoints (for Quick Reference)
45
+ **Note**: Always verify via `/openapi.json` - this list is for reference only (*API field names can change between versions. Using OpenAPI ensures compatibility*).
46
+
47
+ | Endpoint | Method | Purpose |
48
+ | ---------------------- | ------ | -------------------- |
49
+ | `/status` | GET | Health check |
50
+ | `/openapi.json` | GET | API schema |
51
+ | `/logs/query` | GET | Query logs |
52
+ | `/logs/ingest` | POST | Ingest logs |
53
+ | `/analysis/why` | GET | Root cause analysis |
54
+ | `/analysis/time-range` | GET | Time range analysis |
55
+ | `/help/guide/start` | POST | Start setup guide |
56
+ | `/help/guide/current` | GET | Current setup step |
57
+ | `/help/troubleshoot` | POST | Troubleshooting help |
58
+ ### Examples
59
+ **HTTP - Substring Search**:
60
+ ```bash
61
+ curl "http://localhost:8001/logs/query?message_contains=timeout&since=1h"
49
62
  ```
50
-
51
- **Why this matters**: API field names can change between versions. Using OpenAPI ensures compatibility.
52
-
53
- ---
54
-
55
- ## Method 1: HTTP/curl (Preferred)
56
-
57
- ### Check Daemon Status
58
-
63
+ **HTTP - Regex Search**:
59
64
  ```bash
60
- curl http://localhost:8001/status
65
+ curl "http://localhost:8001/logs/query?message_regex=(db|cache).*timeout&since=1h"
61
66
  ```
62
-
63
- ### Query Logs
64
-
67
+ **HTTP - Query Logs**:
65
68
  ```bash
66
69
  # Get logs from last 5 minutes
67
70
  START_TS=$(python3 -c "import time; print(time.time() - 300)")
68
71
  END_TS=$(python3 -c "import time; print(time.time())")
69
-
70
72
  curl "http://localhost:8001/logs/query?start_ts=${START_TS}&end_ts=${END_TS}&application_id=myapp&limit=100"
71
73
  ```
72
-
73
- ### Root Cause Analysis
74
-
74
+ **HTTP - Query with filter**:
75
75
  ```bash
76
76
  curl "http://localhost:8001/analysis/why?application_id=myapp&start_ts=${START_TS}&end_ts=${END_TS}&min_level=ERROR"
77
77
  ```
78
+ ## Python code Approach
79
+ Use when you need rich SDK features or the HTTP method fails.
80
+ ### Examples
81
+ **Get OpenAPI json for API information**
82
+ ```python
83
+ import requests
78
84
 
79
- ### Python requests (HTTP method)
85
+ base_url = "http://localhost:8001"
86
+
87
+ # Fetch schema to discover endpoints and field names
88
+ schema = requests.get(f"{base_url}/openapi.json", timeout=5).json()
89
+ paths = schema.get("paths", {})
90
+ components = schema.get("components", {}).get("schemas", {})
80
91
 
92
+ # Use discovered field names, not hardcoded ones
93
+ ```
94
+ **Python requests (HTTP method)**
81
95
  ```python
82
96
  import requests
83
97
  import time
@@ -109,190 +123,75 @@ for log in logs:
109
123
  level = log.get("level")
110
124
  message = log.get("message")
111
125
  ```
126
+ ## When to Use Each Method
112
127
 
113
- ---
114
-
115
- ## Method 2: Python Code (Fallback)
116
-
117
- Use when you need rich SDK features or the HTTP method fails.
118
-
119
- ### Log Analysis
120
-
121
- ```python
122
- from drtrace_service.agent_interface import process_agent_query, check_daemon_status
123
- import asyncio
124
-
125
- # Check daemon first
126
- status = await check_daemon_status()
127
- if not status.get("available"):
128
- print("Daemon not available")
129
-
130
- # Process query - returns formatted markdown
131
- response = await process_agent_query("explain error from 9:00 to 10:00 for app myapp")
132
- print(response)
133
-
134
- # Non-async context
135
- response = asyncio.run(process_agent_query("show logs from last 5 minutes"))
136
- ```
137
-
138
- ### Setup Help
139
-
140
- ```python
141
- from drtrace_service.help_agent_interface import (
142
- start_setup_guide,
143
- get_current_step,
144
- complete_step,
145
- troubleshoot,
146
- )
147
- from pathlib import Path
148
- import asyncio
149
-
150
- project_root = Path(".")
151
-
152
- # Start setup guide
153
- guide = await start_setup_guide(language="python", project_root=project_root)
154
-
155
- # Get current step
156
- current = await get_current_step(project_root=project_root)
157
-
158
- # Mark step complete
159
- next_step = await complete_step(step_number=1, project_root=project_root)
160
-
161
- # Troubleshoot
162
- help_text = await troubleshoot("daemon not connecting", project_root=project_root)
163
- ```
164
-
165
- ### Setup Suggestions
166
-
128
+ | Scenario | Recommended Method |
129
+ | ----------------------------- | ------------------ |
130
+ | Simple queries (status, logs) | CLI, HTTP/curl |
131
+ | Complex analysis | HTTP or Python |
132
+ | Rich markdown output needed | Python SDK |
133
+ | Running outside Python | CLI, HTTP/curl |
134
+ | Setup guide interaction | Python SDK |
135
+ | Debugging integration | CLI commands |
136
+ | Script automation | CLI, HTTP/curl |
137
+ ## Important Notes
138
+ ### Timestamps Are UTC
139
+ All timestamps in DrTrace API are **UTC Unix timestamps**:
140
+
141
+ | Field/Param | Format | Timezone |
142
+ | -------------------- | -------------------- | -------- |
143
+ | `ts` (in logs) | Unix float | UTC |
144
+ | `start_ts`, `end_ts` | Unix float | UTC |
145
+ | `since`, `until` | Relative or ISO 8601 | UTC |
146
+ **Key Rules**:
147
+ - ISO 8601 without timezone (e.g., `2025-12-31T02:44:03`) is interpreted as **UTC**, not local time
148
+ - Relative times (`5m`, `1h`) are relative to server's current UTC time
149
+ - To query with local time, include timezone offset: `2025-12-31T09:44:03+07:00`
150
+ #### Converting Local Time to UTC
151
+ **Python:**
167
152
  ```python
168
- from drtrace_service.setup_agent_interface import analyze_and_suggest, suggest_for_language
169
- from pathlib import Path
170
- import asyncio
153
+ from datetime import datetime, timezone, timedelta
171
154
 
172
- project_root = Path(".")
155
+ # Local time (e.g., 2025-12-31 09:44:03 in GMT+7)
156
+ local_time = datetime(2025, 12, 31, 9, 44, 3)
173
157
 
174
- # Get setup suggestions
175
- suggestions = await analyze_and_suggest(project_root)
158
+ # Method 1: If you know your timezone offset
159
+ local_tz = timezone(timedelta(hours=7)) # GMT+7
160
+ local_aware = local_time.replace(tzinfo=local_tz)
161
+ utc_time = local_aware.astimezone(timezone.utc)
162
+ unix_ts = utc_time.timestamp()
163
+ print(f"UTC Unix timestamp: {unix_ts}")
176
164
 
177
- # Language-specific suggestions
178
- python_suggestions = await suggest_for_language("python", project_root)
179
- cpp_suggestions = await suggest_for_language("cpp", project_root)
165
+ # Method 2: Using system timezone
166
+ import time
167
+ unix_ts = time.mktime(local_time.timetuple())
180
168
  ```
181
-
182
- ---
183
-
184
- ## Method 3: CLI Commands (Last Resort)
185
-
186
- Use only when HTTP and Python methods are unavailable.
187
-
188
- ### Check Status
189
-
169
+ **Bash:**
190
170
  ```bash
191
- python -m drtrace_service status
192
- ```
193
-
194
- ### Analyze Errors
171
+ # Convert local time to Unix timestamp
172
+ date -d "2025-12-31 09:44:03" +%s
195
173
 
196
- ```bash
197
- python -m drtrace_service why --application-id myapp --since 5m --min-level ERROR
174
+ # Convert with explicit timezone
175
+ TZ=UTC date -d "2025-12-31T02:44:03" +%s
198
176
  ```
199
-
200
- ### Setup Help
201
-
177
+ #### API Query Examples with Timezone
202
178
  ```bash
203
- python -m drtrace_service help guide start --language python --project-root /path/to/project
204
- python -m drtrace_service help guide current --project-root /path/to/project
205
- ```
179
+ # Option 1: Include timezone in ISO 8601 (recommended for local time)
180
+ curl "http://localhost:8001/logs/query?since=2025-12-31T09:44:03%2B07:00"
206
181
 
207
- ---
208
-
209
- ## Error Handling and Fallback Chain
182
+ # Option 2: Use relative time (always relative to server UTC time)
183
+ curl "http://localhost:8001/logs/query?since=5m"
210
184
 
211
- ```python
212
- import requests
185
+ # Option 3: Convert to UTC Unix timestamp first
186
+ UTC_TS=$(TZ=UTC date -d "2025-12-31T02:44:03" +%s)
187
+ curl "http://localhost:8001/logs/query?start_ts=$UTC_TS"
213
188
 
214
- def interact_with_daemon(query: str) -> str:
215
- """Try methods in order: HTTP -> Python -> CLI"""
216
- base_url = "http://localhost:8001"
217
-
218
- # Method 1: HTTP (Preferred)
219
- try:
220
- # Check status first
221
- status = requests.get(f"{base_url}/status", timeout=2)
222
- if status.status_code == 200:
223
- # Make actual request...
224
- return "Success via HTTP"
225
- except requests.exceptions.RequestException:
226
- pass # Fall through to Python
227
-
228
- # Method 2: Python (Fallback)
229
- try:
230
- from drtrace_service.agent_interface import process_agent_query
231
- import asyncio
232
- response = asyncio.run(process_agent_query(query))
233
- return response
234
- except ImportError:
235
- pass # Fall through to CLI
236
-
237
- # Method 3: CLI (Last Resort)
238
- import subprocess
239
- result = subprocess.run(
240
- ["python", "-m", "drtrace_service", "status"],
241
- capture_output=True,
242
- text=True
243
- )
244
- if result.returncode == 0:
245
- return result.stdout
246
-
247
- # All methods failed
248
- return """
249
- Daemon is not available.
250
-
251
- Next Steps:
252
- 1. Start daemon: python -m drtrace_service
253
- 2. Verify: curl http://localhost:8001/status
254
- """
189
+ # Option 4: Use ISO 8601 in UTC (note: no timezone = UTC)
190
+ curl "http://localhost:8001/logs/query?since=2025-12-31T02:44:03"
255
191
  ```
256
-
192
+ #### Common Timezone Pitfalls
193
+ 1. **ISO 8601 Without Timezone**: Interpreted as UTC, not local time. If you pass `2025-12-31T09:44:03` thinking it's local 9:44 AM, it will be treated as 9:44 AM UTC.
194
+ 2. **Server vs Client Timezone**: If your server is in a different timezone than your client, always use explicit UTC timestamps or include timezone offsets.
195
+ 3. **Relative Times**: `since=5m` means 5 minutes before server's current UTC time, regardless of your local timezone.
257
196
  ---
258
-
259
- ## When to Use Each Method
260
-
261
- | Scenario | Recommended Method |
262
- |----------|-------------------|
263
- | Simple queries (status, logs) | HTTP/curl |
264
- | Complex analysis | HTTP or Python |
265
- | Rich markdown output needed | Python SDK |
266
- | Running outside Python | HTTP/curl |
267
- | Setup guide interaction | Python SDK |
268
- | Debugging integration | CLI commands |
269
- | Script automation | HTTP/curl |
270
-
271
- ---
272
-
273
- ## Quick Reference: Common Endpoints
274
-
275
- **Note**: Always verify via `/openapi.json` - this list is for reference only.
276
-
277
- | Endpoint | Method | Purpose |
278
- |----------|--------|---------|
279
- | `/status` | GET | Health check |
280
- | `/openapi.json` | GET | API schema |
281
- | `/logs/query` | GET | Query logs |
282
- | `/logs/ingest` | POST | Ingest logs |
283
- | `/analysis/why` | GET | Root cause analysis |
284
- | `/analysis/time-range` | GET | Time range analysis |
285
- | `/help/guide/start` | POST | Start setup guide |
286
- | `/help/guide/current` | GET | Current setup step |
287
- | `/help/troubleshoot` | POST | Troubleshooting help |
288
-
289
- ---
290
-
291
- ## Related Documentation
292
-
293
- - `docs/daemon-interaction-guide.md` - OpenAPI discovery details
294
- - `docs/api-reference.md` - Complete API reference
295
-
296
- ---
297
-
298
- **Last Updated**: 2025-12-29
197
+ **Last Updated**: 2026-01-06
@@ -11,26 +11,7 @@ You must fully embody this agent's persona and follow all activation instruction
11
11
  <step n="1">Load persona from this current agent file (already in context)</step>
12
12
  <step n="2">Remember: You are a Log Analysis Specialist</step>
13
13
  <step n="3">READ the entire story file BEFORE any analysis - understand the query parsing rules</step>
14
- <step n="4">When processing a user query, try methods in this order:
15
-
16
- **Method 1 (Preferred)**: Python code
17
- - Try: `from drtrace_service.agent_interface import process_agent_query, check_daemon_status`
18
- - If import succeeds: Use `response = await process_agent_query(user_query)` or `asyncio.run(process_agent_query(user_query))`
19
- - Return the response string directly (it's already formatted markdown)
20
-
21
- **Method 2 (Fallback)**: HTTP API
22
- - If Python import fails: Use HTTP requests to call DrTrace API endpoints
23
- - **CRITICAL**: First fetch `/openapi.json` to discover field names (e.g., timestamp is `ts`, NOT `timestamp`)
24
- - Check status: `GET http://localhost:8001/status`
25
- - For analysis: `GET http://localhost:8001/analysis/why?application_id=X&start_ts=Y&end_ts=Z`
26
- - Parse the JSON response using field names from OpenAPI schema
27
-
28
- **Method 3 (Last resort)**: CLI commands
29
- - If both Python and HTTP fail: Execute `python -m drtrace_service why --application-id X --since 5m`
30
- - Parse the CLI output and format for the user
31
-
32
- **Important**: Always check daemon status first. If daemon is unavailable, return clear error message with next steps.
33
- </step>
14
+ <step n="4">When processing a user query, check `agents/daemon-method-selection.md` for details.</step>
34
15
  <step n="5">If information is missing, ask the user for clarification with helpful suggestions</step>
35
16
  <step n="6">If daemon is unavailable, provide clear error message and next steps</step>
36
17
  <step n="7">Show greeting, then display numbered list of ALL menu items from menu section</step>
@@ -65,77 +46,12 @@ You must fully embody this agent's persona and follow all activation instruction
65
46
 
66
47
  **Priority Order**: HTTP/curl (preferred) → Python SDK → CLI (last resort)
67
48
 
68
- ### Quick Reference: Analysis API Operations
69
-
70
- | Operation | HTTP (Preferred) | Python SDK |
71
- |-----------|------------------|------------|
72
- | Query logs | `GET /logs/query` | `process_agent_query("show logs...")` |
73
- | Root cause | `GET /analysis/why` | `process_agent_query("explain error...")` |
74
- | Check status | `GET /status` | `check_daemon_status()` |
75
-
76
- ### HTTP/curl Examples (Preferred)
77
-
78
- ```bash
79
- # Check daemon status
80
- curl http://localhost:8001/status
81
-
82
- # Query logs from last 5 minutes
83
- START_TS=$(python3 -c "import time; print(time.time() - 300)")
84
- END_TS=$(python3 -c "import time; print(time.time())")
85
-
86
- curl "http://localhost:8001/logs/query?start_ts=${START_TS}&end_ts=${END_TS}&application_id=myapp&limit=100"
87
-
88
- # Root cause analysis
89
- curl "http://localhost:8001/analysis/why?application_id=myapp&start_ts=${START_TS}&end_ts=${END_TS}&min_level=ERROR"
90
- ```
91
-
92
- ### Python SDK Examples (Fallback)
93
-
94
- ```python
95
- from drtrace_service.agent_interface import process_agent_query, check_daemon_status
96
- import asyncio
97
-
98
- # Check daemon first
99
- status = await check_daemon_status()
100
- if not status.get("available"):
101
- print("Daemon not available")
102
-
103
- # Process query - returns formatted markdown
104
- response = await process_agent_query("explain error from 9:00 to 10:00 for app myapp")
105
-
106
- # Non-async context
107
- response = asyncio.run(process_agent_query("show logs from last 5 minutes"))
108
- ```
109
-
110
49
  **Key Points:**
111
50
  - **Package**: `drtrace_service` (NOT `drtrace_client`)
112
51
  - **Returns**: Formatted markdown string ready to display
113
52
  - **Async**: Functions are async, use `await` or `asyncio.run()`
114
53
 
115
- ### Fallback Strategy
116
-
117
- 1. **HTTP/curl (Preferred)**: Simple, no dependencies
118
- 2. **Python SDK (Fallback)**: Rich async features when HTTP unavailable
119
- 3. **CLI (Last Resort)**: `python -m drtrace_service why ...`
120
-
121
- **Important**: Always fetch `/openapi.json` first when using HTTP to discover correct field names (e.g., `ts` not `timestamp`).
122
-
123
- See `agents/daemon-method-selection.md` for complete fallback implementation.
124
-
125
- ### Quick Reference: Endpoints
126
-
127
- | Endpoint | Purpose |
128
- |----------|---------|
129
- | `GET /status` | Health check |
130
- | `GET /logs/query` | Query logs |
131
- | `GET /analysis/why` | Root cause analysis |
132
- | `GET /analysis/time-range` | Time range analysis |
133
- | `GET /analysis/cross-module` | Cross-module analysis |
134
-
135
- **Parameters** (verify via `/openapi.json`):
136
- - `start_ts`, `end_ts`: Unix timestamps (floats)
137
- - `min_level`: DEBUG, INFO, WARN, ERROR, CRITICAL
138
- - `limit`: defaults to 100, max 1000
54
+ **Best Practice**: See `docs/agent-design-best-practices.md` → "DrTrace Query Constraints" for detailed guidance.
139
55
 
140
56
  <menu>
141
57
  <item cmd="*analyze">[A] Analyze logs for a time range</item>
@@ -212,6 +128,4 @@ See `agents/daemon-method-selection.md` for complete fallback implementation.
212
128
 
213
129
  </capabilities>
214
130
  </agent>
215
- ```
216
-
217
-
131
+ ```
@@ -11,7 +11,7 @@ You must fully embody this agent's persona and follow all activation instruction
11
11
  <step n="1">Load persona from this current agent file (already in context)</step>
12
12
  <step n="2">Remember: You are a Setup Guide Assistant for DrTrace</step>
13
13
  <step n="3">Your primary mission is to walk users through DrTrace setup step-by-step using the help APIs and setup guide, not to guess or skip steps</step>
14
- <step n="4">ALWAYS prefer Method 1 (Python help APIs) then Method 2 (HTTP help endpoints) → then Method 3 (CLI) in that exact order</step>
14
+ <step n="4">When processing a user query, check `agents/daemon-method-selection.md` for details.</step>
15
15
  <step n="5">For each user interaction, clearly state the current step, what to do next, and how to verify it worked</step>
16
16
  <step n="6">When calling help APIs, use:
17
17
  - `start_setup_guide(language, project_root)` to begin or restart a guide
@@ -32,7 +32,7 @@ You must fully embody this agent's persona and follow all activation instruction
32
32
  <r>NEVER skip verification or pretend steps are complete; use the setup guide and help APIs as the source of truth</r>
33
33
  <r>ALWAYS explain what you are doing when progressing steps or troubleshooting issues</r>
34
34
  <r>Display menu items exactly as defined in the menu section and in the order given</r>
35
- <r>Prefer Python APIs, then HTTP endpoints, then CLI in that order; explain fallbacks when switching methods</r>
35
+ <r>Prefer HTTP/curl, then Python SDK, then CLI in that order; explain fallbacks when switching methods</r>
36
36
  </rules>
37
37
  </activation>
38
38
 
@@ -50,6 +50,10 @@ You must fully embody this agent's persona and follow all activation instruction
50
50
  </principles>
51
51
  </persona>
52
52
 
53
+ ## CLI Availability & Filters
54
+
55
+ See [agents/daemon-method-selection.md](agents/daemon-method-selection.md) for CLI availability guidance and the mutually exclusive `message_contains` vs `message_regex` rule (includes CLI/HTTP examples).
56
+
53
57
  <menu title="How can I guide your DrTrace setup?">
54
58
  <item cmd="S" hotkey="S" name="Start setup guide">
55
59
  Begin or restart the step-by-step setup guide for a specific language.
@@ -92,83 +96,6 @@ You must fully embody this agent's persona and follow all activation instruction
92
96
  </agent>
93
97
  ```
94
98
 
95
- ## How to Use DrTrace Help APIs
96
-
97
- **Reference**: See `agents/daemon-method-selection.md` for complete method selection guide.
98
-
99
- **Priority Order**: HTTP/curl (preferred) → Python SDK → CLI (last resort)
100
-
101
- ### Quick Reference: Help API Operations
102
-
103
- | Operation | HTTP (Preferred) | Python SDK |
104
- |-----------|------------------|------------|
105
- | Start guide | `POST /help/guide/start` | `start_setup_guide(language, project_root)` |
106
- | Current step | `GET /help/guide/current` | `get_current_step(project_root)` |
107
- | Complete step | `POST /help/guide/complete` | `complete_step(step_number, project_root)` |
108
- | Troubleshoot | `POST /help/troubleshoot` | `troubleshoot(issue, project_root)` |
109
-
110
- ### HTTP/curl Examples (Preferred)
111
-
112
- ```bash
113
- # Start setup guide
114
- curl -X POST http://localhost:8001/help/guide/start \
115
- -H "Content-Type: application/json" \
116
- -d '{"language": "python", "project_root": "/path/to/project"}'
117
-
118
- # Get current step
119
- curl "http://localhost:8001/help/guide/current?project_root=/path/to/project"
120
-
121
- # Mark step complete
122
- curl -X POST http://localhost:8001/help/guide/complete \
123
- -H "Content-Type: application/json" \
124
- -d '{"step_number": 1, "project_root": "/path/to/project"}'
125
-
126
- # Troubleshoot
127
- curl -X POST http://localhost:8001/help/troubleshoot \
128
- -H "Content-Type: application/json" \
129
- -d '{"issue": "daemon not connecting", "project_root": "/path/to/project"}'
130
- ```
131
-
132
- ### Python SDK Examples (Fallback)
133
-
134
- ```python
135
- from pathlib import Path
136
- from drtrace_service.help_agent_interface import (
137
- start_setup_guide,
138
- get_current_step,
139
- complete_step,
140
- troubleshoot,
141
- )
142
- import asyncio
143
-
144
- project_root = Path(".")
145
-
146
- # Start guide
147
- guide = await start_setup_guide(language="python", project_root=project_root)
148
-
149
- # Get current step
150
- current = await get_current_step(project_root=project_root)
151
-
152
- # Complete step
153
- next_step = await complete_step(step_number=1, project_root=project_root)
154
-
155
- # Troubleshoot
156
- help_text = await troubleshoot("daemon not connecting", project_root=project_root)
157
-
158
- # Non-async context
159
- guide = asyncio.run(start_setup_guide(language="python", project_root=project_root))
160
- ```
161
-
162
- ### Fallback Strategy
163
-
164
- 1. **HTTP/curl (Preferred)**: Simple, no dependencies, works everywhere
165
- 2. **Python SDK (Fallback)**: Rich async features when HTTP unavailable
166
- 3. **CLI (Last Resort)**: `python -m drtrace_service help guide ...`
167
-
168
- **Important**: Always fetch `/openapi.json` first when using HTTP to discover correct endpoints and field names.
169
-
170
- See `agents/daemon-method-selection.md` for complete fallback implementation.
171
-
172
99
  ## Activation Instructions
173
100
 
174
101
  To activate the `log-help` agent in a project:
@@ -30,6 +30,10 @@ You must fully embody this agent's persona and follow all activation instruction
30
30
  </activation>
31
31
 
32
32
  <persona>
33
+
34
+ ## CLI Availability & Filters
35
+
36
+ See [agents/daemon-method-selection.md](agents/daemon-method-selection.md) for CLI availability guidance and the mutually exclusive `message_contains` vs `message_regex` rule (includes CLI/HTTP examples).
33
37
  <role>Setup Specialist</role>
34
38
  <identity>Expert at analyzing project structures and suggesting intelligent DrTrace integration. Reads source files directly to understand project organization, build systems, and existing logging. Provides language-specific setup suggestions with minimal impact on existing code.</identity>
35
39
  <communication_style>Clear and educational. Reads and analyzes project files before suggesting setup. Explains reasoning for each suggestion. Provides structured responses with code examples. Ensures suggestions are non-destructive and compatible with existing setup.</communication_style>
@@ -52,6 +52,10 @@ You must fully embody this agent's persona and follow all activation instruction
52
52
  </principles>
53
53
  </persona>
54
54
 
55
+ ## CLI Availability & Filters
56
+
57
+ See [agents/daemon-method-selection.md](agents/daemon-method-selection.md) for CLI availability guidance and the mutually exclusive `message_contains` vs `message_regex` rule (includes CLI/HTTP examples).
58
+
55
59
  <menu title="What can I help you log?">
56
60
  <item cmd="L" hotkey="L" name="Log this function">
57
61
  Analyze a specific function and suggest strategic logging points.
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  #pragma once
9
+ #define DRTRACE_VERSION "0.5.0"
9
10
 
10
11
  // Standard library includes required for header-only implementation
11
12
  #include <atomic>
File without changes