locadex 0.1.13-alpha.2 → 0.1.13

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 (103) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cli.js +5 -7
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/fixErrors.d.ts.map +1 -1
  5. package/dist/commands/fixErrors.js +2 -7
  6. package/dist/commands/fixErrors.js.map +1 -1
  7. package/dist/commands/i18n.d.ts.map +1 -1
  8. package/dist/commands/i18n.js +2 -7
  9. package/dist/commands/i18n.js.map +1 -1
  10. package/dist/commands/setup.d.ts.map +1 -1
  11. package/dist/commands/setup.js +3 -10
  12. package/dist/commands/setup.js.map +1 -1
  13. package/dist/index.js +1 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/logging/console.js +1 -4
  16. package/dist/logging/console.js.map +1 -1
  17. package/dist/logging/logger.js +1 -4
  18. package/dist/logging/logger.js.map +1 -1
  19. package/dist/mcp/getDocs.js +1 -4
  20. package/dist/mcp/getDocs.js.map +1 -1
  21. package/dist/mcp/getGuide.js +1 -4
  22. package/dist/mcp/getGuide.js.map +1 -1
  23. package/dist/mcp/getPort.js +1 -4
  24. package/dist/mcp/getPort.js.map +1 -1
  25. package/dist/mcp/tools/docs.js +1 -4
  26. package/dist/mcp/tools/docs.js.map +1 -1
  27. package/dist/mcp/tools/guides.js +1 -4
  28. package/dist/mcp/tools/guides.js.map +1 -1
  29. package/dist/mcp/tools/validate.js +1 -4
  30. package/dist/mcp/tools/validate.js.map +1 -1
  31. package/dist/mcp/validateEnv.js +1 -4
  32. package/dist/mcp/validateEnv.js.map +1 -1
  33. package/dist/mcp-sse.js +1 -4
  34. package/dist/mcp-sse.js.map +1 -1
  35. package/dist/mcp-stdio.js +1 -4
  36. package/dist/mcp-stdio.js.map +1 -1
  37. package/dist/prompts/system.js +1 -4
  38. package/dist/prompts/system.js.map +1 -1
  39. package/dist/resources/getResource.js +1 -4
  40. package/dist/resources/getResource.js.map +1 -1
  41. package/dist/tasks/concurrency.js +1 -4
  42. package/dist/tasks/concurrency.js.map +1 -1
  43. package/dist/tasks/fixErrors.js +1 -4
  44. package/dist/tasks/fixErrors.js.map +1 -1
  45. package/dist/tasks/i18n.d.ts.map +1 -1
  46. package/dist/tasks/i18n.js +3 -8
  47. package/dist/tasks/i18n.js.map +1 -1
  48. package/dist/tasks/setup.d.ts.map +1 -1
  49. package/dist/tasks/setup.js +43 -6
  50. package/dist/tasks/setup.js.map +1 -1
  51. package/dist/telemetry.js +2 -5
  52. package/dist/telemetry.js.map +1 -1
  53. package/dist/types/claude-sdk.js +1 -4
  54. package/dist/types/claude-sdk.js.map +1 -1
  55. package/dist/types/cli.d.ts +2 -1
  56. package/dist/types/cli.d.ts.map +1 -1
  57. package/dist/types/cli.js +1 -4
  58. package/dist/types/cli.js.map +1 -1
  59. package/dist/utils/claudeCode.js +1 -4
  60. package/dist/utils/claudeCode.js.map +1 -1
  61. package/dist/utils/config.js +1 -4
  62. package/dist/utils/config.js.map +1 -1
  63. package/dist/utils/dag/createDag.js +1 -4
  64. package/dist/utils/dag/createDag.js.map +1 -1
  65. package/dist/utils/dag/extractFiles.js +1 -4
  66. package/dist/utils/dag/extractFiles.js.map +1 -1
  67. package/dist/utils/dag/getFiles.js +1 -4
  68. package/dist/utils/dag/getFiles.js.map +1 -1
  69. package/dist/utils/dag/matchFiles.js +1 -4
  70. package/dist/utils/dag/matchFiles.js.map +1 -1
  71. package/dist/utils/errors.js +1 -4
  72. package/dist/utils/errors.js.map +1 -1
  73. package/dist/utils/exec.js +1 -4
  74. package/dist/utils/exec.js.map +1 -1
  75. package/dist/utils/fs/findConfigs.js +1 -4
  76. package/dist/utils/fs/findConfigs.js.map +1 -1
  77. package/dist/utils/fs/getFiles.js +1 -4
  78. package/dist/utils/fs/getFiles.js.map +1 -1
  79. package/dist/utils/fs/git.js +1 -4
  80. package/dist/utils/fs/git.js.map +1 -1
  81. package/dist/utils/fs/writeFiles.js +1 -4
  82. package/dist/utils/fs/writeFiles.js.map +1 -1
  83. package/dist/utils/getPaths.js +1 -4
  84. package/dist/utils/getPaths.js.map +1 -1
  85. package/dist/utils/locadexManager.d.ts +2 -0
  86. package/dist/utils/locadexManager.d.ts.map +1 -1
  87. package/dist/utils/locadexManager.js +6 -4
  88. package/dist/utils/locadexManager.js.map +1 -1
  89. package/dist/utils/lockfile.d.ts +0 -1
  90. package/dist/utils/lockfile.d.ts.map +1 -1
  91. package/dist/utils/lockfile.js +5 -14
  92. package/dist/utils/lockfile.js.map +1 -1
  93. package/dist/utils/packages/installPackage.js +1 -4
  94. package/dist/utils/packages/installPackage.js.map +1 -1
  95. package/dist/utils/session.js +1 -4
  96. package/dist/utils/session.js.map +1 -1
  97. package/dist/utils/shared.js +1 -4
  98. package/dist/utils/shared.js.map +1 -1
  99. package/dist/utils/shutdown.js +1 -4
  100. package/dist/utils/shutdown.js.map +1 -1
  101. package/dist/utils/stats.js +1 -4
  102. package/dist/utils/stats.js.map +1 -1
  103. package/package.json +2 -2
@@ -1,5 +1,3 @@
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]="a14f788a-86ac-5858-a5a8-21c1ba4a5eb4")}catch(e){}}();
3
1
  import { logger } from '../../logging/logger.js';
4
2
  import { execFunction } from '../../utils/exec.js';
5
3
  export function addValidateProjectTool(server, appDirectory) {
@@ -33,5 +31,4 @@ export function addValidateProjectTool(server, appDirectory) {
33
31
  }
34
32
  });
35
33
  }
36
- //# sourceMappingURL=validate.js.map
37
- //# debugId=a14f788a-86ac-5858-a5a8-21c1ba4a5eb4
34
+ //# sourceMappingURL=validate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sources":["mcp/tools/validate.ts"],"sourceRoot":"/","sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { logger } from '../../logging/logger.js';\nimport { execFunction } from '../../utils/exec.js';\n\nexport function addValidateProjectTool(\n server: McpServer,\n appDirectory: string\n) {\n server.tool(\n 'validate-project',\n 'Validates a project for internationalization errors',\n {},\n async () => {\n try {\n const { stdout, stderr, code } = await execFunction(\n 'locadex',\n ['validate'],\n false,\n appDirectory,\n undefined,\n 1 * 60 * 1000 // 1 minute\n );\n if (code === 0) {\n logger.log(\n `[locadex-mcp: validate] Successfully validated project: ${stdout}`\n );\n return {\n content: [{ type: 'text', text: stdout }],\n };\n } else {\n logger.log(\n `[locadex-mcp: validate] Error validating project: ${stdout} with code ${code}`\n );\n return {\n content: [{ type: 'text', text: stdout }],\n };\n }\n } catch (error) {\n logger.log(\n `[locadex-mcp: validate] Error validating project: ${error instanceof Error ? error.message : String(error)}`\n );\n return {\n content: [\n {\n type: 'text',\n text: `Error validating project: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n };\n }\n }\n );\n}\n"],"names":[],"mappings":";;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,UAAU,sBAAsB,CACpC,MAAiB,EACjB,YAAoB;IAEpB,MAAM,CAAC,IAAI,CACT,kBAAkB,EAClB,qDAAqD,EACrD,EAAE,EACF,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,YAAY,CACjD,SAAS,EACT,CAAC,UAAU,CAAC,EACZ,KAAK,EACL,YAAY,EACZ,SAAS,EACT,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW;aAC1B,CAAC;YACF,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,MAAM,CAAC,GAAG,CACR,2DAA2D,MAAM,EAAE,CACpE,CAAC;gBACF,OAAO;oBACL,OAA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AAU,CAAC,EACZ,KAAK,EACL,YAAY,EACZ,SAAS,EACT,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW;aAC1B,CAAC;YACF,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,MAAM,CAAC,GAAG,CACR,2DAA2D,MAAM,EAAE,CACpE,CAAC;gBACF,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iBAC1C,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,GAAG,CACR,qDAAqD,MAAM,cAAc,IAAI,EAAE,CAChF,CAAC;gBACF,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iBAC1C,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,GAAG,CACR,qDAAqD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC9G,CAAC;YACF,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,6BAA6B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBAC5F;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { logger } from '../../logging/logger.js';\nimport { execFunction } from '../../utils/exec.js';\n\nexport function addValidateProjectTool(\n server: McpServer,\n appDirectory: string\n) {\n server.tool(\n 'validate-project',\n 'Validates a project for internationalization errors',\n {},\n async () => {\n try {\n const { stdout, stderr, code } = await execFunction(\n 'locadex',\n ['validate'],\n false,\n appDirectory,\n undefined,\n 1 * 60 * 1000 // 1 minute\n );\n if (code === 0) {\n logger.log(\n `[locadex-mcp: validate] Successfully validated project: ${stdout}`\n );\n return {\n content: [{ type: 'text', text: stdout }],\n };\n } else {\n logger.log(\n `[locadex-mcp: validate] Error validating project: ${stdout} with code ${code}`\n );\n return {\n content: [{ type: 'text', text: stdout }],\n };\n }\n } catch (error) {\n logger.log(\n `[locadex-mcp: validate] Error validating project: ${error instanceof Error ? error.message : String(error)}`\n );\n return {\n content: [\n {\n type: 'text',\n text: `Error validating project: ${error instanceof Error ? error.message : String(error)}`,\n },\n ],\n };\n }\n }\n );\n}\n"]}
@@ -1,5 +1,3 @@
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]="fded2cd6-ceed-5502-bd33-7b96f213b80b")}catch(e){}}();
3
1
  export function validateEnv() {
4
2
  const stateFile = process.env.LOCADEX_FILES_STATE_FILE_PATH;
5
3
  const logFile = process.env.LOCADEX_LOG_FILE_PATH;
@@ -23,5 +21,4 @@ export function validateEnv() {
23
21
  appDirectory,
24
22
  };
25
23
  }
