@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.
@@ -88,6 +88,7 @@ var init_constants = __esm({
88
88
  PROCESS_EVENT: "process-event",
89
89
  RUN_TESTS: "run-tests",
90
90
  VERIFY_CHANGES: "verify-changes",
91
+ TRIAGE_RESULTS: "triage-results",
91
92
  /** @deprecated Use ONBOARD_TESTING instead */
92
93
  FULL_TEST_COVERAGE: "onboard-testing"
93
94
  };
@@ -1327,6 +1328,7 @@ Before running tests, confirm the selection with the user if ambiguous:
1327
1328
  },
1328
1329
  // Step 7-10: Test Execution (library steps)
1329
1330
  "run-tests",
1331
+ "normalize-test-results",
1330
1332
  "parse-test-results",
1331
1333
  "triage-failures",
1332
1334
  "fix-test-issues",
@@ -1335,14 +1337,7 @@ Before running tests, confirm the selection with the user if ambiguous:
1335
1337
  stepId: "log-product-bugs",
1336
1338
  conditionalOnSubagent: "issue-tracker"
1337
1339
  },
1338
- // Step 12: Knowledge Base Update (library)
1339
- "update-knowledge-base",
1340
- // Step 13: Team Communication (conditional - library step)
1341
- {
1342
- stepId: "notify-team",
1343
- conditionalOnSubagent: "team-communicator"
1344
- },
1345
- // Step 14: Handle Special Cases (inline - task-specific)
1340
+ // Step 12: Handle Special Cases (inline - reference material, positioned before final action steps)
1346
1341
  {
1347
1342
  inline: true,
1348
1343
  title: "Handle Special Cases",
@@ -1390,6 +1385,13 @@ If selected test cases have formatting issues:
1390
1385
  **Related Documentation**:
1391
1386
  - \`./tests/docs/test-execution-strategy.md\` - When and why to run specific tests
1392
1387
  - \`./tests/docs/testing-best-practices.md\` - How to write tests (patterns and anti-patterns)`
1388
+ },
1389
+ // Step 13: Knowledge Base Update (library)
1390
+ "update-knowledge-base",
1391
+ // Step 14: Team Communication (conditional - library step, LAST actionable step)
1392
+ {
1393
+ stepId: "notify-team",
1394
+ conditionalOnSubagent: "team-communicator"
1393
1395
  }
1394
1396
  ],
1395
1397
  requiredSubagents: ["browser-automation", "test-debugger-fixer"],
@@ -2135,6 +2137,116 @@ var init_explore_application = __esm({
2135
2137
  }
2136
2138
  });
2137
2139
 
