knowzcode 0.3.6 → 0.4.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.
- package/.claude-plugin/marketplace.json +61 -61
- package/.claude-plugin/plugin.json +8 -8
- package/LICENSE +121 -121
- package/README.md +354 -320
- package/agents/analyst.md +114 -114
- package/agents/architect.md +200 -200
- package/agents/builder.md +104 -104
- package/agents/closer.md +177 -95
- package/agents/context-scout.md +54 -54
- package/agents/knowledge-migrator.md +349 -349
- package/agents/knowz-scout.md +83 -83
- package/agents/knowz-scribe.md +180 -180
- package/agents/microfix-specialist.md +135 -135
- package/agents/project-advisor.md +111 -111
- package/agents/reviewer.md +172 -172
- package/agents/security-officer.md +194 -194
- package/agents/test-advisor.md +162 -162
- package/agents/update-coordinator.md +394 -394
- package/bin/knowzcode.mjs +1199 -956
- package/commands/audit.md +328 -328
- package/commands/connect-mcp.md +549 -549
- package/commands/fix.md +107 -107
- package/commands/init.md +500 -439
- package/commands/learn.md +332 -332
- package/commands/plan.md +272 -272
- package/commands/register.md +733 -733
- package/commands/status.md +309 -309
- package/commands/telemetry-setup.md +368 -368
- package/commands/telemetry.md +188 -188
- package/commands/work.md +1204 -1170
- package/knowzcode/automation_manifest.md +59 -59
- package/knowzcode/claude_code_execution.md +431 -420
- package/knowzcode/copilot_execution.md +231 -231
- package/knowzcode/enterprise/compliance_manifest.md +137 -137
- package/knowzcode/enterprise/compliance_status.md +30 -30
- package/knowzcode/enterprise/guidelines/code-quality.md +67 -67
- package/knowzcode/enterprise/guidelines/security.md +355 -355
- package/knowzcode/enterprise/templates/guideline-template.md +55 -55
- package/knowzcode/gitignore.template +13 -13
- package/knowzcode/knowzcode_architecture.md +51 -51
- package/knowzcode/knowzcode_log.md +142 -142
- package/knowzcode/knowzcode_loop.md +596 -593
- package/knowzcode/knowzcode_orchestration.md +66 -66
- package/knowzcode/knowzcode_project.md +48 -48
- package/knowzcode/knowzcode_tracker.md +40 -40
- package/knowzcode/knowzcode_vaults.md +257 -257
- package/knowzcode/mcp_config.md +191 -191
- package/knowzcode/planning/Readme.md +6 -6
- package/knowzcode/platform_adapters.md +1260 -1047
- package/knowzcode/prompts/Execute_Micro_Fix.md +57 -57
- package/knowzcode/prompts/Investigate_Codebase.md +227 -227
- package/knowzcode/prompts/Migrate_Knowledge.md +301 -301
- package/knowzcode/prompts/Refactor_Node.md +72 -72
- package/knowzcode/prompts/Spec_Verification_Checkpoint.md +59 -59
- package/knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md +52 -52
- package/knowzcode/prompts/[LOOP_1B]__Draft_Specs.md +75 -75
- package/knowzcode/prompts/[LOOP_2A]__Implement_Change_Set.md +55 -55
- package/knowzcode/prompts/[LOOP_2B]__Verify_Implementation.md +72 -72
- package/knowzcode/prompts/[LOOP_3]__Finalize_And_Commit.md +67 -67
- package/knowzcode/specs/Readme.md +10 -10
- package/knowzcode/telemetry_config.md +89 -89
- package/knowzcode/user_preferences.md +120 -120
- package/package.json +53 -53
- package/skills/alias-resolver.json +15 -15
- package/skills/architecture-diff.json +12 -12
- package/skills/check-installation-status.json +14 -14
- package/skills/continue.md +126 -126
- package/skills/environment-guard.json +12 -12
- package/skills/generate-workgroup-id.json +25 -25
- package/skills/install-knowzcode.json +21 -21
- package/skills/load-core-context.json +18 -18
- package/skills/log-entry-builder.json +15 -15
- package/skills/spec-quality-check.json +14 -14
- package/skills/spec-template.json +15 -15
- package/skills/spec-validator.json +25 -25
- package/skills/start-work.md +224 -224
- package/skills/tracker-scan.json +12 -12
- package/skills/tracker-update.json +28 -28
- package/skills/validate-installation.json +14 -14
|
@@ -1,368 +1,368 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: "Configure telemetry sources (Sentry, App Insights) for /kc:telemetry"
|
|
3
|
-
argument-hint: "[sentry|appinsights|all]"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# KnowzCode Telemetry Setup
|
|
7
|
-
|
|
8
|
-
Configure telemetry sources for `/kc:telemetry` investigations.
|
|
9
|
-
|
|
10
|
-
**Usage**: `/kc:telemetry-setup [scope]`
|
|
11
|
-
|
|
12
|
-
| Scope | Description |
|
|
13
|
-
|-------|-------------|
|
|
14
|
-
| `all` | Configure all detected sources (default) |
|
|
15
|
-
| `sentry` | Configure Sentry only |
|
|
16
|
-
| `appinsights` | Configure Azure App Insights only |
|
|
17
|
-
|
|
18
|
-
**Examples**:
|
|
19
|
-
```
|
|
20
|
-
/kc:telemetry-setup
|
|
21
|
-
/kc:telemetry-setup sentry
|
|
22
|
-
/kc:telemetry-setup appinsights
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Workflow
|
|
28
|
-
|
|
29
|
-
### Step 1: Detect Available Tools
|
|
30
|
-
|
|
31
|
-
Check which telemetry tools are available. **CLI is preferred when properly configured; MCP is a fallback.**
|
|
32
|
-
|
|
33
|
-
#### 1.1 Check Sentry CLI (Preferred)
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
# Check Sentry CLI installation
|
|
37
|
-
which sentry-cli 2>/dev/null && echo "SENTRY_CLI_INSTALLED" || echo "NO_SENTRY_CLI"
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
If installed, verify authentication:
|
|
41
|
-
```bash
|
|
42
|
-
# Verify Sentry CLI is authenticated
|
|
43
|
-
sentry-cli info 2>&1 | grep -q "Organization" && echo "SENTRY_AUTHENTICATED" || echo "SENTRY_NOT_AUTHENTICATED"
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
**If Sentry CLI installed + authenticated → use CLI method, skip MCP check for Sentry.**
|
|
47
|
-
|
|
48
|
-
#### 1.2 Check Sentry MCP (Fallback)
|
|
49
|
-
|
|
50
|
-
**Only check MCP if CLI is not available or not authenticated.**
|
|
51
|
-
|
|
52
|
-
Attempt to detect MCP by checking if Sentry MCP tools respond. The agent should:
|
|
53
|
-
1. Try to use `sentry_search_issues` or `mcp__sentry__search_issues` with a minimal test query
|
|
54
|
-
2. If it responds (even with "no results") → MCP is available
|
|
55
|
-
3. If it errors with "tool not found" → MCP not configured
|
|
56
|
-
|
|
57
|
-
**If MCP available → use MCP method for Sentry.**
|
|
58
|
-
|
|
59
|
-
#### 1.3 Check Azure CLI + App Insights
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
# Check Azure CLI
|
|
63
|
-
which az 2>/dev/null && echo "AZURE_CLI_INSTALLED" || echo "NO_AZURE_CLI"
|
|
64
|
-
|
|
65
|
-
# Check App Insights extension
|
|
66
|
-
az extension list --query "[?name=='application-insights'].name" -o tsv 2>/dev/null || echo "NO_APPINSIGHTS_EXTENSION"
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
**Report detected tools and methods** before proceeding:
|
|
70
|
-
|
|
71
|
-
```markdown
|
|
72
|
-
**Detection Results:**
|
|
73
|
-
|
|
74
|
-
| Source | Status | Method |
|
|
75
|
-
|--------|--------|--------|
|
|
76
|
-
| Sentry | ✓ Available | CLI (preferred) |
|
|
77
|
-
| App Insights | ✓ Available | CLI |
|
|
78
|
-
|
|
79
|
-
or
|
|
80
|
-
|
|
81
|
-
| Source | Status | Method |
|
|
82
|
-
|--------|--------|--------|
|
|
83
|
-
| Sentry | ✓ Available | MCP (CLI not configured) |
|
|
84
|
-
| App Insights | ✗ Not available | - |
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Step 2: Verify Authentication
|
|
88
|
-
|
|
89
|
-
For each installed tool, verify authentication:
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
# Sentry: Check if authenticated
|
|
93
|
-
sentry-cli info 2>&1 | head -5
|
|
94
|
-
|
|
95
|
-
# Azure: Check if authenticated
|
|
96
|
-
az account show --query "{name:name, user:user.name}" -o table 2>&1 | head -5
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
**If not authenticated**, provide setup instructions and stop for that source:
|
|
100
|
-
|
|
101
|
-
**For Sentry**:
|
|
102
|
-
```markdown
|
|
103
|
-
⚠️ Sentry CLI is installed but not authenticated.
|
|
104
|
-
|
|
105
|
-
Run these commands to authenticate:
|
|
106
|
-
\`\`\`bash
|
|
107
|
-
sentry-cli login
|
|
108
|
-
# OR set the auth token directly
|
|
109
|
-
export SENTRY_AUTH_TOKEN="your-token-here"
|
|
110
|
-
\`\`\`
|
|
111
|
-
|
|
112
|
-
Then run `/kc:telemetry-setup sentry` again.
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
**For Azure**:
|
|
116
|
-
```markdown
|
|
117
|
-
⚠️ Azure CLI is installed but not authenticated.
|
|
118
|
-
|
|
119
|
-
Run these commands to authenticate:
|
|
120
|
-
\`\`\`bash
|
|
121
|
-
az login
|
|
122
|
-
az extension add --name application-insights # If not installed
|
|
123
|
-
\`\`\`
|
|
124
|
-
|
|
125
|
-
Then run `/kc:telemetry-setup appinsights` again.
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Step 3: Auto-Discover Resources
|
|
129
|
-
|
|
130
|
-
For each authenticated source, discover available resources:
|
|
131
|
-
|
|
132
|
-
**Sentry**:
|
|
133
|
-
```bash
|
|
134
|
-
# List organizations
|
|
135
|
-
sentry-cli organizations list 2>/dev/null
|
|
136
|
-
|
|
137
|
-
# List projects (for each org)
|
|
138
|
-
sentry-cli projects list --org {org-slug} 2>/dev/null
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
**Azure App Insights**:
|
|
142
|
-
```bash
|
|
143
|
-
# List all App Insights resources
|
|
144
|
-
az monitor app-insights component list \
|
|
145
|
-
--query "[].{name:name, appId:appId, resourceGroup:resourceGroup}" \
|
|
146
|
-
-o table 2>/dev/null
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
**Report discovered resources** in a clear format.
|
|
150
|
-
|
|
151
|
-
### Step 4: Interactive Configuration
|
|
152
|
-
|
|
153
|
-
Present discovered resources and ask user to map environments:
|
|
154
|
-
|
|
155
|
-
```markdown
|
|
156
|
-
## Discovered Resources
|
|
157
|
-
|
|
158
|
-
### Sentry Projects
|
|
159
|
-
| # | Organization | Project |
|
|
160
|
-
|---|--------------|---------|
|
|
161
|
-
| 1 | my-company | backend-api |
|
|
162
|
-
| 2 | my-company | frontend-web |
|
|
163
|
-
| 3 | my-company | worker-service |
|
|
164
|
-
|
|
165
|
-
### App Insights Resources
|
|
166
|
-
| # | Name | App ID | Resource Group |
|
|
167
|
-
|---|------|--------|----------------|
|
|
168
|
-
| 1 | appinsights-prod | abc-123-def | rg-production |
|
|
169
|
-
| 2 | appinsights-staging | ghi-456-jkl | rg-staging |
|
|
170
|
-
| 3 | appinsights-dev | mno-789-pqr | rg-development |
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
**Please map each environment to a resource:**
|
|
175
|
-
|
|
176
|
-
For Sentry:
|
|
177
|
-
- Production → (enter project number or skip)
|
|
178
|
-
- Staging → (enter project number or skip)
|
|
179
|
-
- Dev → (enter project number or skip)
|
|
180
|
-
|
|
181
|
-
For App Insights:
|
|
182
|
-
- Production → (enter resource number or skip)
|
|
183
|
-
- Staging → (enter resource number or skip)
|
|
184
|
-
- Dev → (enter resource number or skip)
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
Use the AskUserQuestion tool to collect mappings if multiple resources exist.
|
|
188
|
-
|
|
189
|
-
### Step 5: Save Configuration
|
|
190
|
-
|
|
191
|
-
Update `knowzcode/telemetry_config.md` with the discovered and mapped values.
|
|
192
|
-
|
|
193
|
-
**Include the detection method** (cli or mcp) for each source.
|
|
194
|
-
|
|
195
|
-
**Example result** (CLI method):
|
|
196
|
-
|
|
197
|
-
```markdown
|
|
198
|
-
## Sentry
|
|
199
|
-
|
|
200
|
-
| Field | Value |
|
|
201
|
-
|-------|-------|
|
|
202
|
-
| Enabled | true |
|
|
203
|
-
| Method | cli |
|
|
204
|
-
| Organization | my-company |
|
|
205
|
-
|
|
206
|
-
### Environment Mapping
|
|
207
|
-
|
|
208
|
-
| Environment | Project |
|
|
209
|
-
|-------------|---------|
|
|
210
|
-
| production | my-company/backend-api |
|
|
211
|
-
| staging | my-company/backend-staging |
|
|
212
|
-
| dev | my-company/backend-dev |
|
|
213
|
-
|
|
214
|
-
## Azure Application Insights
|
|
215
|
-
|
|
216
|
-
| Field | Value |
|
|
217
|
-
|-------|-------|
|
|
218
|
-
| Enabled | true |
|
|
219
|
-
| Subscription | 12345678-1234-1234-1234-123456789012 |
|
|
220
|
-
| Resource Group | rg-production |
|
|
221
|
-
|
|
222
|
-
### Environment Mapping
|
|
223
|
-
|
|
224
|
-
| Environment | App Name | App ID |
|
|
225
|
-
|-------------|----------|--------|
|
|
226
|
-
| production | appinsights-prod | abc-123-def |
|
|
227
|
-
| staging | appinsights-staging | ghi-456-jkl |
|
|
228
|
-
| dev | appinsights-dev | mno-789-pqr |
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
**Example result** (MCP method - when CLI not available):
|
|
232
|
-
|
|
233
|
-
```markdown
|
|
234
|
-
## Sentry
|
|
235
|
-
|
|
236
|
-
| Field | Value |
|
|
237
|
-
|-------|-------|
|
|
238
|
-
| Enabled | true |
|
|
239
|
-
| Method | mcp |
|
|
240
|
-
| Organization | my-company |
|
|
241
|
-
|
|
242
|
-
### Environment Mapping
|
|
243
|
-
|
|
244
|
-
| Environment | Project |
|
|
245
|
-
|-------------|---------|
|
|
246
|
-
| production | my-company/backend-api |
|
|
247
|
-
| staging | my-company/backend-staging |
|
|
248
|
-
| dev | my-company/backend-dev |
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
### Step 6: Confirm Setup
|
|
252
|
-
|
|
253
|
-
After saving, show a summary **including the detection method**:
|
|
254
|
-
|
|
255
|
-
```markdown
|
|
256
|
-
◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
257
|
-
◆ TELEMETRY CONFIGURATION COMPLETE
|
|
258
|
-
◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
259
|
-
|
|
260
|
-
**Sentry**: ✓ Configured
|
|
261
|
-
- Method: CLI (preferred)
|
|
262
|
-
- Organization: my-company
|
|
263
|
-
- Environments mapped: production, staging, dev
|
|
264
|
-
|
|
265
|
-
**App Insights**: ✓ Configured
|
|
266
|
-
- Method: CLI
|
|
267
|
-
- Subscription: my-subscription
|
|
268
|
-
- Environments mapped: production, staging, dev
|
|
269
|
-
|
|
270
|
-
**Configuration saved to**: knowzcode/telemetry_config.md
|
|
271
|
-
|
|
272
|
-
You can now run:
|
|
273
|
-
/kc:telemetry "error 500 in staging in the last hour"
|
|
274
|
-
|
|
275
|
-
The telemetry investigator will automatically use the correct
|
|
276
|
-
project/resource for the specified environment.
|
|
277
|
-
◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
---
|
|
281
|
-
|
|
282
|
-
## Error Handling
|
|
283
|
-
|
|
284
|
-
### No Tools Installed
|
|
285
|
-
|
|
286
|
-
If NEITHER CLI nor MCP is available for a source, ask which to install:
|
|
287
|
-
|
|
288
|
-
```markdown
|
|
289
|
-
⚠️ No Sentry connection detected.
|
|
290
|
-
|
|
291
|
-
Would you like to set up Sentry? Choose an option:
|
|
292
|
-
|
|
293
|
-
**Option 1: Sentry CLI** (Recommended)
|
|
294
|
-
- Better error details and breadcrumbs
|
|
295
|
-
- Full issue management capabilities
|
|
296
|
-
\`\`\`bash
|
|
297
|
-
npm install -g @sentry/cli
|
|
298
|
-
sentry-cli login
|
|
299
|
-
\`\`\`
|
|
300
|
-
|
|
301
|
-
**Option 2: Sentry MCP**
|
|
302
|
-
- Configure Sentry MCP server in Claude Code settings
|
|
303
|
-
- Tools: `sentry_search_issues`, `sentry_get_issue_details`, `sentry_list_events`
|
|
304
|
-
- See: https://github.com/modelcontextprotocol/servers/tree/main/sentry
|
|
305
|
-
|
|
306
|
-
---
|
|
307
|
-
|
|
308
|
-
⚠️ No Azure App Insights connection detected.
|
|
309
|
-
|
|
310
|
-
**For Azure App Insights** (CLI only):
|
|
311
|
-
\`\`\`bash
|
|
312
|
-
# Install Azure CLI (if not installed)
|
|
313
|
-
brew install azure-cli # macOS
|
|
314
|
-
# or see https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
|
|
315
|
-
|
|
316
|
-
az login
|
|
317
|
-
az extension add --name application-insights
|
|
318
|
-
\`\`\`
|
|
319
|
-
|
|
320
|
-
Then run `/kc:telemetry-setup` again.
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
### No Resources Found
|
|
324
|
-
|
|
325
|
-
```markdown
|
|
326
|
-
⚠️ Authenticated but no resources found.
|
|
327
|
-
|
|
328
|
-
**Sentry**: No projects found for your account.
|
|
329
|
-
- Create a project at https://sentry.io
|
|
330
|
-
|
|
331
|
-
**App Insights**: No Application Insights resources found.
|
|
332
|
-
- Create one in Azure portal or via CLI:
|
|
333
|
-
\`\`\`bash
|
|
334
|
-
az monitor app-insights component create \
|
|
335
|
-
--app my-app-name \
|
|
336
|
-
--location eastus \
|
|
337
|
-
--resource-group my-rg
|
|
338
|
-
\`\`\`
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
---
|
|
342
|
-
|
|
343
|
-
## Configuration File Location
|
|
344
|
-
|
|
345
|
-
The configuration is saved to:
|
|
346
|
-
- **Path**: `knowzcode/telemetry_config.md`
|
|
347
|
-
- **Git**: Should be committed (shared team configuration)
|
|
348
|
-
- **Override**: Team members can edit locally if needed
|
|
349
|
-
|
|
350
|
-
For sensitive tokens, use environment variables instead of the config file:
|
|
351
|
-
- `SENTRY_AUTH_TOKEN` - Sentry authentication
|
|
352
|
-
- `AZURE_*` - Azure CLI uses `az login` session
|
|
353
|
-
|
|
354
|
-
---
|
|
355
|
-
|
|
356
|
-
## Verification
|
|
357
|
-
|
|
358
|
-
After setup, test the configuration:
|
|
359
|
-
|
|
360
|
-
```bash
|
|
361
|
-
/kc:telemetry "test query in production in the last 5 min"
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
This should:
|
|
365
|
-
1. Load the config from `knowzcode/telemetry_config.md`
|
|
366
|
-
2. Map "production" to the configured project/app
|
|
367
|
-
3. Query the correct telemetry source
|
|
368
|
-
4. Return results (or "no events found" if no matching errors)
|
|
1
|
+
---
|
|
2
|
+
description: "Configure telemetry sources (Sentry, App Insights) for /kc:telemetry"
|
|
3
|
+
argument-hint: "[sentry|appinsights|all]"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# KnowzCode Telemetry Setup
|
|
7
|
+
|
|
8
|
+
Configure telemetry sources for `/kc:telemetry` investigations.
|
|
9
|
+
|
|
10
|
+
**Usage**: `/kc:telemetry-setup [scope]`
|
|
11
|
+
|
|
12
|
+
| Scope | Description |
|
|
13
|
+
|-------|-------------|
|
|
14
|
+
| `all` | Configure all detected sources (default) |
|
|
15
|
+
| `sentry` | Configure Sentry only |
|
|
16
|
+
| `appinsights` | Configure Azure App Insights only |
|
|
17
|
+
|
|
18
|
+
**Examples**:
|
|
19
|
+
```
|
|
20
|
+
/kc:telemetry-setup
|
|
21
|
+
/kc:telemetry-setup sentry
|
|
22
|
+
/kc:telemetry-setup appinsights
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Workflow
|
|
28
|
+
|
|
29
|
+
### Step 1: Detect Available Tools
|
|
30
|
+
|
|
31
|
+
Check which telemetry tools are available. **CLI is preferred when properly configured; MCP is a fallback.**
|
|
32
|
+
|
|
33
|
+
#### 1.1 Check Sentry CLI (Preferred)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Check Sentry CLI installation
|
|
37
|
+
which sentry-cli 2>/dev/null && echo "SENTRY_CLI_INSTALLED" || echo "NO_SENTRY_CLI"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If installed, verify authentication:
|
|
41
|
+
```bash
|
|
42
|
+
# Verify Sentry CLI is authenticated
|
|
43
|
+
sentry-cli info 2>&1 | grep -q "Organization" && echo "SENTRY_AUTHENTICATED" || echo "SENTRY_NOT_AUTHENTICATED"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**If Sentry CLI installed + authenticated → use CLI method, skip MCP check for Sentry.**
|
|
47
|
+
|
|
48
|
+
#### 1.2 Check Sentry MCP (Fallback)
|
|
49
|
+
|
|
50
|
+
**Only check MCP if CLI is not available or not authenticated.**
|
|
51
|
+
|
|
52
|
+
Attempt to detect MCP by checking if Sentry MCP tools respond. The agent should:
|
|
53
|
+
1. Try to use `sentry_search_issues` or `mcp__sentry__search_issues` with a minimal test query
|
|
54
|
+
2. If it responds (even with "no results") → MCP is available
|
|
55
|
+
3. If it errors with "tool not found" → MCP not configured
|
|
56
|
+
|
|
57
|
+
**If MCP available → use MCP method for Sentry.**
|
|
58
|
+
|
|
59
|
+
#### 1.3 Check Azure CLI + App Insights
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Check Azure CLI
|
|
63
|
+
which az 2>/dev/null && echo "AZURE_CLI_INSTALLED" || echo "NO_AZURE_CLI"
|
|
64
|
+
|
|
65
|
+
# Check App Insights extension
|
|
66
|
+
az extension list --query "[?name=='application-insights'].name" -o tsv 2>/dev/null || echo "NO_APPINSIGHTS_EXTENSION"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Report detected tools and methods** before proceeding:
|
|
70
|
+
|
|
71
|
+
```markdown
|
|
72
|
+
**Detection Results:**
|
|
73
|
+
|
|
74
|
+
| Source | Status | Method |
|
|
75
|
+
|--------|--------|--------|
|
|
76
|
+
| Sentry | ✓ Available | CLI (preferred) |
|
|
77
|
+
| App Insights | ✓ Available | CLI |
|
|
78
|
+
|
|
79
|
+
or
|
|
80
|
+
|
|
81
|
+
| Source | Status | Method |
|
|
82
|
+
|--------|--------|--------|
|
|
83
|
+
| Sentry | ✓ Available | MCP (CLI not configured) |
|
|
84
|
+
| App Insights | ✗ Not available | - |
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Step 2: Verify Authentication
|
|
88
|
+
|
|
89
|
+
For each installed tool, verify authentication:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Sentry: Check if authenticated
|
|
93
|
+
sentry-cli info 2>&1 | head -5
|
|
94
|
+
|
|
95
|
+
# Azure: Check if authenticated
|
|
96
|
+
az account show --query "{name:name, user:user.name}" -o table 2>&1 | head -5
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**If not authenticated**, provide setup instructions and stop for that source:
|
|
100
|
+
|
|
101
|
+
**For Sentry**:
|
|
102
|
+
```markdown
|
|
103
|
+
⚠️ Sentry CLI is installed but not authenticated.
|
|
104
|
+
|
|
105
|
+
Run these commands to authenticate:
|
|
106
|
+
\`\`\`bash
|
|
107
|
+
sentry-cli login
|
|
108
|
+
# OR set the auth token directly
|
|
109
|
+
export SENTRY_AUTH_TOKEN="your-token-here"
|
|
110
|
+
\`\`\`
|
|
111
|
+
|
|
112
|
+
Then run `/kc:telemetry-setup sentry` again.
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**For Azure**:
|
|
116
|
+
```markdown
|
|
117
|
+
⚠️ Azure CLI is installed but not authenticated.
|
|
118
|
+
|
|
119
|
+
Run these commands to authenticate:
|
|
120
|
+
\`\`\`bash
|
|
121
|
+
az login
|
|
122
|
+
az extension add --name application-insights # If not installed
|
|
123
|
+
\`\`\`
|
|
124
|
+
|
|
125
|
+
Then run `/kc:telemetry-setup appinsights` again.
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Step 3: Auto-Discover Resources
|
|
129
|
+
|
|
130
|
+
For each authenticated source, discover available resources:
|
|
131
|
+
|
|
132
|
+
**Sentry**:
|
|
133
|
+
```bash
|
|
134
|
+
# List organizations
|
|
135
|
+
sentry-cli organizations list 2>/dev/null
|
|
136
|
+
|
|
137
|
+
# List projects (for each org)
|
|
138
|
+
sentry-cli projects list --org {org-slug} 2>/dev/null
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Azure App Insights**:
|
|
142
|
+
```bash
|
|
143
|
+
# List all App Insights resources
|
|
144
|
+
az monitor app-insights component list \
|
|
145
|
+
--query "[].{name:name, appId:appId, resourceGroup:resourceGroup}" \
|
|
146
|
+
-o table 2>/dev/null
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Report discovered resources** in a clear format.
|
|
150
|
+
|
|
151
|
+
### Step 4: Interactive Configuration
|
|
152
|
+
|
|
153
|
+
Present discovered resources and ask user to map environments:
|
|
154
|
+
|
|
155
|
+
```markdown
|
|
156
|
+
## Discovered Resources
|
|
157
|
+
|
|
158
|
+
### Sentry Projects
|
|
159
|
+
| # | Organization | Project |
|
|
160
|
+
|---|--------------|---------|
|
|
161
|
+
| 1 | my-company | backend-api |
|
|
162
|
+
| 2 | my-company | frontend-web |
|
|
163
|
+
| 3 | my-company | worker-service |
|
|
164
|
+
|
|
165
|
+
### App Insights Resources
|
|
166
|
+
| # | Name | App ID | Resource Group |
|
|
167
|
+
|---|------|--------|----------------|
|
|
168
|
+
| 1 | appinsights-prod | abc-123-def | rg-production |
|
|
169
|
+
| 2 | appinsights-staging | ghi-456-jkl | rg-staging |
|
|
170
|
+
| 3 | appinsights-dev | mno-789-pqr | rg-development |
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
**Please map each environment to a resource:**
|
|
175
|
+
|
|
176
|
+
For Sentry:
|
|
177
|
+
- Production → (enter project number or skip)
|
|
178
|
+
- Staging → (enter project number or skip)
|
|
179
|
+
- Dev → (enter project number or skip)
|
|
180
|
+
|
|
181
|
+
For App Insights:
|
|
182
|
+
- Production → (enter resource number or skip)
|
|
183
|
+
- Staging → (enter resource number or skip)
|
|
184
|
+
- Dev → (enter resource number or skip)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Use the AskUserQuestion tool to collect mappings if multiple resources exist.
|
|
188
|
+
|
|
189
|
+
### Step 5: Save Configuration
|
|
190
|
+
|
|
191
|
+
Update `knowzcode/telemetry_config.md` with the discovered and mapped values.
|
|
192
|
+
|
|
193
|
+
**Include the detection method** (cli or mcp) for each source.
|
|
194
|
+
|
|
195
|
+
**Example result** (CLI method):
|
|
196
|
+
|
|
197
|
+
```markdown
|
|
198
|
+
## Sentry
|
|
199
|
+
|
|
200
|
+
| Field | Value |
|
|
201
|
+
|-------|-------|
|
|
202
|
+
| Enabled | true |
|
|
203
|
+
| Method | cli |
|
|
204
|
+
| Organization | my-company |
|
|
205
|
+
|
|
206
|
+
### Environment Mapping
|
|
207
|
+
|
|
208
|
+
| Environment | Project |
|
|
209
|
+
|-------------|---------|
|
|
210
|
+
| production | my-company/backend-api |
|
|
211
|
+
| staging | my-company/backend-staging |
|
|
212
|
+
| dev | my-company/backend-dev |
|
|
213
|
+
|
|
214
|
+
## Azure Application Insights
|
|
215
|
+
|
|
216
|
+
| Field | Value |
|
|
217
|
+
|-------|-------|
|
|
218
|
+
| Enabled | true |
|
|
219
|
+
| Subscription | 12345678-1234-1234-1234-123456789012 |
|
|
220
|
+
| Resource Group | rg-production |
|
|
221
|
+
|
|
222
|
+
### Environment Mapping
|
|
223
|
+
|
|
224
|
+
| Environment | App Name | App ID |
|
|
225
|
+
|-------------|----------|--------|
|
|
226
|
+
| production | appinsights-prod | abc-123-def |
|
|
227
|
+
| staging | appinsights-staging | ghi-456-jkl |
|
|
228
|
+
| dev | appinsights-dev | mno-789-pqr |
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Example result** (MCP method - when CLI not available):
|
|
232
|
+
|
|
233
|
+
```markdown
|
|
234
|
+
## Sentry
|
|
235
|
+
|
|
236
|
+
| Field | Value |
|
|
237
|
+
|-------|-------|
|
|
238
|
+
| Enabled | true |
|
|
239
|
+
| Method | mcp |
|
|
240
|
+
| Organization | my-company |
|
|
241
|
+
|
|
242
|
+
### Environment Mapping
|
|
243
|
+
|
|
244
|
+
| Environment | Project |
|
|
245
|
+
|-------------|---------|
|
|
246
|
+
| production | my-company/backend-api |
|
|
247
|
+
| staging | my-company/backend-staging |
|
|
248
|
+
| dev | my-company/backend-dev |
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Step 6: Confirm Setup
|
|
252
|
+
|
|
253
|
+
After saving, show a summary **including the detection method**:
|
|
254
|
+
|
|
255
|
+
```markdown
|
|
256
|
+
◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
257
|
+
◆ TELEMETRY CONFIGURATION COMPLETE
|
|
258
|
+
◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
259
|
+
|
|
260
|
+
**Sentry**: ✓ Configured
|
|
261
|
+
- Method: CLI (preferred)
|
|
262
|
+
- Organization: my-company
|
|
263
|
+
- Environments mapped: production, staging, dev
|
|
264
|
+
|
|
265
|
+
**App Insights**: ✓ Configured
|
|
266
|
+
- Method: CLI
|
|
267
|
+
- Subscription: my-subscription
|
|
268
|
+
- Environments mapped: production, staging, dev
|
|
269
|
+
|
|
270
|
+
**Configuration saved to**: knowzcode/telemetry_config.md
|
|
271
|
+
|
|
272
|
+
You can now run:
|
|
273
|
+
/kc:telemetry "error 500 in staging in the last hour"
|
|
274
|
+
|
|
275
|
+
The telemetry investigator will automatically use the correct
|
|
276
|
+
project/resource for the specified environment.
|
|
277
|
+
◆━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Error Handling
|
|
283
|
+
|
|
284
|
+
### No Tools Installed
|
|
285
|
+
|
|
286
|
+
If NEITHER CLI nor MCP is available for a source, ask which to install:
|
|
287
|
+
|
|
288
|
+
```markdown
|
|
289
|
+
⚠️ No Sentry connection detected.
|
|
290
|
+
|
|
291
|
+
Would you like to set up Sentry? Choose an option:
|
|
292
|
+
|
|
293
|
+
**Option 1: Sentry CLI** (Recommended)
|
|
294
|
+
- Better error details and breadcrumbs
|
|
295
|
+
- Full issue management capabilities
|
|
296
|
+
\`\`\`bash
|
|
297
|
+
npm install -g @sentry/cli
|
|
298
|
+
sentry-cli login
|
|
299
|
+
\`\`\`
|
|
300
|
+
|
|
301
|
+
**Option 2: Sentry MCP**
|
|
302
|
+
- Configure Sentry MCP server in Claude Code settings
|
|
303
|
+
- Tools: `sentry_search_issues`, `sentry_get_issue_details`, `sentry_list_events`
|
|
304
|
+
- See: https://github.com/modelcontextprotocol/servers/tree/main/sentry
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
⚠️ No Azure App Insights connection detected.
|
|
309
|
+
|
|
310
|
+
**For Azure App Insights** (CLI only):
|
|
311
|
+
\`\`\`bash
|
|
312
|
+
# Install Azure CLI (if not installed)
|
|
313
|
+
brew install azure-cli # macOS
|
|
314
|
+
# or see https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
|
|
315
|
+
|
|
316
|
+
az login
|
|
317
|
+
az extension add --name application-insights
|
|
318
|
+
\`\`\`
|
|
319
|
+
|
|
320
|
+
Then run `/kc:telemetry-setup` again.
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### No Resources Found
|
|
324
|
+
|
|
325
|
+
```markdown
|
|
326
|
+
⚠️ Authenticated but no resources found.
|
|
327
|
+
|
|
328
|
+
**Sentry**: No projects found for your account.
|
|
329
|
+
- Create a project at https://sentry.io
|
|
330
|
+
|
|
331
|
+
**App Insights**: No Application Insights resources found.
|
|
332
|
+
- Create one in Azure portal or via CLI:
|
|
333
|
+
\`\`\`bash
|
|
334
|
+
az monitor app-insights component create \
|
|
335
|
+
--app my-app-name \
|
|
336
|
+
--location eastus \
|
|
337
|
+
--resource-group my-rg
|
|
338
|
+
\`\`\`
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Configuration File Location
|
|
344
|
+
|
|
345
|
+
The configuration is saved to:
|
|
346
|
+
- **Path**: `knowzcode/telemetry_config.md`
|
|
347
|
+
- **Git**: Should be committed (shared team configuration)
|
|
348
|
+
- **Override**: Team members can edit locally if needed
|
|
349
|
+
|
|
350
|
+
For sensitive tokens, use environment variables instead of the config file:
|
|
351
|
+
- `SENTRY_AUTH_TOKEN` - Sentry authentication
|
|
352
|
+
- `AZURE_*` - Azure CLI uses `az login` session
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Verification
|
|
357
|
+
|
|
358
|
+
After setup, test the configuration:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
/kc:telemetry "test query in production in the last 5 min"
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
This should:
|
|
365
|
+
1. Load the config from `knowzcode/telemetry_config.md`
|
|
366
|
+
2. Map "production" to the configured project/app
|
|
367
|
+
3. Query the correct telemetry source
|
|
368
|
+
4. Return results (or "no events found" if no matching errors)
|