26
- //# sourceMappingURL=validateEnv.js.map
27
- //# debugId=fded2cd6-ceed-5502-bd33-7b96f213b80b
24
+ //# sourceMappingURL=validateEnv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateEnv.js","sources":["mcp/validateEnv.ts"],"sourceRoot":"/","sourcesContent":["export type MCPConfig = {\n stateFile: string;\n logFile: string;\n verbose: boolean;\n debug: boolean;\n appDirectory: string;\n};\n\nexport function validateEnv(): MCPConfig {\n const stateFile = process.env.LOCADEX_FILES_STATE_FILE_PATH;\n const logFile = process.env.LOCADEX_LOG_FILE_PATH;\n if (!stateFile) {\n throw new Error('LOCADEX_FILES_STATE_FILE_PATH is not set');\n }\n if (!logFile) {\n throw new Error('LOCADEX_LOG_FILE_PATH is not set');\n }\n const verbose = process.env.LOCADEX_VERBOSE === 'true';\n const debug = process.env.LOCADEX_DEBUG === 'true';\n const appDirectory = process.env.APP_DIRECTORY;\n if (!appDirectory) {\n throw new Error('APP_DIRECTORY is not set');\n }\n return {\n stateFile,\n logFile,\n verbose,\n debug,\n appDirectory,\n };\n}\n"],"names":[],"mappings":";;AAQA,MAAM,UAAU,WAAW;IACzB,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC;IAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAClD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,MAAM,CAAC;IACvD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,MAAM,CAAC;IACnD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAC/C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO;QACL,SAAS;QACT,OAAO;QACP,OAAO;QACP,KAAK;QACL,YAAY;KACb,CAAC;AACJ,CAAC","debug_id":"fded2cd6-ceed-5502-bd33-7b96f213b80b"}
1
+ {"version":3,"file":"validateEnv.js","sourceRoot":"/","sources":["mcp/validateEnv.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,WAAW;IACzB,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC;IAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAClD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,MAAM,CAAC;IACvD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,MAAM,CAAC;IACnD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAC/C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO;QACL,SAAS;QACT,OAAO;QACP,OAAO;QACP,KAAK;QACL,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["export type MCPConfig = {\n stateFile: string;\n logFile: string;\n verbose: boolean;\n debug: boolean;\n appDirectory: string;\n};\n\nexport function validateEnv(): MCPConfig {\n const stateFile = process.env.LOCADEX_FILES_STATE_FILE_PATH;\n const logFile = process.env.LOCADEX_LOG_FILE_PATH;\n if (!stateFile) {\n throw new Error('LOCADEX_FILES_STATE_FILE_PATH is not set');\n }\n if (!logFile) {\n throw new Error('LOCADEX_LOG_FILE_PATH is not set');\n }\n const verbose = process.env.LOCADEX_VERBOSE === 'true';\n const debug = process.env.LOCADEX_DEBUG === 'true';\n const appDirectory = process.env.APP_DIRECTORY;\n if (!appDirectory) {\n throw new Error('APP_DIRECTORY is not set');\n }\n return {\n stateFile,\n logFile,\n verbose,\n debug,\n appDirectory,\n };\n}\n"]}
package/dist/mcp-sse.js CHANGED
@@ -1,6 +1,4 @@
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]="fc44876b-0ae4-5975-895b-400e4cdf1431")}catch(e){}}();
4
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
3
  import { addDocsTools } from './mcp/tools/docs.js';
6
4
  import { existsSync, readFileSync } from 'node:fs';
@@ -75,5 +73,4 @@ start().catch(async (error) => {
75
73
  logger.error(`[locadex-mcp] Failed to start: ${error instanceof Error ? error.message : String(error)}`);
76
74
  await exit(1);
77
75
  });
78
- //# sourceMappingURL=mcp-sse.js.map
79
- //# debugId=fc44876b-0ae4-5975-895b-400e4cdf1431
76
+ //# sourceMappingURL=mcp-sse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-sse.js","sources":["mcp-sse.ts"],"sourceRoot":"/","sourcesContent":["#!/usr/bin/env node\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { addDocsTools } from './mcp/tools/docs.js';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { fromPackageRoot, getLocadexVersion } from './utils/getPaths.js';\nimport { addGuidesTools } from './mcp/tools/guides.js';\nimport express from 'express';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';\nimport { logger } from './logging/logger.js';\nimport { findAvailablePort } from './mcp/getPort.js';\nimport { exit } from './utils/shutdown.js';\nimport { addValidateProjectTool } from './mcp/tools/validate.js';\nimport { validateEnv } from './mcp/validateEnv.js';\n\nexport async function start() {\n const { stateFile, logFile, verbose, debug, appDirectory } = validateEnv();\n const requestedPort = process.env.PORT ? parseInt(process.env.PORT) : 8888;\n const port = await findAvailablePort(requestedPort);\n\n logger.initialize({ verbose, debug }, logFile);\n\n if (stateFile && existsSync(stateFile)) {\n const state = JSON.parse(readFileSync(stateFile, 'utf8'));\n logger.debugMessage(\n `[locadex-mcp] state: ${JSON.stringify(state, null, 2)}`\n );\n } else {\n throw new Error(`[locadex-mcp] state file not found: ${stateFile}`);\n }\n\n const mcpServer = new McpServer({\n name: 'Locadex: AI Agent for Internationalization',\n version: JSON.parse(readFileSync(fromPackageRoot('package.json'), 'utf8'))\n .version,\n });\n\n const app = express();\n app.use(express.json());\n\n // Store transports for each session type\n const transports = {\n streamable: {} as Record<string, StreamableHTTPServerTransport>,\n sse: {} as Record<string, SSEServerTransport>,\n };\n\n addDocsTools(mcpServer);\n addGuidesTools(mcpServer);\n addValidateProjectTool(mcpServer, appDirectory);\n\n // SSE endpoint for legacy clients\n // Claude Code only supports SSE as of 2025-06-04\n app.get('/sse', async (req, res) => {\n const transport = new SSEServerTransport('/messages', res);\n transports.sse[transport.sessionId] = transport;\n\n res.on('close', () => {\n logger.log(\n `[locadex-mcp] SSE transport closed for sessionId: ${transport.sessionId}`\n );\n delete transports.sse[transport.sessionId];\n });\n\n await mcpServer.connect(transport);\n });\n\n // Companion endpoint for sending messages\n app.post('/messages', async (req, res) => {\n const sessionId = req.query.sessionId as string;\n const transport = transports.sse[sessionId];\n if (transport) {\n await transport.handlePostMessage(req, res, req.body);\n } else {\n logger.log(\n `[locadex-mcp] No transport found for sessionId: ${sessionId}`\n );\n res.status(400).send('No transport found for sessionId');\n }\n });\n\n app.listen(port, () => {\n const portMessage =\n port !== requestedPort\n ? `${port} (requested ${requestedPort} was in use)`\n : `${port}`;\n logger.debugMessage(\n `[locadex-mcp v${getLocadexVersion()}] started on port ${portMessage} with state file ${stateFile}`\n );\n });\n}\n\n// Start the SSE server\nstart().catch(async (error) => {\n logger.error(\n `[locadex-mcp] Failed to start: ${error instanceof Error ? error.message : String(error)}`\n );\n await exit(1);\n});\n"],"names":[],"mappings":";;;AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE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CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { addDocsTools } from './mcp/tools/docs.js';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { fromPackageRoot, getLocadexVersion } from './utils/getPaths.js';\nimport { addGuidesTools } from './mcp/tools/guides.js';\nimport express from 'express';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';\nimport { logger } from './logging/logger.js';\nimport { findAvailablePort } from './mcp/getPort.js';\nimport { exit } from './utils/shutdown.js';\nimport { addValidateProjectTool } from './mcp/tools/validate.js';\nimport { validateEnv } from './mcp/validateEnv.js';\n\nexport async function start() {\n const { stateFile, logFile, verbose, debug, appDirectory } = validateEnv();\n const requestedPort = process.env.PORT ? parseInt(process.env.PORT) : 8888;\n const port = await findAvailablePort(requestedPort);\n\n logger.initialize({ verbose, debug }, logFile);\n\n if (stateFile && existsSync(stateFile)) {\n const state = JSON.parse(readFileSync(stateFile, 'utf8'));\n logger.debugMessage(\n `[locadex-mcp] state: ${JSON.stringify(state, null, 2)}`\n );\n } else {\n throw new Error(`[locadex-mcp] state file not found: ${stateFile}`);\n }\n\n const mcpServer = new McpServer({\n name: 'Locadex: AI Agent for Internationalization',\n version: JSON.parse(readFileSync(fromPackageRoot('package.json'), 'utf8'))\n .version,\n });\n\n const app = express();\n app.use(express.json());\n\n // Store transports for each session type\n const transports = {\n streamable: {} as Record<string, StreamableHTTPServerTransport>,\n sse: {} as Record<string, SSEServerTransport>,\n };\n\n addDocsTools(mcpServer);\n addGuidesTools(mcpServer);\n addValidateProjectTool(mcpServer, appDirectory);\n\n // SSE endpoint for legacy clients\n // Claude Code only supports SSE as of 2025-06-04\n app.get('/sse', async (req, res) => {\n const transport = new SSEServerTransport('/messages', res);\n transports.sse[transport.sessionId] = transport;\n\n res.on('close', () => {\n logger.log(\n `[locadex-mcp] SSE transport closed for sessionId: ${transport.sessionId}`\n );\n delete transports.sse[transport.sessionId];\n });\n\n await mcpServer.connect(transport);\n });\n\n // Companion endpoint for sending messages\n app.post('/messages', async (req, res) => {\n const sessionId = req.query.sessionId as string;\n const transport = transports.sse[sessionId];\n if (transport) {\n await transport.handlePostMessage(req, res, req.body);\n } else {\n logger.log(\n `[locadex-mcp] No transport found for sessionId: ${sessionId}`\n );\n res.status(400).send('No transport found for sessionId');\n }\n });\n\n app.listen(port, () => {\n const portMessage =\n port !== requestedPort\n ? `${port} (requested ${requestedPort} was in use)`\n : `${port}`;\n logger.debugMessage(\n `[locadex-mcp v${getLocadexVersion()}] started on port ${portMessage} with state file ${stateFile}`\n );\n });\n}\n\n// Start the SSE server\nstart().catch(async (error) => {\n logger.error(\n `[locadex-mcp] Failed to start: ${error instanceof Error ? error.message : String(error)}`\n );\n await exit(1);\n});\n"]}
package/dist/mcp-stdio.js CHANGED
@@ -1,6 +1,4 @@
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]="130ecd64-a194-55ed-88c3-852d070aa468")}catch(e){}}();
4
2
  import './telemetry.js';
