locadex 0.0.2-alpha.1 → 0.0.2-alpha.3

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.
Files changed (156) hide show
  1. package/.locadex-mcp-stdio.json +9 -0
  2. package/.locadex-mcp.json +2 -3
  3. package/LICENSE.md +1 -1
  4. package/dist/cli.d.ts +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +44 -9
  7. package/dist/cli.js.map +1 -1
  8. package/dist/commands/i18n.d.ts +1 -1
  9. package/dist/commands/i18n.d.ts.map +1 -1
  10. package/dist/commands/i18n.js +210 -140
  11. package/dist/commands/i18n.js.map +1 -1
  12. package/dist/commands/setup.d.ts +1 -1
  13. package/dist/commands/setup.d.ts.map +1 -1
  14. package/dist/commands/setup.js +85 -86
  15. package/dist/commands/setup.js.map +1 -1
  16. package/dist/index.d.ts +0 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +5 -68
  19. package/dist/index.js.map +1 -1
  20. package/dist/{utils/logging.d.ts → logging/console.d.ts} +8 -12
  21. package/dist/logging/console.d.ts.map +1 -0
  22. package/dist/logging/console.js +134 -0
  23. package/dist/logging/console.js.map +1 -0
  24. package/dist/logging/constructInfo.d.ts +3 -0
  25. package/dist/logging/constructInfo.d.ts.map +1 -0
  26. package/dist/logging/constructInfo.js +15 -0
  27. package/dist/logging/constructInfo.js.map +1 -0
  28. package/dist/logging/logger.d.ts +24 -0
  29. package/dist/logging/logger.d.ts.map +1 -0
  30. package/dist/logging/logger.js +70 -0
  31. package/dist/logging/logger.js.map +1 -0
  32. package/dist/mcp/debugger.d.ts +3 -0
  33. package/dist/mcp/debugger.d.ts.map +1 -0
  34. package/dist/mcp/debugger.js +37 -0
  35. package/dist/mcp/debugger.js.map +1 -0
  36. package/dist/mcp/getDocs.d.ts.map +1 -0
  37. package/dist/mcp/getDocs.js +56 -0
  38. package/dist/mcp/getDocs.js.map +1 -0
  39. package/dist/mcp/getGuide.d.ts +5 -0
  40. package/dist/mcp/getGuide.d.ts.map +1 -0
  41. package/dist/mcp/getGuide.js +17 -0
  42. package/dist/mcp/getGuide.js.map +1 -0
  43. package/dist/{tools → mcp/tools}/docs.d.ts +3 -0
  44. package/dist/mcp/tools/docs.d.ts.map +1 -0
  45. package/dist/mcp/tools/docs.js +86 -0
  46. package/dist/mcp/tools/docs.js.map +1 -0
  47. package/dist/mcp/tools/fileManager.d.ts +6 -0
  48. package/dist/mcp/tools/fileManager.d.ts.map +1 -0
  49. package/dist/mcp/tools/fileManager.js +233 -0
  50. package/dist/mcp/tools/fileManager.js.map +1 -0
  51. package/dist/mcp/tools/guides.d.ts +11 -0
  52. package/dist/mcp/tools/guides.d.ts.map +1 -0
  53. package/dist/mcp/tools/guides.js +130 -0
  54. package/dist/mcp/tools/guides.js.map +1 -0
  55. package/dist/mcp-sse.d.ts +3 -0
  56. package/dist/mcp-sse.d.ts.map +1 -0
  57. package/dist/mcp-sse.js +72 -0
  58. package/dist/mcp-sse.js.map +1 -0
  59. package/dist/mcp.d.ts +3 -0
  60. package/dist/mcp.d.ts.map +1 -0
  61. package/dist/mcp.js +36 -0
  62. package/dist/mcp.js.map +1 -0
  63. package/dist/prompts/system.d.ts +4 -0
  64. package/dist/prompts/system.d.ts.map +1 -0
  65. package/dist/prompts/system.js +23 -0
  66. package/dist/prompts/system.js.map +1 -0
  67. package/dist/telemetry.d.ts +11 -0
  68. package/dist/telemetry.d.ts.map +1 -0
  69. package/dist/telemetry.js +104 -0
  70. package/dist/telemetry.js.map +1 -0
  71. package/dist/types/claude-sdk.d.ts +39 -0
  72. package/dist/types/claude-sdk.d.ts.map +1 -0
  73. package/dist/types/claude-sdk.js +5 -0
  74. package/dist/types/claude-sdk.js.map +1 -0
  75. package/dist/types/cli.d.ts +7 -0
  76. package/dist/types/cli.d.ts.map +1 -0
  77. package/dist/types/cli.js +5 -0
  78. package/dist/types/cli.js.map +1 -0
  79. package/dist/utils/agentManager.d.ts +22 -0
  80. package/dist/utils/agentManager.d.ts.map +1 -0
  81. package/dist/utils/agentManager.js +110 -0
  82. package/dist/utils/agentManager.js.map +1 -0
  83. package/dist/utils/claudeCode.d.ts +13 -5
  84. package/dist/utils/claudeCode.d.ts.map +1 -1
  85. package/dist/utils/claudeCode.js +155 -102
  86. package/dist/utils/claudeCode.js.map +1 -1
  87. package/dist/utils/dag/createDag.d.ts +24 -0
  88. package/dist/utils/dag/createDag.d.ts.map +1 -0
  89. package/dist/utils/dag/createDag.js +175 -0
  90. package/dist/utils/dag/createDag.js.map +1 -0
  91. package/dist/utils/debugLogger.d.ts +3 -0
  92. package/dist/utils/debugLogger.d.ts.map +1 -0
  93. package/dist/utils/debugLogger.js +36 -0
  94. package/dist/utils/debugLogger.js.map +1 -0
  95. package/dist/utils/fs/findConfigs.d.ts +11 -0
  96. package/dist/utils/fs/findConfigs.d.ts.map +1 -0
  97. package/dist/utils/fs/findConfigs.js +63 -0
  98. package/dist/utils/fs/findConfigs.js.map +1 -0
  99. package/dist/utils/fs/getFiles.d.ts +2 -0
  100. package/dist/utils/fs/getFiles.d.ts.map +1 -0
  101. package/dist/utils/fs/getFiles.js +8 -0
  102. package/dist/utils/fs/getFiles.js.map +1 -0
  103. package/dist/utils/fs/writeFiles.d.ts +2 -0
  104. package/dist/utils/fs/writeFiles.d.ts.map +1 -0
  105. package/dist/utils/fs/writeFiles.js +19 -0
  106. package/dist/utils/fs/writeFiles.js.map +1 -0
  107. package/dist/utils/getFiles.d.ts +30 -0
  108. package/dist/utils/getFiles.d.ts.map +1 -0
  109. package/dist/utils/getFiles.js +152 -0
  110. package/dist/utils/getFiles.js.map +1 -0
  111. package/dist/utils/getPaths.d.ts +1 -0
  112. package/dist/utils/getPaths.d.ts.map +1 -1
  113. package/dist/utils/getPaths.js +19 -3
  114. package/dist/utils/getPaths.js.map +1 -1
  115. package/dist/utils/mcpConfig.d.ts.map +1 -1
  116. package/dist/utils/mcpConfig.js +5 -2
  117. package/dist/utils/mcpConfig.js.map +1 -1
  118. package/dist/utils/shared.d.ts +2 -0
  119. package/dist/utils/shared.d.ts.map +1 -0
  120. package/dist/utils/shared.js +15 -0
  121. package/dist/utils/shared.js.map +1 -0
  122. package/dist/utils/validateConfig.d.ts +2 -0
  123. package/dist/utils/validateConfig.d.ts.map +1 -0
  124. package/dist/utils/validateConfig.js +12 -0
  125. package/dist/utils/validateConfig.js.map +1 -0
  126. package/guides/next/advanced/complicated-mapping-expressions.md +200 -0
  127. package/guides/next/advanced/interpolated-strings.md +162 -0
  128. package/guides/next/advanced/migrating.md +86 -0
  129. package/guides/next/advanced/ternary-operators.md +217 -0
  130. package/guides/next/advanced/var-outside-client-component.md +446 -0
  131. package/guides/next/advanced/var-outside-client-server-component.md +550 -0
  132. package/guides/next/advanced/var-outside-server-component.md +545 -0
  133. package/guides/next/basic/branches.md +282 -0
  134. package/guides/next/basic/client-side-components.md +214 -0
  135. package/guides/next/basic/jsx.md +259 -0
  136. package/guides/next/basic/locale-selector.md +5 -0
  137. package/guides/next/basic/server-side-components.md +164 -0
  138. package/guides/next/basic/setup.md +139 -0
  139. package/guides/next/basic/translating-html.md +36 -0
  140. package/guides/next/basic/variables.md +185 -0
  141. package/guides/next/important/functions.md +37 -0
  142. package/package.json +26 -13
  143. package/dist/resources/docs.d.ts +0 -4
  144. package/dist/resources/docs.d.ts.map +0 -1
  145. package/dist/resources/docs.js +0 -176
  146. package/dist/resources/docs.js.map +0 -1
  147. package/dist/tools/docs.d.ts.map +0 -1
  148. package/dist/tools/docs.js +0 -140
  149. package/dist/tools/docs.js.map +0 -1
  150. package/dist/utils/getDocs.d.ts.map +0 -1
  151. package/dist/utils/getDocs.js +0 -113
  152. package/dist/utils/getDocs.js.map +0 -1
  153. package/dist/utils/logging.d.ts.map +0 -1
  154. package/dist/utils/logging.js +0 -226
  155. package/dist/utils/logging.js.map +0 -1
  156. /package/dist/{utils → mcp}/getDocs.d.ts +0 -0
