aztrx-cli 0.4.3 → 0.4.4

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/ui/app.js CHANGED
@@ -2,6 +2,8 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useReducer, useRef, useState } from "react";
3
3
  import { render, Box, Text, useApp } from "ink";
4
4
  import { VERSION } from "../core/version.js";
5
+ import { diagnoseFinding } from "../core/diagnose.js";
6
+ import { diffHunks } from "../core/diff.js";
5
7
  // Palette — mirrors web/app/globals.css "crash seismograph" tokens, mapped to
6
8
  // the nearest ANSI colors so the terminal panel reads as the same instrument.
7
9
  const C = {
@@ -47,6 +49,11 @@ function reducer(state, msg) {
47
49
  }
48
50
  case "repro":
49
51
  return { ...state, repros: { ...state.repros, [msg.repro.finding.fingerprint]: msg.repro } };
52
+ case "heal":
53
+ return {
54
+ ...state,
55
+ findings: state.findings.map((f) => f.fingerprint === msg.heal.finding.fingerprint ? msg.heal.finding : f),
56
+ };
50
57
  default:
51
58
  return state;
52
59
  }
@@ -78,6 +85,7 @@ function useAztrx(bus) {
78
85
  bus.on("noise", () => dispatch({ type: "noise" })),
79
86
  bus.on("route", (r) => dispatch({ type: "route", url: r.url })),
80
87
  bus.on("repro", (r) => dispatch({ type: "repro", repro: r })),
88
+ bus.on("heal", (h) => dispatch({ type: "heal", heal: h })),
81
89
  ];
82
90
  return () => offs.forEach((off) => off());
83
91
  }, [bus]);
@@ -107,11 +115,28 @@ function ReproBadge({ repro }) {
107
115
  return (_jsxs(Text, { color: color, children: ["[", repro.verdict, " ", repro.reproductions, "/", repro.runs, "]"] }));
108
116
  }
109
117
  function FindingRow({ finding, repro }) {
110
- return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(SeverityMark, { severity: finding.severity }), _jsx(Text, { color: C.dim, children: " " }), _jsx(Text, { color: C.fg, children: firstLine(finding.rawMessage) })] }), finding.mappedLocation ? (_jsxs(Text, { color: C.dim, children: [" ", finding.mappedLocation.filePath, ":", finding.mappedLocation.line, ":", finding.mappedLocation.column] })) : null, repro ? (_jsxs(Box, { children: [_jsx(Text, { color: C.dim, children: " " }), _jsx(ReproBadge, { repro: repro }), _jsxs(Text, { color: C.dim, children: [" ", "spec ", repro.specPath, " \u00B7 ", repro.steps, "/", repro.totalSteps, " steps"] })] })) : null] }));
118
+ const dx = diagnoseFinding(finding);
119
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(SeverityMark, { severity: finding.severity }), _jsx(Text, { color: C.dim, children: " " }), _jsx(Text, { color: C.fg, children: firstLine(finding.rawMessage) })] }), finding.mappedLocation ? (_jsxs(Text, { color: C.dim, children: [" ", finding.mappedLocation.filePath, ":", finding.mappedLocation.line, ":", finding.mappedLocation.column] })) : null, dx ? (_jsxs(Text, { color: C.azure, children: [" ↳ ", dx] })) : null, repro ? (_jsxs(Box, { children: [_jsx(Text, { color: C.dim, children: " " }), _jsx(ReproBadge, { repro: repro }), _jsxs(Text, { color: C.dim, children: [" ", "spec ", repro.specPath, " \u00B7 ", repro.steps, "/", repro.totalSteps, " steps"] })] })) : null, finding.heal ? (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: finding.heal.status === "healed" ? C.green : C.amber, children: [" ", finding.heal.status === "healed" ? "✓" : "◐", " ", finding.heal.status, finding.heal.model ? ` · ${finding.heal.model}` : ""] }), finding.heal.status === "healed" && finding.heal.hunks.length > 0 ? (_jsx(DiffView, { hunks: finding.heal.hunks, filePath: finding.heal.filePath })) : null] })) : null] }));
120
+ }
121
+ const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
122
+ function DiffView({ hunks, filePath }) {
123
+ const groups = diffHunks(hunks);
124
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: C.dim, children: [" ", filePath] }), groups.map((group, gi) => (_jsx(Box, { flexDirection: "column", children: group.map((l, i) => (_jsxs(Box, { children: [_jsxs(Text, { color: l.type === "add" ? C.green : C.red, children: [" ", l.type === "add" ? "+" : "-", " "] }), _jsx(Text, { children: l.tokens.map((t, j) => {
125
+ if (t.kind === "del")
126
+ return _jsx(Text, { backgroundColor: "red", color: "white", children: t.text }, j);
127
+ if (t.kind === "add")
128
+ return _jsx(Text, { backgroundColor: "green", color: "black", children: t.text }, j);
129
+ return _jsx(Text, { color: l.type === "add" ? C.green : C.red, children: t.text }, j);
130
+ }) })] }, i))) }, gi)))] }));
111
131
  }
