@gulibs/safe-coder 0.0.1 → 0.0.3

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Safe Coder MCP
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md CHANGED
@@ -87,6 +87,8 @@ npm start
87
87
 
88
88
  ### 2. 在 Cursor 中配置
89
89
 
90
+ > **⚠️ 重要提示**:如果包还没有发布到 npm,请使用"本地开发配置"方式。
91
+
90
92
  #### 步骤 1:找到 Cursor 配置文件
91
93
 
92
94
  Cursor 的 MCP 配置文件位置:
@@ -103,23 +105,42 @@ Cursor 的 MCP 配置文件位置:
103
105
 
104
106
  根据你的安装方式选择对应的配置:
105
107
 
106
- ##### 如果通过 npm 全局安装:
108
+ ##### 方式 A:本地开发配置(推荐,如果包未发布)
107
109
 
108
- 首先找到全局安装路径:
110
+ 使用项目的绝对路径:
111
+
112
+ ```json
113
+ {
114
+ "mcpServers": {
115
+ "safe-coder": {
116
+ "command": "node",
117
+ "args": ["/Users/wormhole/Documents/Developments/Our/mcp/safe-coder/dist/index.js"],
118
+ "env": {
119
+ "CACHE_TTL_MINUTES": "60",
120
+ "GITHUB_TOKEN": "your_token_here"
121
+ }
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ **获取你的项目路径:**
109
128
 
110
129
  ```bash
111
- # 查看全局 node_modules 路径
112
- npm root -g
130
+ # 在项目目录下运行
131
+ pwd
113
132
  ```
114
133
 
115
- 然后配置(替换 `<global-node-modules-path>` 为实际路径):
134
+ ##### 方式 B:通过 npm 安装(需要先发布到 npm)
135
+
136
+ 如果包已发布到 npm,可以使用 npx:
116
137
 
117
138
  ```json
118
139
  {
119
140
  "mcpServers": {
120
141
  "safe-coder": {
121
- "command": "node",
122
- "args": ["<global-node-modules-path>/@gulibs/safe-coder/dist/index.js"],
142
+ "command": "npx",
143
+ "args": ["-y", "@gulibs/safe-coder"],
123
144
  "env": {
124
145
  "CACHE_TTL_MINUTES": "60",
125
146
  "GITHUB_TOKEN": "your_token_here"
@@ -129,14 +150,24 @@ npm root -g
129
150
  }
130
151
  ```
131
152
 
132
- 或者使用 npx(推荐,更简单):
153
+ 或者全局安装后使用:
154
+
155
+ ```bash
156
+ # 全局安装
157
+ npm install -g @gulibs/safe-coder
158
+
159
+ # 查看全局安装路径
160
+ npm root -g
161
+ ```
162
+
163
+ 然后配置(替换 `<global-node-modules-path>` 为实际路径):
133
164
 
134
165
  ```json
135
166
  {
136
167
  "mcpServers": {
137
168
  "safe-coder": {
138
- "command": "npx",
139
- "args": ["-y", "@gulibs/safe-coder"],
169
+ "command": "node",
170
+ "args": ["<global-node-modules-path>/@gulibs/safe-coder/dist/index.js"],
140
171
  "env": {
141
172
  "CACHE_TTL_MINUTES": "60",
142
173
  "GITHUB_TOKEN": "your_token_here"
@@ -1 +1 @@
1
- {"version":3,"file":"eslint-integration.d.ts","sourceRoot":"","sources":["../../src/errors/eslint-integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAS;;IAcjB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAkB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA2BxF,OAAO,CAAC,UAAU;CAGnB"}
1
+ {"version":3,"file":"eslint-integration.d.ts","sourceRoot":"","sources":["../../src/errors/eslint-integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAuB;;IAmB/B,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAkB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA8BxF,OAAO,CAAC,UAAU;CAGnB"}
@@ -1,18 +1,27 @@
1
1
  import { ESLint } from 'eslint';
2
2
  export class ESLintIntegration {
3
- eslint;
3
+ eslint = null;
4
4
  constructor() {
5
- this.eslint = new ESLint({
6
- overrideConfig: {
7
- rules: {
8
- 'no-unused-vars': 'warn',
9
- 'no-undef': 'error',
10
- 'no-console': 'off',
5
+ try {
6
+ this.eslint = new ESLint({
7
+ overrideConfig: {
8
+ rules: {
9
+ 'no-unused-vars': 'warn',
10
+ 'no-undef': 'error',
11
+ 'no-console': 'off',
12
+ },
11
13
  },
12
- },
13
- });
14
+ });
15
+ }
16
+ catch (error) {
17
+ // ESLint initialization failed, continue without it
18
+ this.eslint = null;
19
+ }
14
20
  }
15
21
  async detectErrors(code, filename = 'code.ts') {
22
+ if (!this.eslint) {
23
+ return []; // ESLint not available
24
+ }
16
25
  try {
17
26
  const results = await this.eslint.lintText(code, { filePath: filename });
18
27
  const errors = [];
@@ -1 +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AC;oBACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,yBAAyB;oBAE1E,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,OAAO,CAAC,OAAO;wBACxB,IAAI,EAAE,OAAO,CAAC,IAAI;wBAClB,MAAM,EAAE,OAAO,CAAC,MAAM;wBACtB,QAAQ;wBACR,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS;qBACpD,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,wCAAwC;YACxC,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,MAAuB;QACxC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ #!/usr/bin/env node
1
2
  export {};
2
3
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  import { SafeCoderMCPServer } from './server/mcp-server.js';
2
3
  async function main() {
3
4
  const server = new SafeCoderMCPServer();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACxC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;AACrB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACxC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;AACrB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gulibs/safe-coder",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -16,11 +16,10 @@
16
16
  "test:watch": "vitest --watch",
17
17
  "lint": "eslint src --ext .ts",
18
18
  "type-check": "tsc --noEmit",
19
- "prepublishOnly": "npm run build",
20
- "postinstall": "npm run build"
19
+ "prepublishOnly": "npm run build"
21
20
  },
22
21
  "bin": {
23
- "safe-coder-mcp": "./dist/index.js"
22
+ "safe-coder-mcp": "dist/index.js"
24
23
  },
25
24
  "files": [
26
25
  "dist",
@@ -40,6 +39,7 @@
40
39
  "@modelcontextprotocol/sdk": "^1.22.0",
41
40
  "@typescript-eslint/typescript-estree": "^8.48.0",
42
41
  "axios": "^1.13.2",
42
+ "eslint": "^8.57.1",
43
43
  "zod": "^3.25.76"
44
44
  },
45
45
  "devDependencies": {
@@ -47,7 +47,6 @@
47
47
  "@types/node": "^20.0.0",
48
48
  "@typescript-eslint/eslint-plugin": "^6.21.0",
49
49
  "@typescript-eslint/parser": "^6.21.0",
50
- "eslint": "^8.57.1",
51
50
  "tsx": "^4.0.0",
52
51
  "typescript": "^5.9.3",
53
52
  "vitest": "^1.0.0"