aipeek 0.1.4 → 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
@@ -5,18 +5,12 @@
5
5
 
6
6
 
7
7
 
8
+ var _chunkIOK7MMPTcjs = require('./chunk-IOK7MMPT.cjs');
8
9
 
9
10
 
10
11
 
11
- var _chunkHNRFA6MNcjs = require('./chunk-HNRFA6MN.cjs');
12
12
 
13
13
 
14
14
 
15
15
 
16
-
17
-
18
-
19
-
20
-
21
-
22
- exports.aipeekPlugin = _chunkHNRFA6MNcjs.aipeekPlugin; exports.compact = _chunkHNRFA6MNcjs.compact; exports.compactConsole = _chunkHNRFA6MNcjs.compactConsole; exports.compactErrors = _chunkHNRFA6MNcjs.compactErrors; exports.compactNetwork = _chunkHNRFA6MNcjs.compactNetwork; exports.compactState = _chunkHNRFA6MNcjs.compactState; exports.compactUI = _chunkHNRFA6MNcjs.compactUI; exports.detail = _chunkHNRFA6MNcjs.detail; exports.emit = _chunkHNRFA6MNcjs.emit;
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
@@ -52,18 +52,31 @@ interface CompactState {
52
52
  state: number;
53
53
  };
54
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
+ }
55
71
 
56
- declare function compactUI(tree: string): string;
57
- declare function compactConsole(logs: LogEntry[]): string;
58
- declare function compactNetwork(requests: NetworkRequest[]): string;
59
- declare function compactErrors(errors: ErrorEntry[]): string;
60
- declare function compactState(state: Record<string, unknown>): string;
61
- declare function compact(raw: RawState): CompactState;
72
+ declare function check(raw: RawState): CheckResult;
62
73
 
63
- declare function detail(raw: RawState, section: string, index: string | undefined, full: boolean): Promise<string | null>;
74
+ declare function diffState(prev: RawState | null, curr: RawState): DiffResult;
64
75
 
65
- declare function emit(state: CompactState): string;
76
+ declare function emitSummary(raw: RawState): string;
77
+ declare function emitCheck(result: CheckResult): string;
78
+ declare function emitDiff(diff: DiffResult): string;
66
79
 
67
80
  declare function aipeekPlugin(): Plugin;
68
81
 
69
- export { type CompactState, type ErrorEntry, type LogEntry, type NetworkRequest, type RawState, aipeekPlugin, compact, compactConsole, compactErrors, compactNetwork, compactState, compactUI, detail, emit };
82
+ export { type CheckResult, type CompactState, type DiffResult, type RawState, aipeekPlugin, check, diffState, emitCheck, emitDiff, emitSummary };
package/dist/index.d.ts CHANGED
@@ -52,18 +52,31 @@ interface CompactState {
52
52
  state: number;
53
53
  };
54
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
+ }
55
71
 
56
- declare function compactUI(tree: string): string;
57
- declare function compactConsole(logs: LogEntry[]): string;
58
- declare function compactNetwork(requests: NetworkRequest[]): string;
59
- declare function compactErrors(errors: ErrorEntry[]): string;
60
- declare function compactState(state: Record<string, unknown>): string;
61
- declare function compact(raw: RawState): CompactState;
72
+ declare function check(raw: RawState): CheckResult;
62
73
 
63
- declare function detail(raw: RawState, section: string, index: string | undefined, full: boolean): Promise<string | null>;
74
+ declare function diffState(prev: RawState | null, curr: RawState): DiffResult;
64
75
 
65
- declare function emit(state: CompactState): string;
76
+ declare function emitSummary(raw: RawState): string;
77
+ declare function emitCheck(result: CheckResult): string;
78
+ declare function emitDiff(diff: DiffResult): string;
66
79
 
67
80
  declare function aipeekPlugin(): Plugin;
68
81
 
69
- export { type CompactState, type ErrorEntry, type LogEntry, type NetworkRequest, type RawState, aipeekPlugin, compact, compactConsole, compactErrors, compactNetwork, compactState, compactUI, detail, emit };
82
+ export { type CheckResult, type CompactState, type DiffResult, type RawState, aipeekPlugin, check, diffState, emitCheck, emitDiff, emitSummary };
package/dist/index.js CHANGED
@@ -1,22 +1,16 @@
1
1
  import {
2
2
  aipeekPlugin,
3
- compact,
4
- compactConsole,
5
- compactErrors,
6
- compactNetwork,
7
- compactState,
8
- compactUI,
9
- detail,
10
- emit
11
- } from "./chunk-AFSKSPDG.js";
3
+ check,
4
+ diffState,
5
+ emitCheck,
6
+ emitDiff,
7
+ emitSummary
8
+ } from "./chunk-E7YXT6HW.js";
12
9
  export {
13
10
  aipeekPlugin,
14
- compact,
15
- compactConsole,
16
- compactErrors,
17
- compactNetwork,
18
- compactState,
19
- compactUI,
20
- detail,
21
- emit
11
+ check,
12
+ diffState,
13
+ emitCheck,
14
+ emitDiff,
15
+ emitSummary
22
16
  };
package/dist/plugin.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkHNRFA6MNcjs = require('./chunk-HNRFA6MN.cjs');
3
+ var _chunkIOK7MMPTcjs = require('./chunk-IOK7MMPT.cjs');
4
4
 
5
5
 
6
- exports.aipeekPlugin = _chunkHNRFA6MNcjs.aipeekPlugin;
6
+ exports.aipeekPlugin = _chunkIOK7MMPTcjs.aipeekPlugin;
package/dist/plugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  aipeekPlugin
3
- } from "./chunk-AFSKSPDG.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.4",
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,8 +26,8 @@
26
26
  "test:watch": "vitest"
27
27
  },
28
28
  "dependencies": {
29
- "picocolors": "^1.1.1",
30
- "quicktype-core": "^23.2.6"
29
+ "html-to-image": "^1.11.13",
30
+ "picocolors": "^1.1.1"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "vite": ">=5.0.0"
@@ -38,6 +38,7 @@
38
38
  }
39
39
  },
40
40
  "devDependencies": {
41
+ "jsdom": "^29.1.1",
41
42
  "tsup": "^8.4.0",
42
43
  "typescript": "~5.7.2",
43
44
  "vitest": "^3.1.2"