difflens 0.0.1

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.
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+
25
+ // src/mcp-server.ts
26
+ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
27
+ var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
28
+ var import_zod = require("zod");
29
+ var import_child_process = require("child_process");
30
+ var import_util = require("util");
31
+ var import_path = __toESM(require("path"));
32
+ var execFileAsync = (0, import_util.promisify)(import_child_process.execFile);
33
+ var server = new import_mcp.McpServer({
34
+ name: "difflens",
35
+ version: "0.0.1"
36
+ });
37
+ server.tool(
38
+ "difflens_check",
39
+ "Run visual regression test and accessibility audit for a given URL",
40
+ {
41
+ url: import_zod.z.string().url().describe("The URL to check"),
42
+ label: import_zod.z.string().optional().describe("Label for the scenario (default: 'check')")
43
+ },
44
+ async ({ url, label }) => {
45
+ const scenarioLabel = label || "check";
46
+ const cliPath = import_path.default.resolve(__dirname, "cli.js");
47
+ const args = [cliPath, "test", "--url", url, "--label", scenarioLabel, "--format", "ai"];
48
+ try {
49
+ const { stdout, stderr } = await execFileAsync(process.execPath, args);
50
+ const output = stdout + (stderr ? `
51
+ [Stderr]
52
+ ${stderr}` : "");
53
+ return {
54
+ content: [
55
+ {
56
+ type: "text",
57
+ text: output
58
+ }
59
+ ]
60
+ };
61
+ } catch (error) {
62
+ const output = (error.stdout || "") + (error.stderr ? `
63
+ [Stderr]
64
+ ${error.stderr}` : "");
65
+ return {
66
+ content: [
67
+ {
68
+ type: "text",
69
+ text: output || error.message
70
+ }
71
+ ]
72
+ // Don't mark as error for MCP if it's just a test failure,
73
+ // but maybe we should?
74
+ // If it's a test failure, the tool executed successfully but found issues.
75
+ // So isError: false is probably better, letting the agent interpret the result.
76
+ };
77
+ }
78
+ }
79
+ );
80
+ async function main() {
81
+ const transport = new import_stdio.StdioServerTransport();
82
+ await server.connect(transport);
83
+ console.error("DiffLens MCP Server running on stdio");
84
+ }
85
+ main().catch((error) => {
86
+ console.error("Fatal error in MCP server:", error);
87
+ process.exit(1);
88
+ });
@@ -0,0 +1,64 @@
1
+ // src/mcp-server.ts
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { z } from "zod";
5
+ import { execFile } from "child_process";
6
+ import { promisify } from "util";
7
+ import path from "path";
8
+ var execFileAsync = promisify(execFile);
9
+ var server = new McpServer({
10
+ name: "difflens",
11
+ version: "0.0.1"
12
+ });
13
+ server.tool(
14
+ "difflens_check",
15
+ "Run visual regression test and accessibility audit for a given URL",
16
+ {
17
+ url: z.string().url().describe("The URL to check"),
18
+ label: z.string().optional().describe("Label for the scenario (default: 'check')")
19
+ },
20
+ async ({ url, label }) => {
21
+ const scenarioLabel = label || "check";
22
+ const cliPath = path.resolve(__dirname, "cli.js");
23
+ const args = [cliPath, "test", "--url", url, "--label", scenarioLabel, "--format", "ai"];
24
+ try {
25
+ const { stdout, stderr } = await execFileAsync(process.execPath, args);
26
+ const output = stdout + (stderr ? `
27
+ [Stderr]
28
+ ${stderr}` : "");
29
+ return {
30
+ content: [
31
+ {
32
+ type: "text",
33
+ text: output
34
+ }
35
+ ]
36
+ };
37
+ } catch (error) {
38
+ const output = (error.stdout || "") + (error.stderr ? `
39
+ [Stderr]
40
+ ${error.stderr}` : "");
41
+ return {
42
+ content: [
43
+ {
44
+ type: "text",
45
+ text: output || error.message
46
+ }
47
+ ]
48
+ // Don't mark as error for MCP if it's just a test failure,
49
+ // but maybe we should?
50
+ // If it's a test failure, the tool executed successfully but found issues.
51
+ // So isError: false is probably better, letting the agent interpret the result.
52
+ };
53
+ }
54
+ }
55
+ );
56
+ async function main() {
57
+ const transport = new StdioServerTransport();
58
+ await server.connect(transport);
59
+ console.error("DiffLens MCP Server running on stdio");
60
+ }
61
+ main().catch((error) => {
62
+ console.error("Fatal error in MCP server:", error);
63
+ process.exit(1);
64
+ });
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "difflens",
3
+ "version": "0.0.1",
4
+ "description": "Visual Regression Testing & Accessibility Auditing Tool",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "bin": {
16
+ "difflens": "dist/cli.js"
17
+ },
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "dev": "tsup --watch",
21
+ "test": "vitest",
22
+ "test:run": "vitest run",
23
+ "start": "node dist/cli.js",
24
+ "mcp": "node dist/mcp-server.js",
25
+ "api": "node dist/api-server.js",
26
+ "prepublishOnly": "npm run build && npm run test:run"
27
+ },
28
+ "keywords": [
29
+ "testing",
30
+ "visual-regression",
31
+ "accessibility",
32
+ "playwright",
33
+ "screenshot",
34
+ "diff",
35
+ "a11y",
36
+ "axe-core",
37
+ "mcp",
38
+ "ai"
39
+ ],
40
+ "files": [
41
+ "dist",
42
+ "README.md",
43
+ "LICENSE"
44
+ ],
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ },
48
+ "author": "hayato06",
49
+ "license": "MIT",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/hayato06/difflens.git"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/hayato06/difflens/issues"
56
+ },
57
+ "homepage": "https://github.com/hayato06/difflens#readme",
58
+ "devDependencies": {
59
+ "@axe-core/playwright": "^4.11.0",
60
+ "@types/node": "^20.19.28",
61
+ "@types/pixelmatch": "^5.2.6",
62
+ "@types/pngjs": "^6.0.5",
63
+ "cac": "^6.7.14",
64
+ "esbuild": "^0.27.2",
65
+ "pixelmatch": "^5.3.0",
66
+ "playwright": "^1.57.0",
67
+ "pngjs": "^7.0.0",
68
+ "tsup": "^8.5.1",
69
+ "typescript": "^5.9.3",
70
+ "vitest": "^1.0.0"
71
+ },
72
+ "dependencies": {
73
+ "@hono/node-server": "^1.19.9",
74
+ "@modelcontextprotocol/sdk": "^1.25.2",
75
+ "hono": "^4.11.4",
76
+ "zod": "^4.3.5"
77
+ }
78
+ }