@@ -0,0 +1,9 @@
1
+ {
2
+ "mcpServers": {
3
+ "locadex": {
4
+ "command": "npx",
5
+ "args": ["locadex-mcp"],
6
+ "env": {}
7
+ }
8
+ }
9
+ }
package/.locadex-mcp.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "mcpServers": {
3
3
  "locadex": {
4
- "command": "npx",
5
- "args": ["locadex-mcp"],
6
- "env": {}
4
+ "type": "sse",
5
+ "url": "http://localhost:8888/sse"
7
6
  }
8
7
  }
9
8
  }
package/LICENSE.md CHANGED
@@ -6,7 +6,7 @@ FSL-1.1-ALv2
6
6
 
7
7
  ## Notice
8
8
 
9
- Copyright 2024 General Translation, Inc.
9
+ Copyright 2025 General Translation, Inc.
10
10
 
11
11
  ## Terms and Conditions
12
12
 
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ import './telemetry.js';
3
3
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"/","sources":["cli.ts"],"names":[],"mappings":";AAOA,OAAO,gBAAgB,CAAC"}
package/dist/cli.js CHANGED
@@ -1,24 +1,59 @@
1
1
  #!/usr/bin/env node
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]="4b439b5f-1c8d-5c46-baa6-14d0f50dd4f9")}catch(e){}}();
2
4
  import dotenv from 'dotenv';
