@testver/testver 0.2.4 → 1.0.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/index.js CHANGED
@@ -45018,7 +45018,12 @@ var init_project_scanner = __esm({
45018
45018
  * Search file contents across the project (grep-like).
45019
45019
  */
45020
45020
  searchFiles(pattern, maxResults = 50) {
45021
- const regex = new RegExp(pattern, "gi");
45021
+ let regex;
45022
+ try {
45023
+ regex = new RegExp(pattern, "gi");
45024
+ } catch {
45025
+ regex = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gi");
45026
+ }
45022
45027
  const results = [];
45023
45028
  this.walkTree(this.projectPath, "", (relPath, isDir) => {
45024
45029
  if (isDir || results.length >= maxResults) return;
@@ -94717,6 +94722,198 @@ var init_api_connectors = __esm({
94717
94722
  }
94718
94723
  });
94719
94724
 
94725
+ // src/ui/routes/api-search.ts
94726
+ var api_search_exports = {};
94727
+ __export(api_search_exports, {
94728
+ mountSearchRoutes: () => mountSearchRoutes
94729
+ });
94730
+ function mountSearchRoutes(app, deps) {
94731
+ const { scanner, tmStore: tmStore4, cloudConfigStore, projectPath: projectPath2 } = deps;
94732
+ app.get("/api/search/global", (req, res) => {
94733
+ try {
94734
+ const q4 = String(req.query.q ?? "").trim();
94735
+ const perType = Math.max(1, Math.min(Number(req.query.limit) || 5, 10));
94736
+ if (q4.length < 2) {
94737
+ res.json({ results: [] });
94738
+ return;
94739
+ }
94740
+ const ql = q4.toLowerCase();
94741
+ const results = [];
94742
+ const seen = /* @__PURE__ */ new Set();
94743
+ const group = (fn) => {
94744
+ try {
94745
+ fn();
94746
+ } catch {
94747
+ }
94748
+ };
94749
+ const push = (r) => {
94750
+ const k = `${r.type}:${r.id}`;
94751
+ if (seen.has(k)) return;
94752
+ seen.add(k);
94753
+ results.push(r);
94754
+ };
94755
+ const idMatch = /^(tc|d|tp|src)-?(\d+)$/i.exec(q4);
94756
+ if (idMatch) {
94757
+ const prefix = idMatch[1].toUpperCase();
94758
+ const exactId = `${prefix}-${idMatch[2]}`;
94759
+ group(() => {
94760
+ if (prefix === "TC") {
94761
+ const tc = tmStore4.getTestCase(exactId);
94762
+ if (tc) push({ type: "testcase", id: tc.id, title: tc.title, subtitle: [tc.id, tc.priority].filter(Boolean).join(" \xB7 "), route: `/test-cases?tcId=${encodeURIComponent(tc.id)}` });
94763
+ } else if (prefix === "D") {
94764
+ const d = tmStore4.getDefect(exactId);
94765
+ if (d) push({ type: "defect", id: d.id, title: d.title, subtitle: [d.id, d.severity, d.status].filter(Boolean).join(" \xB7 "), route: `/defects?defectId=${encodeURIComponent(d.id)}` });
94766
+ } else if (prefix === "TP") {
94767
+ const p = tmStore4.getTestPlan(exactId);
94768
+ if (p) push({ type: "testplan", id: p.id, title: p.name, subtitle: [p.id, p.release].filter(Boolean).join(" \xB7 "), route: `/test-plans?planId=${encodeURIComponent(p.id)}` });
94769
+ } else if (prefix === "SRC") {
94770
+ const s = tmStore4.getSource(exactId);
94771
+ if (s) push({ type: "source", id: s.id, title: s.title, subtitle: [s.id, s.type].filter(Boolean).join(" \xB7 "), route: `/sources${s.type ? `?tab=${encodeURIComponent(s.type)}` : ""}` });
94772
+ }
94773
+ });
94774
+ }
94775
+ group(() => {
94776
+ const { testCases } = tmStore4.listTestCases({ search: q4, limit: perType });
94777
+ for (const tc of testCases) {
94778
+ push({
94779
+ type: "testcase",
94780
+ id: tc.id,
94781
+ title: tc.title,
94782
+ subtitle: [tc.id, tc.priority, tc.automationStatus].filter(Boolean).join(" \xB7 "),
94783
+ route: `/test-cases?tcId=${encodeURIComponent(tc.id)}`
94784
+ });
94785
+ }
94786
+ });
94787
+ if (q4.length >= 3) {
94788
+ group(() => {
94789
+ const scan = scanAllTests(projectPath2);
94790
+ const all = scan.suites.flatMap((s) => s.tests);
94791
+ let n = 0;
94792
+ for (const t of all) {
94793
+ if (n >= perType) break;
94794
+ const nameL = t.name.toLowerCase();
94795
+ const fileL = t.file.toLowerCase();
94796
+ if (nameL.includes(ql) || fileL.includes(ql)) {
94797
+ const fileName = t.file.split(/[/\\]/).pop() || t.file;
94798
+ push({
94799
+ type: "test",
94800
+ id: `${t.file}::${t.name}`,
94801
+ title: t.name,
94802
+ subtitle: `${fileName} \xB7 ${t.framework}`,
94803
+ route: `/tests?file=${encodeURIComponent(t.file)}&test=${encodeURIComponent(t.name)}`
94804
+ });
94805
+ n++;
94806
+ }
94807
+ }
94808
+ });
94809
+ }
94810
+ group(() => {
94811
+ const plans = tmStore4.listTestPlans();
94812
+ let n = 0;
94813
+ for (const p of plans) {
94814
+ if (n >= perType) break;
94815
+ if (p.name?.toLowerCase().includes(ql) || p.id.toLowerCase().includes(ql)) {
94816
+ push({
94817
+ type: "testplan",
94818
+ id: p.id,
94819
+ title: p.name,
94820
+ subtitle: [p.id, p.release, p.sprint].filter(Boolean).join(" \xB7 "),
94821
+ route: `/test-plans?planId=${encodeURIComponent(p.id)}`
94822
+ });
94823
+ n++;
94824
+ }
94825
+ }
94826
+ });
94827
+ group(() => {
94828
+ const defects = tmStore4.listDefects({ search: q4 }).slice(0, perType);
94829
+ for (const d of defects) {
94830
+ push({
94831
+ type: "defect",
94832
+ id: d.id,
94833
+ title: d.title,
94834
+ subtitle: [d.id, d.severity, d.status].filter(Boolean).join(" \xB7 "),
94835
+ route: `/defects?defectId=${encodeURIComponent(d.id)}`
94836
+ });
94837
+ }
94838
+ });
94839
+ group(() => {
94840
+ const sources = tmStore4.listSources({ search: q4 }).slice(0, perType);
94841
+ for (const s of sources) {
94842
+ push({
94843
+ type: "source",
94844
+ id: s.id,
94845
+ title: s.title,
94846
+ subtitle: [s.id, s.type].filter(Boolean).join(" \xB7 "),
94847
+ // SourcesPage groups by `tab` (= source type); landing on the
94848
+ // matching tab puts the row in view.
94849
+ route: `/sources${s.type ? `?tab=${encodeURIComponent(s.type)}` : ""}`
94850
+ });
94851
+ }
94852
+ });
94853
+ group(() => {
94854
+ const schedules = cloudConfigStore.getSchedules();
94855
+ let n = 0;
94856
+ for (const s of schedules) {
94857
+ if (n >= perType) break;
94858
+ if (s.name?.toLowerCase().includes(ql)) {
94859
+ push({
94860
+ type: "schedule",
94861
+ id: s.id,
94862
+ title: s.name,
94863
+ subtitle: s.cron ? `cron: ${s.cron}` : void 0,
94864
+ route: "/schedules"
94865
+ });
94866
+ n++;
94867
+ }
94868
+ }
94869
+ });
94870
+ group(() => {
94871
+ const connectors = tmStore4.listConnectors();
94872
+ let n = 0;
94873
+ for (const c2 of connectors) {
94874
+ if (n >= perType) break;
94875
+ const name = String(c2.name ?? "");
94876
+ const type2 = String(c2.type ?? "");
94877
+ if (name.toLowerCase().includes(ql) || type2.toLowerCase().includes(ql)) {
94878
+ push({
94879
+ type: "connector",
94880
+ id: String(c2.id),
94881
+ title: name || type2,
94882
+ subtitle: type2 || void 0,
94883
+ route: "/connectors"
94884
+ });
94885
+ n++;
94886
+ }
94887
+ }
94888
+ });
94889
+ if (q4.length >= 3) {
94890
+ group(() => {
94891
+ const hits = scanner.searchFiles(q4, perType);
94892
+ for (const h of hits) {
94893
+ const fileName = h.file.split(/[/\\]/).pop() || h.file;
94894
+ push({
94895
+ type: "file",
94896
+ id: `${h.file}:${h.line}`,
94897
+ title: fileName,
94898
+ subtitle: `Line ${h.line}: ${h.content.substring(0, 80)}`,
94899
+ route: `/explorer?file=${encodeURIComponent(h.file)}&line=${h.line}`
94900
+ });
94901
+ }
94902
+ });
94903
+ }
94904
+ res.json({ results });
94905
+ } catch (error) {
94906
+ res.status(500).json({ error: String(error) });
94907
+ }
94908
+ });
94909
+ }
94910
+ var init_api_search = __esm({
94911
+ "src/ui/routes/api-search.ts"() {
94912
+ "use strict";
94913
+ init_test_scanner();
94914
+ }
94915
+ });
94916
+
94720
94917
  // src/ui/routes/api-local-browser.ts
94721
94918
  var api_local_browser_exports = {};
94722
94919
  __export(api_local_browser_exports, {
@@ -97422,6 +97619,8 @@ async function createUIServer(options) {
97422
97619
  mountMCPRoutes2(app, mcpConfigStore, mcpClientManager, options.projectPath);
97423
97620
  const { mountConnectorRoutes: mountConnectorRoutes2 } = await Promise.resolve().then(() => (init_api_connectors(), api_connectors_exports));
97424
97621
  mountConnectorRoutes2(app, tmStore4);
97622
+ const { mountSearchRoutes: mountSearchRoutes2 } = await Promise.resolve().then(() => (init_api_search(), api_search_exports));
97623
+ mountSearchRoutes2(app, { scanner, tmStore: tmStore4, cloudConfigStore, projectPath: options.projectPath });
97425
97624
  const { mountLocalBrowserRoutes: mountLocalBrowserRoutes2 } = await Promise.resolve().then(() => (init_api_local_browser(), api_local_browser_exports));
97426
97625
  mountLocalBrowserRoutes2(app);
97427
97626
  const { mountBrowserSessionsRoutes: mountBrowserSessionsRoutes2, setBrowserSessionsContext: setBrowserSessionsContext2 } = await Promise.resolve().then(() => (init_api_browser_sessions(), api_browser_sessions_exports));
@@ -98441,6 +98640,7 @@ URL: ${url}
98441
98640
  import { configDotenv } from "dotenv";
98442
98641
  import { resolve as resolve18 } from "path";
98443
98642
  import { readFileSync as readFileSync49 } from "fs";
98643
+ import chalk4 from "chalk";
98444
98644
 
98445
98645
  // src/repl/repl.ts
98446
98646
  init_orchestrator();
@@ -100651,23 +100851,49 @@ server {
100651
100851
  headless: true
100652
100852
  });
100653
100853
  const bindAddr = host === "0.0.0.0" ? "all interfaces" : host;
100854
+ const version = getPackageVersion();
100855
+ const projectShown = workingDirectory.length > 44 ? "\u2026" + workingDirectory.slice(-43) : workingDirectory;
100856
+ const c2 = chalk4;
100857
+ const INNER = 60;
100858
+ const railTop = " " + c2.cyan("\u256D" + "\u2500".repeat(INNER) + "\u256E");
100859
+ const railBot = " " + c2.cyan("\u2570" + "\u2500".repeat(INNER) + "\u256F");
100860
+ const rail = (colored, visible) => " " + c2.cyan("\u2502") + colored + " ".repeat(Math.max(0, INNER - visible)) + c2.cyan("\u2502");
100861
+ const blank = rail("", 0);
100862
+ const divider = rail(c2.dim(" " + "\u2500".repeat(INNER - 6)), INNER - 3);
100863
+ const titlePlain = " \u{1F9EA} Testver \u2014 AI Testing Tool";
100864
+ const verPlain = `v${version}`;
100865
+ const titleGap = Math.max(1, INNER - titlePlain.length - verPlain.length - 3);
100866
+ const titleRow = rail(
100867
+ " \u{1F9EA} " + c2.bold.cyan("Testver") + c2.bold.white(" \u2014 AI Testing Tool") + " ".repeat(titleGap) + c2.dim(verPlain) + " ",
100868
+ titlePlain.length + titleGap + verPlain.length + 3
100869
+ );
100870
+ const subtitlePlain = " AI-powered test automation & management";
100871
+ const subtitleRow = rail(" " + c2.dim("AI-powered test automation & management"), subtitlePlain.length);
100872
+ const kv = (label, value, valColor) => {
100873
+ const lbl = label.padEnd(9);
100874
+ const plain = " \u25B8 " + lbl + value;
100875
+ const colored = " " + c2.cyan("\u25B8 ") + c2.dim(lbl) + valColor(value);
100876
+ return rail(colored, plain.length);
100877
+ };
100654
100878
  console.log("");
100655
- console.log(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
100656
- console.log(" \u2551 \u2551");
100657
- console.log(" \u2551 \u{1F9EA} Testver Dashboard Server \u2551");
100658
- console.log(" \u2551 \u2551");
100659
- console.log(` \u2551 Local: http://localhost:${server.port} \u2551`);
100879
+ console.log(railTop);
100880
+ console.log(blank);
100881
+ console.log(titleRow);
100882
+ console.log(subtitleRow);
100883
+ console.log(blank);
100884
+ console.log(divider);
100885
+ console.log(blank);
100886
+ console.log(kv("Local", `http://localhost:${server.port}`, (s) => c2.cyan.underline(s)));
100660
100887
  if (host === "0.0.0.0") {
100661
- console.log(` \u2551 Network: http://<your-ip>:${server.port} \u2551`);
100662
- }
100663
- console.log(` \u2551 Host: ${bindAddr.padEnd(42)}\u2551`);
100664
- console.log(` \u2551 Project: ${workingDirectory.substring(0, 42).padEnd(42)}\u2551`);
100665
- console.log(" \u2551 \u2551");
100666
- console.log(" \u2551 Health: /api/health \u2551");
100667
- console.log(" \u2551 \u2551");
100668
- console.log(" \u2551 Press Ctrl+C to stop \u2551");
100669
- console.log(" \u2551 \u2551");
100670
- console.log(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D");
100888
+ console.log(kv("Network", `http://<your-ip>:${server.port}`, (s) => c2.cyan.underline(s)));
100889
+ }
100890
+ console.log(kv("Host", bindAddr, (s) => c2.white(s)));
100891
+ console.log(kv("Project", projectShown, (s) => c2.white(s)));
100892
+ console.log(kv("Health", "/api/health", (s) => c2.white(s)));
100893
+ console.log(blank);
100894
+ console.log(rail(" " + c2.dim("Press ") + c2.bold("Ctrl+C") + c2.dim(" to stop"), " Press Ctrl+C to stop".length));
100895
+ console.log(blank);
100896
+ console.log(railBot);
100671
100897
  console.log("");
100672
100898
  const shutdown = async () => {
100673
100899
  console.log("\n Shutting down Testver server...");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testver/testver",
3
- "version": "0.2.4",
3
+ "version": "1.0.0",
4
4
  "description": "AI-powered interactive CLI for test automation",
5
5
  "type": "module",
6
6
  "publishConfig": {