5
3
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
@@ -35,5 +33,4 @@ async function main() {
35
33
  logger.log('[locadex-mcp] started on stdio');
36
34
  }
37
35
  main();
38
- //# sourceMappingURL=mcp-stdio.js.map
39
- //# debugId=130ecd64-a194-55ed-88c3-852d070aa468
36
+ //# sourceMappingURL=mcp-stdio.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-stdio.js","sources":["mcp-stdio.ts"],"sourceRoot":"/","sourcesContent":["#!/usr/bin/env node\n\nimport './telemetry.js';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { addDocsTools } from './mcp/tools/docs.js';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { fromPackageRoot } from './utils/getPaths.js';\nimport { addGuidesTools } from './mcp/tools/guides.js';\nimport { logger } from './logging/logger.js';\nimport { addValidateProjectTool } from './mcp/tools/validate.js';\nimport { validateEnv } from './mcp/validateEnv.js';\n\nasync function main() {\n const { stateFile, logFile, verbose, debug, appDirectory } = validateEnv();\n logger.initialize({ verbose, debug }, logFile);\n\n if (stateFile && existsSync(stateFile)) {\n const state = JSON.parse(readFileSync(stateFile, 'utf8'));\n logger.log(`[locadex-mcp] state: ${JSON.stringify(state, null, 2)}`);\n } else {\n throw new Error(`[locadex-mcp] state file not found: ${stateFile}`);\n }\n\n const server = new McpServer({\n name: 'Locadex: AI Agent for Internationalization',\n version: JSON.parse(readFileSync(fromPackageRoot('package.json'), 'utf8'))\n .version,\n });\n\n addDocsTools(server);\n addGuidesTools(server);\n addValidateProjectTool(server, appDirectory);\n\n logger.log('[locadex-mcp] All tools registered');\n const transport = new StdioServerTransport();\n await server.connect(transport);\n logger.log('[locadex-mcp] started on stdio');\n}\nmain();\n"],"names":[],"mappings":";;;AAEA,OAAO,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,yB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EAAE,4CAA4C;QAClD,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC;aACvE,OAAO;KACX,CAAC,CAAC;IAEH,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,sBAAsB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAE7C,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAC/C,CAAC;AACD,IAAI,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport './telemetry.js';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { addDocsTools } from './mcp/tools/docs.js';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { fromPackageRoot } from './utils/getPaths.js';\nimport { addGuidesTools } from './mcp/tools/guides.js';\nimport { logger } from './logging/logger.js';\nimport { addValidateProjectTool } from './mcp/tools/validate.js';\nimport { validateEnv } from './mcp/validateEnv.js';\n\nasync function main() {\n const { stateFile, logFile, verbose, debug, appDirectory } = validateEnv();\n logger.initialize({ verbose, debug }, logFile);\n\n if (stateFile && existsSync(stateFile)) {\n const state = JSON.parse(readFileSync(stateFile, 'utf8'));\n logger.log(`[locadex-mcp] state: ${JSON.stringify(state, null, 2)}`);\n } else {\n throw new Error(`[locadex-mcp] state file not found: ${stateFile}`);\n }\n\n const server = new McpServer({\n name: 'Locadex: AI Agent for Internationalization',\n version: JSON.parse(readFileSync(fromPackageRoot('package.json'), 'utf8'))\n .version,\n });\n\n addDocsTools(server);\n addGuidesTools(server);\n addValidateProjectTool(server, appDirectory);\n\n logger.log('[locadex-mcp] All tools registered');\n const transport = new StdioServerTransport();\n await server.connect(transport);\n logger.log('[locadex-mcp] started on stdio');\n}\nmain();\n"]}
@@ -1,5 +1,3 @@
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]="f049faca-f704-566a-abda-540d7a59c61a")}catch(e){}}();
3
1
  import { guides } from '../mcp/tools/guides.js';
4
2
  import { docsTools } from '../mcp/tools/docs.js';
5
3
  export const mcpDocsTools = Object.keys(docsTools).map((tool) => `mcp__locadex__${tool}`);
@@ -25,5 +23,4 @@ ${mcpGuidesTools.join('\n')}
25
23
  mcp__locadex__validate-project
26
24
 
27
25
  Generally, you should use the guides tools to help you with your tasks. You should only call the docs tools when you need specific information not covered by the guides.`;
28
- //# sourceMappingURL=system.js.map
29
- //# debugId=f049faca-f704-566a-abda-540d7a59c61a
26
+ //# sourceMappingURL=system.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.js","sources":["prompts/system.ts"],"sourceRoot":"/","sourcesContent":["import { guides } from '../mcp/tools/guides.js';\nimport { docsTools } from '../mcp/tools/docs.js';\n\nexport const mcpDocsTools = Object.keys(docsTools).map(\n (tool) => `mcp__locadex__${tool}`\n);\n\nexport const mcpGuidesTools = guides.map(\n (guide) => `mcp__locadex__${guide.id}`\n);\n\nexport const allMcpPrompt = `You have access to mcp tools made available via the 'locadex' mcp server:\n\n## Documentation Tools:\n${mcpDocsTools.join('\\n')}\n\n## Guide Tools:\n${mcpGuidesTools.join('\\n')}\n\nGenerally, you should use the guides tools to help you with your tasks. You should only call the docs tools when you need specific information not covered by the guides.`;\n\nexport const allMcpPromptFixErrors = `You have access to mcp tools made available via the 'locadex' mcp server:\n\n## Documentation Tools:\n${mcpDocsTools.join('\\n')}\n\n## Guide Tools:\n${mcpGuidesTools.join('\\n')}\n\n## Validation Tools:\nmcp__locadex__validate-project\n\nGenerally, you should use the guides tools to help you with your tasks. You should only call the docs tools when you need specific information not covered by the guides.`;\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CACpD,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,IAAI,EAAE,CAClC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CACtC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,KAAK,CAAC,EAAE,EAAE,CACvC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;EAG1B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGvB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;;0KAE+I,CAAC;AAE3K,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;EAGnC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGvB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;0KAK+I,CAAC","debug_id":"f049faca-f704-566a-abda-540d7a59c61a"}
1
+ {"version":3,"file":"system.js","sourceRoot":"/","sources":["prompts/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CACpD,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,IAAI,EAAE,CAClC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CACtC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,KAAK,CAAC,EAAE,EAAE,CACvC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;;;EAG1B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGvB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;;0KAE+I,CAAC;AAE3K,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;EAGnC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGvB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;0KAK+I,CAAC","sourcesContent":["import { guides } from '../mcp/tools/guides.js';\nimport { docsTools } from '../mcp/tools/docs.js';\n\nexport const mcpDocsTools = Object.keys(docsTools).map(\n (tool) => `mcp__locadex__${tool}`\n);\n\nexport const mcpGuidesTools = guides.map(\n (guide) => `mcp__locadex__${guide.id}`\n);\n\nexport const allMcpPrompt = `You have access to mcp tools made available via the 'locadex' mcp server:\n\n## Documentation Tools:\n${mcpDocsTools.join('\\n')}\n\n## Guide Tools:\n${mcpGuidesTools.join('\\n')}\n\nGenerally, you should use the guides tools to help you with your tasks. You should only call the docs tools when you need specific information not covered by the guides.`;\n\nexport const allMcpPromptFixErrors = `You have access to mcp tools made available via the 'locadex' mcp server:\n\n## Documentation Tools:\n${mcpDocsTools.join('\\n')}\n\n## Guide Tools:\n${mcpGuidesTools.join('\\n')}\n\n## Validation Tools:\nmcp__locadex__validate-project\n\nGenerally, you should use the guides tools to help you with your tasks. You should only call the docs tools when you need specific information not covered by the guides.`;\n"]}
@@ -1,5 +1,3 @@
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]="88504afd-5278-5cca-855f-d157fa96541e")}catch(e){}}();
3
1
  import { readFileSync } from 'node:fs';
4
2
  import { join } from 'node:path';
5
3
  import { fromPackageRoot } from '../utils/getPaths.js';
@@ -15,5 +13,4 @@ export function getResource(path) {
15
13
  return { error: error instanceof Error ? error.message : String(error) };
16
14
  }
17
15
  }