3
- dotenv.config();
5
+ dotenv.config({ path: '.env' });
6
+ dotenv.config({ path: '.env.local', override: true });
7
+ dotenv.config({ path: '.env.production', override: true });
8
+ import './telemetry.js';
4
9
  import { Command } from 'commander';
5
10
  import { readFileSync } from 'node:fs';
6
11
  import { fromPackageRoot } from './utils/getPaths.js';
7
12
  import { setupCommand } from './commands/setup.js';
13
+ import { withTelemetry } from './telemetry.js';
14
+ import { logger } from './logging/logger.js';
8
15
  import { i18nCommand } from './commands/i18n.js';
9
- var packageJson = JSON.parse(readFileSync(fromPackageRoot('package.json'), 'utf8'));
10
- var program = new Command();
16
+ import { displayHeader } from './logging/console.js';
17
+ import { main } from 'gtx-cli/index';
18
+ const packageJson = JSON.parse(readFileSync(fromPackageRoot('package.json'), 'utf8'));
19
+ const program = new Command();
11
20
  program
12
21
  .name('locadex')
13
22
  .description('AI agent for internationalization')
14
23
  .version(packageJson.version);
15
24
  program
16
- .command('setup')
17
- .description('Set up locadex for your project')
18
- .action(setupCommand);
25
+ .command('start')
26
+ .description('Run Locadex on your project')
27
+ .option('-v, --verbose', 'Verbose output')
28
+ .option('-d, --debug', 'Debug output')
29
+ .option('-b, --batch-size <number>', 'Batch size', '1')
30
+ .option('--no-telemetry', 'Disable telemetry')
31
+ .action((options, command) => {
32
+ const parentOptions = command.parent?.opts() || {};
33
+ const allOptions = { ...parentOptions, ...options };
34
+ withTelemetry({ enabled: !allOptions.noTelemetry, options: allOptions }, () => {
35
+ logger.initialize(allOptions);
36
+ displayHeader();
37
+ setupCommand(Number(allOptions.batchSize) || 1);
38
+ });
39
+ });
19
40
  program
