@bugzy-ai/bugzy 1.15.1 → 1.16.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/dist/index.js CHANGED
@@ -220,6 +220,7 @@ var TASK_SLUGS = {
220
220
  PROCESS_EVENT: "process-event",
221
221
  RUN_TESTS: "run-tests",
222
222
  VERIFY_CHANGES: "verify-changes",
223
+ TRIAGE_RESULTS: "triage-results",
223
224
  /** @deprecated Use ONBOARD_TESTING instead */
224
225
  FULL_TEST_COVERAGE: "onboard-testing"
225
226
  };
@@ -1419,6 +1420,7 @@ Before running tests, confirm the selection with the user if ambiguous:
1419
1420
  },
1420
1421
  // Step 7-10: Test Execution (library steps)
1421
1422
  "run-tests",
1423
+ "normalize-test-results",
1422
1424
  "parse-test-results",
1423
1425
  "triage-failures",
1424
1426
  "fix-test-issues",
@@ -1427,14 +1429,7 @@ Before running tests, confirm the selection with the user if ambiguous:
1427
1429
  stepId: "log-product-bugs",
1428
1430
  conditionalOnSubagent: "issue-tracker"
1429
1431
  },
1430
- // Step 12: Knowledge Base Update (library)
1431
- "update-knowledge-base",
1432
- // Step 13: Team Communication (conditional - library step)
1433
- {
1434
- stepId: "notify-team",
1435
- conditionalOnSubagent: "team-communicator"
1436
- },
1437
- // Step 14: Handle Special Cases (inline - task-specific)
1432
+ // Step 12: Handle Special Cases (inline - reference material, positioned before final action steps)
1438
1433
  {
1439
1434
  inline: true,
1440
1435
  title: "Handle Special Cases",
@@ -1482,6 +1477,13 @@ If selected test cases have formatting issues:
1482
1477
  **Related Documentation**:
1483
1478
  - \`./tests/docs/test-execution-strategy.md\` - When and why to run specific tests
1484
1479
  - \`./tests/docs/testing-best-practices.md\` - How to write tests (patterns and anti-patterns)`
1480
+ },
1481
+ // Step 13: Knowledge Base Update (library)
1482
+ "update-knowledge-base",
1483
+ // Step 14: Team Communication (conditional - library step, LAST actionable step)
1484
+ {
1485
+ stepId: "notify-team",
1486
+ conditionalOnSubagent: "team-communicator"
1485
1487
  }
1486
1488
  ],
1487
1489
  requiredSubagents: ["browser-automation", "test-debugger-fixer"],
@@ -2201,6 +2203,108 @@ var exploreApplicationTask = {
2201
2203
  dependentTasks: []
2202
2204
  };
2203
2205
 