2140
+ // src/tasks/library/triage-results.ts
2141
+ var triageResultsTask;
2142
+ var init_triage_results = __esm({
2143
+ "src/tasks/library/triage-results.ts"() {
2144
+ "use strict";
2145
+ init_cjs_shims();
2146
+ init_constants();
2147
+ triageResultsTask = {
2148
+ slug: TASK_SLUGS.TRIAGE_RESULTS,
2149
+ name: "Triage Results",
2150
+ description: "Analyze externally-submitted test results and triage failures as product bugs or test issues",
2151
+ frontmatter: {
2152
+ description: "Analyze externally-submitted test results and triage failures as product bugs or test issues",
2153
+ "argument-hint": "[event payload with test results]"
2154
+ },
2155
+ steps: [
2156
+ // Step 1: Overview (inline)
2157
+ {
2158
+ inline: true,
2159
+ title: "Triage Results Overview",
2160
+ content: `# Triage External Test Results
2161
+
2162
+ 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.
2163
+
2164
+ **Goal**: Normalize the results into the standard manifest format, classify each failure as a PRODUCT BUG or TEST ISSUE, and generate a triage report.
2165
+
2166
+ This task is triggered automatically when test results are submitted to the Bugzy webhook from a CI system (GitHub Actions, GitLab CI, etc.).`
2167
+ },
2168
+ // Step 2: Security Notice (library)
2169
+ "security-notice",
2170
+ // Step 3: Arguments (inline)
2171
+ {
2172
+ inline: true,
2173
+ title: "Arguments",
2174
+ content: `Arguments: $ARGUMENTS`
2175
+ },
2176
+ // Step 4: Load Project Context (library)
2177
+ "load-project-context",
2178
+ // Step 5: Knowledge Base Read (library)
2179
+ "read-knowledge-base",
2180
+ // Step 6: Normalize Test Results (library — handles URL/inline results + manifest creation)
2181
+ "normalize-test-results",
2182
+ // Step 7: Triage Failures (existing library step)
2183
+ "triage-failures",
2184
+ // Step 8: Fix Test Issues (library — uses test-debugger-fixer)
2185
+ "fix-test-issues",
2186
+ // Step 9: Log Product Bugs (conditional — requires issue-tracker)
2187
+ {
2188
+ stepId: "log-product-bugs",
2189
+ conditionalOnSubagent: "issue-tracker"
2190
+ },
2191
+ // Step 10: Update Knowledge Base (library)
2192
+ "update-knowledge-base",
2193
+ // Step 11: Notify Team (conditional — requires team-communicator)
2194
+ {
2195
+ stepId: "notify-team",
2196
+ conditionalOnSubagent: "team-communicator"
2197
+ },
2198
+ // Step 12: Generate Triage Report (inline)
2199
+ {
2200
+ inline: true,
2201
+ title: "Generate Triage Report",
2202
+ content: `## Generate Triage Report
2203
+
2204
+ Create a structured triage report as the task output. This report is stored in \`task_executions.result\` and displayed in the Bugzy dashboard.
2205
+
2206
+ **Report Structure:**
2207
+ \`\`\`json
2208
+ {
2209
+ "summary": {
2210
+ "total": <number>,
2211
+ "passed": <number>,
2212
+ "failed": <number>,
2213
+ "skipped": <number>,
2214
+ "duration_ms": <number or null>
2215
+ },
2216
+ "ci_metadata": {
2217
+ "pipeline_url": "<from event payload>",
2218
+ "commit_sha": "<from event payload>",
2219
+ "branch": "<from event payload>"
2220
+ },
2221
+ "triage": {
2222
+ "product_bugs": [
2223
+ {
2224
+ "test_name": "<name>",
2225
+ "error": "<brief error>",
2226
+ "reason": "<why this is a product bug>"
2227
+ }
2228
+ ],
2229
+ "test_issues": [
2230
+ {
2231
+ "test_name": "<name>",
2232
+ "error": "<brief error>",
2233
+ "reason": "<why this is a test issue>"
2234
+ }
2235
+ ]
2236
+ }
2237
+ }
2238
+ \`\`\`
2239
+
2240
+ Output this JSON as the final result of the task.`
2241
+ }
2242
+ ],
2243
+ requiredSubagents: ["browser-automation", "test-debugger-fixer"],
2244
+ optionalSubagents: ["issue-tracker", "team-communicator"],
2245
+ dependentTasks: []
2246
+ };
2247
+ }
2248
+ });
2249
+
2138
2250
  // src/tasks/index.ts
2139
2251
  var tasks_exports = {};