18
- //# sourceMappingURL=getResource.js.map
19
- //# debugId=88504afd-5278-5cca-855f-d157fa96541e
16
+ //# sourceMappingURL=getResource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getResource.js","sources":["resources/getResource.ts"],"sourceRoot":"/","sourcesContent":["import { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { fromPackageRoot } from '../utils/getPaths.js';\nimport { logger } from '../logging/logger.js';\n\nexport function getResource(path: string): {\n content?: string;\n error?: string;\n} {\n try {\n const filePath = fromPackageRoot(join('resources', path));\n const content = readFileSync(filePath, 'utf-8');\n return { content };\n } catch (error) {\n logger.log(`Error reading resource ${path}: ${error}`);\n return { error: error instanceof Error ? error.message : String(error) };\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,UAAU,WAAW,CAAC,IAAY;IAItC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,GAAG,CAAC,0BAA0B,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;QACvD,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAC3E,CAAC;AACH,CAAC","debug_id":"88504afd-5278-5cca-855f-d157fa96541e"}
1
+ {"version":3,"file":"getResource.js","sourceRoot":"/","sources":["resources/getResource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,UAAU,WAAW,CAAC,IAAY;IAItC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,GAAG,CAAC,0BAA0B,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;QACvD,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAC3E,CAAC;AACH,CAAC","sourcesContent":["import { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { fromPackageRoot } from '../utils/getPaths.js';\nimport { logger } from '../logging/logger.js';\n\nexport function getResource(path: string): {\n content?: string;\n error?: string;\n} {\n try {\n const filePath = fromPackageRoot(join('resources', path));\n const content = readFileSync(filePath, 'utf-8');\n return { content };\n } catch (error) {\n logger.log(`Error reading resource ${path}: ${error}`);\n return { error: error instanceof Error ? error.message : String(error) };\n }\n}\n"]}
@@ -1,5 +1,3 @@
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]="f92d5871-6752-52e3-a0f3-16e4db1e84fc")}catch(e){}}();
3
1
  import { LocadexManager } from '../utils/locadexManager.js';
4
2
  import { logger } from '../logging/logger.js';
5
3
  import { exit } from '../utils/shutdown.js';
@@ -126,5 +124,4 @@ export async function runParallelProcessing(taskQueue, processor, context, optio
126
124
  agentInfo.agent.aggregateStats();
127
125
  });
128
126
  }
129
- //# sourceMappingURL=concurrency.js.map
130
- //# debugId=f92d5871-6752-52e3-a0f3-16e4db1e84fc
127
+ //# sourceMappingURL=concurrency.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"concurrency.js","sources":["tasks/concurrency.ts"],"sourceRoot":"/","sourcesContent":["import { LocadexManager } from '../utils/locadexManager.js';\nimport { logger } from '../logging/logger.js';\nimport { exit } from '../utils/shutdown.js';\nimport chalk from 'chalk';\nimport { outro } from '@clack/prompts';\n\n/**\n * Interface for defining how to process tasks in parallel.\n * Separates task preparation (preProcess) from result handling (postProcess).\n *\n * @template TTask - The type of individual tasks being processed\n * @template TContext - The type of shared context/configuration\n */\nexport interface TaskProcessor<TTask, TContext> {\n /**\n * Prepares tasks for processing and generates the prompt for the AI agent.\n * Called before each batch is sent to an agent.\n *\n * @param tasks - Batch of tasks to process\n * @param context - Shared context containing configuration and state\n * @returns Promise that resolves to the prompt string for the AI agent\n */\n preProcess: (tasks: TTask[], context: TContext) => Promise<string>;\n\n /**\n * Handles the results after the AI agent completes processing.\n * Called after each batch is successfully processed.\n *\n * @param tasks - The batch of tasks that were processed\n * @param context - Shared context containing configuration and state\n * @param agentReport - The report/output generated by the AI agent\n */\n postProcess: (\n tasks: TTask[],\n context: TContext,\n agentReport: string\n ) => Promise<void>;\n}\n\n/**\n * Configuration options for parallel processing behavior.\n */\nexport interface ParallelProcessingOptions {\n /** Number of concurrent agents to run in parallel */\n concurrency: number;\n /** Number of tasks to process in each batch */\n batchSize: number;\n}\n\n/**\n * Executes tasks in parallel using a pool of agents with proper concurrency control.\n *\n * This is a generic parallel processing framework that handles:\n * - Task queue management with thread-safe access\n * - Agent pool creation and lifecycle management\n * - Error handling and abort signal propagation\n * - Proper cleanup and resource management\n *\n * @template TTask - The type of tasks to process (e.g., string, object, etc.)\n * @template TContext - The type of context passed to the processor functions\n *\n * @param taskQueue - Array of tasks to process. Will be consumed (mutated) during processing.\n * @param processor - Object implementing preProcess and postProcess methods for task handling\n * @param context - Context object passed to processor methods, containing shared state/config\n * @param options - Configuration for parallel processing (concurrency level, batch size)\n *\n * @throws {Error} If processing fails or is aborted\n *\n * @example\n * ```typescript\n * const processor: TaskProcessor<string, { config: Config }> = {\n * preProcess: async (files, context) => generatePrompt(files, context.config),\n * postProcess: async (files, context, report) => handleResults(files, report)\n * };\n *\n * await runParallelProcessing(\n * ['file1.ts', 'file2.ts'],\n * processor,\n * { config: myConfig },\n * { concurrency: 3, batchSize: 2 }\n * );\n * ```\n */\nexport async function runParallelProcessing<TTask, TContext>(\n taskQueue: TTask[],\n processor: TaskProcessor<TTask, TContext>,\n context: TContext,\n options: ParallelProcessingOptions,\n maxRetries: number = 3\n): Promise<void> {\n const { concurrency, batchSize } = options;\n const manager = LocadexManager.getInstance();\n const agentAbortController = manager.getAgentAbortController();\n\n // Mutex for task queue access\n let taskQueueMutex = Promise.resolve();\n\n // Helper function to safely get tasks from queue\n const getNextTasks = async (batchSize: number): Promise<TTask[]> => {\n return new Promise((resolve) => {\n taskQueueMutex = taskQueueMutex.then(() => {\n const tasks = taskQueue.splice(0, batchSize);\n resolve(tasks);\n });\n });\n };\n\n const processTask = async (): Promise<void> => {\n while (taskQueue.length > 0 && !agentAbortController.signal.aborted) {\n // Check if we should abort early\n if (agentAbortController.signal.aborted) {\n return;\n }\n\n // Get an available agent atomically\n const agentInfo = await manager.getAvailableAgent();\n if (!agentInfo) {\n // No available agents, wait a bit (but check for abort)\n await new Promise((resolve) => {\n const timeout = global.setTimeout(resolve, 100);\n agentAbortController.signal.addEventListener('abort', () => {\n global.clearTimeout(timeout);\n resolve(undefined);\n });\n });\n continue;\n }\n\n const { id: agentId, agent } = agentInfo;\n\n // Get the next batch of tasks (thread-safe)\n const tasks = await getNextTasks(batchSize);\n if (tasks.length === 0) {\n manager.markAgentFree(agentId);\n break;\n }\n\n logger.debugMessage(`Using agent ${agentId} for ${tasks.length} tasks.`);\n\n // Process tasks using the provided processor\n try {\n // Pre-process: generate prompt\n const prompt = await processor.preProcess(tasks, context);\n\n // dynamic timeout based on the number of tasks\n const dynamicTimeoutSec = manager.getTimeoutFactor() * tasks.length;\n\n // Claude call with timeout and retry (handled inside agent.run)\n await agent.run(\n prompt,\n {\n timeoutSec: dynamicTimeoutSec,\n maxRetries,\n },\n {}\n );\n\n const agentReport = agent.generateReport();\n manager.markAgentFree(agentId);\n\n // Post-process: handle reports, progress, etc.\n await processor.postProcess(tasks, context, agentReport);\n } catch (error) {\n logger.debugMessage(`[${agentId}] error: ${error}`);\n throw error;\n }\n }\n };\n\n // Create agent pool with 100 (soft) turns cutoff\n manager.createAgentPool({ softTurnLimit: 100 });\n\n // Start parallel processing\n const processingPromises = Array.from({ length: concurrency }, () =>\n processTask()\n );\n\n try {\n await Promise.all(processingPromises);\n } catch (error) {\n manager.getAgentPool().forEach((agentInfo) => {\n agentInfo.agent.aggregateStats();\n });\n manager.stats.recordTelemetry(false); // do this after aggregateStats()\n\n // Check if this is a manual abort\n if (agentAbortController.signal.aborted) {\n return;\n }\n\n outro(\n chalk.red('❌ Locadex failed with error: ' + (error as Error).message)\n );\n await exit(1); // Exit the process\n }\n manager.getAgentPool().forEach((agentInfo) => {\n agentInfo.agent.aggregateStats();\n });\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAA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,KAAK,CAAC,GAAG,CAAC,+BAA+B,GAAI,KAAe,CAAC,OAAO,CAAC,CACtE,CAAC;QACF,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB;IACpC,CAAC;IACD,OAAO,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;QAC3C,SAAS,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { LocadexManager } from '../utils/locadexManager.js';\nimport { logger } from '../logging/logger.js';\nimport { exit } from '../utils/shutdown.js';\nimport chalk from 'chalk';\nimport { outro } from '@clack/prompts';\n\n/**\n * Interface for defining how to process tasks in parallel.\n * Separates task preparation (preProcess) from result handling (postProcess).\n *\n * @template TTask - The type of individual tasks being processed\n * @template TContext - The type of shared context/configuration\n */\nexport interface TaskProcessor<TTask, TContext> {\n /**\n * Prepares tasks for processing and generates the prompt for the AI agent.\n * Called before each batch is sent to an agent.\n *\n * @param tasks - Batch of tasks to process\n * @param context - Shared context containing configuration and state\n * @returns Promise that resolves to the prompt string for the AI agent\n */\n preProcess: (tasks: TTask[], context: TContext) => Promise<string>;\n\n /**\n * Handles the results after the AI agent completes processing.\n * Called after each batch is successfully processed.\n *\n * @param tasks - The batch of tasks that were processed\n * @param context - Shared context containing configuration and state\n * @param agentReport - The report/output generated by the AI agent\n */\n postProcess: (\n tasks: TTask[],\n context: TContext,\n agentReport: string\n ) => Promise<void>;\n}\n\n/**\n * Configuration options for parallel processing behavior.\n */\nexport interface ParallelProcessingOptions {\n /** Number of concurrent agents to run in parallel */\n concurrency: number;\n /** Number of tasks to process in each batch */\n batchSize: number;\n}\n\n/**\n * Executes tasks in parallel using a pool of agents with proper concurrency control.\n *\n * This is a generic parallel processing framework that handles:\n * - Task queue management with thread-safe access\n * - Agent pool creation and lifecycle management\n * - Error handling and abort signal propagation\n * - Proper cleanup and resource management\n *\n * @template TTask - The type of tasks to process (e.g., string, object, etc.)\n * @template TContext - The type of context passed to the processor functions\n *\n * @param taskQueue - Array of tasks to process. Will be consumed (mutated) during processing.\n * @param processor - Object implementing preProcess and postProcess methods for task handling\n * @param context - Context object passed to processor methods, containing shared state/config\n * @param options - Configuration for parallel processing (concurrency level, batch size)\n *\n * @throws {Error} If processing fails or is aborted\n *\n * @example\n * ```typescript\n * const processor: TaskProcessor<string, { config: Config }> = {\n * preProcess: async (files, context) => generatePrompt(files, context.config),\n * postProcess: async (files, context, report) => handleResults(files, report)\n * };\n *\n * await runParallelProcessing(\n * ['file1.ts', 'file2.ts'],\n * processor,\n * { config: myConfig },\n * { concurrency: 3, batchSize: 2 }\n * );\n * ```\n */\nexport async function runParallelProcessing<TTask, TContext>(\n taskQueue: TTask[],\n processor: TaskProcessor<TTask, TContext>,\n context: TContext,\n options: ParallelProcessingOptions,\n maxRetries: number = 3\n): Promise<void> {\n const { concurrency, batchSize } = options;\n const manager = LocadexManager.getInstance();\n const agentAbortController = manager.getAgentAbortController();\n\n // Mutex for task queue access\n let taskQueueMutex = Promise.resolve();\n\n // Helper function to safely get tasks from queue\n const getNextTasks = async (batchSize: number): Promise<TTask[]> => {\n return new Promise((resolve) => {\n taskQueueMutex = taskQueueMutex.then(() => {\n const tasks = taskQueue.splice(0, batchSize);\n resolve(tasks);\n });\n });\n };\n\n const processTask = async (): Promise<void> => {\n while (taskQueue.length > 0 && !agentAbortController.signal.aborted) {\n // Check if we should abort early\n if (agentAbortController.signal.aborted) {\n return;\n }\n\n // Get an available agent atomically\n const agentInfo = await manager.getAvailableAgent();\n if (!agentInfo) {\n // No available agents, wait a bit (but check for abort)\n await new Promise((resolve) => {\n const timeout = global.setTimeout(resolve, 100);\n agentAbortController.signal.addEventListener('abort', () => {\n global.clearTimeout(timeout);\n resolve(undefined);\n });\n });\n continue;\n }\n\n const { id: agentId, agent } = agentInfo;\n\n // Get the next batch of tasks (thread-safe)\n const tasks = await getNextTasks(batchSize);\n if (tasks.length === 0) {\n manager.markAgentFree(agentId);\n break;\n }\n\n logger.debugMessage(`Using agent ${agentId} for ${tasks.length} tasks.`);\n\n // Process tasks using the provided processor\n try {\n // Pre-process: generate prompt\n const prompt = await processor.preProcess(tasks, context);\n\n // dynamic timeout based on the number of tasks\n const dynamicTimeoutSec = manager.getTimeoutFactor() * tasks.length;\n\n // Claude call with timeout and retry (handled inside agent.run)\n await agent.run(\n prompt,\n {\n timeoutSec: dynamicTimeoutSec,\n maxRetries,\n },\n {}\n );\n\n const agentReport = agent.generateReport();\n manager.markAgentFree(agentId);\n\n // Post-process: handle reports, progress, etc.\n await processor.postProcess(tasks, context, agentReport);\n } catch (error) {\n logger.debugMessage(`[${agentId}] error: ${error}`);\n throw error;\n }\n }\n };\n\n // Create agent pool with 100 (soft) turns cutoff\n manager.createAgentPool({ softTurnLimit: 100 });\n\n // Start parallel processing\n const processingPromises = Array.from({ length: concurrency }, () =>\n processTask()\n );\n\n try {\n await Promise.all(processingPromises);\n } catch (error) {\n manager.getAgentPool().forEach((agentInfo) => {\n agentInfo.agent.aggregateStats();\n });\n manager.stats.recordTelemetry(false); // do this after aggregateStats()\n\n // Check if this is a manual abort\n if (agentAbortController.signal.aborted) {\n return;\n }\n\n outro(\n chalk.red('❌ Locadex failed with error: ' + (error as Error).message)\n );\n await exit(1); // Exit the process\n }\n manager.getAgentPool().forEach((agentInfo) => {\n agentInfo.agent.aggregateStats();\n });\n}\n"]}
@@ -1,5 +1,3 @@
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]="75d184a3-1343-57e6-abe7-ee95709748cf")}catch(e){}}();
3
1
  import { allMcpPromptFixErrors } from '../prompts/system.js';
