lovecode-ai 0.1.9 → 0.2.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,101 @@
1
+ import {
2
+ allTools
3
+ } from "./chunk-PX34PVT4.js";
4
+ import "./chunk-OTEQ6CQ7.js";
5
+ import "./chunk-4IPMBDCG.js";
6
+ import "./chunk-7CT3XDH6.js";
7
+ import "./chunk-Y3HADLWO.js";
8
+ import "./chunk-LKUWOZUZ.js";
9
+ import "./chunk-IVAMLKMS.js";
10
+ import "./chunk-MOZHR2QY.js";
11
+
12
+ // src/mcp/server.ts
13
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
14
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
15
+ import {
16
+ CallToolRequestSchema,
17
+ ListToolsRequestSchema
18
+ } from "@modelcontextprotocol/sdk/types.js";
19
+ function mcpToolSchema(tool) {
20
+ const parts = tool.usage ? tool.usage.split("\n").filter(Boolean) : [];
21
+ const properties = {};
22
+ const required = [];
23
+ for (const part of parts) {
24
+ const eqIdx = part.indexOf("=");
25
+ if (eqIdx > 0) {
26
+ const key = part.slice(0, eqIdx).trim();
27
+ const desc = part.slice(eqIdx + 1).trim();
28
+ properties[key] = { type: "string", description: desc };
29
+ required.push(key);
30
+ }
31
+ }
32
+ if (Object.keys(properties).length === 0) {
33
+ properties.path = { type: "string", description: "File or directory path" };
34
+ }
35
+ return {
36
+ type: "object",
37
+ properties,
38
+ required
39
+ };
40
+ }
41
+ function createMcpServer() {
42
+ const server = new Server(
43
+ {
44
+ name: "lovecode-ai",
45
+ version: "0.1.9"
46
+ },
47
+ {
48
+ capabilities: {
49
+ tools: {}
50
+ }
51
+ }
52
+ );
53
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
54
+ return {
55
+ tools: allTools.map((tool) => ({
56
+ name: tool.name,
57
+ description: tool.description,
58
+ inputSchema: mcpToolSchema(tool)
59
+ }))
60
+ };
61
+ });
62
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
63
+ const { name, arguments: args } = request.params;
64
+ const tool = allTools.find((t) => t.name === name);
65
+ if (!tool) {
66
+ return {
67
+ content: [{ type: "text", text: `Unknown tool: ${name}` }],
68
+ isError: true
69
+ };
70
+ }
71
+ try {
72
+ const workingDir = process.cwd();
73
+ const result = await tool.execute(workingDir, args || {});
74
+ if (result.success) {
75
+ return {
76
+ content: [{ type: "text", text: result.output }]
77
+ };
78
+ } else {
79
+ return {
80
+ content: [{ type: "text", text: result.error || result.output }],
81
+ isError: true
82
+ };
83
+ }
84
+ } catch (err) {
85
+ return {
86
+ content: [{ type: "text", text: err.message }],
87
+ isError: true
88
+ };
89
+ }
90
+ });
91
+ return server;
92
+ }
93
+ async function startMcpServer() {
94
+ const server = createMcpServer();
95
+ const transport = new StdioServerTransport();
96
+ await server.connect(transport);
97
+ }
98
+ export {
99
+ createMcpServer,
100
+ startMcpServer
101
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lovecode-ai",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
4
4
  "description": "Terminal-native autonomous coding agent powered by free AI models",
5
5
  "keywords": [
6
6
  "ai",
@@ -29,7 +29,7 @@
29
29
  "LICENSE"
30
30
  ],
31
31
  "scripts": {
32
- "build": "tsup src/index.ts --out-dir dist --format esm --clean --dts --external playwright --external ink --external react --external react-dom",
32
+ "build": "tsup src/index.ts --out-dir dist --format esm --clean --dts --external playwright --external ink --external react --external react-dom --external @modelcontextprotocol/sdk",
33
33
  "dev": "tsup src/index.ts --out-dir dist --format esm --watch",
34
34
  "start": "node bin/lovecode.js",
35
35
  "lint": "eslint src/",
@@ -45,6 +45,7 @@
45
45
  "node": ">=18.0.0"
46
46
  },
47
47
  "dependencies": {
48
+ "@modelcontextprotocol/sdk": "^1.29.0",
48
49
  "@types/react": "^19.2.15",
49
50
  "chalk": "^5.3.0",
50
51
  "commander": "^12.0.0",