@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.cjs CHANGED
@@ -276,6 +276,7 @@ var TASK_SLUGS = {
276
276
  PROCESS_EVENT: "process-event",
277
277
  RUN_TESTS: "run-tests",
278
278
  VERIFY_CHANGES: "verify-changes",
279
+ TRIAGE_RESULTS: "triage-results",
279
280
  /** @deprecated Use ONBOARD_TESTING instead */
280
281
  FULL_TEST_COVERAGE: "onboard-testing"
281
282
  };
@@ -1475,6 +1476,7 @@ Before running tests, confirm the selection with the user if ambiguous:
1475
1476
  },
1476
1477
  // Step 7-10: Test Execution (library steps)
1477
1478
  "run-tests",
1479
+ "normalize-test-results",
1478
1480
  "parse-test-results",
1479
1481
  "triage-failures",
1480
1482
  "fix-test-issues",
@@ -1483,14 +1485,7 @@ Before running tests, confirm the selection with the user if ambiguous:
1483
1485
  stepId: "log-product-bugs",
1484
1486
  conditionalOnSubagent: "issue-tracker"
1485
1487
  },
1486
- // Step 12: Knowledge Base Update (library)
1487
- "update-knowledge-base",
1488
- // Step 13: Team Communication (conditional - library step)
1489
- {
1490
- stepId: "notify-team",
1491
- conditionalOnSubagent: "team-communicator"
1492
- },
1493
- // Step 14: Handle Special Cases (inline - task-specific)
1488
+ // Step 12: Handle Special Cases (inline - reference material, positioned before final action steps)
1494
1489
  {
1495
1490
  inline: true,
1496
1491
  title: "Handle Special Cases",
@@ -1538,6 +1533,13 @@ If selected test cases have formatting issues:
1538
1533
  **Related Documentation**:
1539
1534
  - \`./tests/docs/test-execution-strategy.md\` - When and why to run specific tests
1540
1535
  - \`./tests/docs/testing-best-practices.md\` - How to write tests (patterns and anti-patterns)`
1536
+ },
1537
+ // Step 13: Knowledge Base Update (library)
1538
+ "update-knowledge-base",
1539
+ // Step 14: Team Communication (conditional - library step, LAST actionable step)
1540
+ {
1541
+ stepId: "notify-team",
1542
+ conditionalOnSubagent: "team-communicator"
1541
1543
  }
1542
1544
  ],
1543
1545
  requiredSubagents: ["browser-automation", "test-debugger-fixer"],
@@ -2257,6 +2259,108 @@ var exploreApplicationTask = {
2257
2259
  dependentTasks: []
2258
2260
  };
2259
2261
 