4
2
  import { exit } from '../utils/shutdown.js';
5
3
  import { logger } from '../logging/logger.js';
@@ -79,5 +77,4 @@ ${allMcpPromptFixErrors}
79
77
  `;
80
78
  return prompt;
81
79
  }
82
- //# sourceMappingURL=fixErrors.js.map
83
- //# debugId=75d184a3-1343-57e6-abe7-ee95709748cf
80
+ //# sourceMappingURL=fixErrors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fixErrors.js","sources":["tasks/fixErrors.ts"],"sourceRoot":"/","sourcesContent":["import { allMcpPromptFixErrors } from '../prompts/system.js';\nimport { exit } from '../utils/shutdown.js';\nimport { logger } from '../logging/logger.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport { outro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { CLAUDE_CODE_VERSION } from '../utils/shared.js';\nimport { installGlobalPackage } from '../utils/packages/installPackage.js';\n\nexport async function fixErrorsTask() {\n const manager = LocadexManager.getInstance();\n const reports: string[] = [];\n // Install claude-code if not installed\n await installGlobalPackage('@anthropic-ai/claude-code', CLAUDE_CODE_VERSION);\n\n // Create a clean agent for cleanup\n const cleanupAgent = manager.createSingleAgent('claude_cleanup_agent', {});\n\n logger.initializeSpinner();\n logger.spinner.start('Fixing errors...');\n const fixPrompt = getFixPrompt(manager.appDirectory);\n try {\n await cleanupAgent.run(\n fixPrompt,\n {\n maxTurns: 200,\n timeoutSec: 300,\n maxRetries: 2,\n },\n {}\n );\n reports.push(`## Fixed errors\\n${cleanupAgent.generateReport()}`);\n } catch (error) {\n cleanupAgent.aggregateStats();\n logger.debugMessage(\n `[claude_cleanup_agent] Fixing errors failed: ${error}`\n );\n manager.stats.recordTelemetry(false);\n outro(chalk.red('❌ Locadex i18n failed!'));\n await exit(1);\n return;\n }\n cleanupAgent.aggregateStats();\n logger.spinner.stop('Fixed errors');\n return reports;\n}\n\n// check (dry run and ts check) should be at the end\n\nfunction getFixPrompt(appDirectory: string) {\n const prompt = `# Task: Fix internationalization errors in the project.\n\n## INSTRUCTIONS\n\nPreviously, you helped me internationalize a set of files in this project (app directory: \"${appDirectory}\").\nYour new task is to fix any errors that were introduced by your previous implementation.\nYou should only fix errors that the gt-next validator has identified.\n\n## Steps:\n1. Run the gt-next validator.\n2. Fix all errors output by the gt-next validator.\n3. Repeat steps 1-2 until there are no more errors, or until you believe that you have fixed all errors.\n\nTo run the gt-next validator, call the 'mcp__locadex__validate-project' tool.\n\n## RULES:\n- ONLY modify files that are relevant to the internationalization of the project.\n- ONLY fix errors that the gt-next validator has identified.\n- Resolve missing imports from 'gt-next'. If a file is missing an import from 'gt-next', add it.\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- NEVER move content to a different file. All content MUST remain in the same file where it came from.\n- NEVER CREATE OR DELETE ANY FILES (especially .bak files)\n- NEVER try running build commands (for example, 'next dev' or 'next build')\n\n## MCP TOOLS\n\n${allMcpPromptFixErrors}\n\n## Final output\n- When you are done, please return a brief summary of the files you modified, following this format.\n- **DO NOT** include any other text in your response. \n- If there were issues with some files, please include the issues in the list of changes for that file.\n\n[file 1 path]\n- List of changes to file 1\n`;\n\n return prompt;\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IAC7C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,uCAAuC;IACvC,MAAM,oBAAoB,CAAC,2BAA2B,EAAE,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,CAAC,cAAc,EAAE,CAAC;QAC9B,MAAM,CAAC,YAAY,CACjB,gDAAgD,KAAK,EAAE,CACxD,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,OAAO;IACT,CAAC;IACD,YAAY,CAAC,cAAc,EAAE,CAAC;IAC9B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,oDAAoD;AAEpD,SAAS,YAAY,CAAC,YAAoB;IACxC,MAAM,MAAM,GAAG;;;;6FAI4E,YAAY;;;;;;;;;;;;;;;;;;;;;;;EAuBvG,qBAAqB;;;;;;;;;CAStB,CAAC;IAEA,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { allMcpPromptFixErrors } from '../prompts/system.js';\nimport { exit } from '../utils/shutdown.js';\nimport { logger } from '../logging/logger.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport { outro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { CLAUDE_CODE_VERSION } from '../utils/shared.js';\nimport { installGlobalPackage } from '../utils/packages/installPackage.js';\n\nexport async function fixErrorsTask() {\n const manager = LocadexManager.getInstance();\n const reports: string[] = [];\n // Install claude-code if not installed\n await installGlobalPackage('@anthropic-ai/claude-code', CLAUDE_CODE_VERSION);\n\n // Create a clean agent for cleanup\n const cleanupAgent = manager.createSingleAgent('claude_cleanup_agent', {});\n\n logger.initializeSpinner();\n logger.spinner.start('Fixing errors...');\n const fixPrompt = getFixPrompt(manager.appDirectory);\n try {\n await cleanupAgent.run(\n fixPrompt,\n {\n maxTurns: 200,\n timeoutSec: 300,\n maxRetries: 2,\n },\n {}\n );\n reports.push(`## Fixed errors\\n${cleanupAgent.generateReport()}`);\n } catch (error) {\n cleanupAgent.aggregateStats();\n logger.debugMessage(\n `[claude_cleanup_agent] Fixing errors failed: ${error}`\n );\n manager.stats.recordTelemetry(false);\n outro(chalk.red('❌ Locadex i18n failed!'));\n await exit(1);\n return;\n }\n cleanupAgent.aggregateStats();\n logger.spinner.stop('Fixed errors');\n return reports;\n}\n\n// check (dry run and ts check) should be at the end\n\nfunction getFixPrompt(appDirectory: string) {\n const prompt = `# Task: Fix internationalization errors in the project.\n\n## INSTRUCTIONS\n\nPreviously, you helped me internationalize a set of files in this project (app directory: \"${appDirectory}\").\nYour new task is to fix any errors that were introduced by your previous implementation.\nYou should only fix errors that the gt-next validator has identified.\n\n## Steps:\n1. Run the gt-next validator.\n2. Fix all errors output by the gt-next validator.\n3. Repeat steps 1-2 until there are no more errors, or until you believe that you have fixed all errors.\n\nTo run the gt-next validator, call the 'mcp__locadex__validate-project' tool.\n\n## RULES:\n- ONLY modify files that are relevant to the internationalization of the project.\n- ONLY fix errors that the gt-next validator has identified.\n- Resolve missing imports from 'gt-next'. If a file is missing an import from 'gt-next', add it.\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- NEVER move content to a different file. All content MUST remain in the same file where it came from.\n- NEVER CREATE OR DELETE ANY FILES (especially .bak files)\n- NEVER try running build commands (for example, 'next dev' or 'next build')\n\n## MCP TOOLS\n\n${allMcpPromptFixErrors}\n\n## Final output\n- When you are done, please return a brief summary of the files you modified, following this format.\n- **DO NOT** include any other text in your response. \n- If there were issues with some files, please include the issues in the list of changes for that file.\n\n[file 1 path]\n- List of changes to file 1\n`;\n\n return prompt;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"/","sources":["tasks/i18n.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,UAAU,EAAE,UAAU,iBAyOpD"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"/","sources":["tasks/i18n.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,UAAU,EAAE,UAAU,iBAsOpD"}
@@ -1,5 +1,3 @@
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]="d655e317-abac-5345-8a2c-ea1e6a0ca6f0")}catch(e){}}();
3
1
  import { createSpinner } from '../logging/console.js';
