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