aipeek 0.1.5 → 0.2.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.cjs CHANGED
@@ -1,41 +1,62 @@
1
- "use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/cli.ts
1
+ "use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/server/cli.ts
2
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
2
3
  var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
3
- var args = process.argv.slice(2);
4
+ var args = _process2.default.argv.slice(2);
4
5
  var flags = Object.fromEntries(
5
6
  args.filter((a) => a.startsWith("--")).map((a) => {
6
7
  const [k, v] = a.slice(2).split("=");
7
8
  return [k, _nullishCoalesce(v, () => ( "true"))];
8
9
  })
9
10
  );
11
+ var positional = args.filter((a) => !a.startsWith("--"));
10
12
  async function main() {
11
13
  if (flags.help) {
12
14
  console.log(`
13
15
  ${_picocolors2.default.bold("aipeek")} \u2014 runtime snapshot from Vite dev server
14
16
 
15
17
  ${_picocolors2.default.dim("Usage:")}
16
- aipeek Fetch from localhost:5173
17
- aipeek --port=3000 Fetch from localhost:3000
18
+ aipeek Full summary
19
+ aipeek check Health check (pass/fail)
20
+ aipeek console Console logs
21
+ aipeek network/0 Network request detail
22
+ aipeek errors/1?full Error detail (untruncated)
18
23
 
19
24
  ${_picocolors2.default.dim("Options:")}
20
25
  --port=<port> Dev server port (default: 5173)
26
+ --full Untruncated output
21
27
  --help Show this help
22
28
 
23
29
  ${_picocolors2.default.dim("Setup:")}
24
30
  Add aipeekPlugin() to your vite.config.ts plugins array.
25
31
  `);
26
- process.exit(0);
32
+ _process2.default.exit(0);
27
33
  }
28
34
  const port = flags.port || "5173";
29
- const endpoint = `http://localhost:${port}/__aipeek`;
35
+ const sub = positional[0] || "";
36
+ const full = flags.full ? "?full" : "";
37
+ const path = sub ? `/${sub}` : "";
38
+ const endpoint = `http://localhost:${port}/__aipeek${path}${full}`;
30
39
  const resp = await fetch(endpoint);
31
- if (!resp.ok) {
32
- const text = await resp.text();
33
- console.error(_picocolors2.default.red(`Error ${resp.status}: ${text}`));
34
- process.exit(1);
40
+ if (!resp.ok && resp.status !== 417) {
41
+ const text2 = await resp.text();
42
+ console.error(_picocolors2.default.red(`Error ${resp.status}: ${text2}`));
43
+ _process2.default.exit(1);
35
44
  }
36
- console.log(await resp.text());
45
+ const text = await resp.text();
46
+ if (sub === "check") {
47
+ const colored = text.split("\n").map((line) => {
48
+ if (line.startsWith("\u2713"))
49
+ return _picocolors2.default.green(line);
50
+ if (line.startsWith("\u2717"))
51
+ return _picocolors2.default.red(line);
52
+ return line;
53
+ }).join("\n");
54
+ console.log(colored);
55
+ _process2.default.exit(resp.status === 417 ? 1 : 0);
56
+ }
57
+ console.log(text);
37
58
  }
38
59
  main().catch((err) => {
39
60
  console.error(_picocolors2.default.red(`Error: ${err.message}`));
40
- process.exit(1);
61
+ _process2.default.exit(1);
41
62
  });
package/dist/cli.js CHANGED
@@ -1,4 +1,5 @@
1
- // src/cli.ts
1
+ // src/server/cli.ts
2
+ import process from "process";
2
3
  import pc from "picocolors";
3
4
  var args = process.argv.slice(2);
4
5
  var flags = Object.fromEntries(
@@ -7,17 +8,22 @@ var flags = Object.fromEntries(
7
8
  return [k, v ?? "true"];
8
9
  })
9
10
  );