4
2
  import { allMcpPrompt } from '../prompts/system.js';
5
3
  import { exit } from '../utils/shutdown.js';
@@ -12,7 +10,7 @@ import chalk from 'chalk';
12
10
  import { appendFileSync } from 'node:fs';
13
11
  import { detectFormatter, formatFiles } from 'gtx-cli/hooks/postProcess';
14
12
  import path from 'node:path';
15
- import { updateLockfile, cleanupLockfile } from '../utils/lockfile.js';
13
+ import { updateLockfile } from '../utils/lockfile.js';
16
14
  import { extractFiles } from '../utils/dag/extractFiles.js';
17
15
  import { getPackageJson, isPackageInstalled } from 'gtx-cli/utils/packageJson';
18
16
  import { deleteAddedFiles } from '../utils/fs/git.js';
@@ -145,11 +143,9 @@ ${reports.join('\n')}`;
145
143
  }
146
144
  const lockfilePath = manager.getLockFilePath();
147
145
  // Delete any files the AI may have arbitrarily created
148
- deleteAddedFiles([path.relative(manager.rootDirectory, manager.locadexDirectory)], ['dictionary.json', 'gt.config.json', 'locadex.yml']);
146
+ deleteAddedFiles([path.relative(manager.rootDirectory, manager.locadexDirectory)], ['dictionary.json', 'gt.config.json', 'locadex.yml', 'loadTranslations.js']);
149
147
  // Update lockfile with processed files
150
148
  updateLockfile(files, lockfilePath, manager.rootDirectory);
151
- // Clean up stale entries from lockfile
152
- cleanupLockfile(lockfilePath, manager.rootDirectory);
153
149
  logger.message(chalk.dim(`Updated lockfile with ${files.length} files`));
154
150
  cleanupOnExit();
155
151
  // Run translate cmd
@@ -255,5 +251,4 @@ ${allMcpPrompt}
255
251
  `;
256
252
  return prompt;
257
253
  }
