badgr-ci-triage 0.1.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/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # badgr-ci-triage
2
+
3
+ Paste a failing CI log and get a plain-English diagnosis — dependency conflict, flaky test, build error, race condition, or environment issue.
4
+
5
+ ```bash
6
+ npx badgr-ci-triage --log "npm ERR ERESOLVE unable to resolve dependency tree"
7
+ ```
8
+
9
+ **Free. No signup required.** Runs entirely on your machine.
10
+
11
+ ---
12
+
13
+ ## The problem it solves
14
+
15
+ CI failures produce walls of text. Finding the root cause means scanning hundreds of log lines to spot the one error that matters. `badgr-ci-triage` classifies the failure instantly and tells you exactly what to do — no log reading required.
16
+
17
+ ---
18
+
19
+ ## Quick start
20
+
21
+ ```bash
22
+ # Pass log text directly
23
+ npx badgr-ci-triage --log "npm ERR ERESOLVE unable to resolve dependency tree"
24
+
25
+ # Pipe from a file or command
26
+ cat ci-output.txt | npx badgr-ci-triage
27
+
28
+ # Machine-readable JSON (for CI dashboards or scripts)
29
+ npx badgr-ci-triage --log "TypeError: Cannot read properties of undefined" --json
30
+ ```
31
+
32
+ ---
33
+
34
+ ## CLI flags
35
+
36
+ | Flag | Description |
37
+ |------|-------------|
38
+ | `--log <text>` | CI log text to triage (alternatively, pipe via stdin) |
39
+ | `--json` | Output machine-readable JSON |
40
+
41
+ **Exit codes:** `0` = failure categorized with a recommended action, `1` = unknown or empty log
42
+
43
+ ---
44
+
45
+ ## Failure categories
46
+
47
+ | Category | Detected from |
48
+ |---|---|
49
+ | `dependency` | `ERESOLVE`, lockfile errors, `package not found` |
50
+ | `build` | TypeScript errors (`tsc`), `SyntaxError`, webpack/vite failures |
51
+ | `test` | `assert`, snapshot mismatches, `test failed` |
52
+ | `deployment` | Deploy/release failures, health check timeouts |
53
+ | `race` | Flaky failures, timeouts, deadlocks |
54
+ | `environment` | Missing env vars, `permission denied`, secret references |
55
+
56
+ ---
57
+
58
+ ## Example output
59
+
60
+ ```
61
+ badgr-ci-triage — dependency failure
62
+
63
+ ✗ ERESOLVE: unable to resolve dependency tree
64
+
65
+ Recommended action: Delete node_modules and package-lock.json, then reinstall from scratch.
66
+ rm -rf node_modules package-lock.json && npm install
67
+ ```
68
+
69
+ ```
70
+ badgr-ci-triage — environment failure
71
+
72
+ ✗ Missing environment variable: DATABASE_URL
73
+
74
+ Recommended action: Add DATABASE_URL to your CI environment secrets.
75
+ Check your CI settings or .env.example for required variables.
76
+ ```
77
+
78
+ ---
79
+
80
+ ## TypeScript API
81
+
82
+ ```ts
83
+ import { triageCiLog } from "badgr-ci-triage";
84
+
85
+ const result = triageCiLog(`
86
+ npm ERR code ERESOLVE
87
+ npm ERR ERESOLVE unable to resolve dependency tree
88
+ `);
89
+
90
+ console.log(result.category); // "dependency"
91
+ console.log(result.checks); // [{ status: "fail", label: "ERESOLVE", detail: "..." }]
92
+ ```
93
+
94
+ **Types:**
95
+
96
+ ```ts
97
+ interface CiTriageResult {
98
+ category:
99
+ | "dependency"
100
+ | "build"
101
+ | "test"
102
+ | "deployment"
103
+ | "race"
104
+ | "environment"
105
+ | "unknown";
106
+ checks: DiagnosticCheck[];
107
+ report: JsonReport;
108
+ }
109
+
110
+ function triageCiLog(log: string): CiTriageResult
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Use in CI
116
+
117
+ Triage your own CI logs as part of the pipeline to get structured failure data:
118
+
119
+ ```yaml
120
+ # GitHub Actions example
121
+ - name: Triage CI failure
122
+ if: failure()
123
+ run: echo "${{ steps.build.outputs.stderr }}" | npx badgr-ci-triage --json
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Requirements
129
+
130
+ - Node.js 18+
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ import { createLogger, fireTelemetry } from "badgr-shared";
3
+ import { triageCiLog } from "./index.js";
4
+ fireTelemetry({ package: "badgr-ci-triage" });
5
+ function readArg(name) {
6
+ const index = process.argv.indexOf(name);
7
+ return index >= 0 ? process.argv[index + 1] : undefined;
8
+ }
9
+ if (process.argv.includes("--help") || process.argv.includes("-h")) {
10
+ console.log(`badgr-ci-triage — local CI log triage
11
+
12
+ Usage:
13
+ npx badgr-ci-triage --log "npm ERR ERESOLVE unable to resolve dependency tree"
14
+ npx badgr-ci-triage --log "<log text>" --json
15
+ echo "<log>" | npx badgr-ci-triage
16
+
17
+ Flags:
18
+ --log <text> First failing CI log section to triage
19
+ --json Output machine-readable JSON
20
+
21
+ Categories detected:
22
+ dependency ERESOLVE, lockfile, package not found
23
+ build tsc, SyntaxError, webpack, vite
24
+ test assert, snapshot, test failed
25
+ deployment deploy, release, health check
26
+ race flaky, timeout, deadlock
27
+ environment env, secret, permission denied
28
+
29
+ Exit codes:
30
+ 0 Log present and categorised
31
+ 1 Log empty or uncategorised
32
+
33
+ No signup required. Hosted execution receipts are optional.
34
+
35
+ Environment:
36
+ BADGR_TELEMETRY=0 Disable anonymous usage telemetry`);
37
+ process.exit(0);
38
+ }
39
+ const logArg = readArg("--log");
40
+ // Accept piped stdin or positional args when --log is not provided.
41
+ const logText = logArg ?? process.argv.slice(2).filter((a) => a !== "--json").join(" ");
42
+ const json = process.argv.includes("--json");
43
+ const result = triageCiLog(logText);
44
+ const logger = createLogger(json);
45
+ if (json) {
46
+ logger.report(result.report);
47
+ }
48
+ else {
49
+ logger.line(`Likely CI failure: ${result.category}`);
50
+ logger.line("");
51
+ for (const action of result.report.recommendedActions)
52
+ logger.line(` - ${action}`);
53
+ logger.line("");
54
+ logger.line("Optional: use AI Badgr for execution receipts and failure history.");
55
+ }
56
+ process.exitCode = result.report.status === "failed" ? 1 : 0;
57
+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AI,CAAC,CAAC;AAClC,IAAI,IAAI,EAAE,CAAC;IACT,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;KAAM,CAAC;IACN,MAAM,CAAC,IAAI,CAAC,sBAAsB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrD,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChB,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB;QAAE,MAAM,CAAC,IAAI,CAAC,OAAO,MAAM,EAAE,CAAC,CAAC;IACpF,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChB,MAAM,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;AACpF,CAAC;AACD,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type DiagnosticCheck, type JsonReport } from "badgr-shared";
2
+ export interface CiTriageResult {
3
+ category: "dependency" | "build" | "test" | "deployment" | "race" | "environment" | "unknown";
4
+ checks: DiagnosticCheck[];
5
+ report: JsonReport;
6
+ }
7
+ export declare function triageCiLog(log: string): CiTriageResult;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0D,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE7H,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;IAC9F,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAsBvD"}
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ import { checkToFinding, createReport, reportStatusFromFindings } from "badgr-shared";
2
+ export function triageCiLog(log) {
3
+ const lower = log.toLowerCase();
4
+ const category = classify(lower);
5
+ const checks = [
6
+ { name: "log-present", status: log.trim() ? "pass" : "fail", message: log.trim() ? "CI log provided" : "CI log is empty" },
7
+ { name: "failure-category", status: category === "unknown" ? "warn" : "fail", message: category === "unknown" ? "No known CI failure pattern matched" : `Likely ${category} failure detected`, details: { category } },
8
+ ];
9
+ const findings = checks.map((check) => checkToFinding(check, "CI_TRIAGE"));
10
+ const status = reportStatusFromFindings(findings);
11
+ return {
12
+ category,
13
+ checks,
14
+ report: createReport({
15
+ tool: "ci-triage",
16
+ status,
17
+ summary: category === "unknown" ? "CI failure needs manual review" : `Likely ${category} CI failure`,
18
+ findings,
19
+ recommendedActions: [nextStep(category), "Attach the triage report to the failing automation issue"],
20
+ nextCommand: "npx @aibadgr/ci-triage --json",
21
+ actionUrl: "https://aibadgr.com/agents/connect",
22
+ }),
23
+ };
24
+ }
25
+ function classify(log) {
26
+ if (/module not found|eresolve|dependency|lockfile|package not found/.test(log))
27
+ return "dependency";
28
+ if (/tsc|syntaxerror|compile|build failed|webpack|vite/.test(log))
29
+ return "build";
30
+ if (/flaky|timed out|timeout|race condition|deadlock/.test(log))
31
+ return "race";
32
+ if (/assert|expected|test failed|snapshot/.test(log))
33
+ return "test";
34
+ if (/deploy|release|rollout|health check/.test(log))
35
+ return "deployment";
36
+ if (/env|secret|permission denied|not configured/.test(log))
37
+ return "environment";
38
+ return "unknown";
39
+ }
40
+ function nextStep(category) {
41
+ const steps = {
42
+ dependency: "Reinstall dependencies from a clean lockfile and verify package versions",
43
+ build: "Run the build locally with the same runtime and inspect the first compiler error",
44
+ test: "Rerun the failing test with focused logging and isolate the assertion mismatch",
45
+ deployment: "Check deployment health checks, environment variables, and release logs",
46
+ race: "Rerun with serial execution or increased timeout to confirm race/flake behavior",
47
+ environment: "Verify required secrets, permissions, paths, and runtime config",
48
+ unknown: "Collect the first failing log section and rerun with verbose output",
49
+ };
50
+ return steps[category];
51
+ }
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,wBAAwB,EAAyC,MAAM,cAAc,CAAC;AAQ7H,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAChC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,MAAM,GAAsB;QAChC,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,EAAE;QAC1H,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,UAAU,QAAQ,mBAAmB,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE;KACvN,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO;QACL,QAAQ;QACR,MAAM;QACN,MAAM,EAAE,YAAY,CAAC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-first CI log triage for flaky tests, dependency failures, build errors, and race conditions.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": { "badgr-ci-triage": "dist/cli.js" },
9
+ "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
10
+ "files": ["dist", "README.md"],
11
+ "scripts": { "build": "tsc -b", "typecheck": "tsc -b --pretty false", "test": "vitest run" },
12
+ "dependencies": { "badgr-shared": "0.1.1" },
13
+ "engines": { "node": ">=18.0.0" },
14
+ "keywords": ["ci", "triage", "github-actions", "flaky", "build-failure"],
15
+ "license": "MIT"
16
+ }