@scoutello/i18n-magic 0.40.0 → 0.42.0
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/dist/mcp-server.js +48 -8
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
- package/src/mcp-server.ts +58 -8
package/dist/mcp-server.js
CHANGED
|
@@ -6,6 +6,24 @@ import { z } from "zod";
|
|
|
6
6
|
import { addTranslationKey } from "./lib/utils.js";
|
|
7
7
|
import { loadConfig } from "./lib/utils.js";
|
|
8
8
|
import path from "path";
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
// Get __dirname equivalent in ES modules
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
// Helper function to find project root by looking for i18n-magic.js
|
|
15
|
+
function findProjectRoot(startDir) {
|
|
16
|
+
let currentDir = startDir;
|
|
17
|
+
const root = path.parse(currentDir).root;
|
|
18
|
+
while (currentDir !== root) {
|
|
19
|
+
const configPath = path.join(currentDir, "i18n-magic.js");
|
|
20
|
+
if (fs.existsSync(configPath)) {
|
|
21
|
+
return currentDir;
|
|
22
|
+
}
|
|
23
|
+
currentDir = path.dirname(currentDir);
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
9
27
|
// Helper function to resolve project root
|
|
10
28
|
function resolveProjectRoot() {
|
|
11
29
|
// 1. Check for --project-root CLI argument
|
|
@@ -22,7 +40,14 @@ function resolveProjectRoot() {
|
|
|
22
40
|
console.error(`[i18n-magic MCP] Using project root from I18N_MCP_PROJECT_ROOT: ${projectRoot}`);
|
|
23
41
|
return path.resolve(projectRoot);
|
|
24
42
|
}
|
|
25
|
-
// 3.
|
|
43
|
+
// 3. Try to auto-detect project root from script location
|
|
44
|
+
// When installed in node_modules, traverse up to find i18n-magic.js
|
|
45
|
+
const autoDetected = findProjectRoot(__dirname);
|
|
46
|
+
if (autoDetected) {
|
|
47
|
+
console.error(`[i18n-magic MCP] Auto-detected project root: ${autoDetected}`);
|
|
48
|
+
return autoDetected;
|
|
49
|
+
}
|
|
50
|
+
// 4. Fall back to current working directory
|
|
26
51
|
const cwd = process.cwd();
|
|
27
52
|
console.error(`[i18n-magic MCP] Using current working directory as project root: ${cwd}`);
|
|
28
53
|
return cwd;
|
|
@@ -108,13 +133,26 @@ class I18nMagicServer {
|
|
|
108
133
|
const params = AddTranslationKeySchema.parse(request.params.arguments);
|
|
109
134
|
// Ensure config is loaded
|
|
110
135
|
const config = await this.ensureConfig();
|
|
111
|
-
//
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
136
|
+
// Suppress console.log to prevent interference with MCP JSON protocol
|
|
137
|
+
// Only console.error is allowed in MCP servers
|
|
138
|
+
const originalConsoleLog = console.log;
|
|
139
|
+
console.log = () => { };
|
|
140
|
+
let result;
|
|
141
|
+
try {
|
|
142
|
+
// Add the translation key
|
|
143
|
+
result = await addTranslationKey({
|
|
144
|
+
key: params.key,
|
|
145
|
+
value: params.value,
|
|
146
|
+
namespace: params.namespace,
|
|
147
|
+
config,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
// Restore console.log
|
|
152
|
+
console.log = originalConsoleLog;
|
|
153
|
+
}
|
|
154
|
+
// Log to stderr for debugging (this is safe in MCP)
|
|
155
|
+
console.error(`[i18n-magic MCP] Added key "${result.key}" to ${result.locale}/${result.namespace}`);
|
|
118
156
|
return {
|
|
119
157
|
content: [
|
|
120
158
|
{
|
|
@@ -134,6 +172,8 @@ class I18nMagicServer {
|
|
|
134
172
|
}
|
|
135
173
|
catch (error) {
|
|
136
174
|
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
175
|
+
// Log error to stderr for debugging
|
|
176
|
+
console.error(`[i18n-magic MCP] Error adding translation key:`, errorMessage);
|
|
137
177
|
return {
|
|
138
178
|
content: [
|
|
139
179
|
{
|
package/dist/mcp-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,IAAI,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,yCAAyC;AACzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C,oEAAoE;AACpE,SAAS,eA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QACrC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;QAEzB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;QAC5C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACpC,OAAO,CAAC,KAAK,CACX,iEAAiE,CAClE,CAAA;IACH,CAAC;CACF;AAED,mBAAmB;AACnB,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;AACpC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAA;IACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "@scoutello/i18n-magic",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.42.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "Intelligent CLI toolkit that automates internationalization workflows with AI-powered translations for JavaScript/TypeScript projects",
|
package/src/mcp-server.ts
CHANGED
|
@@ -9,6 +9,28 @@ import { addTranslationKey } from "./lib/utils.js"
|
|
|
9
9
|
import { loadConfig } from "./lib/utils.js"
|
|
10
10
|
import type { Configuration } from "./lib/types.js"
|
|
11
11
|
import path from "path"
|
|
12
|
+
import fs from "fs"
|
|
13
|
+
import { fileURLToPath } from "url"
|
|
14
|
+
|
|
15
|
+
// Get __dirname equivalent in ES modules
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
17
|
+
const __dirname = path.dirname(__filename)
|
|
18
|
+
|
|
19
|
+
// Helper function to find project root by looking for i18n-magic.js
|
|
20
|
+
function findProjectRoot(startDir: string): string | null {
|
|
21
|
+
let currentDir = startDir
|
|
22
|
+
const root = path.parse(currentDir).root
|
|
23
|
+
|
|
24
|
+
while (currentDir !== root) {
|
|
25
|
+
const configPath = path.join(currentDir, "i18n-magic.js")
|
|
26
|
+
if (fs.existsSync(configPath)) {
|
|
27
|
+
return currentDir
|
|
28
|
+
}
|
|
29
|
+
currentDir = path.dirname(currentDir)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
12
34
|
|
|
13
35
|
// Helper function to resolve project root
|
|
14
36
|
function resolveProjectRoot(): string {
|
|
@@ -28,7 +50,15 @@ function resolveProjectRoot(): string {
|
|
|
28
50
|
return path.resolve(projectRoot)
|
|
29
51
|
}
|
|
30
52
|
|
|
31
|
-
// 3.
|
|
53
|
+
// 3. Try to auto-detect project root from script location
|
|
54
|
+
// When installed in node_modules, traverse up to find i18n-magic.js
|
|
55
|
+
const autoDetected = findProjectRoot(__dirname)
|
|
56
|
+
if (autoDetected) {
|
|
57
|
+
console.error(`[i18n-magic MCP] Auto-detected project root: ${autoDetected}`)
|
|
58
|
+
return autoDetected
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 4. Fall back to current working directory
|
|
32
62
|
const cwd = process.cwd()
|
|
33
63
|
console.error(`[i18n-magic MCP] Using current working directory as project root: ${cwd}`)
|
|
34
64
|
return cwd
|
|
@@ -137,13 +167,29 @@ class I18nMagicServer {
|
|
|
137
167
|
// Ensure config is loaded
|
|
138
168
|
const config = await this.ensureConfig()
|
|
139
169
|
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
170
|
+
// Suppress console.log to prevent interference with MCP JSON protocol
|
|
171
|
+
// Only console.error is allowed in MCP servers
|
|
172
|
+
const originalConsoleLog = console.log
|
|
173
|
+
console.log = () => {}
|
|
174
|
+
|
|
175
|
+
let result
|
|
176
|
+
try {
|
|
177
|
+
// Add the translation key
|
|
178
|
+
result = await addTranslationKey({
|
|
179
|
+
key: params.key,
|
|
180
|
+
value: params.value,
|
|
181
|
+
namespace: params.namespace,
|
|
182
|
+
config,
|
|
183
|
+
})
|
|
184
|
+
} finally {
|
|
185
|
+
// Restore console.log
|
|
186
|
+
console.log = originalConsoleLog
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Log to stderr for debugging (this is safe in MCP)
|
|
190
|
+
console.error(
|
|
191
|
+
`[i18n-magic MCP] Added key "${result.key}" to ${result.locale}/${result.namespace}`,
|
|
192
|
+
)
|
|
147
193
|
|
|
148
194
|
return {
|
|
149
195
|
content: [
|
|
@@ -169,6 +215,10 @@ class I18nMagicServer {
|
|
|
169
215
|
} catch (error) {
|
|
170
216
|
const errorMessage =
|
|
171
217
|
error instanceof Error ? error.message : "Unknown error occurred"
|
|
218
|
+
|
|
219
|
+
// Log error to stderr for debugging
|
|
220
|
+
console.error(`[i18n-magic MCP] Error adding translation key:`, errorMessage)
|
|
221
|
+
|
|
172
222
|
return {
|
|
173
223
|
content: [
|
|
174
224
|
{
|