20
41
  .command('i18n')
21
- .description('Run AI-powered internationalization tasks')
22
- .action(i18nCommand);
42
+ .description('Run Locadex i18n on your project')
43
+ .option('-v, --verbose', 'Verbose output')
44
+ .option('-d, --debug', 'Debug output')
45
+ .option('-b, --batch-size <number>', 'Batch size', '1')
46
+ .option('--no-telemetry', 'Disable telemetry')
47
+ .action((options, command) => {
48
+ const parentOptions = command.parent?.opts() || {};
49
+ const allOptions = { ...parentOptions, ...options };
50
+ withTelemetry({ enabled: !allOptions.noTelemetry, options: allOptions }, () => {
51
+ logger.initialize(allOptions);
52
+ displayHeader();
53
+ i18nCommand(Number(allOptions.batchSize) || 1);
54
+ });
55
+ });
56
+ main(program);
23
57
  program.parse();
24
- //# sourceMappingURL=cli.js.map
58
+ //# sourceMappingURL=cli.js.map
59
+ //# debugId=4b439b5f-1c8d-5c46-baa6-14d0f50dd4f9
package/dist/cli.js.map CHANGED
@@ -1 +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"}
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 { logger } from './logging/logger.js';\nimport { i18nCommand } from './commands/i18n.js';\nimport { displayHeader } from './logging/console.js';\nimport { main } from 'gtx-cli/index';\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>', 'Batch size', '1')\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 () => {\n logger.initialize(allOptions);\n displayHeader();\n setupCommand(Number(allOptions.batchSize) || 1);\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>', 'Batch size', '1')\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 () => {\n logger.initialize(allOptions);\n displayHeader();\n i18nCommand(Number(allOptions.batchSize) || 1);\n }\n );\n });\n\nmain(program);\n\nprogram.parse();\n"],"names":[],"mappings":";;;AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,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C,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,IAAI,CAAC,OAAO,CAAC,CAAC;AAEd,OAAO,CAAC,KAAK,EAAE,CAAC","debug_id":"4b439b5f-1c8d-5c46-baa6-14d0f50dd4f9"}
@@ -1,2 +1,2 @@
1
- export declare function i18nCommand(): Promise<void>;
1
+ export declare function i18nCommand(batchSize: number): Promise<void>;
2
2
  //# sourceMappingURL=i18n.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/commands/i18n.ts"],"names":[],"mappings":"AAkBA,wBAAsB,WAAW,kBAiGhC"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"/","sources":["commands/i18n.ts"],"names":[],"mappings":"AA4CA,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,iBAyIlD"}
@@ -1,145 +1,215 @@
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';
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]="07fa5837-c204-572a-a464-4653a2df8e31")}catch(e){}}();
3
+ import { createSpinner } from '../logging/console.js';
4
+ import { allMcpPrompt } from '../prompts/system.js';
5
+ import { logger } from '../logging/logger.js';
6
+ import { createDag } from '../utils/dag/createDag.js';
7
+ import { findTsConfig, findWebpackConfig, findRequireConfig, } from '../utils/fs/findConfigs.js';
8
+ import { configureAgent } from '../utils/agentManager.js';
9
+ import { addFilesToManager, markFileAsEdited, markFileAsInProgress, } from '../utils/getFiles.js';
10
+ import { outro } from '@clack/prompts';
38
11
  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*/];