2140
2252
  __export(tasks_exports, {
@@ -2170,6 +2282,7 @@ var init_tasks = __esm({
2170
2282
  init_verify_changes();
2171
2283
  init_onboard_testing();
2172
2284
  init_explore_application();
2285
+ init_triage_results();
2173
2286
  init_constants();
2174
2287
  TASK_TEMPLATES = {
2175
2288
  [TASK_SLUGS.GENERATE_TEST_CASES]: generateTestCasesTask,
@@ -2179,7 +2292,8 @@ var init_tasks = __esm({
2179
2292
  [TASK_SLUGS.RUN_TESTS]: runTestsTask,
2180
2293
  [TASK_SLUGS.VERIFY_CHANGES]: verifyChangesTask,
2181
2294
  [TASK_SLUGS.ONBOARD_TESTING]: onboardTestingTask,
2182
- [TASK_SLUGS.EXPLORE_APPLICATION]: exploreApplicationTask
2295
+ [TASK_SLUGS.EXPLORE_APPLICATION]: exploreApplicationTask,
2296
+ [TASK_SLUGS.TRIAGE_RESULTS]: triageResultsTask
2183
2297
  };
2184
2298
  }
2185
2299
  });
@@ -7230,6 +7344,10 @@ The agent will:
7230
7344
  4. Apply appropriate fix pattern from \`./tests/CLAUDE.md\`
7231
7345
  5. Rerun the test
7232
7346
  6. The custom reporter will automatically create the next exec-N/ folder
7347
+ 6b. If no custom reporter (BYOT mode \u2014 check for \`reporters/bugzy-reporter.ts\`):
7348
+ Run the parse script to update the manifest with re-run results:
7349
+ \`npx tsx reporters/parse-results.ts --input <re-run-output> --timestamp <current> --test-id <testCaseId>\`
7350
+ This creates exec-N+1/ and updates the manifest.
7233
7351
  7. Repeat up to 3 times if needed (exec-1, exec-2, exec-3)
7234
7352
  8. Report success or escalate as likely product bug
7235
7353
 
@@ -7425,6 +7543,88 @@ ls -t test-runs/ | head -1
7425
7543
  tags: ["execution", "exploration"]
7426
7544
  };
7427
7545
 
7546
+ // src/tasks/steps/execution/normalize-test-results.ts
7547
+ init_cjs_shims();
7548
+ var normalizeTestResultsStep = {
7549
+ id: "normalize-test-results",
7550
+ title: "Normalize Test Results",
7551
+ category: "execution",
7552
+ content: `## Normalize Test Results
7553
+
7554
+ 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.
7555
+
7556
+ ### 1. Check for Existing Manifest
7557
+
7558
+ 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.
7559
+
7560
+ ### 2. Determine Input Source
7561
+
7562
+ Check how test results are available:
7563
+
7564
+ **From event payload** (external CI \u2014 \`$ARGUMENTS\` contains event data):
7565
+ - \`data.results_url\` \u2014 URL to download results from (the parse script handles the download)
7566
+ - \`data.results\` \u2014 inline results (write to a temp file first: \`/tmp/bugzy-results-<random>.json\`)
7567
+
7568
+ **From local test run** (agent executed BYOT tests):
7569
+ - Read \`./tests/CLAUDE.md\` for the native test output location
7570
+ - Find the most recent test output file
7571
+
7572
+ ### 3. Locate and Run Parse Script
7573
+
7574
+ Look for the parse script at \`reporters/parse-results.ts\`.
7575
+
7576
+ **If the parse script exists:**
7577
+ \`\`\`bash
7578
+ npx tsx reporters/parse-results.ts --input <source>
7579
+ \`\`\`
7580
+ Where \`<source>\` is the file path, temp file path, or URL determined in step 2.
7581
+
7582
+ **If the parse script is missing** (fallback for robustness):
7583
+ Create the manifest inline using the same approach \u2014 parse the results format by inspecting the data structure:
7584
+ - JSON with \`suites\` or \`specs\` arrays: Likely Playwright JSON report
7585
+ - XML with \`<testsuites>\` or \`<testsuite>\` root: JUnit XML format
7586
+ - JSON with \`results\` array and \`stats\` object: Likely Cypress/Mocha JSON
7587
+ - Other: Inspect structure and adapt
7588
+
7589
+ Then create:
7590
+ 1. \`test-runs/{timestamp}/manifest.json\` with the standard Bugzy schema
7591
+ 2. \`test-runs/{timestamp}/{testCaseId}/exec-1/result.json\` for each failed test
7592
+
7593
+ Save the inline parse logic to \`reporters/parse-results.ts\` for future reuse.
7594
+
7595
+ ### 4. Verify Manifest
7596
+
7597
+ Confirm \`manifest.json\` was created:
7598
+ - Read the manifest and validate the structure
7599
+ - Check that \`stats\` counts match the \`testCases\` array
7600
+
7601
+ ### 5. Generate Summary
7602
+
7603
+ Read the manifest and produce a summary:
7604
+
7605
+ \`\`\`markdown
7606
+ ## Test Results Summary
7607
+
7608
+ - Total Tests: [count]
7609
+ - Passed: [count] ([percentage]%)
7610
+ - Failed: [count] ([percentage]%)
7611
+ - Skipped: [count] ([percentage]%)
7612
+ - Duration: [time if available]
7613
+ \`\`\`
7614
+
7615
+ ### 6. Include CI Metadata (if from event payload)
7616
+
7617
+ If the results came from an external CI event (\`$ARGUMENTS\` contains \`data.metadata\`), include:
7618
+ - **Pipeline URL**: \`data.metadata.pipeline_url\`
7619
+ - **Commit**: \`data.metadata.commit_sha\`
7620
+ - **Branch**: \`data.metadata.branch\`
7621
+
7622
+ ### 7. All Tests Passed?
7623
+
7624
+ If there are **no failures**, note that all tests passed. Downstream triage and fix steps can be skipped.`,
7625
+ tags: ["execution", "results", "normalization", "byot"]
7626
+ };
7627
+
7428
7628
  // src/tasks/steps/generation/generate-test-plan.ts
7429
7629
  init_cjs_shims();
7430
7630
  var generateTestPlanStep = {
@@ -7613,6 +7813,117 @@ TEST_API_KEY=secret_key_here
7613
7813
  tags: ["generation", "environment"]
7614
7814
  };
7615
7815
 
7816
+ // src/tasks/steps/generation/create-results-parser.ts
7817
+ init_cjs_shims();
7818
+ var createResultsParserStep = {
7819
+ id: "create-results-parser",
7820
+ title: "Create Results Parser Script",
7821
+ category: "generation",
7822
+ content: `## Create Results Parser Script
7823
+
7824
+ 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.
7825
+
7826
+ ### Inspect the Test Project
7827
+
7828
+ 1. Read \`./tests/CLAUDE.md\` to understand:
7829
+ - Which test framework is used (Playwright, Cypress, Jest, Mocha, etc.)
7830
+ - How tests are run and where output goes
7831
+ - The native report format (JSON, JUnit XML, etc.)
7832
+ 2. Check the test runner config file (e.g., \`playwright.config.ts\`, \`cypress.config.ts\`, \`jest.config.ts\`) for report settings
7833
+ 3. If a sample test output exists, read it to understand the exact structure
7834
+
7835
+ ### Create the Parse Script
7836
+
7837
+ Create \`reporters/parse-results.ts\` \u2014 a Node.js/TypeScript CLI script.
7838
+
7839
+ **Interface:**
7840
+ \`\`\`
7841
+ npx tsx reporters/parse-results.ts --input <file-or-url> [--timestamp <existing>] [--test-id <id>]
7842
+ \`\`\`
7843
+
7844
+ **Arguments:**
7845
+ - \`--input\` (required): file path or URL to the test results
7846
+ - If URL (starts with \`http://\` or \`https://\`): download with 30s timeout
7847
+ - If file path: read directly from disk
7848
+ - \`--timestamp\` (optional): existing run timestamp for incremental updates
7849
+ - \`--test-id\` (optional): specific test case ID for incremental updates (used with \`--timestamp\`)
7850
+
7851
+ **Normal mode** (no \`--timestamp\`):
7852
+ 1. Parse the project-specific test output format
7853
+ 2. Generate a timestamp: \`YYYYMMDD-HHmmss\`
7854
+ 3. Create \`test-runs/{timestamp}/manifest.json\` with the standard Bugzy schema:
7855
+ \`\`\`json
7856
+ {
7857
+ "bugzyExecutionId": "<from BUGZY_EXECUTION_ID env var or 'local'>",
7858
+ "timestamp": "<YYYYMMDD-HHmmss>",
7859
+ "startTime": "<ISO8601>",
7860
+ "endTime": "<ISO8601>",
7861
+ "status": "completed",
7862
+ "stats": {
7863
+ "totalTests": 0,
7864
+ "passed": 0,
7865
+ "failed": 0,
7866
+ "totalExecutions": 0
7867
+ },
7868
+ "testCases": [
7869
+ {
7870
+ "id": "<slugified test name, e.g. TC-001-login>",
7871
+ "name": "<original test name>",
7872
+ "totalExecutions": 1,
7873
+ "finalStatus": "passed|failed",
7874
+ "executions": [
7875
+ {
7876
+ "executionNumber": 1,
7877
+ "status": "passed|failed",
7878
+ "error": "<error message if failed, null if passed>",
7879
+ "duration": null,
7880
+ "hasTrace": false,
7881
+ "hasScreenshots": false
7882
+ }
7883
+ ]
7884
+ }
7885
+ ]
7886
+ }
7887
+ \`\`\`
7888
+ 4. For each failed test, create:
7889
+ - Directory: \`test-runs/{timestamp}/{testCaseId}/exec-1/\`
7890
+ - File: \`test-runs/{timestamp}/{testCaseId}/exec-1/result.json\` containing:
7891
+ \`\`\`json
7892
+ {
7893
+ "status": "failed",
7894
+ "error": "<full error message>",
7895
+ "stackTrace": "<stack trace if available>",
7896
+ "duration": null,
7897
+ "testFile": "<file path if available>"
7898
+ }
7899
+ \`\`\`
7900
+ 5. Print the manifest path to stdout
7901
+ 6. Exit code 0 on success, non-zero on failure
7902
+
7903
+ **Incremental mode** (\`--timestamp\` + \`--test-id\` provided):
7904
+ 1. Read existing \`test-runs/{timestamp}/manifest.json\`
7905
+ 2. Parse the new test results for the specified test case
7906
+ 3. Find the next execution number (e.g., if exec-2 exists, create exec-3)
7907
+ 4. Create \`test-runs/{timestamp}/{testCaseId}/exec-N/result.json\`
7908
+ 5. Update the manifest: add execution entry, update \`totalExecutions\`, update \`finalStatus\` and stats
7909
+ 6. Print the manifest path to stdout
7910
+
7911
+ ### Test the Script
7912
+
7913
+ 1. Run the project's tests to generate a sample output (or use an existing one)
7914
+ 2. Run the parse script: \`npx tsx reporters/parse-results.ts --input <sample-output>\`
7915
+ 3. Verify \`test-runs/\` was created with correct manifest.json structure
7916
+ 4. Check that failed test directories have result.json files
7917
+
7918
+ ### Document in CLAUDE.md
7919
+
7920
+ Add to \`./tests/CLAUDE.md\`:
7921
+ - Location: \`reporters/parse-results.ts\`
7922
+ - Usage: \`npx tsx reporters/parse-results.ts --input <file-or-url> [--timestamp <ts>] [--test-id <id>]\`
7923
+ - Where the project's native test output is located (for local runs)`,
7924
+ tags: ["generation", "byot", "results", "parser"]
7925
+ };
7926
+
7616
7927
  // src/tasks/steps/communication/notify-team.ts
7617
7928
  init_cjs_shims();
7618
7929
  var notifyTeamStep = {
@@ -7868,11 +8179,13 @@ var STEP_LIBRARY = {
7868
8179
  "create-exploration-test-case": createExplorationTestCaseStep,
7869
8180
  "run-exploration": runExplorationStep,
7870
8181
  "process-exploration-results": processExplorationResultsStep,
8182
+ "normalize-test-results": normalizeTestResultsStep,
7871
8183
  // Generation
7872
8184
  "generate-test-plan": generateTestPlanStep,
7873
8185
  "generate-test-cases": generateTestCasesStep,
7874
8186
  "automate-test-cases": automateTestCasesStep,
7875
8187
  "extract-env-variables": extractEnvVariablesStep,
8188
+ "create-results-parser": createResultsParserStep,
7876
8189
  // Communication
7877
8190
  "notify-team": notifyTeamStep,
7878
8191
  // Maintenance