locadex 0.0.0 → 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/LICENSE.md +105 -0
- package/README.md +22 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/docs.d.ts +4 -0
- package/dist/resources/docs.d.ts.map +1 -0
- package/dist/resources/docs.js +176 -0
- package/dist/resources/docs.js.map +1 -0
- package/dist/tools/docs.d.ts +3 -0
- package/dist/tools/docs.d.ts.map +1 -0
- package/dist/tools/docs.js +140 -0
- package/dist/tools/docs.js.map +1 -0
- package/dist/utils/getDocs.d.ts +10 -0
- package/dist/utils/getDocs.d.ts.map +1 -0
- package/dist/utils/getDocs.js +113 -0
- package/dist/utils/getDocs.js.map +1 -0
- package/dist/utils/getPaths.d.ts +2 -0
- package/dist/utils/getPaths.d.ts.map +1 -0
- package/dist/utils/getPaths.js +7 -0
- package/dist/utils/getPaths.js.map +1 -0
- package/package.json +61 -8
package/LICENSE.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-ALv2
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2024 General Translation, Inc.
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://generaltranslation.com" target="_blank">
|
|
3
|
+
<img src="https://generaltranslation.com/gt-logo-light.svg" alt="General Translation" width="100" height="100">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
1
7
|
# Locadex
|
|
8
|
+
|
|
9
|
+
Locadex is an AI Agent for internationalization.
|
|
10
|
+
|
|
11
|
+
Start it with
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx locadex@latest
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Documentation
|
|
18
|
+
|
|
19
|
+
Full documentation, including guides, examples, and API references, can be found at [General Translation Docs](generaltranslation.com/docs).
|
|
20
|
+
|
|
21
|
+
## Contributing
|
|
22
|
+
|
|
23
|
+
We welcome any contributions to our libraries. Please submit a pull request!
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
39
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
40
|
+
import { addDocsTools } from './tools/docs.js';
|
|
41
|
+
import { addDocsResource } from './resources/docs.js';
|
|
42
|
+
import { readFileSync } from 'node:fs';
|
|
43
|
+
import { fromPackageRoot } from './utils/getPaths.js';
|
|
44
|
+
function main() {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
+
var server, transport;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
server = new McpServer({
|
|
51
|
+
name: 'Locadex: AI Agent for Internationalization',
|
|
52
|
+
version: JSON.parse(readFileSync(fromPackageRoot('package.json'), 'utf8'))
|
|
53
|
+
.version,
|
|
54
|
+
});
|
|
55
|
+
addDocsResource(server);
|
|
56
|
+
addDocsTools(server);
|
|
57
|
+
transport = new StdioServerTransport();
|
|
58
|
+
return [4 /*yield*/, server.connect(transport)];
|
|
59
|
+
case 1:
|
|
60
|
+
_a.sent();
|
|
61
|
+
console.error('Locadex started on stdio');
|
|
62
|
+
return [2 /*return*/];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
main();
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,SAAe,IAAI;;;;;;oBACX,MAAM,GAAG,IAAI,SAAS,CAAC;wBAC3B,IAAI,EAAE,4CAA4C;wBAClD,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC;6BACvE,OAAO;qBACX,CAAC,CAAC;oBACH,eAAe,CAAC,MAAM,CAAC,CAAC;oBACxB,YAAY,CAAC,MAAM,CAAC,CAAC;oBACf,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;oBAC7C,qBAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAA;;oBAA/B,SAA+B,CAAC;oBAChC,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;;;;;CAC3C;AACD,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/resources/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAEV,MAAM,yCAAyC,CAAC;AAGjD,wBAAsB,eAAe,CAAC,MAAM,EAAE,SAAS,iBA+EtD;AAGD,wBAAgB,oBAAoB,eAoBnC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { ResourceTemplate, } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
38
|
+
import { CACHE_TTL, fetchDocContent } from '../utils/getDocs.js';
|
|
39
|
+
export function addDocsResource(server) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
41
|
+
var _this = this;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
// Add root resource for MCP docs
|
|
44
|
+
server.resource('mcp-docs', new ResourceTemplate('mcp-docs://', {
|
|
45
|
+
list: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
return [2 /*return*/, ({
|
|
48
|
+
resources: [
|
|
49
|
+
{
|
|
50
|
+
name: 'Standard LLM specification',
|
|
51
|
+
uri: 'llms://llms.txt',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'Full LLM specification',
|
|
55
|
+
uri: 'llms://llms-full.txt',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
})];
|
|
59
|
+
});
|
|
60
|
+
}); },
|
|
61
|
+
}), function (uri) { return __awaiter(_this, void 0, void 0, function () {
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
return [2 /*return*/, ({
|
|
64
|
+
contents: [
|
|
65
|
+
{
|
|
66
|
+
uri: uri.href,
|
|
67
|
+
text: 'MCP Documentation Resources',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
})];
|
|
71
|
+
});
|
|
72
|
+
}); });
|
|
73
|
+
// Resource for llms-full.txt
|
|
74
|
+
server.resource('llms-full.txt', 'llms://llms-full.txt', function (uri) { return __awaiter(_this, void 0, void 0, function () {
|
|
75
|
+
var content, error_1;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
_a.trys.push([0, 2, , 3]);
|
|
80
|
+
return [4 /*yield*/, fetchDocContent('llms-full.txt')];
|
|
81
|
+
case 1:
|
|
82
|
+
content = _a.sent();
|
|
83
|
+
return [2 /*return*/, {
|
|
84
|
+
contents: [
|
|
85
|
+
{
|
|
86
|
+
uri: uri.href,
|
|
87
|
+
text: content,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
}];
|
|
91
|
+
case 2:
|
|
92
|
+
error_1 = _a.sent();
|
|
93
|
+
console.error('Error retrieving llms-full.txt resource:', error_1);
|
|
94
|
+
return [2 /*return*/, {
|
|
95
|
+
contents: [
|
|
96
|
+
{
|
|
97
|
+
uri: uri.href,
|
|
98
|
+
text: "Error: Unable to retrieve llms-full.txt resource. ".concat(error_1),
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
}];
|
|
102
|
+
case 3: return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}); });
|
|
106
|
+
// Resource for llms.txt
|
|
107
|
+
server.resource('llms.txt', 'llms://llms.txt', function (uri) { return __awaiter(_this, void 0, void 0, function () {
|
|
108
|
+
var content, error_2;
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
switch (_a.label) {
|
|
111
|
+
case 0:
|
|
112
|
+
_a.trys.push([0, 2, , 3]);
|
|
113
|
+
return [4 /*yield*/, fetchDocContent('llms.txt')];
|
|
114
|
+
case 1:
|
|
115
|
+
content = _a.sent();
|
|
116
|
+
return [2 /*return*/, {
|
|
117
|
+
contents: [
|
|
118
|
+
{
|
|
119
|
+
uri: uri.href,
|
|
120
|
+
text: content,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
}];
|
|
124
|
+
case 2:
|
|
125
|
+
error_2 = _a.sent();
|
|
126
|
+
console.error('Error retrieving llms.txt resource:', error_2);
|
|
127
|
+
return [2 /*return*/, {
|
|
128
|
+
contents: [
|
|
129
|
+
{
|
|
130
|
+
uri: uri.href,
|
|
131
|
+
text: "Error: Unable to retrieve llms.txt resource. ".concat(error_2),
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
}];
|
|
135
|
+
case 3: return [2 /*return*/];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}); });
|
|
139
|
+
return [2 /*return*/];
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
// Start a background job to periodically refresh the cache
|
|
144
|
+
export function startCacheRefreshJob() {
|
|
145
|
+
var _this = this;
|
|
146
|
+
var refreshCache = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
147
|
+
var error_3;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
_a.trys.push([0, 3, , 4]);
|
|
152
|
+
console.error('Refreshing MCP resources cache...');
|
|
153
|
+
return [4 /*yield*/, fetchDocContent('llms.txt')];
|
|
154
|
+
case 1:
|
|
155
|
+
_a.sent();
|
|
156
|
+
return [4 /*yield*/, fetchDocContent('llms-full.txt')];
|
|
157
|
+
case 2:
|
|
158
|
+
_a.sent();
|
|
159
|
+
console.error('Cache refresh complete');
|
|
160
|
+
return [3 /*break*/, 4];
|
|
161
|
+
case 3:
|
|
162
|
+
error_3 = _a.sent();
|
|
163
|
+
console.error('Error refreshing cache:', error_3);
|
|
164
|
+
return [3 /*break*/, 4];
|
|
165
|
+
case 4: return [2 /*return*/];
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}); };
|
|
169
|
+
// Initial fetch
|
|
170
|
+
refreshCache();
|
|
171
|
+
// Set up periodic refresh
|
|
172
|
+
var interval = setInterval(refreshCache, CACHE_TTL);
|
|
173
|
+
// Return cleanup function
|
|
174
|
+
return function () { return clearInterval(interval); };
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/resources/docs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAEL,gBAAgB,GACjB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,eAAe,E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"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { z } from 'zod';
|
|
38
|
+
import { fetchDocContent, getDocs } from '../utils/getDocs.js';
|
|
39
|
+
export function addDocsTools(server) {
|
|
40
|
+
var _this = this;
|
|
41
|
+
server.tool('fetch-docs', 'Fetches the content of a documentation file by its path.', {
|
|
42
|
+
path: z
|
|
43
|
+
.string()
|
|
44
|
+
.describe('The path to the documentation file (e.g., "platform/index.mdx" or "react/introduction.mdx")'),
|
|
45
|
+
}, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
46
|
+
var content, error_1;
|
|
47
|
+
var path = _b.path;
|
|
48
|
+
return __generator(this, function (_c) {
|
|
49
|
+
switch (_c.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
_c.trys.push([0, 2, , 3]);
|
|
52
|
+
return [4 /*yield*/, getDocs(path)];
|
|
53
|
+
case 1:
|
|
54
|
+
content = _c.sent();
|
|
55
|
+
if (!content) {
|
|
56
|
+
return [2 /*return*/, {
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: 'text',
|
|
60
|
+
text: "Failed to fetch documentation for path: ".concat(path),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
isError: true,
|
|
64
|
+
}];
|
|
65
|
+
}
|
|
66
|
+
return [2 /*return*/, {
|
|
67
|
+
content: [
|
|
68
|
+
{
|
|
69
|
+
type: 'text',
|
|
70
|
+
text: content,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
}];
|
|
74
|
+
case 2:
|
|
75
|
+
error_1 = _c.sent();
|
|
76
|
+
return [2 /*return*/, {
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: 'text',
|
|
80
|
+
text: "Error fetching documentation: ".concat(error_1 instanceof Error ? error_1.message : String(error_1)),
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
isError: true,
|
|
84
|
+
}];
|
|
85
|
+
case 3: return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); });
|
|
89
|
+
server.tool('list-docs', 'Lists available documentation files in the format of an llms.txt or llms-full.txt file. "full" returns the full documentation, "short" returns a summary.', {
|
|
90
|
+
type: z
|
|
91
|
+
.enum(['full', 'short'])
|
|
92
|
+
.default('short')
|
|
93
|
+
.describe('Type of documentation list: "full" for llms-full.txt or "short" for llms.txt'),
|
|
94
|
+
}, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
95
|
+
var filename, content, error_2;
|
|
96
|
+
var type = _b.type;
|
|
97
|
+
return __generator(this, function (_c) {
|
|
98
|
+
switch (_c.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
_c.trys.push([0, 2, , 3]);
|
|
101
|
+
filename = type === 'full' ? 'llms-full.txt' : 'llms.txt';
|
|
102
|
+
return [4 /*yield*/, fetchDocContent(filename)];
|
|
103
|
+
case 1:
|
|
104
|
+
content = _c.sent();
|
|
105
|
+
if (!content) {
|
|
106
|
+
return [2 /*return*/, {
|
|
107
|
+
content: [
|
|
108
|
+
{
|
|
109
|
+
type: 'text',
|
|
110
|
+
text: "Failed to fetch ".concat(filename, " documentation index"),
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
isError: true,
|
|
114
|
+
}];
|
|
115
|
+
}
|
|
116
|
+
return [2 /*return*/, {
|
|
117
|
+
content: [
|
|
118
|
+
{
|
|
119
|
+
type: 'text',
|
|
120
|
+
text: content,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
}];
|
|
124
|
+
case 2:
|
|
125
|
+
error_2 = _c.sent();
|
|
126
|
+
return [2 /*return*/, {
|
|
127
|
+
content: [
|
|
128
|
+
{
|
|
129
|
+
type: 'text',
|
|
130
|
+
text: "Error listing documentation: ".concat(error_2 instanceof Error ? error_2.message : String(error_2)),
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
isError: true,
|
|
134
|
+
}];
|
|
135
|
+
case 3: return [2 /*return*/];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}); });
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/tools/docs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,UAAU,YAAY,CAAC,MAAiB;IAA9C,iBAkGC;IAjGC,MAAM,CAAC,IAAI,CACT,YAAY,EACZ,0DAA0D,EAC1D;QACE,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,CACP,6FAA6F,CAC9F;KACJ,EACD,gEAAO,EAAQ;;YAAN,IAAI,UAAA;;;;;oBAEO,qBAAM,OAAO,CAAC,IAAI,CAAC,EAAA;;oBAA7B,OAAO,GAAG,SAAmB;oBAEnC,IAAI,CAAC,OAAO,EAAE,CAAC;wBACb,sBAAO;gCACL,OAAO,EAAE;oCACP;wCACE,IAAI,EAAE,MAAM;wCACZ,IAAI,EAAE,kDAA2C,IAAI,CAAE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;oCACZ,IAAI,EAAE,uCAAgC,OAAK,YAAY,KAAK,CAAC,CAAC,CAAC,OAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAK,CAAC,CAAE;iCAC/F;6BACF;4BACD,OAAO,EAAE,IAAI;yBACd,EAAC;;;;SAEL,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const GITHUB_URL = "https://raw.githubusercontent.com/generaltranslation/gt/refs/heads/main/apps/docs/content/docs/en";
|
|
2
|
+
export declare const DOCS_URL = "https://docs.generaltranslation.app";
|
|
3
|
+
export declare const getDocs: (path: string) => Promise<string | null>;
|
|
4
|
+
export declare const CACHE_TTL: number;
|
|
5
|
+
/**
|
|
6
|
+
* Fetches content from the docs URL with caching
|
|
7
|
+
* Refreshes cache every 5 minutes
|
|
8
|
+
*/
|
|
9
|
+
export declare function fetchDocContent(path: string): Promise<string>;
|
|
10
|
+
//# sourceMappingURL=getDocs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDocs.d.ts","sourceRoot":"","sources":["../../src/utils/getDocs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,sGAC8E,CAAC;AAEtG,eAAO,MAAM,QAAQ,wCAAwC,CAAC;AAE9D,eAAO,MAAM,OAAO,GAAU,MAAM,MAAM,2BAWzC,CAAC;AAUF,eAAO,MAAM,SAAS,QAAgB,CAAC;AAEvC;;;GAGG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwCnE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export var GITHUB_URL = 'https://raw.githubusercontent.com/generaltranslation/gt/refs/heads/main/apps/docs/content/docs/en';
|
|
38
|
+
export var DOCS_URL = 'https://docs.generaltranslation.app';
|
|
39
|
+
export var getDocs = function (path) { return __awaiter(void 0, void 0, void 0, function () {
|
|
40
|
+
var url, response, error_1;
|
|
41
|
+
return __generator(this, function (_a) {
|
|
42
|
+
switch (_a.label) {
|
|
43
|
+
case 0:
|
|
44
|
+
url = "".concat(GITHUB_URL, "/").concat(path);
|
|
45
|
+
console.error("Fetching document from: ".concat(url));
|
|
46
|
+
_a.label = 1;
|
|
47
|
+
case 1:
|
|
48
|
+
_a.trys.push([1, 3, , 4]);
|
|
49
|
+
return [4 /*yield*/, fetch(url)];
|
|
50
|
+
case 2:
|
|
51
|
+
response = _a.sent();
|
|
52
|
+
return [2 /*return*/, response.text()];
|
|
53
|
+
case 3:
|
|
54
|
+
error_1 = _a.sent();
|
|
55
|
+
console.error("Error fetching ".concat(path, ":"), error_1);
|
|
56
|
+
return [2 /*return*/, null];
|
|
57
|
+
case 4: return [2 /*return*/];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}); };
|
|
61
|
+
// Cache with 5-minute expiration
|
|
62
|
+
var cache = {};
|
|
63
|
+
export var CACHE_TTL = 5 * 60 * 1000; // 5 minutes in milliseconds
|
|
64
|
+
/**
|
|
65
|
+
* Fetches content from the docs URL with caching
|
|
66
|
+
* Refreshes cache every 5 minutes
|
|
67
|
+
*/
|
|
68
|
+
export function fetchDocContent(path) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var now, url, response, content, error_2;
|
|
71
|
+
return __generator(this, function (_a) {
|
|
72
|
+
switch (_a.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
now = Date.now();
|
|
75
|
+
// Check if we have a valid cached entry
|
|
76
|
+
if (cache[path] && now - cache[path].timestamp < CACHE_TTL) {
|
|
77
|
+
return [2 /*return*/, cache[path].content];
|
|
78
|
+
}
|
|
79
|
+
url = "".concat(DOCS_URL, "/").concat(path);
|
|
80
|
+
console.error("Fetching document from: ".concat(url));
|
|
81
|
+
_a.label = 1;
|
|
82
|
+
case 1:
|
|
83
|
+
_a.trys.push([1, 4, , 5]);
|
|
84
|
+
return [4 /*yield*/, fetch(url)];
|
|
85
|
+
case 2:
|
|
86
|
+
response = _a.sent();
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
throw new Error("Failed to fetch ".concat(path, ": ").concat(response.status, " ").concat(response.statusText));
|
|
89
|
+
}
|
|
90
|
+
return [4 /*yield*/, response.text()];
|
|
91
|
+
case 3:
|
|
92
|
+
content = _a.sent();
|
|
93
|
+
// Update cache
|
|
94
|
+
cache[path] = {
|
|
95
|
+
content: content,
|
|
96
|
+
timestamp: now,
|
|
97
|
+
};
|
|
98
|
+
return [2 /*return*/, content];
|
|
99
|
+
case 4:
|
|
100
|
+
error_2 = _a.sent();
|
|
101
|
+
console.error("Error fetching ".concat(path, ":"), error_2);
|
|
102
|
+
// Return cached content if available, even if expired
|
|
103
|
+
if (cache[path]) {
|
|
104
|
+
console.error("Returning stale cached content for ".concat(path));
|
|
105
|
+
return [2 /*return*/, cache[path].content];
|
|
106
|
+
}
|
|
107
|
+
throw error_2;
|
|
108
|
+
case 5: return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=getDocs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDocs.js","sourceRoot":"","sources":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AAQ,GAAG,SAAgB;oBAEjC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;wBACjB,MAAM,IAAI,KAAK,CACb,0BAAmB,IAAI,eAAK,QAAQ,CAAC,MAAM,cAAI,QAAQ,CAAC,UAAU,CAAE,CACrE,CAAC;oBACJ,CAAC;oBAEe,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;oBAA/B,OAAO,GAAG,SAAqB;oBAErC,eAAe;oBACf,KAAK,CAAC,IAAI,CAAC,GAAG;wBACZ,OAAO,SAAA;wBACP,SAAS,EAAE,GAAG;qBACf,CAAC;oBAEF,sBAAO,OAAO,EAAC;;;oBAEf,OAAO,CAAC,KAAK,CAAC,yBAAkB,IAAI,MAAG,EAAE,OAAK,CAAC,CAAC;oBAEhD,sDAAsD;oBACtD,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;wBAChB,OAAO,CAAC,KAAK,CAAC,6CAAsC,IAAI,CAAE,CAAC,CAAC;wBAC5D,sBAAO,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAC;oBAC7B,CAAC;oBAED,MAAM,OAAK,CAAC;;;;;CAEf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPaths.d.ts","sourceRoot":"","sources":["../../src/utils/getPaths.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,UAE/C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import path, { dirname } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
4
|
+
export function fromPackageRoot(relative) {
|
|
5
|
+
return path.resolve(__dirname, "../../", relative);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=getPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPaths.js","sourceRoot":"","sources":["../../src/utils/getPaths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,IAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "locadex",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "An AI agent for internationalization",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"gt-mcp-server": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"CHANGELOG.md"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@modelcontextprotocol/sdk": "^1.12.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@modelcontextprotocol/inspector": "^0.13.0",
|
|
19
|
+
"@types/jest": "^29.5.14",
|
|
20
|
+
"@types/node": ">=20.0.0",
|
|
21
|
+
"eslint": "^9.19.0",
|
|
22
|
+
"@typescript-eslint/eslint-plugin": "^8.19.1",
|
|
23
|
+
"@typescript-eslint/parser": "^8.19.1",
|
|
24
|
+
"prettier": "^3.4.2",
|
|
25
|
+
"tsx": "^4.16.5",
|
|
26
|
+
"typescript": "^5.7.3"
|
|
27
|
+
},
|
|
6
28
|
"scripts": {
|
|
7
|
-
"
|
|
29
|
+
"patch": "npm version patch",
|
|
30
|
+
"transpile": "tsc",
|
|
31
|
+
"build": "npm run transpile",
|
|
32
|
+
"build:clean": "rm -rf dist; npm run lint && npm run build",
|
|
33
|
+
"dev": "npm run build && node dist/index.js",
|
|
34
|
+
"inspect": "npx @modelcontextprotocol/inspector node dist/index.js",
|
|
35
|
+
"lint": "eslint .",
|
|
36
|
+
"lint:fix": "eslint . --fix",
|
|
37
|
+
"release": "npm run build:clean && npm publish --access public",
|
|
38
|
+
"release:alpha": "npm run build:clean && npm publish --access public --tag alpha",
|
|
39
|
+
"release:beta": "npm run build:clean && npm publish --access public --tag beta",
|
|
40
|
+
"release:latest": "npm run build:clean && npm publish --access public --tag latest",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"test:watch": "vitest"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/generaltranslation/gt.git"
|
|
47
|
+
},
|
|
48
|
+
"author": "General Translation, Inc.",
|
|
49
|
+
"license": "FSL-1.1-ALv2",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/generaltranslation/gt/issues"
|
|
8
52
|
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
53
|
+
"homepage": "https://generaltranslation.com/",
|
|
54
|
+
"compilerOptions": {},
|
|
55
|
+
"keywords": [
|
|
56
|
+
"react",
|
|
57
|
+
"translation",
|
|
58
|
+
"internationalization",
|
|
59
|
+
"localization",
|
|
60
|
+
"i18n",
|
|
61
|
+
"l10n",
|
|
62
|
+
"mcp",
|
|
63
|
+
"ai",
|
|
64
|
+
"agent"
|
|
65
|
+
]
|
|
13
66
|
}
|