11
+ var positional = args.filter((a) => !a.startsWith("--"));
10
12
  async function main() {
11
13
  if (flags.help) {
12
14
  console.log(`
13
15
  ${pc.bold("aipeek")} \u2014 runtime snapshot from Vite dev server
14
16
 
15
17
  ${pc.dim("Usage:")}
16
- aipeek Fetch from localhost:5173
17
- aipeek --port=3000 Fetch from localhost:3000
18
+ aipeek Full summary
19
+ aipeek check Health check (pass/fail)
20
+ aipeek console Console logs
21
+ aipeek network/0 Network request detail
22
+ aipeek errors/1?full Error detail (untruncated)
18
23
 
19
24
  ${pc.dim("Options:")}
20
25
  --port=<port> Dev server port (default: 5173)
26
+ --full Untruncated output
21
27
  --help Show this help
22
28
 
23
29
  ${pc.dim("Setup:")}
@@ -26,14 +32,29 @@ ${pc.dim("Setup:")}
26
32
  process.exit(0);
27
33
  }
28
34
  const port = flags.port || "5173";
29
- const endpoint = `http://localhost:${port}/__aipeek`;
35
+ const sub = positional[0] || "";
36
+ const full = flags.full ? "?full" : "";
37
+ const path = sub ? `/${sub}` : "";
38
+ const endpoint = `http://localhost:${port}/__aipeek${path}${full}`;
30
39
  const resp = await fetch(endpoint);
31
- if (!resp.ok) {
32
- const text = await resp.text();
33
- console.error(pc.red(`Error ${resp.status}: ${text}`));
40
+ if (!resp.ok && resp.status !== 417) {
41
+ const text2 = await resp.text();
42
+ console.error(pc.red(`Error ${resp.status}: ${text2}`));
34
43
  process.exit(1);
35
44
  }
36
- console.log(await resp.text());
45
+ const text = await resp.text();
46
+ if (sub === "check") {
47
+ const colored = text.split("\n").map((line) => {
48
+ if (line.startsWith("\u2713"))
49
+ return pc.green(line);
50
+ if (line.startsWith("\u2717"))
51
+ return pc.red(line);
52
+ return line;
53
+ }).join("\n");
54
+ console.log(colored);
55
+ process.exit(resp.status === 417 ? 1 : 0);
56
+ }
57
+ console.log(text);
37
58
  }
38
59
  main().catch((err) => {
39
60
  console.error(pc.red(`Error: ${err.message}`));
package/dist/index.cjs CHANGED
@@ -1,6 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkP73WZQ2Rcjs = require('./chunk-P73WZQ2R.cjs');
4
3
 
5
4
 
6
- exports.aipeekPlugin = _chunkP73WZQ2Rcjs.aipeekPlugin;
5
+
6
+
7
+
8
+ var _chunkIOK7MMPTcjs = require('./chunk-IOK7MMPT.cjs');
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ exports.aipeekPlugin = _chunkIOK7MMPTcjs.aipeekPlugin; exports.check = _chunkIOK7MMPTcjs.check; exports.diffState = _chunkIOK7MMPTcjs.diffState; exports.emitCheck = _chunkIOK7MMPTcjs.emitCheck; exports.emitDiff = _chunkIOK7MMPTcjs.emitDiff; exports.emitSummary = _chunkIOK7MMPTcjs.emitSummary;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- declare function aipeekPlugin(): Plugin;
4
-
5
3
  interface LogEntry {
6
4
  level: 'error' | 'warn' | 'info' | 'debug' | 'log';
7
5
  text: string;
@@ -54,5 +52,31 @@ interface CompactState {
54
52
  state: number;
55
53
  };
56
54
  }
55
+ interface Assertion {
56
+ name: string;
57
+ pass: boolean;
58
+ detail?: string;
59
+ }
60
+ interface CheckResult {
61
+ pass: boolean;
62
+ assertions: Assertion[];
63
+ }
64
+ interface DiffResult {
65
+ newErrors: LogEntry[];
66
+ newExceptions: ErrorEntry[];
67
+ newFailedRequests: NetworkRequest[];
68
+ uiGone: boolean;
69
+ clean: boolean;
70
+ }
71
+
72
+ declare function check(raw: RawState): CheckResult;
73
+
74
+ declare function diffState(prev: RawState | null, curr: RawState): DiffResult;
75
+
76
+ declare function emitSummary(raw: RawState): string;
77
+ declare function emitCheck(result: CheckResult): string;
78
+ declare function emitDiff(diff: DiffResult): string;
79
+
80
+ declare function aipeekPlugin(): Plugin;
57
81
 
58
- export { type CompactState, type RawState, aipeekPlugin };
82
+ export { type CheckResult, type CompactState, type DiffResult, type RawState, aipeekPlugin, check, diffState, emitCheck, emitDiff, emitSummary };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- declare function aipeekPlugin(): Plugin;
4
-
5
3
  interface LogEntry {
6
4
  level: 'error' | 'warn' | 'info' | 'debug' | 'log';
7
5
  text: string;
@@ -54,5 +52,31 @@ interface CompactState {
54
52
  state: number;
55
53
  };
56
54
  }
55
+ interface Assertion {
56
+ name: string;
57
+ pass: boolean;
58
+ detail?: string;
59
+ }
60
+ interface CheckResult {
61
+ pass: boolean;
62
+ assertions: Assertion[];
63
+ }
64
+ interface DiffResult {
65
+ newErrors: LogEntry[];
66
+ newExceptions: ErrorEntry[];
67
+ newFailedRequests: NetworkRequest[];
68
+ uiGone: boolean;
69
+ clean: boolean;
70
+ }
71
+
72
+ declare function check(raw: RawState): CheckResult;
73
+
74
+ declare function diffState(prev: RawState | null, curr: RawState): DiffResult;
75
+
76
+ declare function emitSummary(raw: RawState): string;
77
+ declare function emitCheck(result: CheckResult): string;
78
+ declare function emitDiff(diff: DiffResult): string;
79
+
80
+ declare function aipeekPlugin(): Plugin;
57
81
 
58
- export { type CompactState, type RawState, aipeekPlugin };
82
+ export { type CheckResult, type CompactState, type DiffResult, type RawState, aipeekPlugin, check, diffState, emitCheck, emitDiff, emitSummary };
package/dist/index.js CHANGED
@@ -1,6 +1,16 @@
1
1
  import {
2
- aipeekPlugin
3
- } from "./chunk-4PG5UWRS.js";
2
+ aipeekPlugin,
3
+ check,
4
+ diffState,
5
+ emitCheck,
6
+ emitDiff,
7
+ emitSummary
8
+ } from "./chunk-E7YXT6HW.js";
4
9
  export {
5
- aipeekPlugin
10
+ aipeekPlugin,
11
+ check,
12
+ diffState,
13
+ emitCheck,
14
+ emitDiff,
15
+ emitSummary
6
16
  };
package/dist/plugin.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkP73WZQ2Rcjs = require('./chunk-P73WZQ2R.cjs');
3
+ var _chunkIOK7MMPTcjs = require('./chunk-IOK7MMPT.cjs');
4
4
 
5
5
 
6
- exports.aipeekPlugin = _chunkP73WZQ2Rcjs.aipeekPlugin;
6
+ exports.aipeekPlugin = _chunkIOK7MMPTcjs.aipeekPlugin;
package/dist/plugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  aipeekPlugin
3
- } from "./chunk-4PG5UWRS.js";
3
+ } from "./chunk-E7YXT6HW.js";
4
4
  export {
5
5
  aipeekPlugin
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aipeek",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "description": "Gives AI a peek into your running browser app — UI tree, console, network, errors, state",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,6 +26,7 @@
26
26
  "test:watch": "vitest"
27
27
  },
28
28
  "dependencies": {
29
+ "html-to-image": "^1.11.13",
29
30
  "picocolors": "^1.1.1"
30
31
  },
31
32
  "peerDependencies": {
@@ -37,6 +38,7 @@
37
38
  }
38
39
  },
39
40
  "devDependencies": {
41
+ "jsdom": "^29.1.1",
40
42
  "tsup": "^8.4.0",
41
43
  "typescript": "~5.7.2",
42
44
  "vitest": "^3.1.2"