112
132
  function AztrxApp({ bus, done, targetUrl, repoRoot, mode }) {
113
133
  const { exit } = useApp();
114
134
  const { state, rate } = useAztrx(bus);
135
+ const [spin, setSpin] = useState(0);
136
+ useEffect(() => {
137
+ const id = setInterval(() => setSpin((s) => (s + 1) % SPINNER.length), 80);
138
+ return () => clearInterval(id);
139
+ }, []);
115
140
  useEffect(() => {
116
141
  let cancelled = false;
117
142
  const finish = () => {
@@ -125,7 +150,7 @@ function AztrxApp({ bus, done, targetUrl, repoRoot, mode }) {
125
150
  }, [done, exit]);
126
151
  const phase = PHASE_LABEL[state.phase];
127
152
  const currentRoute = state.routes[state.routes.length - 1] ?? targetUrl;
128
- return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: C.azure, bold: true, children: "Aztrx AI" }), _jsx(Text, { color: C.dim, children: " \u2014 Runtime Detector" }), _jsxs(Text, { color: C.dim, children: [" v", VERSION] })] }), _jsxs(Text, { color: C.dim, children: [" target ", targetUrl, " repo ", repoRoot] }), _jsxs(Text, { color: C.dim, children: [" mode ", mode] }), _jsx(Text, { color: C.dim, children: "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" }), _jsxs(Box, { marginTop: 1, children: [_jsx(Text, { color: phase.color, children: phase.text }), _jsx(Text, { color: C.dim, children: " " }), _jsx(Text, { color: C.azureBright, bold: true, children: rate.toFixed(1) }), _jsx(Text, { color: C.dim, children: " ops/s \u00B7 " }), _jsx(Text, { color: C.fg, children: state.actions }), _jsx(Text, { color: C.dim, children: " actions \u00B7 " }), _jsx(Text, { color: C.fg, children: state.clicks }), _jsx(Text, { color: C.dim, children: " clicks" })] }), _jsxs(Box, { children: [_jsx(Text, { color: C.dim, children: " route " }), _jsx(Text, { color: C.muted, children: currentRoute }), _jsxs(Text, { color: C.dim, children: [" \u00B7 ", state.routes.length, " route(s)"] })] }), state.findings.length > 0 ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { color: C.muted, bold: true, children: ["findings (", state.findings.length, ")"] }), state.findings.map((f) => (_jsx(FindingRow, { finding: f, repro: state.repros[f.fingerprint] }, f.fingerprint)))] })) : null, state.noise > 0 ? (_jsxs(Text, { color: C.dim, children: [" \u25B8 ", state.noise, " noise event(s) suppressed"] })) : null] }));
153
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: C.azure, bold: true, children: "Aztrx AI" }), _jsx(Text, { color: C.dim, children: " \u2014 Runtime Detector" }), _jsxs(Text, { color: C.dim, children: [" v", VERSION] })] }), _jsxs(Text, { color: C.dim, children: [" target ", targetUrl, " repo ", repoRoot] }), _jsxs(Text, { color: C.dim, children: [" mode ", mode] }), _jsx(Text, { color: C.dim, children: "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" }), _jsxs(Box, { marginTop: 1, children: [_jsxs(Text, { color: phase.color, children: [state.phase === "done" ? "✓" : SPINNER[spin], " ", phase.text.replace(/^[◉✓]\s*/, "")] }), _jsx(Text, { color: C.dim, children: " " }), _jsx(Text, { color: C.azureBright, bold: true, children: rate.toFixed(1) }), _jsx(Text, { color: C.dim, children: " ops/s \u00B7 " }), _jsx(Text, { color: C.fg, children: state.actions }), _jsx(Text, { color: C.dim, children: " actions \u00B7 " }), _jsx(Text, { color: C.fg, children: state.clicks }), _jsx(Text, { color: C.dim, children: " clicks" })] }), _jsxs(Box, { children: [_jsx(Text, { color: C.dim, children: " route " }), _jsx(Text, { color: C.muted, children: currentRoute }), _jsxs(Text, { color: C.dim, children: [" \u00B7 ", state.routes.length, " route(s)"] })] }), state.findings.length > 0 ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { color: C.muted, bold: true, children: ["findings (", state.findings.length, ")"] }), state.findings.map((f) => (_jsx(FindingRow, { finding: f, repro: state.repros[f.fingerprint] }, f.fingerprint)))] })) : null, state.noise > 0 ? (_jsxs(Text, { color: C.dim, children: [" \u25B8 ", state.noise, " noise event(s) suppressed"] })) : null] }));
129
154
  }
130
155
  /** Mount the live terminal panel and resolve once the run (or a failure) ends. */
131
156
  export function renderTui(props) {
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aztrx-cli",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "private": false,
5
5
  "description": "Aztrx AI — runtime stress-tester for web apps. Detect bugs, then prove them with an executable repro.",
6
6
  "license": "Apache-2.0",
@@ -38,6 +38,7 @@
38
38
  "build": "tsc",
39
39
  "dev": "node dist/cli.js",
40
40
  "bench": "npm run build && tsx bench/run.ts",
41
+ "test": "tsx --test \"tests/**/*.test.ts\"",
41
42
  "typecheck": "tsc --noEmit && tsc -p server/tsconfig.json",
42
43
  "server": "tsx server/index.ts",
43
44
  "server:typecheck": "tsc -p server/tsconfig.json",
@@ -46,14 +47,17 @@
46
47
  "dependencies": {
47
48
  "@jridgewell/trace-mapping": "^0.3.25",
48
49
  "commander": "^12.1.0",
50
+ "gifenc": "^1.0.3",
49
51
  "ink": "^5.2.0",
50
52
  "picocolors": "^1.1.1",
51
53
  "playwright": "1.62.1",
54
+ "pngjs": "^7.0.0",
52
55
  "react": "^18.3.1",
53
56
  "typescript": "^5.7.0"
54
57
  },
55
58
  "devDependencies": {
56
59
  "@types/node": "^22.10.0",
60
+ "@types/pngjs": "^6.0.5",
57
61
  "@types/react": "^18.3.12",
58
62
  "tsx": "^4.19.0"
59
63
  }