2262
+ // src/tasks/library/triage-results.ts
2263
+ var triageResultsTask = {
2264
+ slug: TASK_SLUGS.TRIAGE_RESULTS,
2265
+ name: "Triage Results",
2266
+ description: "Analyze externally-submitted test results and triage failures as product bugs or test issues",
2267
+ frontmatter: {
2268
+ description: "Analyze externally-submitted test results and triage failures as product bugs or test issues",
2269
+ "argument-hint": "[event payload with test results]"
2270
+ },
2271
+ steps: [
2272
+ // Step 1: Overview (inline)
2273
+ {
2274
+ inline: true,
2275
+ title: "Triage Results Overview",
2276
+ content: `# Triage External Test Results
2277
+
2278
+ 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.
2279
+
2280
+ **Goal**: Normalize the results into the standard manifest format, classify each failure as a PRODUCT BUG or TEST ISSUE, and generate a triage report.
2281
+
2282
+ This task is triggered automatically when test results are submitted to the Bugzy webhook from a CI system (GitHub Actions, GitLab CI, etc.).`
2283
+ },
2284
+ // Step 2: Security Notice (library)
2285
+ "security-notice",
2286
+ // Step 3: Arguments (inline)
2287
+ {
2288
+ inline: true,
2289
+ title: "Arguments",
2290
+ content: `Arguments: $ARGUMENTS`
2291
+ },
2292
+ // Step 4: Load Project Context (library)
2293
+ "load-project-context",
2294
+ // Step 5: Knowledge Base Read (library)
2295
+ "read-knowledge-base",
2296
+ // Step 6: Normalize Test Results (library — handles URL/inline results + manifest creation)
2297
+ "normalize-test-results",
2298
+ // Step 7: Triage Failures (existing library step)
2299
+ "triage-failures",
2300
+ // Step 8: Fix Test Issues (library — uses test-debugger-fixer)
2301
+ "fix-test-issues",
2302
+ // Step 9: Log Product Bugs (conditional — requires issue-tracker)
2303
+ {
2304
+ stepId: "log-product-bugs",
2305
+ conditionalOnSubagent: "issue-tracker"
2306
+ },
2307
+ // Step 10: Update Knowledge Base (library)
2308
+ "update-knowledge-base",
2309
+ // Step 11: Notify Team (conditional — requires team-communicator)
2310
+ {
2311
+ stepId: "notify-team",
2312
+ conditionalOnSubagent: "team-communicator"
2313
+ },
2314
+ // Step 12: Generate Triage Report (inline)
2315
+ {
2316
+ inline: true,
2317
+ title: "Generate Triage Report",
2318
+ content: `## Generate Triage Report
2319
+
2320
+ Create a structured triage report as the task output. This report is stored in \`task_executions.result\` and displayed in the Bugzy dashboard.
2321
+
2322
+ **Report Structure:**
2323
+ \`\`\`json
2324
+ {
2325
+ "summary": {
2326
+ "total": <number>,
2327
+ "passed": <number>,
2328
+ "failed": <number>,
2329
+ "skipped": <number>,
2330
+ "duration_ms": <number or null>
2331
+ },
2332
+ "ci_metadata": {
2333
+ "pipeline_url": "<from event payload>",
2334
+ "commit_sha": "<from event payload>",
2335
+ "branch": "<from event payload>"
2336
+ },
2337
+ "triage": {
2338
+ "product_bugs": [
2339
+ {
2340
+ "test_name": "<name>",
2341
+ "error": "<brief error>",
2342
+ "reason": "<why this is a product bug>"
2343
+ }
2344
+ ],
2345
+ "test_issues": [
2346
+ {
2347
+ "test_name": "<name>",
2348
+ "error": "<brief error>",
2349
+ "reason": "<why this is a test issue>"
2350
+ }
2351
+ ]
2352
+ }
2353
+ }
2354
+ \`\`\`
2355
+
2356
+ Output this JSON as the final result of the task.`
2357
+ }
2358
+ ],
2359
+ requiredSubagents: ["browser-automation", "test-debugger-fixer"],
2360
+ optionalSubagents: ["issue-tracker", "team-communicator"],
2361
+ dependentTasks: []
2362
+ };
2363
+
2260
2364
  // src/tasks/index.ts
