aztrx-cli 0.4.3 → 0.4.5

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,13 @@ 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
+ };
57
+ case "notice":
58
+ return { ...state, notices: [...state.notices, msg.notice] };
50
59
  default:
51
60
  return state;
52
61
  }
@@ -61,6 +70,7 @@ const initialState = {
61
70
  routes: [],
62
71
  navigations: 0,
63
72
  done: false,
73
+ notices: [],
64
74
  };
65
75
  function useAztrx(bus) {
66
76
  const [state, dispatch] = useReducer(reducer, initialState);
@@ -78,6 +88,8 @@ function useAztrx(bus) {
78
88
  bus.on("noise", () => dispatch({ type: "noise" })),
79
89
  bus.on("route", (r) => dispatch({ type: "route", url: r.url })),
80
90
  bus.on("repro", (r) => dispatch({ type: "repro", repro: r })),
91
+ bus.on("heal", (h) => dispatch({ type: "heal", heal: h })),
92
+ bus.on("notice", (n) => dispatch({ type: "notice", notice: n })),
81
93
  ];
82
94
  return () => offs.forEach((off) => off());
83
95
  }, [bus]);
@@ -107,11 +119,37 @@ function ReproBadge({ repro }) {
107
119
  return (_jsxs(Text, { color: color, children: ["[", repro.verdict, " ", repro.reproductions, "/", repro.runs, "]"] }));
108
120
  }
109
121
  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] }));
122
+ const dx = diagnoseFinding(finding);
123
+ 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] }));
124
+ }
125
+ const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
126
+ const NOTICE_STYLE = {
127
+ hint: { color: C.azure, glyph: "💡" },
128
+ warning: { color: C.amber, glyph: "⚠" },
129
+ danger: { color: C.red, glyph: "⚠" },
130
+ };
131
+ function NoticeRow({ notice }) {
132
+ const style = NOTICE_STYLE[notice.level];
133
+ return (_jsxs(Text, { color: style.color, children: [style.glyph, " ", notice.message] }));
134
+ }
135
+ function DiffView({ hunks, filePath }) {
136
+ const groups = diffHunks(hunks);
137
+ 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) => {
138
+ if (t.kind === "del")
139
+ return _jsx(Text, { backgroundColor: "red", color: "white", children: t.text }, j);
140
+ if (t.kind === "add")
141
+ return _jsx(Text, { backgroundColor: "green", color: "black", children: t.text }, j);
142
+ return _jsx(Text, { color: l.type === "add" ? C.green : C.red, children: t.text }, j);
143
+ }) })] }, i))) }, gi)))] }));
111
144
  }
112
145
  function AztrxApp({ bus, done, targetUrl, repoRoot, mode }) {
113
146
  const { exit } = useApp();
114
147
  const { state, rate } = useAztrx(bus);
148
+ const [spin, setSpin] = useState(0);
149
+ useEffect(() => {
150
+ const id = setInterval(() => setSpin((s) => (s + 1) % SPINNER.length), 80);
151
+ return () => clearInterval(id);
152
+ }, []);
115
153
  useEffect(() => {
116
154
  let cancelled = false;
117
155
  const finish = () => {
@@ -125,7 +163,7 @@ function AztrxApp({ bus, done, targetUrl, repoRoot, mode }) {
125
163
  }, [done, exit]);
126
164
  const phase = PHASE_LABEL[state.phase];
127
165
  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] }));
166
+ 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.notices.length > 0 ? (_jsx(Box, { flexDirection: "column", marginTop: 1, children: state.notices.map((n, i) => (_jsx(NoticeRow, { notice: n }, i))) })) : null, 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
167
  }
130
168
  /** Mount the live terminal panel and resolve once the run (or a failure) ends. */
131
169
  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.5",
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
  }