locadex 0.0.0 → 0.0.2-alpha.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/.locadex-mcp.json +9 -0
- package/LICENSE.md +105 -0
- package/README.md +22 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +24 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/i18n.d.ts +2 -0
- package/dist/commands/i18n.d.ts.map +1 -0
- package/dist/commands/i18n.js +145 -0
- package/dist/commands/i18n.js.map +1 -0
- package/dist/commands/setup.d.ts +2 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +90 -0
- package/dist/commands/setup.js.map +1 -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/claudeCode.d.ts +16 -0
- package/dist/utils/claudeCode.d.ts.map +1 -0
- package/dist/utils/claudeCode.js +114 -0
- package/dist/utils/claudeCode.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/dist/utils/logging.d.ts +49 -0
- package/dist/utils/logging.d.ts.map +1 -0
- package/dist/utils/logging.js +226 -0
- package/dist/utils/logging.js.map +1 -0
- package/dist/utils/mcpConfig.d.ts +10 -0
- package/dist/utils/mcpConfig.d.ts.map +1 -0
- package/dist/utils/mcpConfig.js +10 -0
- package/dist/utils/mcpConfig.js.map +1 -0
- package/package.json +67 -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/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { fromPackageRoot } from './utils/getPaths.js';
|
|
7
|
+
import { setupCommand } from './commands/setup.js';
|
|
8
|
+
import { i18nCommand } from './commands/i18n.js';
|
|
9
|
+
var packageJson = JSON.parse(readFileSync(fromPackageRoot('package.json'), 'utf8'));
|
|
10
|
+
var program = new Command();
|
|
11
|
+
program
|
|
12
|
+
.name('locadex')
|
|
13
|
+
.description('AI agent for internationalization')
|
|
14
|
+
.version(packageJson.version);
|
|
15
|
+
program
|
|
16
|
+
.command('setup')
|
|
17
|
+
.description('Set up locadex for your project')
|
|
18
|
+
.action(setupCommand);
|
|
19
|
+
program
|
|
20
|
+
.command('i18n')
|
|
21
|
+
.description('Run AI-powered internationalization tasks')
|
|
22
|
+
.action(i18nCommand);
|
|
23
|
+
program.parse();
|
|
24
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,IAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,YAAY,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,CACtD,CAAC;AAEF,IAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,mCAAmC,CAAC;KAChD,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAEhC,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,iCAAiC,CAAC;KAC9C,MAAM,CAAC,YAAY,CAAC,CAAC;AAExB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,2CAA2C,CAAC;KACxD,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/commands/i18n.ts"],"names":[],"mappings":"AAkBA,wBAAsB,WAAW,kBAiGhC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
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 { intro, outro, text, select, spinner } from '@clack/prompts';
|
|
38
|
+
import chalk from 'chalk';
|
|
39
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
40
|
+
import { join } from 'node:path';
|
|
41
|
+
import { ClaudeCodeRunner } from '../utils/claudeCode.js';
|
|
42
|
+
import { fromPackageRoot } from '../utils/getPaths.js';
|
|
43
|
+
import { logInfo } from '../utils/logging.js';
|
|
44
|
+
var I18N_SYSTEM_PROMPT = "";
|
|
45
|
+
export function i18nCommand() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
+
var configPath, config, task, prompt_1, _a, targetLang, customPrompt, s, claudeRunner, mcpConfigPath, result, error_1;
|
|
48
|
+
return __generator(this, function (_b) {
|
|
49
|
+
switch (_b.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
intro(chalk.blue('🌍 Locadex i18n'));
|
|
52
|
+
_b.label = 1;
|
|
53
|
+
case 1:
|
|
54
|
+
_b.trys.push([1, 12, , 13]);
|
|
55
|
+
configPath = join(process.cwd(), '.locadex.json');
|
|
56
|
+
if (!existsSync(configPath)) {
|
|
57
|
+
outro(chalk.red('❌ Locadex not configured. Run `npx locadex setup` first.'));
|
|
58
|
+
return [2 /*return*/];
|
|
59
|
+
}
|
|
60
|
+
config = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
61
|
+
if (!config.setupComplete) {
|
|
62
|
+
outro(chalk.red('❌ Setup incomplete. Please run `npx locadex setup` again.'));
|
|
63
|
+
return [2 /*return*/];
|
|
64
|
+
}
|
|
65
|
+
return [4 /*yield*/, select({
|
|
66
|
+
message: 'What would you like to do?',
|
|
67
|
+
options: [
|
|
68
|
+
{ value: 'extract', label: 'Extract text for translation' },
|
|
69
|
+
{ value: 'translate', label: 'Generate translations' },
|
|
70
|
+
{ value: 'audit', label: 'Audit existing translations' },
|
|
71
|
+
{ value: 'refactor', label: 'Refactor hardcoded strings' },
|
|
72
|
+
{ value: 'custom', label: 'Custom i18n task' },
|
|
73
|
+
],
|
|
74
|
+
})];
|
|
75
|
+
case 2:
|
|
76
|
+
task = _b.sent();
|
|
77
|
+
prompt_1 = '';
|
|
78
|
+
_a = task;
|
|
79
|
+
switch (_a) {
|
|
80
|
+
case 'extract': return [3 /*break*/, 3];
|
|
81
|
+
case 'translate': return [3 /*break*/, 4];
|
|
82
|
+
case 'audit': return [3 /*break*/, 6];
|
|
83
|
+
case 'refactor': return [3 /*break*/, 7];
|
|
84
|
+
case 'custom': return [3 /*break*/, 8];
|
|
85
|
+
}
|
|
86
|
+
return [3 /*break*/, 10];
|
|
87
|
+
case 3:
|
|
88
|
+
prompt_1 =
|
|
89
|
+
'Scan the codebase and extract all user-facing text that needs translation. Create appropriate translation keys and organize them logically.';
|
|
90
|
+
return [3 /*break*/, 10];
|
|
91
|
+
case 4: return [4 /*yield*/, text({
|
|
92
|
+
message: 'Target language (e.g., "es", "fr", "de"):',
|
|
93
|
+
placeholder: 'es',
|
|
94
|
+
})];
|
|
95
|
+
case 5:
|
|
96
|
+
targetLang = _b.sent();
|
|
97
|
+
prompt_1 = "Generate translations for the target language: ".concat(typeof targetLang === 'string' ? targetLang : 'es', ". Maintain context and ensure culturally appropriate translations.");
|
|
98
|
+
return [3 /*break*/, 10];
|
|
99
|
+
case 6:
|
|
100
|
+
prompt_1 =
|
|
101
|
+
'Audit existing translations for completeness, consistency, and quality. Identify missing keys and potential improvements.';
|
|
102
|
+
return [3 /*break*/, 10];
|
|
103
|
+
case 7:
|
|
104
|
+
prompt_1 =
|
|
105
|
+
'Find hardcoded strings in the codebase and refactor them to use the i18n system. Maintain functionality while making text translatable.';
|
|
106
|
+
return [3 /*break*/, 10];
|
|
107
|
+
case 8: return [4 /*yield*/, text({
|
|
108
|
+
message: 'Describe your i18n task:',
|
|
109
|
+
placeholder: 'I need help with...',
|
|
110
|
+
})];
|
|
111
|
+
case 9:
|
|
112
|
+
customPrompt = _b.sent();
|
|
113
|
+
prompt_1 = typeof customPrompt === 'string' ? customPrompt : '';
|
|
114
|
+
return [3 /*break*/, 10];
|
|
115
|
+
case 10:
|
|
116
|
+
s = spinner();
|
|
117
|
+
s.start('Processing i18n task...');
|
|
118
|
+
claudeRunner = new ClaudeCodeRunner({
|
|
119
|
+
apiKey: config.apiKey,
|
|
120
|
+
});
|
|
121
|
+
mcpConfigPath = fromPackageRoot('.locadex-mcp.json');
|
|
122
|
+
return [4 /*yield*/, claudeRunner.run({
|
|
123
|
+
// systemPrompt: I18N_SYSTEM_PROMPT,
|
|
124
|
+
prompt: prompt_1,
|
|
125
|
+
mcpConfig: mcpConfigPath,
|
|
126
|
+
allowedTools: ['mcp__*'],
|
|
127
|
+
})];
|
|
128
|
+
case 11:
|
|
129
|
+
result = _b.sent();
|
|
130
|
+
s.stop('Task complete');
|
|
131
|
+
logInfo('\n' + chalk.green('📋 Result:'));
|
|
132
|
+
logInfo(result);
|
|
133
|
+
outro(chalk.green('✅ i18n task completed!'));
|
|
134
|
+
return [3 /*break*/, 13];
|
|
135
|
+
case 12:
|
|
136
|
+
error_1 = _b.sent();
|
|
137
|
+
outro(chalk.red("\u274C Task failed: ".concat(error_1 instanceof Error ? error_1.message : String(error_1))));
|
|
138
|
+
process.exit(1);
|
|
139
|
+
return [3 /*break*/, 13];
|
|
140
|
+
case 13: return [2 /*return*/];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/commands/i18n.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,E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,IAAI,CAAC,eAAe,CAAC,CAAC;oBAExB,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;oBAC1C,OAAO,CAAC,MAAM,CAAC,CAAC;oBAEhB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC;;;;oBAE7C,KAAK,CACH,KAAK,CAAC,GAAG,CACP,8BAAkB,OAAK,YAAY,KAAK,CAAC,CAAC,CAAC,OAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAK,CAAC,CAAE,CAC3E,CACF,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;;;;;CAEnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAUA,wBAAsB,YAAY,kBAkDjC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { intro, outro, text, spinner } from '@clack/prompts';
|
|
38
|
+
import chalk from 'chalk';
|
|
39
|
+
import { ClaudeCodeRunner } from '../utils/claudeCode.js';
|
|
40
|
+
import { fromPackageRoot } from '../utils/getPaths.js';
|
|
41
|
+
import { logInfo } from '../utils/logging.js';
|
|
42
|
+
var SETUP_SYSTEM_PROMPT = "";
|
|
43
|
+
export function setupCommand() {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
var projectType, s, mcpConfigPath, claudeRunner, setupPrompt, result, error_1;
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
intro(chalk.blue('🌍 Locadex Setup'));
|
|
50
|
+
_a.label = 1;
|
|
51
|
+
case 1:
|
|
52
|
+
_a.trys.push([1, 4, , 5]);
|
|
53
|
+
return [4 /*yield*/, text({
|
|
54
|
+
message: 'What type of project is this? (e.g., React, Vue, Node.js, etc.):',
|
|
55
|
+
placeholder: 'React',
|
|
56
|
+
})];
|
|
57
|
+
case 2:
|
|
58
|
+
projectType = _a.sent();
|
|
59
|
+
s = spinner();
|
|
60
|
+
mcpConfigPath = fromPackageRoot('.locadex-mcp.json');
|
|
61
|
+
// Run Claude Code for project analysis
|
|
62
|
+
s.start('Analyzing project for i18n setup...');
|
|
63
|
+
claudeRunner = new ClaudeCodeRunner({
|
|
64
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
65
|
+
});
|
|
66
|
+
setupPrompt = "Use the locadex mcp server to learn how to use gt-next. \nThen, use gt-next to internationalize this next.js app";
|
|
67
|
+
return [4 /*yield*/, claudeRunner.run({
|
|
68
|
+
// systemPrompt: SETUP_SYSTEM_PROMPT,
|
|
69
|
+
prompt: setupPrompt,
|
|
70
|
+
mcpConfig: mcpConfigPath,
|
|
71
|
+
allowedTools: ['mcp__*'],
|
|
72
|
+
})];
|
|
73
|
+
case 3:
|
|
74
|
+
result = _a.sent();
|
|
75
|
+
s.stop('Analysis complete');
|
|
76
|
+
logInfo('\n' + chalk.green('📋 Setup Analysis:'));
|
|
77
|
+
logInfo(result);
|
|
78
|
+
outro(chalk.green('✅ Locadex setup complete! Run `npx locadex i18n` to start working on internationalization.'));
|
|
79
|
+
return [3 /*break*/, 5];
|
|
80
|
+
case 4:
|
|
81
|
+
error_1 = _a.sent();
|
|
82
|
+
outro(chalk.red("\u274C Setup failed: ".concat(error_1 instanceof Error ? error_1.message : String(error_1))));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
return [3 /*break*/, 5];
|
|
85
|
+
case 5: return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAW,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,IAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,MAAM,UAAgB,YAAY;;;;;;oBAChC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;;;;oBAIhB,qBAAM,IAAI,CAAC;4BAC7B,OAAO,EACL,kEAAkE;4BACpE,WAAW,EAAE,OAAO;yBACrB,CAAC,EAAA;;oBAJI,WAAW,GAAG,SAIlB;oBAEI,CAAC,GAAG,OAAO,EAAE,CAAC;oBAEd,aAAa,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;oBAE3D,uCAAuC;oBACvC,CAAC,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;oBAEzC,YAAY,GAAG,IAAI,gBAAgB,CAAC;wBACxC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;qBACtC,CAAC,CAAC;oBAEG,WAAW,GAAG,kHAC+B,CAAC;oBAErC,qBAAM,YAAY,CAAC,GAAG,CAAC;4BACpC,qCAAqC;4BACrC,MAAM,EAAE,WAAW;4BACnB,SAAS,EAAE,aAAa;4BACxB,YAAY,EAAE,CAAC,QAAQ,CAAC;yBACzB,CAAC,EAAA;;oBALI,MAAM,GAAG,SAKb;oBAEF,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;oBAE5B,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;oBAClD,OAAO,CAAC,MAAM,CAAC,CAAC;oBAEhB,KAAK,CACH,KAAK,CAAC,KAAK,CACT,4FAA4F,CAC7F,CACF,CAAC;;;;oBAEF,KAAK,CACH,KAAK,CAAC,GAAG,CACP,+BAAmB,OAAK,YAAY,KAAK,CAAC,CAAC,CAAC,OAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAK,CAAC,CAAE,CAC5E,CACF,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;;;;;CAEnB"}
|
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"}
|