2261
2365
  var TASK_TEMPLATES = {
2262
2366
  [TASK_SLUGS.GENERATE_TEST_CASES]: generateTestCasesTask,
@@ -2266,7 +2370,8 @@ var TASK_TEMPLATES = {
2266
2370
  [TASK_SLUGS.RUN_TESTS]: runTestsTask,
2267
2371
  [TASK_SLUGS.VERIFY_CHANGES]: verifyChangesTask,
2268
2372
  [TASK_SLUGS.ONBOARD_TESTING]: onboardTestingTask,
2269
- [TASK_SLUGS.EXPLORE_APPLICATION]: exploreApplicationTask
2373
+ [TASK_SLUGS.EXPLORE_APPLICATION]: exploreApplicationTask,
2374
+ [TASK_SLUGS.TRIAGE_RESULTS]: triageResultsTask
2270
2375
  };
2271
2376
  function getTaskTemplate(slug) {
2272
2377
  return TASK_TEMPLATES[slug];
@@ -6859,6 +6964,10 @@ The agent will:
6859
6964
  4. Apply appropriate fix pattern from \`./tests/CLAUDE.md\`
6860
6965
  5. Rerun the test
6861
6966
  6. The custom reporter will automatically create the next exec-N/ folder
6967
+ 6b. If no custom reporter (BYOT mode \u2014 check for \`reporters/bugzy-reporter.ts\`):
6968
+ Run the parse script to update the manifest with re-run results:
6969
+ \`npx tsx reporters/parse-results.ts --input <re-run-output> --timestamp <current> --test-id <testCaseId>\`
6970
+ This creates exec-N+1/ and updates the manifest.
6862
6971
  7. Repeat up to 3 times if needed (exec-1, exec-2, exec-3)
6863
6972
  8. Report success or escalate as likely product bug
6864
6973
 
@@ -7050,6 +7159,87 @@ ls -t test-runs/ | head -1
7050
7159
  tags: ["execution", "exploration"]
7051
7160
  };
7052
7161
 
7162
+ // src/tasks/steps/execution/normalize-test-results.ts
7163
+ var normalizeTestResultsStep = {
7164
+ id: "normalize-test-results",
7165
+ title: "Normalize Test Results",
7166
+ category: "execution",
7167
+ content: `## Normalize Test Results
7168
+
7169
+ 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.
7170
+
7171
+ ### 1. Check for Existing Manifest
7172
+
7173
+ 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.
7174
+
7175
+ ### 2. Determine Input Source
7176
+
7177
+ Check how test results are available:
7178
+
7179
+ **From event payload** (external CI \u2014 \`$ARGUMENTS\` contains event data):
7180
+ - \`data.results_url\` \u2014 URL to download results from (the parse script handles the download)
7181
+ - \`data.results\` \u2014 inline results (write to a temp file first: \`/tmp/bugzy-results-<random>.json\`)
7182
+
7183
+ **From local test run** (agent executed BYOT tests):
7184
+ - Read \`./tests/CLAUDE.md\` for the native test output location
7185
+ - Find the most recent test output file
7186
+
7187
+ ### 3. Locate and Run Parse Script
7188
+
7189
+ Look for the parse script at \`reporters/parse-results.ts\`.
7190
+
7191
+ **If the parse script exists:**
7192
+ \`\`\`bash
7193
+ npx tsx reporters/parse-results.ts --input <source>
7194
+ \`\`\`
7195
+ Where \`<source>\` is the file path, temp file path, or URL determined in step 2.
7196
+
7197
+ **If the parse script is missing** (fallback for robustness):
7198
+ Create the manifest inline using the same approach \u2014 parse the results format by inspecting the data structure:
7199
+ - JSON with \`suites\` or \`specs\` arrays: Likely Playwright JSON report
7200
+ - XML with \`<testsuites>\` or \`<testsuite>\` root: JUnit XML format
7201
+ - JSON with \`results\` array and \`stats\` object: Likely Cypress/Mocha JSON
7202
+ - Other: Inspect structure and adapt
7203
+
7204
+ Then create:
7205
+ 1. \`test-runs/{timestamp}/manifest.json\` with the standard Bugzy schema
7206
+ 2. \`test-runs/{timestamp}/{testCaseId}/exec-1/result.json\` for each failed test
7207
+
7208
+ Save the inline parse logic to \`reporters/parse-results.ts\` for future reuse.
7209
+
7210
+ ### 4. Verify Manifest
7211
+
7212
+ Confirm \`manifest.json\` was created:
7213
+ - Read the manifest and validate the structure
7214
+ - Check that \`stats\` counts match the \`testCases\` array
7215
+
7216
+ ### 5. Generate Summary
7217
+
7218
+ Read the manifest and produce a summary:
7219
+
7220
+ \`\`\`markdown
7221
+ ## Test Results Summary
7222
+
7223
+ - Total Tests: [count]
7224
+ - Passed: [count] ([percentage]%)
7225
+ - Failed: [count] ([percentage]%)
7226
+ - Skipped: [count] ([percentage]%)
7227
+ - Duration: [time if available]
7228
+ \`\`\`
7229
+
7230
+ ### 6. Include CI Metadata (if from event payload)
7231
+
7232
+ If the results came from an external CI event (\`$ARGUMENTS\` contains \`data.metadata\`), include:
7233
+ - **Pipeline URL**: \`data.metadata.pipeline_url\`
7234
+ - **Commit**: \`data.metadata.commit_sha\`
7235
+ - **Branch**: \`data.metadata.branch\`
7236
+
7237
+ ### 7. All Tests Passed?
7238
+
7239
+ If there are **no failures**, note that all tests passed. Downstream triage and fix steps can be skipped.`,
7240
+ tags: ["execution", "results", "normalization", "byot"]
7241
+ };
7242
+
7053
7243
  // src/tasks/steps/generation/generate-test-plan.ts
7054
7244
  var generateTestPlanStep = {
7055
7245
  id: "generate-test-plan",
@@ -7234,6 +7424,116 @@ TEST_API_KEY=secret_key_here
7234
7424
  tags: ["generation", "environment"]
7235
7425
  };
7236
7426
 
7427
+ // src/tasks/steps/generation/create-results-parser.ts
7428
+ var createResultsParserStep = {
7429
+ id: "create-results-parser",
7430
+ title: "Create Results Parser Script",
7431
+ category: "generation",
7432
+ content: `## Create Results Parser Script
7433
+
7434
+ 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.
7435
+
7436
+ ### Inspect the Test Project
7437
+
7438
+ 1. Read \`./tests/CLAUDE.md\` to understand:
7439
+ - Which test framework is used (Playwright, Cypress, Jest, Mocha, etc.)
7440
+ - How tests are run and where output goes
7441
+ - The native report format (JSON, JUnit XML, etc.)
7442
+ 2. Check the test runner config file (e.g., \`playwright.config.ts\`, \`cypress.config.ts\`, \`jest.config.ts\`) for report settings
7443
+ 3. If a sample test output exists, read it to understand the exact structure
7444
+
7445
+ ### Create the Parse Script
7446
+
7447
+ Create \`reporters/parse-results.ts\` \u2014 a Node.js/TypeScript CLI script.
7448
+
7449
+ **Interface:**
7450
+ \`\`\`
7451
+ npx tsx reporters/parse-results.ts --input <file-or-url> [--timestamp <existing>] [--test-id <id>]
7452
+ \`\`\`
7453
+
7454
+ **Arguments:**
7455
+ - \`--input\` (required): file path or URL to the test results
7456
+ - If URL (starts with \`http://\` or \`https://\`): download with 30s timeout
7457
+ - If file path: read directly from disk
7458
+ - \`--timestamp\` (optional): existing run timestamp for incremental updates
7459
+ - \`--test-id\` (optional): specific test case ID for incremental updates (used with \`--timestamp\`)
7460
+
7461
+ **Normal mode** (no \`--timestamp\`):
7462
+ 1. Parse the project-specific test output format
7463
+ 2. Generate a timestamp: \`YYYYMMDD-HHmmss\`
7464
+ 3. Create \`test-runs/{timestamp}/manifest.json\` with the standard Bugzy schema:
7465
+ \`\`\`json
7466
+ {
7467
+ "bugzyExecutionId": "<from BUGZY_EXECUTION_ID env var or 'local'>",
7468
+ "timestamp": "<YYYYMMDD-HHmmss>",
7469
+ "startTime": "<ISO8601>",
7470
+ "endTime": "<ISO8601>",
7471
+ "status": "completed",
7472
+ "stats": {
7473
+ "totalTests": 0,
7474
+ "passed": 0,
7475
+ "failed": 0,
7476
+ "totalExecutions": 0
7477
+ },
7478
+ "testCases": [
7479
+ {
7480
+ "id": "<slugified test name, e.g. TC-001-login>",
7481
+ "name": "<original test name>",
7482
+ "totalExecutions": 1,
7483
+ "finalStatus": "passed|failed",
7484
+ "executions": [
7485
+ {
7486
+ "executionNumber": 1,
7487
+ "status": "passed|failed",
7488
+ "error": "<error message if failed, null if passed>",
7489
+ "duration": null,
7490
+ "hasTrace": false,
7491
+ "hasScreenshots": false
7492
+ }
7493
+ ]
7494
+ }
7495
+ ]
7496
+ }
7497
+ \`\`\`
7498
+ 4. For each failed test, create:
7499
+ - Directory: \`test-runs/{timestamp}/{testCaseId}/exec-1/\`
7500
+ - File: \`test-runs/{timestamp}/{testCaseId}/exec-1/result.json\` containing:
7501
+ \`\`\`json
7502
+ {
7503
+ "status": "failed",
7504
+ "error": "<full error message>",
7505
+ "stackTrace": "<stack trace if available>",
7506
+ "duration": null,
7507
+ "testFile": "<file path if available>"
7508
+ }
7509
+ \`\`\`
7510
+ 5. Print the manifest path to stdout
7511
+ 6. Exit code 0 on success, non-zero on failure
7512
+
7513
+ **Incremental mode** (\`--timestamp\` + \`--test-id\` provided):
7514
+ 1. Read existing \`test-runs/{timestamp}/manifest.json\`
7515
+ 2. Parse the new test results for the specified test case
7516
+ 3. Find the next execution number (e.g., if exec-2 exists, create exec-3)
7517
+ 4. Create \`test-runs/{timestamp}/{testCaseId}/exec-N/result.json\`
7518
+ 5. Update the manifest: add execution entry, update \`totalExecutions\`, update \`finalStatus\` and stats
7519
+ 6. Print the manifest path to stdout
7520
+
7521
+ ### Test the Script
7522
+
7523
+ 1. Run the project's tests to generate a sample output (or use an existing one)
7524
+ 2. Run the parse script: \`npx tsx reporters/parse-results.ts --input <sample-output>\`
7525
+ 3. Verify \`test-runs/\` was created with correct manifest.json structure
7526
+ 4. Check that failed test directories have result.json files
7527
+
7528
+ ### Document in CLAUDE.md
7529
+
7530
+ Add to \`./tests/CLAUDE.md\`:
7531
+ - Location: \`reporters/parse-results.ts\`
7532
+ - Usage: \`npx tsx reporters/parse-results.ts --input <file-or-url> [--timestamp <ts>] [--test-id <id>]\`
7533
+ - Where the project's native test output is located (for local runs)`,
7534
+ tags: ["generation", "byot", "results", "parser"]
7535
+ };
7536
+
7237
7537
  // src/tasks/steps/communication/notify-team.ts
7238
7538
  var notifyTeamStep = {
7239
7539
  id: "notify-team",
@@ -7482,11 +7782,13 @@ var STEP_LIBRARY = {
7482
7782
  "create-exploration-test-case": createExplorationTestCaseStep,
7483
7783
  "run-exploration": runExplorationStep,
7484
7784
  "process-exploration-results": processExplorationResultsStep,
7785
+ "normalize-test-results": normalizeTestResultsStep,
7485
7786
  // Generation
7486
7787
  "generate-test-plan": generateTestPlanStep,
7487
7788
  "generate-test-cases": generateTestCasesStep,
7488
7789
  "automate-test-cases": automateTestCasesStep,
7489
7790
  "extract-env-variables": extractEnvVariablesStep,
7791
+ "create-results-parser": createResultsParserStep,
7490
7792
  // Communication
7491
7793
  "notify-team": notifyTeamStep,
7492
7794
  // Maintenance