258
- //# sourceMappingURL=i18n.js.map
259
- //# debugId=d655e317-abac-5345-8a2c-ea1e6a0ca6f0
254
+ //# sourceMappingURL=i18n.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","sources":["tasks/i18n.ts"],"sourceRoot":"/","sourcesContent":["import { createSpinner } from '../logging/console.js';\nimport { allMcpPrompt } from '../prompts/system.js';\nimport { exit } from '../utils/shutdown.js';\nimport { logger } from '../logging/logger.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport {\n addFilesToManager,\n markFileAsEdited,\n markFileAsInProgress,\n} from '../utils/dag/getFiles.js';\nimport { runParallelProcessing, TaskProcessor } from './concurrency.js';\nimport { outro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { appendFileSync } from 'node:fs';\nimport { detectFormatter, formatFiles } from 'gtx-cli/hooks/postProcess';\nimport path from 'node:path';\nimport { updateLockfile, cleanupLockfile } from '../utils/lockfile.js';\nimport { extractFiles } from '../utils/dag/extractFiles.js';\nimport { Dag } from '../utils/dag/createDag.js';\nimport { getPackageJson, isPackageInstalled } from 'gtx-cli/utils/packageJson';\nimport { deleteAddedFiles } from '../utils/fs/git.js';\nimport { CLAUDE_CODE_VERSION } from '../utils/shared.js';\nimport { installGlobalPackage } from '../utils/packages/installPackage.js';\nimport { fixErrorsTask } from './fixErrors.js';\nimport { getLocadexVersion } from '../utils/getPaths.js';\nimport { execFunction } from '../utils/exec.js';\nimport { isGTAuthConfigured } from '../utils/config.js';\nimport { CliOptions } from '../types/cli.js';\n\n/**\n * Run Locadex i18n on the project\n * This task requires no human intervention and is safe to run in CI/CD pipelines.\n */\nexport async function i18nTask(cliOptions: CliOptions) {\n const manager = LocadexManager.getInstance();\n // have to use the package.json from the appDir\n const packageJson = await getPackageJson(manager.appDirectory);\n const isUsingGTNext = packageJson\n ? isPackageInstalled('gt-next', packageJson)\n : false;\n if (!isUsingGTNext) {\n logger.error(\n `gt-next not detected in ${manager.appDirectory}. Please specify the correct app directory with the --app-dir flag, or ensure that gt-next is correctly installed in the project.`\n );\n await exit(1);\n }\n\n // Install claude-code if not installed\n await installGlobalPackage('@anthropic-ai/claude-code', CLAUDE_CODE_VERSION);\n // Install locadex if not installed\n await installGlobalPackage('locadex', getLocadexVersion());\n\n logger.debugMessage('App directory: ' + manager.appDirectory);\n logger.debugMessage('Root directory: ' + manager.rootDirectory);\n\n // Init message\n const spinner = createSpinner();\n spinner.start('Initializing Locadex...');\n\n const { files, dag } = extractFiles(manager);\n\n if (files.length === 0) {\n spinner.stop('No files have changed since last run');\n outro(chalk.green('✅ Locadex i18n complete - no changes detected!'));\n await exit(0);\n }\n\n const filesStateFilePath = manager.getFilesStateFilePath();\n const concurrency = manager.getMaxConcurrency();\n const batchSize = manager.getBatchSize();\n\n // Create the list of files (aka tasks) to process\n const taskQueue = Array.from(files);\n\n // Add files to manager\n const stateFilePath = addFilesToManager(filesStateFilePath, taskQueue);\n spinner.stop('Locadex initialized');\n\n logger.verboseMessage(`Processing ${files.length} modified files`);\n logger.debugMessage(`Track progress here: ${stateFilePath}`);\n logger.debugMessage(`Order:\\n${taskQueue.join('\\n')}`);\n\n logger.message(`Using ${concurrency} concurrent agents`);\n logger.initializeProgressBar(taskQueue.length);\n\n const fileProcessingStartTime = Date.now();\n logger.progressBar.start(`Processing ${taskQueue.length} files...`);\n\n // Shared reports array for collecting results\n const reports: string[] = [];\n\n // Create i18n task processor\n const i18nProcessor: TaskProcessor<\n string,\n {\n dag: Dag;\n files: string[];\n filesStateFilePath: string;\n }\n > = {\n preProcess: async (files, context) => {\n const { dag, filesStateFilePath } = context;\n logger.debugMessage(`Files: ${files.join(', ')}`);\n // Mark tasks as in progress\n await Promise.all(\n files.map((file) => markFileAsInProgress(file, filesStateFilePath))\n );\n\n // Construct prompt\n const dependencies = Object.fromEntries(\n files.map((file) => [\n file,\n Array.from(new Set(dag.getDependencies(file))).map(String),\n ])\n );\n const dependents = Object.fromEntries(\n files.map((file) => [\n file,\n Array.from(new Set(dag.getDependents(file))).map(String),\n ])\n );\n\n return getPrompt({\n targetFile: files,\n dependencyFiles: dependencies,\n dependentFiles: dependents,\n });\n },\n postProcess: async (processedFiles, context, agentReport) => {\n const { filesStateFilePath } = context;\n\n // Mark tasks as complete\n await Promise.all(\n processedFiles.map((file) => markFileAsEdited(file, filesStateFilePath))\n );\n\n // Add agent report\n reports.push(agentReport);\n\n // Update stats\n manager.stats.updateStats({\n newProcessedFiles: processedFiles.length,\n });\n\n // Update progress bar\n logger.progressBar.advance(\n processedFiles.length,\n `Processed ${Number((manager.stats.getStats().processedFiles / files.length) * 100).toFixed(2)}% of files`\n );\n },\n };\n\n // Run parallel processing\n await runParallelProcessing(\n Array.from(taskQueue),\n i18nProcessor,\n { dag, files, filesStateFilePath },\n {\n concurrency,\n batchSize,\n },\n 3\n );\n\n if (manager.isAborted()) {\n cleanupOnExit();\n await exit(1);\n return;\n }\n\n logger.progressBar.stop(\n `Processed ${files.length} files [${Math.round(\n (Date.now() - fileProcessingStartTime) / 1000\n )}s]`\n );\n\n const cleanupReports = await fixErrorsTask();\n if (cleanupReports) {\n reports.push(...cleanupReports);\n }\n\n // Generate report\n const reportSummary = `# Summary of locadex i18n changes\n${reports.join('\\n')}`;\n const summaryFilePath = path.join(\n manager.getLogDirectory(),\n 'locadex-report.md'\n );\n appendFileSync(summaryFilePath, reportSummary);\n logger.step(`Saved summary of changes to: ${summaryFilePath}`);\n\n // cleanup\n if (cliOptions.formatCmd) {\n const { stderr, code } = await execFunction(\n cliOptions.formatCmd,\n [],\n false,\n manager.appDirectory,\n manager.getAgentAbortController()\n );\n if (code !== 0) {\n logger.error(`Error running '${cliOptions.formatCmd}': ${stderr}`);\n } else {\n logger.step(\n `Formatted ${files.length} files with ${cliOptions.formatCmd}`\n );\n }\n } else {\n const formatter = await detectFormatter();\n if (formatter && files.length > 0) {\n await formatFiles(files, formatter);\n logger.log(`Formatted ${files.length} files with ${formatter}`);\n }\n }\n\n const lockfilePath = manager.getLockFilePath();\n\n // Delete any files the AI may have arbitrarily created\n deleteAddedFiles(\n [path.relative(manager.rootDirectory, manager.locadexDirectory)],\n ['dictionary.json', 'gt.config.json', 'locadex.yml']\n );\n\n // Update lockfile with processed files\n updateLockfile(files, lockfilePath, manager.rootDirectory);\n\n // Clean up stale entries from lockfile\n cleanupLockfile(lockfilePath, manager.rootDirectory);\n\n logger.message(chalk.dim(`Updated lockfile with ${files.length} files`));\n\n cleanupOnExit();\n\n // Run translate cmd\n if (isGTAuthConfigured(manager.appDirectory) && !cliOptions.noTranslate) {\n try {\n logger.initializeSpinner();\n logger.spinner.start('Running locadex translate...');\n const { stderr, code } = await execFunction(\n 'locadex',\n ['translate'],\n false,\n manager.appDirectory,\n manager.getAgentAbortController()\n );\n if (code !== 0) {\n logger.spinner.stop('Translations failed!');\n logger.error(`Error running 'locadex translate': ${stderr}`);\n } else {\n logger.spinner.stop('Translations generated!');\n logger.log(`Translations generated with 'locadex translate'`);\n }\n } catch (error) {\n logger.spinner.stop('Translations failed!');\n logger.error(\n `Error running 'locadex translate': ${(error as Error).message}`\n );\n }\n } else {\n logger.step(\n `No GT_API_KEY or GT_PROJECT_ID found. Skipping translation step...`\n );\n }\n\n outro(chalk.green('✅ Locadex i18n complete!'));\n await exit(0);\n}\n\nfunction cleanupOnExit() {\n const manager = LocadexManager.getInstance();\n logger.info(\n chalk.dim(\n `Locadex Cost: $${manager.stats.getStats().totalCost.toFixed(2)}\nLocadex wall time: ${Math.round(\n (Date.now() - manager.stats.getStats().startTime) / 1000\n )}s\nLocadex files processed: ${manager.stats.getStats().processedFiles}`\n )\n );\n\n const finalStats = manager.stats.getStats();\n\n // Record telemetry for final stats\n manager.stats.recordTelemetry(true);\n\n logger.verboseMessage(\n `Locadex input tokens: ${finalStats.inputTokens}\nLocadex cached input tokens: ${finalStats.cachedInputTokens}\nLocadex output tokens: ${finalStats.outputTokens}\nLocadex turns: ${finalStats.turns}`\n );\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 \n - You do not have to read the dependency/dependent files for each target file. They are provided for convenience.\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. Is the content that needs to be i18ned being used in this same file, or is it being used in another file?\n - 3.b. Is there any string interpolation that needs to be i18ned?\n - 3.c. Is there any conditional logic or rendering that needs to be i18ned?\n - 3.d. 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 run validation checks such as tsc. We will do that later.\n\n## RULES:\n- ALWAYS use the <T> component to internationalize HTML/JSX content.\n- ALWAYS use useGT() or useTranslations() to internationalize string content (strings created with '', \"\", or \\`\\`).\n - When possible, avoid using useTranslations(); useGT() is always 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- 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 all user facing content in the target files. \n- NEVER move content to a different file. All content MUST remain in the same file where it came from.\n- NEVER CREATE OR DELETE ANY FILES (especially .bak 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## Final output\n- When you are done, please return a brief summary of the files you modified, following this format.\n- **DO NOT** include any other text in your response. \n- If there were issues with some files, please include the issues in the list of changes for that file.\n\n[file 1 path]\n- List of changes to file 1\n`;\n\n return prompt;\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAiB,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,IAAI,MAAM,W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E5C,mCAAmC;IACnC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAEpC,MAAM,CAAC,cAAc,CACnB,yBAAyB,UAAU,CAAC,WAAW;+BACpB,UAAU,CAAC,iBAAiB;yBAClC,UAAU,CAAC,YAAY;iBAC/B,UAAU,CAAC,KAAK,EAAE,CAChC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,EACjB,UAAU,EACV,eAAe,EACf,cAAc,GAKf;IACC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCf,UAAU,CAAC,GAAG,CACd,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;cACL,KAAK,GAAG,CAAC;EACrB,IAAI;;kDAE4C,KAAK,GAAG,CAAC;EACzD,eAAe,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM;;iDAEnC,KAAK,GAAG,CAAC;EACxD,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM;CACjF,CACA;;;;;;EAMC,YAAY;;;;;;;;;CASb,CAAC;IAEA,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createSpinner } from '../logging/console.js';\nimport { allMcpPrompt } from '../prompts/system.js';\nimport { exit } from '../utils/shutdown.js';\nimport { logger } from '../logging/logger.js';\nimport { LocadexManager } from '../utils/locadexManager.js';\nimport {\n addFilesToManager,\n markFileAsEdited,\n markFileAsInProgress,\n} from '../utils/dag/getFiles.js';\nimport { runParallelProcessing, TaskProcessor } from './concurrency.js';\nimport { outro } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { appendFileSync } from 'node:fs';\nimport { detectFormatter, formatFiles } from 'gtx-cli/hooks/postProcess';\nimport path from 'node:path';\nimport { updateLockfile } from '../utils/lockfile.js';\nimport { extractFiles } from '../utils/dag/extractFiles.js';\nimport { Dag } from '../utils/dag/createDag.js';\nimport { getPackageJson, isPackageInstalled } from 'gtx-cli/utils/packageJson';\nimport { deleteAddedFiles } from '../utils/fs/git.js';\nimport { CLAUDE_CODE_VERSION } from '../utils/shared.js';\nimport { installGlobalPackage } from '../utils/packages/installPackage.js';\nimport { fixErrorsTask } from './fixErrors.js';\nimport { getLocadexVersion } from '../utils/getPaths.js';\nimport { execFunction } from '../utils/exec.js';\nimport { isGTAuthConfigured } from '../utils/config.js';\nimport { CliOptions } from '../types/cli.js';\n\n/**\n * Run Locadex i18n on the project\n * This task requires no human intervention and is safe to run in CI/CD pipelines.\n */\nexport async function i18nTask(cliOptions: CliOptions) {\n const manager = LocadexManager.getInstance();\n // have to use the package.json from the appDir\n const packageJson = await getPackageJson(manager.appDirectory);\n const isUsingGTNext = packageJson\n ? isPackageInstalled('gt-next', packageJson)\n : false;\n if (!isUsingGTNext) {\n logger.error(\n `gt-next not detected in ${manager.appDirectory}. Please specify the correct app directory with the --app-dir flag, or ensure that gt-next is correctly installed in the project.`\n );\n await exit(1);\n }\n\n // Install claude-code if not installed\n await installGlobalPackage('@anthropic-ai/claude-code', CLAUDE_CODE_VERSION);\n // Install locadex if not installed\n await installGlobalPackage('locadex', getLocadexVersion());\n\n logger.debugMessage('App directory: ' + manager.appDirectory);\n logger.debugMessage('Root directory: ' + manager.rootDirectory);\n\n // Init message\n const spinner = createSpinner();\n spinner.start('Initializing Locadex...');\n\n const { files, dag } = extractFiles(manager);\n\n if (files.length === 0) {\n spinner.stop('No files have changed since last run');\n outro(chalk.green('✅ Locadex i18n complete - no changes detected!'));\n await exit(0);\n }\n\n const filesStateFilePath = manager.getFilesStateFilePath();\n const concurrency = manager.getMaxConcurrency();\n const batchSize = manager.getBatchSize();\n\n // Create the list of files (aka tasks) to process\n const taskQueue = Array.from(files);\n\n // Add files to manager\n const stateFilePath = addFilesToManager(filesStateFilePath, taskQueue);\n spinner.stop('Locadex initialized');\n\n logger.verboseMessage(`Processing ${files.length} modified files`);\n logger.debugMessage(`Track progress here: ${stateFilePath}`);\n logger.debugMessage(`Order:\\n${taskQueue.join('\\n')}`);\n\n logger.message(`Using ${concurrency} concurrent agents`);\n logger.initializeProgressBar(taskQueue.length);\n\n const fileProcessingStartTime = Date.now();\n logger.progressBar.start(`Processing ${taskQueue.length} files...`);\n\n // Shared reports array for collecting results\n const reports: string[] = [];\n\n // Create i18n task processor\n const i18nProcessor: TaskProcessor<\n string,\n {\n dag: Dag;\n files: string[];\n filesStateFilePath: string;\n }\n > = {\n preProcess: async (files, context) => {\n const { dag, filesStateFilePath } = context;\n logger.debugMessage(`Files: ${files.join(', ')}`);\n // Mark tasks as in progress\n await Promise.all(\n files.map((file) => markFileAsInProgress(file, filesStateFilePath))\n );\n\n // Construct prompt\n const dependencies = Object.fromEntries(\n files.map((file) => [\n file,\n Array.from(new Set(dag.getDependencies(file))).map(String),\n ])\n );\n const dependents = Object.fromEntries(\n files.map((file) => [\n file,\n Array.from(new Set(dag.getDependents(file))).map(String),\n ])\n );\n\n return getPrompt({\n targetFile: files,\n dependencyFiles: dependencies,\n dependentFiles: dependents,\n });\n },\n postProcess: async (processedFiles, context, agentReport) => {\n const { filesStateFilePath } = context;\n\n // Mark tasks as complete\n await Promise.all(\n processedFiles.map((file) => markFileAsEdited(file, filesStateFilePath))\n );\n\n // Add agent report\n reports.push(agentReport);\n\n // Update stats\n manager.stats.updateStats({\n newProcessedFiles: processedFiles.length,\n });\n\n // Update progress bar\n logger.progressBar.advance(\n processedFiles.length,\n `Processed ${Number((manager.stats.getStats().processedFiles / files.length) * 100).toFixed(2)}% of files`\n );\n },\n };\n\n // Run parallel processing\n await runParallelProcessing(\n Array.from(taskQueue),\n i18nProcessor,\n { dag, files, filesStateFilePath },\n {\n concurrency,\n batchSize,\n },\n 3\n );\n\n if (manager.isAborted()) {\n cleanupOnExit();\n await exit(1);\n return;\n }\n\n logger.progressBar.stop(\n `Processed ${files.length} files [${Math.round(\n (Date.now() - fileProcessingStartTime) / 1000\n )}s]`\n );\n\n const cleanupReports = await fixErrorsTask();\n if (cleanupReports) {\n reports.push(...cleanupReports);\n }\n\n // Generate report\n const reportSummary = `# Summary of locadex i18n changes\n${reports.join('\\n')}`;\n const summaryFilePath = path.join(\n manager.getLogDirectory(),\n 'locadex-report.md'\n );\n appendFileSync(summaryFilePath, reportSummary);\n logger.step(`Saved summary of changes to: ${summaryFilePath}`);\n\n // cleanup\n if (cliOptions.formatCmd) {\n const { stderr, code } = await execFunction(\n cliOptions.formatCmd,\n [],\n false,\n manager.appDirectory,\n manager.getAgentAbortController()\n );\n if (code !== 0) {\n logger.error(`Error running '${cliOptions.formatCmd}': ${stderr}`);\n } else {\n logger.step(\n `Formatted ${files.length} files with ${cliOptions.formatCmd}`\n );\n }\n } else {\n const formatter = await detectFormatter();\n if (formatter && files.length > 0) {\n await formatFiles(files, formatter);\n logger.log(`Formatted ${files.length} files with ${formatter}`);\n }\n }\n\n const lockfilePath = manager.getLockFilePath();\n\n // Delete any files the AI may have arbitrarily created\n deleteAddedFiles(\n [path.relative(manager.rootDirectory, manager.locadexDirectory)],\n ['dictionary.json', 'gt.config.json', 'locadex.yml', 'loadTranslations.js']\n );\n\n // Update lockfile with processed files\n updateLockfile(files, lockfilePath, manager.rootDirectory);\n\n logger.message(chalk.dim(`Updated lockfile with ${files.length} files`));\n\n cleanupOnExit();\n\n // Run translate cmd\n if (isGTAuthConfigured(manager.appDirectory) && !cliOptions.noTranslate) {\n try {\n logger.initializeSpinner();\n logger.spinner.start('Running locadex translate...');\n const { stderr, code } = await execFunction(\n 'locadex',\n ['translate'],\n false,\n manager.appDirectory,\n manager.getAgentAbortController()\n );\n if (code !== 0) {\n logger.spinner.stop('Translations failed!');\n logger.error(`Error running 'locadex translate': ${stderr}`);\n } else {\n logger.spinner.stop('Translations generated!');\n logger.log(`Translations generated with 'locadex translate'`);\n }\n } catch (error) {\n logger.spinner.stop('Translations failed!');\n logger.error(\n `Error running 'locadex translate': ${(error as Error).message}`\n );\n }\n } else {\n logger.step(\n `No GT_API_KEY or GT_PROJECT_ID found. Skipping translation step...`\n );\n }\n\n outro(chalk.green('✅ Locadex i18n complete!'));\n await exit(0);\n}\n\nfunction cleanupOnExit() {\n const manager = LocadexManager.getInstance();\n logger.info(\n chalk.dim(\n `Locadex Cost: $${manager.stats.getStats().totalCost.toFixed(2)}\nLocadex wall time: ${Math.round(\n (Date.now() - manager.stats.getStats().startTime) / 1000\n )}s\nLocadex files processed: ${manager.stats.getStats().processedFiles}`\n )\n );\n\n const finalStats = manager.stats.getStats();\n\n // Record telemetry for final stats\n manager.stats.recordTelemetry(true);\n\n logger.verboseMessage(\n `Locadex input tokens: ${finalStats.inputTokens}\nLocadex cached input tokens: ${finalStats.cachedInputTokens}\nLocadex output tokens: ${finalStats.outputTokens}\nLocadex turns: ${finalStats.turns}`\n );\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 \n - You do not have to read the dependency/dependent files for each target file. They are provided for convenience.\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. Is the content that needs to be i18ned being used in this same file, or is it being used in another file?\n - 3.b. Is there any string interpolation that needs to be i18ned?\n - 3.c. Is there any conditional logic or rendering that needs to be i18ned?\n - 3.d. 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 run validation checks such as tsc. We will do that later.\n\n## RULES:\n- ALWAYS use the <T> component to internationalize HTML/JSX content.\n- ALWAYS use useGT() or useTranslations() to internationalize string content (strings created with '', \"\", or \\`\\`).\n - When possible, avoid using useTranslations(); useGT() is always 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- 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 all user facing content in the target files. \n- NEVER move content to a different file. All content MUST remain in the same file where it came from.\n- NEVER CREATE OR DELETE ANY FILES (especially .bak 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## Final output\n- When you are done, please return a brief summary of the files you modified, following this format.\n- **DO NOT** include any other text in your response. \n- If there were issues with some files, please include the issues in the list of changes for that file.\n\n[file 1 path]\n- List of changes to file 1\n`;\n\n return prompt;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"/","sources":["tasks/setup.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,OAAO,EACtB,uBAAuB,CAAC,EAAE,MAAM,iBA2JjC"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"/","sources":["tasks/setup.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,OAAO,EACtB,uBAAuB,CAAC,EAAE,MAAM,iBA2KjC"}
@@ -1,5 +1,3 @@
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]="da80142d-3899-5af8-abcc-7e9163fff826")}catch(e){}}();
3
1
  import { createSpinner, promptConfirm } from '../logging/console.js';