12
+ import { readdirSync, statSync } from 'node:fs';
13
+ import { EXCLUDED_DIRS } from '../utils/shared.js';
14
+ import { validateInitialConfig } from '../utils/validateConfig.js';
15
+ function getCurrentDirectories() {
16
+ try {
17
+ return readdirSync(process.cwd())
18
+ .filter((item) => {
19
+ try {
20
+ return statSync(item).isDirectory();
141
21
  }
22
+ catch {
23
+ return false;
24
+ }
25
+ })
26
+ .map((dir) => `./${dir}`)
27
+ .filter((dir) => {
28
+ return !EXCLUDED_DIRS.includes(dir);
142
29
  });
30
+ }
31
+ catch {
32
+ return [];
33
+ }
34
+ }
35
+ export async function i18nCommand(batchSize) {
36
+ validateInitialConfig();
37
+ // Init message
38
+ const spinner = createSpinner();
39
+ spinner.start('Initializing Locadex...');
40
+ // Create DAG
41
+ logger.debugMessage('getCurrentDirectories(): ' + getCurrentDirectories().join(', '));
42
+ const dag = createDag(getCurrentDirectories(), {
43
+ tsConfig: findTsConfig(),
44
+ webpackConfig: findWebpackConfig(),
45
+ requireConfig: findRequireConfig(),
46
+ });
47
+ logger.info('dag.getDag().length: ' + String(Object.keys(dag.getDag()).length));
48
+ logger.info('dag.getReverseDag().length: ' +
49
+ String(Object.keys(dag.getReverseDag()).length));
50
+ logger.info('dag.getTopologicalOrder().length: ' +
51
+ String(dag.getTopologicalOrder().length));
52
+ // Configure agent
53
+ const { agent, filesStateFilePath } = configureAgent({
54
+ mcpTransport: 'sse',
143
55
  });
56
+ // Track session id
57
+ let sessionId = undefined;
58
+ // Create the list of files (aka tasks) to process
59
+ const taskQueue = dag.getTopologicalOrder();
60
+ // Add files to manager
61
+ const stateFilePath = addFilesToManager(filesStateFilePath, taskQueue);
62
+ logger.info(`[dagCommand] Track progress here: ${stateFilePath}`);
63
+ // Main loop
64
+ let hasError = false;
65
+ while (taskQueue.length > 0) {
66
+ // Get the next task
67
+ const tasks = taskQueue.splice(0, batchSize);
68
+ if (tasks.length === 0) {
69
+ break;
70
+ }
71
+ // Mark task as in progress
72
+ tasks.forEach((task) => markFileAsInProgress(task, filesStateFilePath));
73
+ // Construct prompt
74
+ const dependencies = Object.fromEntries(tasks.map((task) => [
75
+ task,
76
+ Array.from(new Set(dag.getDependencies(task))),
77
+ ]));
78
+ const dependents = Object.fromEntries(tasks.map((task) => [task, Array.from(new Set(dag.getDependents(task)))]));
79
+ const prompt = getPrompt({
80
+ targetFile: tasks,
81
+ dependencyFiles: dependencies,
82
+ dependentFiles: dependents,
83
+ });
84
+ // Claude call
85
+ try {
86
+ await agent.run({
87
+ prompt,
88
+ sessionId,
89
+ }, { spinner });
90
+ if (!sessionId) {
91
+ sessionId = agent.getSessionId();
92
+ }
93
+ }
94
+ catch (error) {
95
+ hasError = true;
96
+ logger.debugMessage(`[dagCommand] Error in claude i18n process: ${error}`);
97
+ break;
98
+ }
99
+ // Mark task as complete
100
+ tasks.forEach((task) => markFileAsEdited(task, filesStateFilePath));
101
+ }
102
+ // TODO: uncomment
103
+ // // Always clean up the file list when done, regardless of success or failure
104
+ // logger.info(`[dagCommand] Cleaning up file list: ${stateFilePath}`);
105
+ // cleanUp(stateFilePath);
106
+ // If there was an error, exit with code 1
107
+ if (hasError) {
108
+ outro(chalk.red('❌ Locadex i18n failed!'));
109
+ process.exit(1);
110
+ }
111
+ // Fix prompt
112
+ const fixPrompt = getFixPrompt();
113
+ try {
114
+ await agent.run({ prompt: fixPrompt, sessionId }, { spinner });
115
+ }
116
+ catch (error) {
117
+ logger.debugMessage(`[dagCommand] Fixing errors failed: ${error}`);
118
+ outro(chalk.red('❌ Locadex i18n failed!'));
119
+ process.exit(1);
120
+ }
121
+ // Generate report
122
+ const reportPrompt = getReportPrompt();
123
+ try {
124
+ await agent.run({
125
+ prompt: reportPrompt,
126
+ sessionId,
127
+ }, { spinner });
128
+ }
129
+ catch (error) {
130
+ logger.debugMessage(`[dagCommand] Error in claude report generation: ${error}`);
131
+ outro(chalk.red('❌ Locadex i18n failed!'));
132
+ process.exit(1);
133
+ }
134
+ outro(chalk.green('✅ Locadex i18n complete!'));
135
+ process.exit(0);
136
+ }
137
+ function getPrompt({ targetFile, dependencyFiles, dependentFiles, }) {
138
+ const prompt = `# Task: Internationalize the target file using gt-next.
139
+
140
+ --- INSTRUCTIONS ---
141
+
142
+ - You are given a list of target files and a list of dependency/dependent files.
143
+ - The project is already setup for internationalization. You do not need to setup the project again for i18n.
144
+
145
+ ## Workflow:
146
+ 1. **Gather background** Read the target files closely (you should not have to read the dependency/dependent files).
147
+ 2. **Evaluate if i18n is necessary** Evaluate if just the target files need to be internationalized using gt-next (the target files may have no relevant content, they may already be internationalized, or they contain build-time code (e.g. nextjs plugins) should never be internationalized).
148
+ **IMPORTANT**: IF NONE OF THE TARGET FILES NEED TO BE INTERNATIONALIZED, YOUR TASK IS COMPLETE AND YOU MAY RETURN.
149
+ 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:
150
+ - 3.a. Does this file contain a component? If so, is it a server-side component or a client-side component?
151
+ - 3.b. Is the content that needs to be i18ned being used in this same file, or is it being used in another file?
152
+ - 3.c. Is there any string interpolation that needs to be i18ned?
153
+ - 3.d. Is there any conditional logic or rendering that needs to be i18ned?
154
+ - 3.e. Is the content that needs to be i18ned HTML/JSX or a string?
155
+ 4. **Internationalize** You now have the necessary knowledge. Internationalize the files using the information from the tools provided to you.
156
+ - 4.a. Do not worry about running tsc. We will do that later.
157
+
158
+ ## RULES:
159
+ - ALWAYS use the <T> component to internationalize HTML/JSX content. Only use getGT() or useGT() and getDict() or useDict() for string content.
160
+ - Do not add i18n middleware to the app
161
+ - When adding 'useGT()' or 'useDict()' to a client component, you must add 'use client' to the top of the file.
162
+ - Strictly adhere to the guides provided to gain necessary knowledge about how to internationalize the content.
163
+ - Minimize the footprint of the changes.
164
+ - Only focus on internationalizing the content of the target files.
165
+ - NEVER move internationalized content to a different file. All content MUST remain in the same file where it came from.
166
+ - NEVER CREATE OR REMOVE ANY FILES (especially .bak files)
167
+ - Internationalize all user facing content in the target files. Do not internationalize content that is not user facing.
168
+ - NEVER EDIT FILES THAT ARE NOT GIVEN TO YOU.
169
+
170
+
171
+ --- TARGET FILE INFORMATION ---
172
+ ${targetFile.map((file) => `
173
+ Target file path:
174
+ ${file}
175
+
176
+ Dependency files (files imported by the target file):
177
+ ${dependencyFiles[file].length > 0 ? ` ${dependencyFiles[file].join(', ')}` : 'none'}
178
+
179
+ Dependent files (files that import the target file):
180
+ ${dependentFiles[file].length > 0 ? ` ${dependentFiles[file].join(', ')}` : 'none'}
181
+ `)}
182
+ --- MCP TOOLS ---
183
+
184
+ ${allMcpPrompt}
185
+ `;
186
+ return prompt;
187
+ }
188
+ // check (dry run and ts check) should be at the end
189
+ function getFixPrompt() {
190
+ const prompt = `--- INSTRUCTIONS ---
191
+
192
+ Your task is as follows:
193
+ Start by running the gt-next linter (and ts type check if there are ts/tsx files).
194
+ (1) You need to fix all errors relevant to the gt implementation code.
195
+ (2) Whenever you are finished with your changes please run the gt-next linter (and ts type check if applicable).
196
+ (3) Repeat steps 1-2 until there are no more errors or until you believe that you have fixed all errors.
197
+
198
+ Rules:
199
+ - DO NOT modify any files that are not relevant to the gt implementation code.
200
+ - ONLY fix errors that are relevant to the gt implementation code and your implementation.
201
+
202
+ To run the gt-next linter, run the following command:
203
+ 'npx gtx-cli translate --dry-run'and is appropriate for the files you have modified.`;
204
+ return prompt;
205
+ }
206
+ function getReportPrompt() {
207
+ const prompt = `--- INSTRUCTIONS ---
208
+
209
+ - Please add a markdown file called 'locadex-report.md' to the root of the project.
210
+ - The report should include a summary of the changes you made to the project.
211
+ - A list of items the user needs to complete to finish the internationalization process (adding env vars, etc.).`;
212
+ return prompt;
144
213
  }
