### Define Project Metadata and Dependencies (package.json) Source: https://github.com/kongyo2/my-llms-txt/blob/main/llms.txt This JSON snippet outlines the `dxt` project's metadata, including its name, version, description, and main entry points. It defines various scripts for building, testing, starting, linting, and formatting the project. Additionally, it lists development and runtime dependencies required for the application. ```JSON { "name": "dxt", "version": "0.1.0", "description": "Desktop Extensions: One-click local MCP server installation in desktop apps", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "build": "tsc", "test": "jest", "start": "node dist/index.js", "lint": "eslint src/**/*.ts", "format": "prettier --write \"src/**/*.ts\"" }, "keywords": ["desktop", "extensions", "mcp", "server"], "author": "Anthropic", "license": "MIT", "devDependencies": { "@types/jest": "^29.5.0", "@types/node": "^20.0.0", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "eslint": "^8.0.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.0", "jest": "^29.5.0", "prettier": "^3.0.0", "ts-jest": "^29.1.0", "typescript": "^5.0.0" }, "dependencies": { "express": "^4.18.2", "ws": "^8.13.0" } } ``` -------------------------------- ### Initialize DXT HTTP and WebSocket Servers Source: https://github.com/kongyo2/my-llms-txt/blob/main/llms.txt This TypeScript code snippet demonstrates the main entry point for the `dxt` application, setting up both an HTTP server using Express and a WebSocket server using `ws`. It listens for incoming HTTP requests on a specified port and handles WebSocket connections, logging messages and echoing them back to clients. This forms the core communication layer for the desktop extensions. ```TypeScript import express from 'express'; import { WebSocketServer } from 'ws'; const app = express(); const port = process.env.PORT || 3000; app.get('/', (req, res) => { res.send('DXT Server is running!'); }); const server = app.listen(port, () => { console.log(`DXT HTTP server listening on port ${port}`); }); const wss = new WebSocketServer({ server }); wss.on('connection', ws => { console.log('Client connected via WebSocket'); ws.on('message', message => { console.log(`Received: ${message}`); ws.send(`Echo: ${message}`); }); ws.on('close', () => { console.log('Client disconnected'); }); ws.send('Welcome to DXT WebSocket server!'); }); console.log('DXT WebSocket server initialized.'); ``` -------------------------------- ### Configure Jest for TypeScript Testing Source: https://github.com/kongyo2/my-llms-txt/blob/main/llms.txt This snippet defines the Jest configuration for the `dxt` project, enabling TypeScript support using `ts-jest`. It specifies the test environment, file matching patterns, module extensions, and global settings for TypeScript compilation during tests. It also configures code coverage reporting. ```JavaScript /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { preset: 'ts-jest', testEnvironment: 'node', testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'], moduleFileExtensions: ['ts', 'js', 'json', 'node'], transform: { '^.+\.ts$': 'ts-jest' }, globals: { 'ts-jest': { tsconfig: 'tsconfig.test.json' } }, collectCoverage: true, coverageDirectory: 'coverage', coverageReporters: ['json', 'lcov', 'text', 'clover'] }; ``` -------------------------------- ### Configure TypeScript Compiler Options (tsconfig.json) Source: https://github.com/kongyo2/my-llms-txt/blob/main/llms.txt This JSON snippet defines the base TypeScript compiler options for the `dxt` project. It specifies the target ECMAScript version, module system, output directory, strict type checking, and options for interoperability and declaration file generation. It also includes and excludes specific file patterns for compilation. ```JSON { "compilerOptions": { "target": "es2020", "module": "commonjs", "lib": ["es2020", "dom"], "outDir": "./dist", "rootDir": "./src", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "declaration": true, "sourceMap": true }, "include": ["src/**/*.ts"], "exclude": ["node_modules", "dist", "src/**/*.test.ts"] } ``` -------------------------------- ### Configure TypeScript Compiler for Tests (tsconfig.test.json) Source: https://github.com/kongyo2/my-llms-txt/blob/main/llms.txt This TypeScript configuration extends the base `tsconfig.json` to provide specific compiler options for testing environments. It overrides the module and target settings, defines a separate output directory for test builds, and includes Jest and Node.js types. It ensures that both source and test files are included for compilation during testing. ```JSON { "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs", "target": "es2020", "outDir": "./dist-test", "types": ["jest", "node"] }, "include": ["src/**/*.ts", "src/**/*.test.ts", "src/**/*.spec.ts"], "exclude": ["node_modules", "dist"] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.