locadex 0.0.2-alpha.6 → 0.0.2-alpha.7
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/cli.d.ts.map +1 -1
- package/dist/cli.js +67 -9
- package/dist/cli.js.map +1 -1
- package/dist/commands/i18n.d.ts +1 -2
- package/dist/commands/i18n.d.ts.map +1 -1
- package/dist/commands/i18n.js +5 -256
- package/dist/commands/i18n.js.map +1 -1
- package/dist/commands/setup.d.ts +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +5 -142
- package/dist/commands/setup.js.map +1 -1
- package/dist/logging/console.d.ts +3 -3
- package/dist/logging/console.d.ts.map +1 -1
- package/dist/logging/console.js +9 -8
- package/dist/logging/console.js.map +1 -1
- package/dist/logging/logger.d.ts +4 -2
- package/dist/logging/logger.d.ts.map +1 -1
- package/dist/logging/logger.js +33 -7
- package/dist/logging/logger.js.map +1 -1
- package/dist/mcp/getDocs.d.ts.map +1 -1
- package/dist/mcp/getDocs.js +2 -3
- package/dist/mcp/getDocs.js.map +1 -1
- package/dist/mcp/getPort.d.ts +2 -0
- package/dist/mcp/getPort.d.ts.map +1 -0
- package/dist/mcp/getPort.js +25 -0
- package/dist/mcp/getPort.js.map +1 -0
- package/dist/mcp/tools/docs.d.ts.map +1 -1
- package/dist/mcp/tools/docs.js +9 -2
- package/dist/mcp/tools/docs.js.map +1 -1
- package/dist/mcp/tools/guides.d.ts.map +1 -1
- package/dist/mcp/tools/guides.js +5 -2
- package/dist/mcp/tools/guides.js.map +1 -1
- package/dist/mcp-sse.d.ts.map +1 -1
- package/dist/mcp-sse.js +10 -28
- package/dist/mcp-sse.js.map +1 -1
- package/dist/tasks/i18n.d.ts +2 -0
- package/dist/tasks/i18n.d.ts.map +1 -0
- package/dist/tasks/i18n.js +317 -0
- package/dist/tasks/i18n.js.map +1 -0
- package/dist/tasks/setup.d.ts +2 -0
- package/dist/tasks/setup.d.ts.map +1 -0
- package/dist/tasks/setup.js +171 -0
- package/dist/tasks/setup.js.map +1 -0
- package/dist/telemetry.d.ts +1 -3
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +27 -25
- package/dist/telemetry.js.map +1 -1
- package/dist/types/cli.d.ts +9 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/cli.js +2 -2
- package/dist/types/cli.js.map +1 -1
- package/dist/utils/claudeCode.d.ts +7 -2
- package/dist/utils/claudeCode.d.ts.map +1 -1
- package/dist/utils/claudeCode.js +50 -31
- package/dist/utils/claudeCode.js.map +1 -1
- package/dist/utils/config.d.ts +10 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +66 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/dag/createDag.d.ts +1 -1
- package/dist/utils/dag/createDag.d.ts.map +1 -1
- package/dist/utils/dag/createDag.js +4 -41
- package/dist/utils/dag/createDag.js.map +1 -1
- package/dist/utils/dag/matchFiles.d.ts +2 -0
- package/dist/utils/dag/matchFiles.d.ts.map +1 -0
- package/dist/utils/dag/matchFiles.js +40 -0
- package/dist/utils/dag/matchFiles.js.map +1 -0
- package/dist/utils/getFiles.d.ts +2 -3
- package/dist/utils/getFiles.d.ts.map +1 -1
- package/dist/utils/getFiles.js +23 -14
- package/dist/utils/getFiles.js.map +1 -1
- package/dist/utils/locadexManager.d.ts +69 -0
- package/dist/utils/locadexManager.d.ts.map +1 -0
- package/dist/utils/locadexManager.js +250 -0
- package/dist/utils/locadexManager.js.map +1 -0
- package/dist/utils/session.d.ts +2 -0
- package/dist/utils/session.d.ts.map +1 -0
- package/dist/utils/session.js +12 -0
- package/dist/utils/session.js.map +1 -0
- package/dist/utils/shared.d.ts +2 -1
- package/dist/utils/shared.d.ts.map +1 -1
- package/dist/utils/shared.js +37 -14
- package/dist/utils/shared.js.map +1 -1
- package/dist/utils/shutdown.d.ts +20 -0
- package/dist/utils/shutdown.d.ts.map +1 -0
- package/dist/utils/shutdown.js +63 -0
- package/dist/utils/shutdown.js.map +1 -0
- package/dist/utils/stats.d.ts +13 -0
- package/dist/utils/stats.d.ts.map +1 -1
- package/dist/utils/stats.js +55 -2
- package/dist/utils/stats.js.map +1 -1
- package/package.json +2 -5
- package/.locadex-mcp-stdio.json +0 -9
- package/.locadex-mcp.json +0 -8
- package/dist/utils/agentManager.d.ts +0 -34
- package/dist/utils/agentManager.d.ts.map +0 -1
- package/dist/utils/agentManager.js +0 -123
- package/dist/utils/agentManager.js.map +0 -1
- package/dist/utils/debugLogger.d.ts +0 -3
- package/dist/utils/debugLogger.d.ts.map +0 -1
- package/dist/utils/debugLogger.js +0 -36
- package/dist/utils/debugLogger.js.map +0 -1
- package/dist/utils/mcpConfig.d.ts +0 -10
- package/dist/utils/mcpConfig.d.ts.map +0 -1
- package/dist/utils/mcpConfig.js +0 -13
- package/dist/utils/mcpConfig.js.map +0 -1
- package/dist/utils/validateConfig.d.ts +0 -2
- package/dist/utils/validateConfig.d.ts.map +0 -1
- package/dist/utils/validateConfig.js +0 -12
- package/dist/utils/validateConfig.js.map +0 -1
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"/","sources":["cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"/","sources":["cli.ts"],"names":[],"mappings":";AAQA,OAAO,gBAAgB,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="12144166-1323-59a4-afba-5b73e54e7b2c")}catch(e){}}();
|
|
4
4
|
import dotenv from 'dotenv';
|
|
5
5
|
dotenv.config({ path: '.env' });
|
|
6
6
|
dotenv.config({ path: '.env.local', override: true });
|
|
@@ -11,10 +11,12 @@ import { readFileSync } from 'node:fs';
|
|
|
11
11
|
import { fromPackageRoot } from './utils/getPaths.js';
|
|
12
12
|
import { setupCommand } from './commands/setup.js';
|
|
13
13
|
import { withTelemetry } from './telemetry.js';
|
|
14
|
-
import { logger } from './logging/logger.js';
|
|
15
14
|
import { i18nCommand } from './commands/i18n.js';
|
|
16
15
|
import { displayHeader } from './logging/console.js';
|
|
17
16
|
import { main } from 'gtx-cli/index';
|
|
17
|
+
import { LocadexManager } from './utils/locadexManager.js';
|
|
18
|
+
import { logger } from './logging/logger.js';
|
|
19
|
+
import { exit } from './utils/shutdown.js';
|
|
18
20
|
const packageJson = JSON.parse(readFileSync(fromPackageRoot('package.json'), 'utf8'));
|
|
19
21
|
const program = new Command();
|
|
20
22
|
program
|
|
@@ -27,14 +29,43 @@ program
|
|
|
27
29
|
.option('-v, --verbose', 'Verbose output')
|
|
28
30
|
.option('-d, --debug', 'Debug output')
|
|
29
31
|
.option('-b, --batch-size <number>', 'File batch size', '10')
|
|
32
|
+
.option('-c, --concurrency <number>', 'Max number of concurrent agents', '1')
|
|
33
|
+
.option('-f, --files <pattern>', 'Comma-separated list of glob patterns to match source files')
|
|
34
|
+
.option('-e, --extensions <extensions>', 'Comma-separated list of file extensions to match')
|
|
35
|
+
.option('--package-manager <manager>', 'Package manager to use. (npm, pnpm, yarn_v1, yarn_v2, bun, deno)')
|
|
36
|
+
.option('-y, --bypass-prompts', 'Bypass interactive prompts')
|
|
30
37
|
.option('--no-telemetry', 'Disable telemetry')
|
|
31
38
|
.action((options, command) => {
|
|
32
39
|
const parentOptions = command.parent?.opts() || {};
|
|
33
40
|
const allOptions = { ...parentOptions, ...options };
|
|
34
|
-
withTelemetry({ enabled: !allOptions.noTelemetry, options: allOptions }, () => {
|
|
35
|
-
|
|
41
|
+
withTelemetry({ enabled: !allOptions.noTelemetry, options: allOptions }, async () => {
|
|
42
|
+
const batchSize = Number(allOptions.batchSize) || 1;
|
|
43
|
+
const concurrency = Number(allOptions.concurrency) || 1;
|
|
44
|
+
if (concurrency < 1 || batchSize < 1) {
|
|
45
|
+
logger.error('Batch size and concurrency must be greater than 0');
|
|
46
|
+
await exit(1);
|
|
47
|
+
}
|
|
36
48
|
displayHeader();
|
|
37
|
-
|
|
49
|
+
LocadexManager.initialize({
|
|
50
|
+
mcpTransport: 'sse',
|
|
51
|
+
metadata: {},
|
|
52
|
+
cliOptions: allOptions,
|
|
53
|
+
options: {
|
|
54
|
+
...(allOptions.matchingFiles && {
|
|
55
|
+
matchingFiles: allOptions.matchingFiles
|
|
56
|
+
.split(',')
|
|
57
|
+
.map((file) => file.trim()),
|
|
58
|
+
}),
|
|
59
|
+
...(allOptions.matchingExtensions && {
|
|
60
|
+
matchingExtensions: allOptions.matchingExtensions
|
|
61
|
+
.split(',')
|
|
62
|
+
.map((ext) => ext.trim()),
|
|
63
|
+
}),
|
|
64
|
+
maxConcurrency: concurrency,
|
|
65
|
+
batchSize,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
await setupCommand(!!allOptions.bypassPrompts, allOptions.packageManager);
|
|
38
69
|
});
|
|
39
70
|
});
|
|
40
71
|
program
|
|
@@ -43,17 +74,44 @@ program
|
|
|
43
74
|
.option('-v, --verbose', 'Verbose output')
|
|
44
75
|
.option('-d, --debug', 'Debug output')
|
|
45
76
|
.option('-b, --batch-size <number>', 'File batch size', '10')
|
|
77
|
+
.option('-c, --concurrency <number>', 'Max number of concurrent agents', '1')
|
|
78
|
+
.option('-m, --matching-files <pattern>', 'Comma-separated list of glob patterns to match source files')
|
|
79
|
+
.option('-e, --matching-extensions <extensions>', 'Comma-separated list of file extensions to match')
|
|
46
80
|
.option('--no-telemetry', 'Disable telemetry')
|
|
47
81
|
.action((options, command) => {
|
|
48
82
|
const parentOptions = command.parent?.opts() || {};
|
|
49
83
|
const allOptions = { ...parentOptions, ...options };
|
|
50
|
-
withTelemetry({ enabled: !allOptions.noTelemetry, options: allOptions }, () => {
|
|
51
|
-
|
|
84
|
+
withTelemetry({ enabled: !allOptions.noTelemetry, options: allOptions }, async () => {
|
|
85
|
+
const batchSize = Number(allOptions.batchSize) || 1;
|
|
86
|
+
const concurrency = Number(allOptions.concurrency) || 1;
|
|
87
|
+
if (concurrency < 1 || batchSize < 1) {
|
|
88
|
+
logger.error('Batch size and concurrency must be greater than 0');
|
|
89
|
+
await exit(1);
|
|
90
|
+
}
|
|
52
91
|
displayHeader();
|
|
53
|
-
|
|
92
|
+
LocadexManager.initialize({
|
|
93
|
+
mcpTransport: 'sse',
|
|
94
|
+
metadata: {},
|
|
95
|
+
cliOptions: allOptions,
|
|
96
|
+
options: {
|
|
97
|
+
...(allOptions.matchingFiles && {
|
|
98
|
+
matchingFiles: allOptions.matchingFiles
|
|
99
|
+
.split(',')
|
|
100
|
+
.map((file) => file.trim()),
|
|
101
|
+
}),
|
|
102
|
+
...(allOptions.matchingExtensions && {
|
|
103
|
+
matchingExtensions: allOptions.matchingExtensions
|
|
104
|
+
.split(',')
|
|
105
|
+
.map((ext) => ext.trim()),
|
|
106
|
+
}),
|
|
107
|
+
maxConcurrency: concurrency,
|
|
108
|
+
batchSize,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
await i18nCommand();
|
|
54
112
|
});
|
|
55
113
|
});
|
|
56
114
|
main(program);
|
|
57
115
|
program.parse();
|
|
58
116
|
//# sourceMappingURL=cli.js.map
|
|
59
|
-
//# debugId=
|
|
117
|
+
//# debugId=12144166-1323-59a4-afba-5b73e54e7b2c
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["cli.ts"],"sourceRoot":"/","sourcesContent":["#!/usr/bin/env node\nimport dotenv from 'dotenv';\n\ndotenv.config({ path: '.env' });\ndotenv.config({ path: '.env.local', override: true });\ndotenv.config({ path: '.env.production', override: true });\n\nimport './telemetry.js';\nimport { Command } from 'commander';\nimport { readFileSync } from 'node:fs';\nimport { fromPackageRoot } from './utils/getPaths.js';\nimport { setupCommand } from './commands/setup.js';\nimport { CliOptions } from './types/cli.js';\nimport { withTelemetry } from './telemetry.js';\nimport {
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["cli.ts"],"sourceRoot":"/","sourcesContent":["#!/usr/bin/env node\n\nimport dotenv from 'dotenv';\n\ndotenv.config({ path: '.env' });\ndotenv.config({ path: '.env.local', override: true });\ndotenv.config({ path: '.env.production', override: true });\n\nimport './telemetry.js';\nimport { Command } from 'commander';\nimport { readFileSync } from 'node:fs';\nimport { fromPackageRoot } from './utils/getPaths.js';\nimport { setupCommand } from './commands/setup.js';\nimport { CliOptions } from './types/cli.js';\nimport { withTelemetry } from './telemetry.js';\nimport { i18nCommand } from './commands/i18n.js';\nimport { displayHeader } from './logging/console.js';\nimport { main } from 'gtx-cli/index';\nimport { LocadexManager } from './utils/locadexManager.js';\nimport { logger } from './logging/logger.js';\nimport { exit } from './utils/shutdown.js';\n\nconst packageJson = JSON.parse(\n readFileSync(fromPackageRoot('package.json'), 'utf8')\n);\n\nconst program = new Command();\n\nprogram\n .name('locadex')\n .description('AI agent for internationalization')\n .version(packageJson.version);\n\nprogram\n .command('start')\n .description('Run Locadex on your project')\n .option('-v, --verbose', 'Verbose output')\n .option('-d, --debug', 'Debug output')\n .option('-b, --batch-size <number>', 'File batch size', '10')\n .option('-c, --concurrency <number>', 'Max number of concurrent agents', '1')\n .option(\n '-f, --files <pattern>',\n 'Comma-separated list of glob patterns to match source files'\n )\n .option(\n '-e, --extensions <extensions>',\n 'Comma-separated list of file extensions to match'\n )\n .option(\n '--package-manager <manager>',\n 'Package manager to use. (npm, pnpm, yarn_v1, yarn_v2, bun, deno)'\n )\n .option('-y, --bypass-prompts', 'Bypass interactive prompts')\n .option('--no-telemetry', 'Disable telemetry')\n .action(\n (\n options: CliOptions & {\n packageManager?: string;\n bypassPrompts?: boolean;\n },\n command: Command\n ) => {\n const parentOptions = command.parent?.opts() || {};\n const allOptions = { ...parentOptions, ...options };\n withTelemetry(\n { enabled: !allOptions.noTelemetry, options: allOptions },\n async () => {\n const batchSize = Number(allOptions.batchSize) || 1;\n const concurrency = Number(allOptions.concurrency) || 1;\n\n if (concurrency < 1 || batchSize < 1) {\n logger.error('Batch size and concurrency must be greater than 0');\n await exit(1);\n }\n\n displayHeader();\n LocadexManager.initialize({\n mcpTransport: 'sse',\n metadata: {},\n cliOptions: allOptions,\n options: {\n ...(allOptions.matchingFiles && {\n matchingFiles: allOptions.matchingFiles\n .split(',')\n .map((file) => file.trim()),\n }),\n ...(allOptions.matchingExtensions && {\n matchingExtensions: allOptions.matchingExtensions\n .split(',')\n .map((ext) => ext.trim()),\n }),\n maxConcurrency: concurrency,\n batchSize,\n },\n });\n await setupCommand(\n !!allOptions.bypassPrompts,\n allOptions.packageManager\n );\n }\n );\n }\n );\n\nprogram\n .command('i18n')\n .description('Run Locadex i18n on your project')\n .option('-v, --verbose', 'Verbose output')\n .option('-d, --debug', 'Debug output')\n .option('-b, --batch-size <number>', 'File batch size', '10')\n .option('-c, --concurrency <number>', 'Max number of concurrent agents', '1')\n .option(\n '-m, --matching-files <pattern>',\n 'Comma-separated list of glob patterns to match source files'\n )\n .option(\n '-e, --matching-extensions <extensions>',\n 'Comma-separated list of file extensions to match'\n )\n .option('--no-telemetry', 'Disable telemetry')\n .action((options: CliOptions, command: Command) => {\n const parentOptions = command.parent?.opts() || {};\n const allOptions = { ...parentOptions, ...options };\n withTelemetry(\n { enabled: !allOptions.noTelemetry, options: allOptions },\n async () => {\n const batchSize = Number(allOptions.batchSize) || 1;\n const concurrency = Number(allOptions.concurrency) || 1;\n\n if (concurrency < 1 || batchSize < 1) {\n logger.error('Batch size and concurrency must be greater than 0');\n await exit(1);\n }\n\n displayHeader();\n LocadexManager.initialize({\n mcpTransport: 'sse',\n metadata: {},\n cliOptions: allOptions,\n options: {\n ...(allOptions.matchingFiles && {\n matchingFiles: allOptions.matchingFiles\n .split(',')\n .map((file) => file.trim()),\n }),\n ...(allOptions.matchingExtensions && {\n matchingExtensions: allOptions.matchingExtensions\n .split(',')\n .map((ext) => ext.trim()),\n }),\n maxConcurrency: concurrency,\n batchSize,\n },\n });\n await i18nCommand();\n }\n );\n });\n\nmain(program);\n\nprogram.parse();\n"],"names":[],"mappings":";;;AAEA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AAE3D,OAAO,gBAAgB,CAAC;AACxB,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;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO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,IAAI;oBACnC,kBAAkB,EAAE,UAAU,CAAC,kBAAkB;yBAC9C,KAAK,CAAC,GAAG,CAAC;yBACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;iBAC5B,CAAC;gBACF,cAAc,EAAE,WAAW;gBAC3B,SAAS;aACV;SACF,CAAC,CAAC;QACH,MAAM,WAAW,EAAE,CAAC;IACtB,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,IAAI,CAAC,OAAO,CAAC,CAAC;AAEd,OAAO,CAAC,KAAK,EAAE,CAAC","debug_id":"12144166-1323-59a4-afba-5b73e54e7b2c"}
|
package/dist/commands/i18n.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"/","sources":["commands/i18n.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"/","sources":["commands/i18n.ts"],"names":[],"mappings":"AAEA,wBAAsB,WAAW,kBAEhC"}
|
package/dist/commands/i18n.js
CHANGED
|
@@ -1,259 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { createDag } from '../utils/dag/createDag.js';
|
|
7
|
-
import { findTsConfig, findWebpackConfig, findRequireConfig, } from '../utils/fs/findConfigs.js';
|
|
8
|
-
import { LocadexManager } from '../utils/agentManager.js';
|
|
9
|
-
import { addFilesToManager, markFileAsEdited, markFileAsInProgress, } from '../utils/getFiles.js';
|
|
10
|
-
import { outro } from '@clack/prompts';
|
|
11
|
-
import chalk from 'chalk';
|
|
12
|
-
import { readdirSync, statSync } from 'node:fs';
|
|
13
|
-
import { EXCLUDED_DIRS } from '../utils/shared.js';
|
|
14
|
-
import { validateInitialConfig } from '../utils/validateConfig.js';
|
|
15
|
-
import { detectFormatter, formatFiles } from 'gtx-cli/hooks/postProcess';
|
|
16
|
-
function getCurrentDirectories() {
|
|
17
|
-
try {
|
|
18
|
-
return readdirSync(process.cwd())
|
|
19
|
-
.filter((item) => {
|
|
20
|
-
try {
|
|
21
|
-
return statSync(item).isDirectory();
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
.map((dir) => `./${dir}`)
|
|
28
|
-
.filter((dir) => {
|
|
29
|
-
return !EXCLUDED_DIRS.includes(dir);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export async function i18nCommand(batchSize, manager) {
|
|
37
|
-
validateInitialConfig();
|
|
38
|
-
// Init message
|
|
39
|
-
const spinner = createSpinner();
|
|
40
|
-
spinner.start('Initializing Locadex...');
|
|
41
|
-
const dag = createDag(getCurrentDirectories(), {
|
|
42
|
-
tsConfig: findTsConfig(),
|
|
43
|
-
webpackConfig: findWebpackConfig(),
|
|
44
|
-
requireConfig: findRequireConfig(),
|
|
45
|
-
});
|
|
46
|
-
// If no manager is provided, create a new one
|
|
47
|
-
if (!manager) {
|
|
48
|
-
manager = new LocadexManager({
|
|
49
|
-
mcpTransport: 'sse',
|
|
50
|
-
metadata: {
|
|
51
|
-
batchSize: batchSize,
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
process.on('beforeExit', () => manager.cleanup());
|
|
55
|
-
}
|
|
56
|
-
const agent = manager.createAgent();
|
|
57
|
-
const filesStateFilePath = manager.getFilesStateFilePath();
|
|
58
|
-
// Track session id
|
|
59
|
-
let sessionId = undefined;
|
|
60
|
-
// Create the list of files (aka tasks) to process
|
|
61
|
-
const taskQueue = [...dag.getTopologicalOrder()];
|
|
62
|
-
const allFiles = [...dag.getTopologicalOrder()];
|
|
63
|
-
// Add files to manager
|
|
64
|
-
const stateFilePath = addFilesToManager(filesStateFilePath, taskQueue);
|
|
65
|
-
spinner.stop('Locadex initialized');
|
|
66
|
-
logger.verboseMessage(`Number of files to process: ${dag.getTopologicalOrder().length}`);
|
|
67
|
-
logger.debugMessage(`Track progress here: ${stateFilePath}`);
|
|
68
|
-
logger.initializeProgressBar(taskQueue.length);
|
|
69
|
-
logger.progressBar.start('Processing files...');
|
|
70
|
-
// Main loop
|
|
71
|
-
let hasError = false;
|
|
72
|
-
while (taskQueue.length > 0) {
|
|
73
|
-
// Get the next task
|
|
74
|
-
const tasks = taskQueue.splice(0, batchSize);
|
|
75
|
-
if (tasks.length === 0) {
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
// Mark task as in progress
|
|
79
|
-
tasks.forEach((task) => markFileAsInProgress(task, filesStateFilePath));
|
|
80
|
-
// Construct prompt
|
|
81
|
-
const dependencies = Object.fromEntries(tasks.map((task) => [
|
|
82
|
-
task,
|
|
83
|
-
Array.from(new Set(dag.getDependencies(task))),
|
|
84
|
-
]));
|
|
85
|
-
const dependents = Object.fromEntries(tasks.map((task) => [task, Array.from(new Set(dag.getDependents(task)))]));
|
|
86
|
-
const prompt = getPrompt({
|
|
87
|
-
targetFile: tasks,
|
|
88
|
-
dependencyFiles: dependencies,
|
|
89
|
-
dependentFiles: dependents,
|
|
90
|
-
});
|
|
91
|
-
// Claude call
|
|
92
|
-
try {
|
|
93
|
-
await agent.run({
|
|
94
|
-
prompt,
|
|
95
|
-
sessionId,
|
|
96
|
-
}, { spinner });
|
|
97
|
-
if (!sessionId) {
|
|
98
|
-
sessionId = agent.getSessionId();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
hasError = true;
|
|
103
|
-
logger.debugMessage(`[i18n] Error in claude i18n process: ${error}`);
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
// Mark task as complete
|
|
107
|
-
tasks.forEach((task) => markFileAsEdited(task, filesStateFilePath));
|
|
108
|
-
logger.progressBar.advance(tasks.length, `Processed ${Number(((allFiles.length - taskQueue.length) / allFiles.length) * 100).toFixed(2)}% of files`);
|
|
109
|
-
manager.stats.updateStats({
|
|
110
|
-
newProcessedFiles: tasks.length,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
logger.progressBar.stop(`Processed ${allFiles.length} files`);
|
|
114
|
-
// TODO: uncomment
|
|
115
|
-
// // Always clean up the file list when done, regardless of success or failure
|
|
116
|
-
// logger.info(`Cleaning up file list: ${stateFilePath}`);
|
|
117
|
-
// cleanUp(stateFilePath);
|
|
118
|
-
// If there was an error, exit with code 1
|
|
119
|
-
if (hasError) {
|
|
120
|
-
outro(chalk.red('❌ Locadex i18n failed!'));
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
// Fix prompt
|
|
124
|
-
logger.initializeSpinner();
|
|
125
|
-
logger.spinner.start('Fixing errors...');
|
|
126
|
-
const fixPrompt = getFixPrompt();
|
|
127
|
-
try {
|
|
128
|
-
await agent.run({ prompt: fixPrompt, sessionId }, { spinner });
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
logger.debugMessage(`[i18n] Fixing errors failed: ${error}`);
|
|
132
|
-
outro(chalk.red('❌ Locadex i18n failed!'));
|
|
133
|
-
process.exit(1);
|
|
134
|
-
}
|
|
135
|
-
logger.spinner.stop('Fixed errors');
|
|
136
|
-
// Generate report
|
|
137
|
-
logger.initializeSpinner();
|
|
138
|
-
logger.spinner.start('Generating report...');
|
|
139
|
-
const reportPrompt = getReportPrompt();
|
|
140
|
-
try {
|
|
141
|
-
await agent.run({
|
|
142
|
-
prompt: reportPrompt,
|
|
143
|
-
sessionId,
|
|
144
|
-
}, { spinner });
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
logger.debugMessage(`[i18n] Error in claude report generation: ${error}`);
|
|
148
|
-
outro(chalk.red('❌ Locadex i18n failed!'));
|
|
149
|
-
process.exit(1);
|
|
150
|
-
}
|
|
151
|
-
logger.spinner.stop('Report generated');
|
|
152
|
-
// cleanup
|
|
153
|
-
const formatter = await detectFormatter();
|
|
154
|
-
if (formatter) {
|
|
155
|
-
await formatFiles(allFiles, formatter);
|
|
156
|
-
}
|
|
157
|
-
logger.info(chalk.dim(`Total Cost: $${manager.stats.getStats().totalCost.toFixed(2)}
|
|
158
|
-
Total API duration: ${Math.round(manager.stats.getStats().totalApiDuration / 1000)}s
|
|
159
|
-
Total wall time: ${Math.round((Date.now() - manager.stats.getStats().startTime) / 1000)}s
|
|
160
|
-
Total files processed: ${manager.stats.getStats().processedFiles}`));
|
|
161
|
-
outro(chalk.green('✅ Locadex i18n complete!'));
|
|
162
|
-
process.exit(0);
|
|
163
|
-
}
|
|
164
|
-
function getPrompt({ targetFile, dependencyFiles, dependentFiles, }) {
|
|
165
|
-
const prompt = `# Task: Internationalize the target file(s) using gt-next.
|
|
166
|
-
|
|
167
|
-
## INSTRUCTIONS
|
|
168
|
-
|
|
169
|
-
- You are given a list of target files and their corresponding dependency/dependent files.
|
|
170
|
-
- The project is already setup for internationalization. Do not try to setup the project again for i18n.
|
|
171
|
-
|
|
172
|
-
## Workflow:
|
|
173
|
-
1. **Gather context** Read the target files closely (you should not have to read the dependency/dependent files).
|
|
174
|
-
2. **Evaluate if i18n is necessary** Evaluate if the target files need to be internationalized using gt-next
|
|
175
|
-
- If the target files have no relevant content, are already internationalized, or contain build-time code (e.g. nextjs plugins) they should never be internationalized.
|
|
176
|
-
**IMPORTANT**: IF NONE OF THE TARGET FILES NEED TO BE INTERNATIONALIZED, YOUR TASK IS COMPLETE AND YOU MAY RETURN.
|
|
177
|
-
3. **Identify the tools to use** Given the contents of the files, ask yourself which tools and guides you need to use to get the necessary knowledge to internationalize the target files. Here are some helpful questions to evaluate for tool selection:
|
|
178
|
-
- 3.a. Does this file contain a component? If so, is it a server-side component or a client-side component?
|
|
179
|
-
- 3.b. Is the content that needs to be i18ned being used in this same file, or is it being used in another file?
|
|
180
|
-
- 3.c. Is there any string interpolation that needs to be i18ned?
|
|
181
|
-
- 3.d. Is there any conditional logic or rendering that needs to be i18ned?
|
|
182
|
-
- 3.e. Is the content that needs to be i18ned HTML/JSX or a string?
|
|
183
|
-
4. **Internationalize** You now have the necessary knowledge. Internationalize the files using the information from the tools provided to you.
|
|
184
|
-
- 4.a. Do not worry about running tsc. We will do that later.
|
|
185
|
-
|
|
186
|
-
## RULES:
|
|
187
|
-
- ALWAYS use the <T> component to internationalize HTML/JSX content.
|
|
188
|
-
- ALWAYS use getGT() or useGT() and getDict() or useDict() to internationalize string content.
|
|
189
|
-
- When possible, avoid using getDict() or useDict(); getGT() and useGT() are preferred.
|
|
190
|
-
- DO NOT internationalize non-user facing content or content that is functional, such as ids, class names, error strings, logical strings, etc.
|
|
191
|
-
- Do not add i18n middleware to the app.
|
|
192
|
-
- When adding 'useGT()' or 'useDict()' to a client component, you must add 'use client' to the top of the file.
|
|
193
|
-
- Always adhere to the guides provided via the 'mcp__locadex__' tools.
|
|
194
|
-
- These guides provide additional knowledge about how to internationalize the content.
|
|
195
|
-
- Minimize the footprint of your changes.
|
|
196
|
-
- Focus on internationalizing the content of the target files.
|
|
197
|
-
- NEVER move internationalized content to a different file. All content MUST remain in the same file where it came from.
|
|
198
|
-
- NEVER CREATE OR REMOVE ANY FILES (especially .bak files)
|
|
199
|
-
- Internationalize all user facing content in the target files.
|
|
200
|
-
- NEVER EDIT FILES THAT ARE NOT GIVEN TO YOU.
|
|
201
|
-
|
|
202
|
-
## TARGET FILE INFORMATION
|
|
203
|
-
${targetFile.map((file, index) => `
|
|
204
|
-
TARGET FILE ${index + 1}:
|
|
205
|
-
${file}
|
|
206
|
-
|
|
207
|
-
DEPENDENCY FILES (files imported by target file ${index + 1}):
|
|
208
|
-
${dependencyFiles[file].length > 0 ? ` ${dependencyFiles[file].join(', ')}` : 'none'}
|
|
209
|
-
|
|
210
|
-
DEPENDENT FILES (files that import target file ${index + 1}):
|
|
211
|
-
${dependentFiles[file].length > 0 ? ` ${dependentFiles[file].join(', ')}` : 'none'}
|
|
212
|
-
`)}
|
|
213
|
-
|
|
214
|
-
---
|
|
215
|
-
|
|
216
|
-
## MCP TOOLS
|
|
217
|
-
|
|
218
|
-
${allMcpPrompt}
|
|
219
|
-
`;
|
|
220
|
-
return prompt;
|
|
221
|
-
}
|
|
222
|
-
// check (dry run and ts check) should be at the end
|
|
223
|
-
function getFixPrompt() {
|
|
224
|
-
const prompt = `# Task: Fix implementation errors in the project.
|
|
225
|
-
|
|
226
|
-
## INSTRUCTIONS
|
|
227
|
-
|
|
228
|
-
Previously, you helped me internationalize a set of files in this project.
|
|
229
|
-
Your new task is as follows:
|
|
230
|
-
|
|
231
|
-
1. Run the gt-next validator.
|
|
232
|
-
2. Fix all errors relevant to the gt-next implementation code.
|
|
233
|
-
3. Whenever you are finished with your changes, run the gt-next validator.
|
|
234
|
-
4. Repeat steps 1-3 until there are no more errors, or until you believe that you have fixed all errors.
|
|
235
|
-
5. If the project is setup with linting, lint the project and fix all errors.
|
|
236
|
-
|
|
237
|
-
## RULES:
|
|
238
|
-
- DO NOT modify any files that are not relevant to the gt-next implementation code.
|
|
239
|
-
- ONLY fix errors that are relevant to the gt-next implementation code and your current or previous implementation.
|
|
240
|
-
- Resolve unused imports from 'gt-next'.
|
|
241
|
-
- In particular, if a file contains user-facing content that should be internationalized and is not, you should internationalize it.
|
|
242
|
-
- Resolve missing imports from 'gt-next'. If a file is missing an import from 'gt-next', add it.
|
|
243
|
-
|
|
244
|
-
To run the gt-next validator, run the following command:
|
|
245
|
-
'npx locadex translate --dry-run'
|
|
246
|
-
|
|
247
|
-
## MCP TOOLS
|
|
248
|
-
${allMcpPrompt}`;
|
|
249
|
-
return prompt;
|
|
250
|
-
}
|
|
251
|
-
function getReportPrompt() {
|
|
252
|
-
const prompt = `Your new task is as follows:
|
|
253
|
-
- Please add a markdown file called 'locadex-report.md' to the root of the project.
|
|
254
|
-
- The report should include a summary of the changes you made to the project.
|
|
255
|
-
- A list of items the user needs to complete to finish the internationalization process (adding env vars, etc.).`;
|
|
256
|
-
return prompt;
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="36971a2a-48a4-5b4f-81a5-5b00f8d4ec9f")}catch(e){}}();
|
|
3
|
+
import { i18nTask } from '../tasks/i18n.js';
|
|
4
|
+
export async function i18nCommand() {
|
|
5
|
+
await i18nTask();
|
|
257
6
|
}
|
|
258
7
|
//# sourceMappingURL=i18n.js.map
|
|
259
|
-
//# debugId=
|
|
8
|
+
//# debugId=36971a2a-48a4-5b4f-81a5-5b00f8d4ec9f
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sources":["commands/i18n.ts"],"sourceRoot":"/","sourcesContent":["import { createProgressBar, createSpinner } from '../logging/console.js';\nimport { allMcpPrompt } from '../prompts/system.js';\n\nimport { logger } from '../logging/logger.js';\nimport { createDag } from '../utils/dag/createDag.js';\nimport {\n findTsConfig,\n findWebpackConfig,\n findRequireConfig,\n} from '../utils/fs/findConfigs.js';\nimport { LocadexManager } from '../utils/agentManager.js';\nimport {\n addFilesToManager,\n markFileAsEdited,\n markFileAsInProgress,\n} from '../utils/getFiles.js';\nimport { outro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { readdirSync, statSync } from 'node:fs';\nimport { EXCLUDED_DIRS } from '../utils/shared.js';\nimport { validateInitialConfig } from '../utils/validateConfig.js';\nimport { detectFormatter, formatFiles } from 'gtx-cli/hooks/postProcess';\n\nfunction getCurrentDirectories(): string[] {\n try {\n return readdirSync(process.cwd())\n .filter((item) => {\n try {\n return statSync(item).isDirectory();\n } catch {\n return false;\n }\n })\n .map((dir) => `./${dir}`)\n .filter((dir) => {\n return !EXCLUDED_DIRS.includes(dir);\n });\n } catch {\n return [];\n }\n}\n\nexport async function i18nCommand(batchSize: number, manager?: LocadexManager) {\n validateInitialConfig();\n\n // Init message\n const spinner = createSpinner();\n spinner.start('Initializing Locadex...');\n\n const dag = createDag(getCurrentDirectories(), {\n tsConfig: findTsConfig(),\n webpackConfig: findWebpackConfig(),\n requireConfig: findRequireConfig(),\n });\n\n // If no manager is provided, create a new one\n if (!manager) {\n manager = new LocadexManager({\n mcpTransport: 'sse',\n metadata: {\n batchSize: batchSize,\n },\n });\n process.on('beforeExit', () => manager!.cleanup());\n }\n\n const agent = manager.createAgent();\n const filesStateFilePath = manager.getFilesStateFilePath();\n\n // Track session id\n let sessionId: string | undefined = undefined;\n\n // Create the list of files (aka tasks) to process\n const taskQueue = [...dag.getTopologicalOrder()];\n\n const allFiles = [...dag.getTopologicalOrder()];\n\n // Add files to manager\n const stateFilePath = addFilesToManager(filesStateFilePath, taskQueue);\n spinner.stop('Locadex initialized');\n\n logger.verboseMessage(\n `Number of files to process: ${dag.getTopologicalOrder().length}`\n );\n logger.debugMessage(`Track progress here: ${stateFilePath}`);\n\n logger.initializeProgressBar(taskQueue.length);\n logger.progressBar.start('Processing files...');\n // Main loop\n let hasError = false;\n while (taskQueue.length > 0) {\n // Get the next task\n const tasks = taskQueue.splice(0, batchSize);\n if (tasks.length === 0) {\n break;\n }\n\n // Mark task as in progress\n tasks.forEach((task) => markFileAsInProgress(task, filesStateFilePath));\n\n // Construct prompt\n const dependencies = Object.fromEntries(\n tasks.map((task) => [\n task,\n Array.from(new Set(dag.getDependencies(task))),\n ])\n );\n const dependents = Object.fromEntries(\n tasks.map((task) => [task, Array.from(new Set(dag.getDependents(task)))])\n );\n const prompt = getPrompt({\n targetFile: tasks,\n dependencyFiles: dependencies,\n dependentFiles: dependents,\n });\n\n // Claude call\n try {\n await agent.run(\n {\n prompt,\n sessionId,\n },\n { spinner }\n );\n if (!sessionId) {\n sessionId = agent.getSessionId();\n }\n } catch (error) {\n hasError = true;\n logger.debugMessage(`[i18n] Error in claude i18n process: ${error}`);\n break;\n }\n\n // Mark task as complete\n tasks.forEach((task) => markFileAsEdited(task, filesStateFilePath));\n logger.progressBar.advance(\n tasks.length,\n `Processed ${Number(((allFiles.length - taskQueue.length) / allFiles.length) * 100).toFixed(2)}% of files`\n );\n manager.stats.updateStats({\n newProcessedFiles: tasks.length,\n });\n }\n\n logger.progressBar.stop(`Processed ${allFiles.length} files`);\n\n // TODO: uncomment\n // // Always clean up the file list when done, regardless of success or failure\n // logger.info(`Cleaning up file list: ${stateFilePath}`);\n // cleanUp(stateFilePath);\n\n // If there was an error, exit with code 1\n if (hasError) {\n outro(chalk.red('❌ Locadex i18n failed!'));\n process.exit(1);\n }\n\n // Fix prompt\n logger.initializeSpinner();\n logger.spinner.start('Fixing errors...');\n const fixPrompt = getFixPrompt();\n try {\n await agent.run({ prompt: fixPrompt, sessionId }, { spinner });\n } catch (error) {\n logger.debugMessage(`[i18n] Fixing errors failed: ${error}`);\n outro(chalk.red('❌ Locadex i18n failed!'));\n process.exit(1);\n }\n logger.spinner.stop('Fixed errors');\n\n // Generate report\n logger.initializeSpinner();\n logger.spinner.start('Generating report...');\n const reportPrompt = getReportPrompt();\n try {\n await agent.run(\n {\n prompt: reportPrompt,\n sessionId,\n },\n { spinner }\n );\n } catch (error) {\n logger.debugMessage(`[i18n] Error in claude report generation: ${error}`);\n outro(chalk.red('❌ Locadex i18n failed!'));\n process.exit(1);\n }\n logger.spinner.stop('Report generated');\n\n // cleanup\n\n const formatter = await detectFormatter();\n\n if (formatter) {\n await formatFiles(allFiles, formatter);\n }\n\n logger.info(\n chalk.dim(\n `Total Cost: $${manager.stats.getStats().totalCost.toFixed(2)}\nTotal API duration: ${Math.round(manager.stats.getStats().totalApiDuration / 1000)}s\nTotal wall time: ${Math.round(\n (Date.now() - manager.stats.getStats().startTime) / 1000\n )}s\nTotal files processed: ${manager.stats.getStats().processedFiles}`\n )\n );\n\n outro(chalk.green('✅ Locadex i18n complete!'));\n process.exit(0);\n}\n\nfunction getPrompt({\n targetFile,\n dependencyFiles,\n dependentFiles,\n}: {\n targetFile: string[];\n dependencyFiles: Record<string, string[]>;\n dependentFiles: Record<string, string[]>;\n}) {\n const prompt = `# Task: Internationalize the target file(s) using gt-next.\n\n## INSTRUCTIONS\n\n- You are given a list of target files and their corresponding dependency/dependent files.\n- The project is already setup for internationalization. Do not try to setup the project again for i18n.\n\n## Workflow:\n1. **Gather context** Read the target files closely (you should not have to read the dependency/dependent files).\n2. **Evaluate if i18n is necessary** Evaluate if the target files need to be internationalized using gt-next \n - If the target files have no relevant content, are already internationalized, or contain build-time code (e.g. nextjs plugins) they should never be internationalized.\n**IMPORTANT**: IF NONE OF THE TARGET FILES NEED TO BE INTERNATIONALIZED, YOUR TASK IS COMPLETE AND YOU MAY RETURN.\n3. **Identify the tools to use** Given the contents of the files, ask yourself which tools and guides you need to use to get the necessary knowledge to internationalize the target files. Here are some helpful questions to evaluate for tool selection:\n - 3.a. Does this file contain a component? If so, is it a server-side component or a client-side component?\n - 3.b. Is the content that needs to be i18ned being used in this same file, or is it being used in another file?\n - 3.c. Is there any string interpolation that needs to be i18ned?\n - 3.d. Is there any conditional logic or rendering that needs to be i18ned?\n - 3.e. Is the content that needs to be i18ned HTML/JSX or a string?\n4. **Internationalize** You now have the necessary knowledge. Internationalize the files using the information from the tools provided to you.\n - 4.a. Do not worry about running tsc. We will do that later.\n\n## RULES:\n- ALWAYS use the <T> component to internationalize HTML/JSX content.\n- ALWAYS use getGT() or useGT() and getDict() or useDict() to internationalize string content.\n - When possible, avoid using getDict() or useDict(); getGT() and useGT() are preferred.\n- DO NOT internationalize non-user facing content or content that is functional, such as ids, class names, error strings, logical strings, etc.\n- Do not add i18n middleware to the app.\n- When adding 'useGT()' or 'useDict()' to a client component, you must add 'use client' to the top of the file.\n- Always adhere to the guides provided via the 'mcp__locadex__' tools.\n - These guides provide additional knowledge about how to internationalize the content.\n- Minimize the footprint of your changes.\n- Focus on internationalizing the content of the target files.\n- NEVER move internationalized content to a different file. All content MUST remain in the same file where it came from.\n- NEVER CREATE OR REMOVE ANY FILES (especially .bak files)\n- Internationalize all user facing content in the target files. \n- NEVER EDIT FILES THAT ARE NOT GIVEN TO YOU.\n\n## TARGET FILE INFORMATION\n${targetFile.map(\n (file, index) => `\nTARGET FILE ${index + 1}:\n${file}\n\nDEPENDENCY FILES (files imported by target file ${index + 1}):\n${dependencyFiles[file].length > 0 ? ` ${dependencyFiles[file].join(', ')}` : 'none'}\n\nDEPENDENT FILES (files that import target file ${index + 1}):\n${dependentFiles[file].length > 0 ? ` ${dependentFiles[file].join(', ')}` : 'none'}\n`\n)}\n\n---\n\n## MCP TOOLS\n\n${allMcpPrompt}\n`;\n\n return prompt;\n}\n\n// check (dry run and ts check) should be at the end\n\nfunction getFixPrompt() {\n const prompt = `# Task: Fix implementation errors in the project.\n\n## INSTRUCTIONS\n\nPreviously, you helped me internationalize a set of files in this project.\nYour new task is as follows:\n\n1. Run the gt-next validator.\n2. Fix all errors relevant to the gt-next implementation code.\n3. Whenever you are finished with your changes, run the gt-next validator.\n4. Repeat steps 1-3 until there are no more errors, or until you believe that you have fixed all errors.\n5. If the project is setup with linting, lint the project and fix all errors.\n\n## RULES:\n- DO NOT modify any files that are not relevant to the gt-next implementation code.\n- ONLY fix errors that are relevant to the gt-next implementation code and your current or previous implementation.\n- Resolve unused imports from 'gt-next'. \n - In particular, if a file contains user-facing content that should be internationalized and is not, you should internationalize it.\n- Resolve missing imports from 'gt-next'. If a file is missing an import from 'gt-next', add it.\n\nTo run the gt-next validator, run the following command:\n'npx locadex translate --dry-run'\n\n## MCP TOOLS\n${allMcpPrompt}`;\n\n return prompt;\n}\n\nfunction getReportPrompt() {\n const prompt = `Your new task is as follows:\n- Please add a markdown file called 'locadex-report.md' to the root of the project.\n- The report should include a summary of the changes you made to the project.\n- A list of items the user needs to complete to finish the internationalization process (adding env vars,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Ac,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM;CACjF,CACA;;;;;;EAMC,YAAY;CACb,CAAC;IAEA,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,oDAAoD;AAEpD,SAAS,YAAY;IACnB,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;EAwBf,YAAY,EAAE,CAAC;IAEf,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,eAAe;IACtB,MAAM,MAAM,GAAG;;;iHAGgG,CAAC;IAEhH,OAAO,MAAM,CAAC;AAChB,CAAC","debug_id":"45fc236d-924c-5d3f-9d18-1f9b354d86e1"}
|
|
1
|
+
{"version":3,"file":"i18n.js","sources":["commands/i18n.ts"],"sourceRoot":"/","sourcesContent":["import { i18nTask } from '../tasks/i18n.js';\n\nexport async function i18nCommand() {\n await i18nTask();\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,QAAQ,EAAE,CAAC;AACnB,CAAC","debug_id":"36971a2a-48a4-5b4f-81a5-5b00f8d4ec9f"}
|
package/dist/commands/setup.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function setupCommand(
|
|
1
|
+
export declare function setupCommand(bypassPrompts: boolean, specifiedPackageManager?: string): Promise<void>;
|
|
2
2
|
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"/","sources":["commands/setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"/","sources":["commands/setup.ts"],"names":[],"mappings":"AAEA,wBAAsB,YAAY,CAChC,aAAa,EAAE,OAAO,EACtB,uBAAuB,CAAC,EAAE,MAAM,iBAGjC"}
|
package/dist/commands/setup.js
CHANGED
|
@@ -1,145 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { installPackage } from 'gtx-cli/utils/installPackage';
|
|
7
|
-
import chalk from 'chalk';
|
|
8
|
-
import { logger } from '../logging/logger.js';
|
|
9
|
-
import { findFilepaths } from '../utils/fs/findConfigs.js';
|
|
10
|
-
import { wrapContentNext } from 'gtx-cli/next/parse/wrapContent';
|
|
11
|
-
import { handleInitGT } from 'gtx-cli/next/parse/handleInitGT';
|
|
12
|
-
import { detectFormatter, formatFiles } from 'gtx-cli/hooks/postProcess';
|
|
13
|
-
import { createOrUpdateConfig } from 'gtx-cli/fs/config/setupConfig';
|
|
14
|
-
import { i18nCommand } from './i18n.js';
|
|
15
|
-
import { validateInitialConfig } from '../utils/validateConfig.js';
|
|
16
|
-
import { getNextDirectories } from '../utils/fs/getFiles.js';
|
|
17
|
-
import { LocadexManager } from '../utils/agentManager.js';
|
|
18
|
-
import { outro } from '@clack/prompts';
|
|
19
|
-
export async function setupCommand(batchSize) {
|
|
20
|
-
validateInitialConfig();
|
|
21
|
-
const answer = await promptConfirm({
|
|
22
|
-
message: chalk.yellow(`Locadex will modify files! Make sure you have committed or stashed any changes. Do you want to continue?`),
|
|
23
|
-
defaultValue: true,
|
|
24
|
-
cancelMessage: 'Operation cancelled.',
|
|
25
|
-
});
|
|
26
|
-
if (!answer) {
|
|
27
|
-
logger.info('Operation cancelled.');
|
|
28
|
-
process.exit(0);
|
|
29
|
-
}
|
|
30
|
-
const packageJson = await getPackageJson();
|
|
31
|
-
const packageManager = await getPackageManager();
|
|
32
|
-
const spinner = createSpinner('timer');
|
|
33
|
-
spinner.start(`Installing gt-next with ${packageManager.name}...`);
|
|
34
|
-
await installPackage('gt-next', packageManager);
|
|
35
|
-
spinner.stop(chalk.green('Automatically installed gt-next.'));
|
|
36
|
-
const nextConfigPath = findFilepaths([
|
|
37
|
-
'./next.config.js',
|
|
38
|
-
'./next.config.ts',
|
|
39
|
-
'./next.config.mjs',
|
|
40
|
-
'./next.config.mts',
|
|
41
|
-
])[0];
|
|
42
|
-
if (!nextConfigPath) {
|
|
43
|
-
logger.error('No next.config.[js|ts|mjs|mts] file found.');
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
const errors = [];
|
|
47
|
-
const warnings = [];
|
|
48
|
-
let filesUpdated = [];
|
|
49
|
-
const babel = createSpinner();
|
|
50
|
-
babel.start('Wrapping JSX content with <T> tags...');
|
|
51
|
-
// Wrap all JSX elements in the src directory with a <T> tag, with unique ids
|
|
52
|
-
const { filesUpdated: filesUpdatedNext } = await wrapContentNext({
|
|
53
|
-
src: getNextDirectories(),
|
|
54
|
-
config: nextConfigPath,
|
|
55
|
-
disableIds: true,
|
|
56
|
-
disableFormatting: true,
|
|
57
|
-
skipTs: true,
|
|
58
|
-
addGTProvider: true,
|
|
59
|
-
}, 'gt-next', errors, warnings);
|
|
60
|
-
filesUpdated = [...filesUpdated, ...filesUpdatedNext];
|
|
61
|
-
babel.stop(chalk.green(`Modified ${filesUpdated.length} files.`));
|
|
62
|
-
// Add the withGTConfig() function to the next.config.js file
|
|
63
|
-
await handleInitGT(nextConfigPath, errors, warnings, filesUpdated);
|
|
64
|
-
logger.step(chalk.green(`Added withGTConfig() to your ${nextConfigPath} file.`));
|
|
65
|
-
// Create gt.config.json
|
|
66
|
-
await createOrUpdateConfig('gt.config.json', {
|
|
67
|
-
defaultLocale: 'en',
|
|
68
|
-
locales: ['es', 'fr', 'de', 'ja', 'zh'],
|
|
69
|
-
framework: 'next-app',
|
|
70
|
-
});
|
|
71
|
-
logger.success(`Feel free to edit ${chalk.cyan('gt.config.json')} to customize your translation setup. Docs: https://generaltranslation.com/docs/cli/reference/config`);
|
|
72
|
-
// Install locadex if not installed
|
|
73
|
-
const isLocadexInstalled = packageJson
|
|
74
|
-
? isPackageInstalled('locadex', packageJson, true, true)
|
|
75
|
-
: true; // if no package.json, we can't install it
|
|
76
|
-
if (!isLocadexInstalled) {
|
|
77
|
-
const packageManager = await getPackageManager();
|
|
78
|
-
const spinner = createSpinner();
|
|
79
|
-
spinner.start(`Installing locadex as a dev dependency with ${packageManager.name}...`);
|
|
80
|
-
await installPackage('locadex', packageManager, true);
|
|
81
|
-
spinner.stop(chalk.green('Installed locadex.'));
|
|
82
|
-
}
|
|
83
|
-
// Create manager
|
|
84
|
-
const manager = new LocadexManager({
|
|
85
|
-
mcpTransport: 'sse',
|
|
86
|
-
metadata: {
|
|
87
|
-
batchSize: batchSize,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
process.on('beforeExit', () => manager.cleanup());
|
|
91
|
-
// Set up locale selector
|
|
92
|
-
await setupLocaleSelector(manager);
|
|
93
|
-
const formatter = await detectFormatter();
|
|
94
|
-
if (formatter && filesUpdated.length > 0) {
|
|
95
|
-
await formatFiles(filesUpdated, formatter);
|
|
96
|
-
}
|
|
97
|
-
// Run i18n command
|
|
98
|
-
i18nCommand(batchSize, manager);
|
|
99
|
-
}
|
|
100
|
-
async function setupLocaleSelector(manager) {
|
|
101
|
-
logger.initializeSpinner();
|
|
102
|
-
logger.spinner.start('Creating locale selector...');
|
|
103
|
-
// Create agent
|
|
104
|
-
const agent = manager.createAgent();
|
|
105
|
-
// Fix prompt
|
|
106
|
-
const localeSelectorPrompt = getLocaleSelectorPrompt();
|
|
107
|
-
try {
|
|
108
|
-
await agent.run({ prompt: localeSelectorPrompt }, {});
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
logger.debugMessage(`[setup] Adding locale selector failed: ${error}`);
|
|
112
|
-
outro(chalk.red('❌ Locadex setup failed!'));
|
|
113
|
-
process.exit(1);
|
|
114
|
-
}
|
|
115
|
-
logger.spinner.stop('Locale selector setup complete');
|
|
116
|
-
}
|
|
117
|
-
function getLocaleSelectorPrompt() {
|
|
118
|
-
const prompt = `Here is your task:
|
|
119
|
-
- Please add a locale selector to the project.
|
|
120
|
-
- The locale selector should be a dropdown that allows the user to select the locale.
|
|
121
|
-
|
|
122
|
-
--- LOCALE SELECTOR USAGE ---
|
|
123
|
-
(1) Import the locale selector component from 'gt-next/client'
|
|
124
|
-
(2) Add the locale selector to the project
|
|
125
|
-
|
|
126
|
-
For example:
|
|
127
|
-
import { LocaleSelector } from 'gt-next/client';
|
|
128
|
-
|
|
129
|
-
function MyComponent() {
|
|
130
|
-
return (
|
|
131
|
-
<div>
|
|
132
|
-
<LocaleSelector />
|
|
133
|
-
<p>Hello, world!</p>
|
|
134
|
-
</div>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
--- ADVICE ---
|
|
139
|
-
- The locale selector should be added to a header or footer or some other very obvious place in the project.
|
|
140
|
-
- Scan across files to find the best place to add the locale selector.
|
|
141
|
-
`;
|
|
142
|
-
return prompt;
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9b84f24c-6352-5dac-9161-c025c23578f6")}catch(e){}}();
|
|
3
|
+
import { setupTask } from '../tasks/setup.js';
|
|
4
|
+
export async function setupCommand(bypassPrompts, specifiedPackageManager) {
|
|
5
|
+
await setupTask(bypassPrompts, specifiedPackageManager);
|
|
143
6
|
}
|
|
144
7
|
//# sourceMappingURL=setup.js.map
|
|
145
|
-
//# debugId=
|
|
8
|
+
//# debugId=9b84f24c-6352-5dac-9161-c025c23578f6
|