2206
+ // src/tasks/library/triage-results.ts
2207
+ var triageResultsTask = {
2208
+ slug: TASK_SLUGS.TRIAGE_RESULTS,
2209
+ name: "Triage Results",
2210
+ description: "Analyze externally-submitted test results and triage failures as product bugs or test issues",
2211
+ frontmatter: {
2212
+ description: "Analyze externally-submitted test results and triage failures as product bugs or test issues",
2213
+ "argument-hint": "[event payload with test results]"
2214
+ },
2215
+ steps: [
2216
+ // Step 1: Overview (inline)
2217
+ {
2218
+ inline: true,
2219
+ title: "Triage Results Overview",
2220
+ content: `# Triage External Test Results
2221
+
2222
+ Analyze test results submitted from an external CI pipeline. The results were sent via webhook and are available in the event payload \u2014 either as inline data or a URL to download.
2223
+
2224
+ **Goal**: Normalize the results into the standard manifest format, classify each failure as a PRODUCT BUG or TEST ISSUE, and generate a triage report.
2225
+
2226
+ This task is triggered automatically when test results are submitted to the Bugzy webhook from a CI system (GitHub Actions, GitLab CI, etc.).`
2227
+ },
2228
+ // Step 2: Security Notice (library)
2229
+ "security-notice",
2230
+ // Step 3: Arguments (inline)
2231
+ {
2232
+ inline: true,
2233
+ title: "Arguments",
2234
+ content: `Arguments: $ARGUMENTS`
2235
+ },
2236
+ // Step 4: Load Project Context (library)
2237
+ "load-project-context",
2238
+ // Step 5: Knowledge Base Read (library)
2239
+ "read-knowledge-base",
2240
+ // Step 6: Normalize Test Results (library — handles URL/inline results + manifest creation)
2241
+ "normalize-test-results",
2242
+ // Step 7: Triage Failures (existing library step)
2243
+ "triage-failures",
2244
+ // Step 8: Fix Test Issues (library — uses test-debugger-fixer)
2245
+ "fix-test-issues",
2246
+ // Step 9: Log Product Bugs (conditional — requires issue-tracker)
2247
+ {
2248
+ stepId: "log-product-bugs",
2249
+ conditionalOnSubagent: "issue-tracker"
2250
+ },
2251
+ // Step 10: Update Knowledge Base (library)
2252
+ "update-knowledge-base",
2253
+ // Step 11: Notify Team (conditional — requires team-communicator)
2254
+ {
2255
+ stepId: "notify-team",
2256
+ conditionalOnSubagent: "team-communicator"
2257
+ },
2258
+ // Step 12: Generate Triage Report (inline)
2259
+ {
2260
+ inline: true,
2261
+ title: "Generate Triage Report",
2262
+ content: `## Generate Triage Report
2263
+
2264
+ Create a structured triage report as the task output. This report is stored in \`task_executions.result\` and displayed in the Bugzy dashboard.
2265
+
2266
+ **Report Structure:**
2267
+ \`\`\`json
2268
+ {
2269
+ "summary": {
2270
+ "total": <number>,
2271
+ "passed": <number>,
2272
+ "failed": <number>,
2273
+ "skipped": <number>,
2274
+ "duration_ms": <number or null>
2275
+ },
2276
+ "ci_metadata": {
2277
+ "pipeline_url": "<from event payload>",
2278
+ "commit_sha": "<from event payload>",
2279
+ "branch": "<from event payload>"
2280
+ },
2281
+ "triage": {
2282
+ "product_bugs": [
2283
+ {
2284
+ "test_name": "<name>",
2285
+ "error": "<brief error>",
2286
+ "reason": "<why this is a product bug>"
2287
+ }
2288
+ ],
2289
+ "test_issues": [
2290
+ {
2291
+ "test_name": "<name>",
2292
+ "error": "<brief error>",
2293
+ "reason": "<why this is a test issue>"
2294
+ }
2295
+ ]
2296
+ }
2297
+ }
2298
+ \`\`\`
2299
+
2300
+ Output this JSON as the final result of the task.`
2301
+ }
2302
+ ],
2303
+ requiredSubagents: ["browser-automation", "test-debugger-fixer"],
2304
+ optionalSubagents: ["issue-tracker", "team-communicator"],
2305
+ dependentTasks: []
2306
+ };
2307
+
2204
2308
  // src/tasks/index.ts
