@gulibs/safe-coder 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.
- package/README.md +515 -0
- package/dist/documentation/cache.d.ts +13 -0
- package/dist/documentation/cache.d.ts.map +1 -0
- package/dist/documentation/cache.js +48 -0
- package/dist/documentation/cache.js.map +1 -0
- package/dist/documentation/github-client.d.ts +11 -0
- package/dist/documentation/github-client.d.ts.map +1 -0
- package/dist/documentation/github-client.js +88 -0
- package/dist/documentation/github-client.js.map +1 -0
- package/dist/documentation/http-fetcher.d.ts +5 -0
- package/dist/documentation/http-fetcher.d.ts.map +1 -0
- package/dist/documentation/http-fetcher.js +27 -0
- package/dist/documentation/http-fetcher.js.map +1 -0
- package/dist/documentation/index.d.ts +14 -0
- package/dist/documentation/index.d.ts.map +1 -0
- package/dist/documentation/index.js +75 -0
- package/dist/documentation/index.js.map +1 -0
- package/dist/documentation/normalizer.d.ts +6 -0
- package/dist/documentation/normalizer.d.ts.map +1 -0
- package/dist/documentation/normalizer.js +38 -0
- package/dist/documentation/normalizer.js.map +1 -0
- package/dist/documentation/npm-client.d.ts +7 -0
- package/dist/documentation/npm-client.d.ts.map +1 -0
- package/dist/documentation/npm-client.js +49 -0
- package/dist/documentation/npm-client.js.map +1 -0
- package/dist/errors/contextual-analysis.d.ts +11 -0
- package/dist/errors/contextual-analysis.d.ts.map +1 -0
- package/dist/errors/contextual-analysis.js +75 -0
- package/dist/errors/contextual-analysis.js.map +1 -0
- package/dist/errors/eslint-integration.d.ts +8 -0
- package/dist/errors/eslint-integration.d.ts.map +1 -0
- package/dist/errors/eslint-integration.js +43 -0
- package/dist/errors/eslint-integration.js.map +1 -0
- package/dist/errors/index.d.ts +11 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +58 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/pattern-matcher.d.ts +25 -0
- package/dist/errors/pattern-matcher.d.ts.map +1 -0
- package/dist/errors/pattern-matcher.js +44 -0
- package/dist/errors/pattern-matcher.js.map +1 -0
- package/dist/errors/patterns.json +36 -0
- package/dist/errors/typescript-integration.d.ts +6 -0
- package/dist/errors/typescript-integration.d.ts.map +1 -0
- package/dist/errors/typescript-integration.js +46 -0
- package/dist/errors/typescript-integration.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/server/mcp-server.d.ts +11 -0
- package/dist/server/mcp-server.d.ts.map +1 -0
- package/dist/server/mcp-server.js +213 -0
- package/dist/server/mcp-server.js.map +1 -0
- package/dist/types/documentation.d.ts +26 -0
- package/dist/types/documentation.d.ts.map +1 -0
- package/dist/types/documentation.js +2 -0
- package/dist/types/documentation.js.map +1 -0
- package/dist/utils/config.d.ts +9 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +10 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/rate-limiter.d.ts +9 -0
- package/dist/utils/rate-limiter.d.ts.map +1 -0
- package/dist/utils/rate-limiter.js +26 -0
- package/dist/utils/rate-limiter.js.map +1 -0
- package/dist/validation/auto-fix.d.ts +15 -0
- package/dist/validation/auto-fix.d.ts.map +1 -0
- package/dist/validation/auto-fix.js +49 -0
- package/dist/validation/auto-fix.js.map +1 -0
- package/dist/validation/index.d.ts +21 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +45 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/resolution-db.d.ts +15 -0
- package/dist/validation/resolution-db.d.ts.map +1 -0
- package/dist/validation/resolution-db.js +62 -0
- package/dist/validation/resolution-db.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export class ResolutionDatabase {
|
|
2
|
+
resolutions = new Map();
|
|
3
|
+
constructor() {
|
|
4
|
+
this.initializeDefaultResolutions();
|
|
5
|
+
}
|
|
6
|
+
getResolution(error) {
|
|
7
|
+
// Try exact match first
|
|
8
|
+
let resolution = this.resolutions.get(error.type);
|
|
9
|
+
// Try partial match
|
|
10
|
+
if (!resolution) {
|
|
11
|
+
for (const [key, value] of this.resolutions.entries()) {
|
|
12
|
+
if (error.type.includes(key) || error.message.includes(key)) {
|
|
13
|
+
resolution = value;
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// Default resolution
|
|
19
|
+
if (!resolution) {
|
|
20
|
+
resolution = {
|
|
21
|
+
errorType: error.type,
|
|
22
|
+
description: error.message,
|
|
23
|
+
solution: error.fix || 'Review the error message and fix the issue manually',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return resolution;
|
|
27
|
+
}
|
|
28
|
+
initializeDefaultResolutions() {
|
|
29
|
+
this.resolutions.set('undefined-variable', {
|
|
30
|
+
errorType: 'undefined-variable',
|
|
31
|
+
description: 'Variable is used before being defined',
|
|
32
|
+
solution: 'Define the variable before use or import it from the appropriate module',
|
|
33
|
+
codeExample: '// Before: console.log(myVar);\n// After: const myVar = value; console.log(myVar);',
|
|
34
|
+
});
|
|
35
|
+
this.resolutions.set('missing-import', {
|
|
36
|
+
errorType: 'missing-import',
|
|
37
|
+
description: 'Required import statement is missing',
|
|
38
|
+
solution: 'Add the import statement at the top of the file',
|
|
39
|
+
codeExample: "import { functionName } from './module';",
|
|
40
|
+
});
|
|
41
|
+
this.resolutions.set('async-await', {
|
|
42
|
+
errorType: 'async-await',
|
|
43
|
+
description: 'Async function call is missing await',
|
|
44
|
+
solution: 'Add await keyword before the async function call',
|
|
45
|
+
codeExample: '// Before: myAsyncFunction();\n// After: await myAsyncFunction();',
|
|
46
|
+
});
|
|
47
|
+
this.resolutions.set('typescript', {
|
|
48
|
+
errorType: 'typescript',
|
|
49
|
+
description: 'TypeScript compilation error',
|
|
50
|
+
solution: 'Fix the type error according to TypeScript compiler suggestions',
|
|
51
|
+
});
|
|
52
|
+
this.resolutions.set('eslint', {
|
|
53
|
+
errorType: 'eslint',
|
|
54
|
+
description: 'ESLint code quality issue',
|
|
55
|
+
solution: 'Fix the code style or logic issue according to ESLint rules',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
addResolution(resolution) {
|
|
59
|
+
this.resolutions.set(resolution.errorType, resolution);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=resolution-db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution-db.js","sourceRoot":"","sources":["../../src/validation/resolution-db.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,kBAAkB;IACrB,WAAW,GAAiC,IAAI,GAAG,EAAE,CAAC;IAE9D;QACE,IAAI,CAAC,4BAA4B,EAAE,CAAC;IACtC,CAAC;IAED,aAAa,CAAC,KAAoB;QAChC,wBAAwB;QACxB,IAAI,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAElD,oBAAoB;QACpB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC;gBACtD,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC5D,UAAU,GAAG,KAAK,CAAC;oBACnB,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QAED,qBAAqB;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,UAAU,GAAG;gBACX,SAAS,EAAE,KAAK,CAAC,IAAI;gBACrB,WAAW,EAAE,KAAK,CAAC,OAAO;gBAC1B,QAAQ,EAAE,KAAK,CAAC,GAAG,IAAI,qDAAqD;aAC7E,CAAC;QACJ,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAEO,4BAA4B;QAClC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,oBAAoB,EAAE;YACzC,SAAS,EAAE,oBAAoB;YAC/B,WAAW,EAAE,uCAAuC;YACpD,QAAQ,EAAE,yEAAyE;YACnF,WAAW,EAAE,oFAAoF;SAClG,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,gBAAgB,EAAE;YACrC,SAAS,EAAE,gBAAgB;YAC3B,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,iDAAiD;YAC3D,WAAW,EAAE,0CAA0C;SACxD,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,EAAE;YAClC,SAAS,EAAE,aAAa;YACxB,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,kDAAkD;YAC5D,WAAW,EAAE,mEAAmE;SACjF,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE;YACjC,SAAS,EAAE,YAAY;YACvB,WAAW,EAAE,8BAA8B;YAC3C,QAAQ,EAAE,iEAAiE;SAC5E,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC7B,SAAS,EAAE,QAAQ;YACnB,WAAW,EAAE,2BAA2B;YACxC,QAAQ,EAAE,6DAA6D;SACxE,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,UAA2B;QACvC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gulibs/safe-coder",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"registry": "https://registry.npmjs.org"
|
|
7
|
+
},
|
|
8
|
+
"description": "MCP service for documentation fetching, error detection, and code validation",
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsx src/index.ts",
|
|
14
|
+
"start": "node dist/index.js",
|
|
15
|
+
"test": "vitest",
|
|
16
|
+
"test:watch": "vitest --watch",
|
|
17
|
+
"lint": "eslint src --ext .ts",
|
|
18
|
+
"type-check": "tsc --noEmit",
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"postinstall": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"bin": {
|
|
23
|
+
"safe-coder-mcp": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"keywords": [
|
|
31
|
+
"mcp",
|
|
32
|
+
"model-context-protocol",
|
|
33
|
+
"documentation",
|
|
34
|
+
"error-detection",
|
|
35
|
+
"code-validation"
|
|
36
|
+
],
|
|
37
|
+
"author": "",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.22.0",
|
|
41
|
+
"@typescript-eslint/typescript-estree": "^8.48.0",
|
|
42
|
+
"axios": "^1.13.2",
|
|
43
|
+
"zod": "^3.25.76"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/eslint": "^9.6.1",
|
|
47
|
+
"@types/node": "^20.0.0",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
49
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
50
|
+
"eslint": "^8.57.1",
|
|
51
|
+
"tsx": "^4.0.0",
|
|
52
|
+
"typescript": "^5.9.3",
|
|
53
|
+
"vitest": "^1.0.0"
|
|
54
|
+
}
|
|
55
|
+
}
|