145
- //# sourceMappingURL=i18n.js.map
214
+ //# sourceMappingURL=i18n.js.map
215
+ //# debugId=07fa5837-c204-572a-a464-4653a2df8e31
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/commands/i18n.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,I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ACtB,CAAC,CAAC;oBAEG,aAAa,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;oBAE5C,qBAAM,YAAY,CAAC,GAAG,CAAC;4BACpC,oCAAoC;4BACpC,MAAM,UAAA;4BACN,SAAS,EAAE,aAAa;4BACxB,YAAY,EAAE,CAAC,QAAQ,CAAC;yBACzB,CAAC,EAAA;;oBALI,MAAM,GAAG,SAKb;oBAEF,CAAC,CAAC,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"}
1
+ {"version":3,"file":"i18n.js","sources":["commands/i18n.ts"],"sourceRoot":"/","sourcesContent":["import { createSpinner, displayHeader } 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 { configureAgent } from '../utils/agentManager.js';\nimport {\n addFilesToManager,\n cleanUp,\n markFileAsEdited,\n markFileAsInProgress,\n} from '../utils/getFiles.js';\nimport { outro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { readdirSync, statSync } from 'node:fs';\nimport { EXCLUDED_DIRS } from '../utils/shared.js';\nimport { validateInitialConfig } from '../utils/validateConfig.js';\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) {\n validateInitialConfig();\n\n // Init message\n const spinner = createSpinner();\n spinner.start('Initializing Locadex...');\n\n // Create DAG\n logger.debugMessage(\n 'getCurrentDirectories(): ' + getCurrentDirectories().join(', ')\n );\n const dag = createDag(getCurrentDirectories(), {\n tsConfig: findTsConfig(),\n webpackConfig: findWebpackConfig(),\n requireConfig: findRequireConfig(),\n });\n\n logger.info(\n 'dag.getDag().length: ' + String(Object.keys(dag.getDag()).length)\n );\n logger.info(\n 'dag.getReverseDag().length: ' +\n String(Object.keys(dag.getReverseDag()).length)\n );\n logger.info(\n 'dag.getTopologicalOrder().length: ' +\n String(dag.getTopologicalOrder().length)\n );\n\n // Configure agent\n const { agent, filesStateFilePath } = configureAgent({\n mcpTransport: 'sse',\n });\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 // Add files to manager\n const stateFilePath = addFilesToManager(filesStateFilePath, taskQueue);\n logger.info(`[dagCommand] Track progress here: ${stateFilePath}`);\n\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(\n `[dagCommand] Error in claude i18n process: ${error}`\n );\n break;\n }\n\n // Mark task as complete\n tasks.forEach((task) => markFileAsEdited(task, filesStateFilePath));\n }\n\n // TODO: uncomment\n // // Always clean up the file list when done, regardless of success or failure\n // logger.info(`[dagCommand] 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 const fixPrompt = getFixPrompt();\n try {\n await agent.run({ prompt: fixPrompt, sessionId }, { spinner });\n } catch (error) {\n logger.debugMessage(`[dagCommand] Fixing errors failed: ${error}`);\n outro(chalk.red('❌ Locadex i18n failed!'));\n process.exit(1);\n }\n\n // Generate 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(\n `[dagCommand] Error in claude report generation: ${error}`\n );\n outro(chalk.red('❌ Locadex i18n failed!'));\n process.exit(1);\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 using gt-next.\n\n--- INSTRUCTIONS ---\n\n- You are given a list of target files and a list of dependency/dependent files.\n- The project is already setup for internationalization. You do not need to setup the project again for i18n.\n\n## Workflow:\n1. **Gather background** Read the target files closely (you should not have to read the dependency/dependent files).\n2. **Evaluate if i18n is necessary** Evaluate if just the target files need to be internationalized using gt-next (the target files may have no relevant content, they may already be internationalized, or they contain build-time code (e.g. nextjs plugins) 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. Only use getGT() or useGT() and getDict() or useDict() for string content.\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- Strictly adhere to the guides provided to gain necessary knowledge about how to internationalize the content.\n- Minimize the footprint of the changes.\n- Only 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. Do not internationalize content that is not user facing.\n- NEVER EDIT FILES THAT ARE NOT GIVEN TO YOU.\n\n\n--- TARGET FILE INFORMATION ---\n${targetFile.map(\n (file) => `\nTarget file path:\n${file}\n\nDependency files (files imported by the target file):\n${dependencyFiles[file].length > 0 ? ` ${dependencyFiles[file].join(', ')}` : 'none'}\n\nDependent files (files that import the target file):\n${dependentFiles[file].length > 0 ? ` ${dependentFiles[file].join(', ')}` : 'none'}\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 = `--- INSTRUCTIONS ---\n \n Your task is as follows:\n Start by running the gt-next linter (and ts type check if there are ts/tsx files).\n (1) You need to fix all errors relevant to the gt implementation code.\n (2) Whenever you are finished with your changes please run the gt-next linter (and ts type check if applicable).\n (3) Repeat steps 1-2 until there are no more errors or until you believe that you have fixed all errors.\n\n Rules:\n - DO NOT modify any files that are not relevant to the gt implementation code.\n - ONLY fix errors that are relevant to the gt implementation code and your implementation.\n\n To run the gt-next linter, run the following command:\n 'npx gtx-cli translate --dry-run'and is appropriate for the files you have modified.`;\n\n return prompt;\n}\n\nfunction getReportPrompt() {\n const prompt = `--- INSTRUCTIONS ---\n\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, etc.).`;\n\n return prompt;\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,iBAAiB,EAEjB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,SAAS,qBAAqB;IAC5B,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,OAAO,CAAC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CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM;CACjF,CACA;;;EAGC,YAAY;CACb,CAAC;IAEA,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,oDAAoD;AAEpD,SAAS,YAAY;IACnB,MAAM,MAAM,GAAG;;;;;;;;;;;;;uFAasE,CAAC;IAEtF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,eAAe;IACtB,MAAM,MAAM,GAAG;;;;iHAIgG,CAAC;IAEhH,OAAO,MAAM,CAAC;AAChB,CAAC","debug_id":"07fa5837-c204-572a-a464-4653a2df8e31"}
@@ -1,2 +1,2 @@
1
- export declare function setupCommand(): Promise<void>;
1
+ export declare function setupCommand(batchSize: number): Promise<void>;
2
2
  //# sourceMappingURL=setup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAUA,wBAAsB,YAAY,kBAkDjC"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"/","sources":["commands/setup.ts"],"names":[],"mappings":"AAmBA,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,iBAuGnD"}