4
2
  import { getPackageJson, isPackageInstalled } from 'gtx-cli/utils/packageJson';
5
3
  import { getPackageManager, } from 'gtx-cli/utils/packageManager';
@@ -91,12 +89,25 @@ export async function setupTask(cliOptions, autoSetup, bypassPrompts, specifiedP
91
89
  await handleInitGT(nextConfigPath, errors, warnings, filesUpdated);
92
90
  logger.step(`Added withGTConfig() to your ${nextConfigPath} file.`);
93
91
  // Create gt.config.json
94
- await createOrUpdateConfig(path.resolve(manager.appDirectory, 'gt.config.json'), {
92
+ const gtConfig = {
95
93
  defaultLocale: 'en',
96
94
  locales: ['es', 'fr', 'de', 'ja', 'zh'],
97
95
  framework: 'next-app',
98
- });
96
+ };
97
+ // Add local translations config if flag is set
98
+ if (manager.getCliOptions().localTranslations) {
99
+ gtConfig.files = {
100
+ gt: {
101
+ output: 'public/_gt/[locale].json',
102
+ },
103
+ };
104
+ }
105
+ await createOrUpdateConfig(path.resolve(manager.appDirectory, 'gt.config.json'), gtConfig);
99
106
  logger.success(`Feel free to edit ${chalk.cyan('gt.config.json')} to customize your translation setup. Docs: https://generaltranslation.com/docs/cli/reference/config`);
107
+ // Create loadTranslations file if local translations flag is set
108
+ if (manager.getCliOptions().localTranslations) {
109
+ await createLoadTranslationsFile(manager.appDirectory);
110
+ }
100
111
  // Add translate to scripts
101
112
  // Re-get the package.json to make sure it's updated
102
113
  appPackageJson = await getPackageJson(manager.appDirectory);
@@ -205,6 +216,33 @@ ${report}`;
205
216
  agent.aggregateStats();
206
217
  logger.spinner.stop('Locale selector setup complete');
207
218
  }
219
+ async function createLoadTranslationsFile(appDirectory) {
220
+ const usingSrcDirectory = existsSync(path.join(appDirectory, 'src'));
221
+ const publicPath = usingSrcDirectory ? '../public/_gt/' : './public/_gt/';
222
+ const filePath = usingSrcDirectory
223
+ ? path.join(appDirectory, 'src', 'loadTranslations.js')
224
+ : path.join(appDirectory, 'loadTranslations.js');
225
+ if (!existsSync(filePath)) {
226
+ const loadTranslationsContent = `
227
+ export default async function loadTranslations(locale) {
228
+ try {
229
+ // Load translations from public/_gt directory
230
+ // This matches the GT config files.gt.output path
231
+ const t = await import(\`${publicPath}\${locale}.json\`);
232
+ return t.default;
233
+ } catch (error) {
234
+ console.warn(\`Failed to load translations for locale \${locale}:\`, error);
235
+ return {};
236
+ }
237
+ }
238
+ `;
239
+ writeFileSync(filePath, loadTranslationsContent);
240
+ logger.step(`Created ${chalk.cyan('loadTranslations.js')} file at ${chalk.cyan(filePath)}.`);
241
+ }
242
+ else {
243
+ logger.step(`Found ${chalk.cyan('loadTranslations.js')} file at ${chalk.cyan(filePath)}. Skipping creation...`);
244
+ }
245
+ }
208
246
  function getLocaleSelectorPrompt(appDirectory) {
209
247
  const prompt = `# Task: Add a locale selector to the app
210
248
 
@@ -240,5 +278,4 @@ function MyComponent() {
240
278
  `;
241
279
  return prompt;
242
280
  }
243
- //# sourceMappingURL=setup.js.map
244
- //# debugId=da80142d-3899-5af8-abcc-7e9163fff826
281
+ //# sourceMappingURL=setup.js.map