2205
2309
  var TASK_TEMPLATES = {
2206
2310
  [TASK_SLUGS.GENERATE_TEST_CASES]: generateTestCasesTask,
@@ -2210,7 +2314,8 @@ var TASK_TEMPLATES = {
2210
2314
  [TASK_SLUGS.RUN_TESTS]: runTestsTask,
2211
2315
  [TASK_SLUGS.VERIFY_CHANGES]: verifyChangesTask,
2212
2316
  [TASK_SLUGS.ONBOARD_TESTING]: onboardTestingTask,
2213
- [TASK_SLUGS.EXPLORE_APPLICATION]: exploreApplicationTask
2317
+ [TASK_SLUGS.EXPLORE_APPLICATION]: exploreApplicationTask,
2318
+ [TASK_SLUGS.TRIAGE_RESULTS]: triageResultsTask
2214
2319
  };
2215
2320
  function getTaskTemplate(slug) {
2216
2321
  return TASK_TEMPLATES[slug];
@@ -6803,6 +6908,10 @@ The agent will:
6803
6908
  4. Apply appropriate fix pattern from \`./tests/CLAUDE.md\`
6804
6909
  5. Rerun the test
6805
6910
  6. The custom reporter will automatically create the next exec-N/ folder
6911
+ 6b. If no custom reporter (BYOT mode \u2014 check for \`reporters/bugzy-reporter.ts\`):
6912
+ Run the parse script to update the manifest with re-run results:
6913
+ \`npx tsx reporters/parse-results.ts --input <re-run-output> --timestamp <current> --test-id <testCaseId>\`
6914
+ This creates exec-N+1/ and updates the manifest.
6806
6915
  7. Repeat up to 3 times if needed (exec-1, exec-2, exec-3)
6807
6916
  8. Report success or escalate as likely product bug
6808
6917
 
@@ -6994,6 +7103,87 @@ ls -t test-runs/ | head -1
6994
7103
  tags: ["execution", "exploration"]
6995
7104
  };
6996
7105
 
7106
+ // src/tasks/steps/execution/normalize-test-results.ts
7107
+ var normalizeTestResultsStep = {
7108
+ id: "normalize-test-results",
7109
+ title: "Normalize Test Results",
7110
+ category: "execution",
7111
+ content: `## Normalize Test Results
7112
+
7113
+ Convert test results into the standard Bugzy \`test-runs/\` manifest format. This step handles both external CI results (via webhook) and local BYOT test output. In managed mode (bugzy-reporter already created the manifest), this step is skipped.
7114
+
7115
+ ### 1. Check for Existing Manifest
7116
+
7117
+ Look for a \`test-runs/*/manifest.json\` from the most recent run. If a manifest already exists from the bugzy-reporter (managed mode), **skip this step entirely** \u2014 the results are already normalized.
7118
+
7119
+ ### 2. Determine Input Source
7120
+
7121
+ Check how test results are available:
7122
+
7123
+ **From event payload** (external CI \u2014 \`$ARGUMENTS\` contains event data):
7124
+ - \`data.results_url\` \u2014 URL to download results from (the parse script handles the download)
7125
+ - \`data.results\` \u2014 inline results (write to a temp file first: \`/tmp/bugzy-results-<random>.json\`)
7126
+
7127
+ **From local test run** (agent executed BYOT tests):
7128
+ - Read \`./tests/CLAUDE.md\` for the native test output location
7129
+ - Find the most recent test output file
7130
+
7131
+ ### 3. Locate and Run Parse Script
7132
+
7133
+ Look for the parse script at \`reporters/parse-results.ts\`.
7134
+
7135
+ **If the parse script exists:**
7136
+ \`\`\`bash
7137
+ npx tsx reporters/parse-results.ts --input <source>
7138
+ \`\`\`
7139
+ Where \`<source>\` is the file path, temp file path, or URL determined in step 2.
7140
+
7141
+ **If the parse script is missing** (fallback for robustness):
7142
+ Create the manifest inline using the same approach \u2014 parse the results format by inspecting the data structure:
7143
+ - JSON with \`suites\` or \`specs\` arrays: Likely Playwright JSON report
7144
+ - XML with \`<testsuites>\` or \`<testsuite>\` root: JUnit XML format
7145
+ - JSON with \`results\` array and \`stats\` object: Likely Cypress/Mocha JSON
7146
+ - Other: Inspect structure and adapt
7147
+
7148
+ Then create:
7149
+ 1. \`test-runs/{timestamp}/manifest.json\` with the standard Bugzy schema
7150
+ 2. \`test-runs/{timestamp}/{testCaseId}/exec-1/result.json\` for each failed test
7151
+
7152
+ Save the inline parse logic to \`reporters/parse-results.ts\` for future reuse.
7153
+
7154
+ ### 4. Verify Manifest
7155
+
7156
+ Confirm \`manifest.json\` was created:
7157
+ - Read the manifest and validate the structure
7158
+ - Check that \`stats\` counts match the \`testCases\` array
7159
+
7160
+ ### 5. Generate Summary
7161
+
7162
+ Read the manifest and produce a summary:
7163
+
7164
+ \`\`\`markdown
7165
+ ## Test Results Summary
7166
+
7167
+ - Total Tests: [count]
7168
+ - Passed: [count] ([percentage]%)
7169
+ - Failed: [count] ([percentage]%)
7170
+ - Skipped: [count] ([percentage]%)
7171
+ - Duration: [time if available]
7172
+ \`\`\`
7173
+
7174
+ ### 6. Include CI Metadata (if from event payload)
7175
+
7176
+ If the results came from an external CI event (\`$ARGUMENTS\` contains \`data.metadata\`), include:
7177
+ - **Pipeline URL**: \`data.metadata.pipeline_url\`
7178
+ - **Commit**: \`data.metadata.commit_sha\`
7179
+ - **Branch**: \`data.metadata.branch\`
7180
+
7181
+ ### 7. All Tests Passed?
7182
+
7183
+ If there are **no failures**, note that all tests passed. Downstream triage and fix steps can be skipped.`,
7184
+ tags: ["execution", "results", "normalization", "byot"]
7185
+ };
7186
+
6997
7187
  // src/tasks/steps/generation/generate-test-plan.ts
6998
7188
  var generateTestPlanStep = {
6999
7189
  id: "generate-test-plan",
@@ -7178,6 +7368,116 @@ TEST_API_KEY=secret_key_here
7178
7368
  tags: ["generation", "environment"]
7179
7369
  };
7180
7370
 
7371
+ // src/tasks/steps/generation/create-results-parser.ts
7372
+ var createResultsParserStep = {
7373
+ id: "create-results-parser",
7374
+ title: "Create Results Parser Script",
7375
+ category: "generation",
7376
+ content: `## Create Results Parser Script
7377
+
7378
+ Create a reusable script that normalizes test results from the project's test framework into Bugzy's standard \`test-runs/\` manifest format. This script is used at runtime by both external CI events and agent-executed BYOT test runs.
7379
+
7380
+ ### Inspect the Test Project
7381
+
7382
+ 1. Read \`./tests/CLAUDE.md\` to understand:
7383
+ - Which test framework is used (Playwright, Cypress, Jest, Mocha, etc.)
7384
+ - How tests are run and where output goes
7385
+ - The native report format (JSON, JUnit XML, etc.)
7386
+ 2. Check the test runner config file (e.g., \`playwright.config.ts\`, \`cypress.config.ts\`, \`jest.config.ts\`) for report settings
7387
+ 3. If a sample test output exists, read it to understand the exact structure
7388
+
7389
+ ### Create the Parse Script
7390
+
7391
+ Create \`reporters/parse-results.ts\` \u2014 a Node.js/TypeScript CLI script.
7392
+
7393
+ **Interface:**
7394
+ \`\`\`
7395
+ npx tsx reporters/parse-results.ts --input <file-or-url> [--timestamp <existing>] [--test-id <id>]
7396
+ \`\`\`
7397
+
7398
+ **Arguments:**
7399
+ - \`--input\` (required): file path or URL to the test results
7400
+ - If URL (starts with \`http://\` or \`https://\`): download with 30s timeout
7401
+ - If file path: read directly from disk
7402
+ - \`--timestamp\` (optional): existing run timestamp for incremental updates
7403
+ - \`--test-id\` (optional): specific test case ID for incremental updates (used with \`--timestamp\`)
7404
+
7405
+ **Normal mode** (no \`--timestamp\`):
7406
+ 1. Parse the project-specific test output format
7407
+ 2. Generate a timestamp: \`YYYYMMDD-HHmmss\`
7408
+ 3. Create \`test-runs/{timestamp}/manifest.json\` with the standard Bugzy schema:
7409
+ \`\`\`json
7410
+ {
7411
+ "bugzyExecutionId": "<from BUGZY_EXECUTION_ID env var or 'local'>",
7412
+ "timestamp": "<YYYYMMDD-HHmmss>",
7413
+ "startTime": "<ISO8601>",
7414
+ "endTime": "<ISO8601>",
7415
+ "status": "completed",
7416
+ "stats": {
7417
+ "totalTests": 0,
7418
+ "passed": 0,
7419
+ "failed": 0,
7420
+ "totalExecutions": 0
7421
+ },
7422
+ "testCases": [
7423
+ {
7424
+ "id": "<slugified test name, e.g. TC-001-login>",
7425
+ "name": "<original test name>",
7426
+ "totalExecutions": 1,
7427
+ "finalStatus": "passed|failed",
7428
+ "executions": [
7429
+ {
7430
+ "executionNumber": 1,
7431
+ "status": "passed|failed",
7432
+ "error": "<error message if failed, null if passed>",
7433
+ "duration": null,
7434
+ "hasTrace": false,
7435
+ "hasScreenshots": false
7436
+ }
7437
+ ]
7438
+ }
7439
+ ]
7440
+ }
7441
+ \`\`\`
7442
+ 4. For each failed test, create:
7443
+ - Directory: \`test-runs/{timestamp}/{testCaseId}/exec-1/\`
7444
+ - File: \`test-runs/{timestamp}/{testCaseId}/exec-1/result.json\` containing:
7445
+ \`\`\`json
7446
+ {
7447
+ "status": "failed",
7448
+ "error": "<full error message>",
7449
+ "stackTrace": "<stack trace if available>",
7450
+ "duration": null,
7451
+ "testFile": "<file path if available>"
7452
+ }
7453
+ \`\`\`
7454
+ 5. Print the manifest path to stdout
7455
+ 6. Exit code 0 on success, non-zero on failure
7456
+
7457
+ **Incremental mode** (\`--timestamp\` + \`--test-id\` provided):
7458
+ 1. Read existing \`test-runs/{timestamp}/manifest.json\`
7459
+ 2. Parse the new test results for the specified test case
7460
+ 3. Find the next execution number (e.g., if exec-2 exists, create exec-3)
7461
+ 4. Create \`test-runs/{timestamp}/{testCaseId}/exec-N/result.json\`
7462
+ 5. Update the manifest: add execution entry, update \`totalExecutions\`, update \`finalStatus\` and stats
7463
+ 6. Print the manifest path to stdout
7464
+
7465
+ ### Test the Script
7466
+
7467
+ 1. Run the project's tests to generate a sample output (or use an existing one)
7468
+ 2. Run the parse script: \`npx tsx reporters/parse-results.ts --input <sample-output>\`
7469
+ 3. Verify \`test-runs/\` was created with correct manifest.json structure
7470
+ 4. Check that failed test directories have result.json files
7471
+
7472
+ ### Document in CLAUDE.md
7473
+
7474
+ Add to \`./tests/CLAUDE.md\`:
7475
+ - Location: \`reporters/parse-results.ts\`
7476
+ - Usage: \`npx tsx reporters/parse-results.ts --input <file-or-url> [--timestamp <ts>] [--test-id <id>]\`
7477
+ - Where the project's native test output is located (for local runs)`,
7478
+ tags: ["generation", "byot", "results", "parser"]
7479
+ };
7480
+
7181
7481
  // src/tasks/steps/communication/notify-team.ts
7182
7482
  var notifyTeamStep = {
7183
7483
  id: "notify-team",
@@ -7426,11 +7726,13 @@ var STEP_LIBRARY = {
7426
7726
  "create-exploration-test-case": createExplorationTestCaseStep,
7427
7727
  "run-exploration": runExplorationStep,
7428
7728
  "process-exploration-results": processExplorationResultsStep,
7729
+ "normalize-test-results": normalizeTestResultsStep,
7429
7730
  // Generation
7430
7731
  "generate-test-plan": generateTestPlanStep,
7431
7732
  "generate-test-cases": generateTestCasesStep,
7432
7733
  "automate-test-cases": automateTestCasesStep,
7433
7734
  "extract-env-variables": extractEnvVariablesStep,
7735
+ "create-results-parser": createResultsParserStep,
7434
7736
  // Communication
7435
7737
  "notify-team": notifyTeamStep,
7436
7738
  // Maintenance