@intlayer/cli 7.5.0-canary.1 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/IntlayerEventListener.cjs +8 -8
- package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
- package/dist/cjs/auth/login.cjs +16 -16
- package/dist/cjs/auth/login.cjs.map +1 -1
- package/dist/cjs/build.cjs +5 -5
- package/dist/cjs/build.cjs.map +1 -1
- package/dist/cjs/cli.cjs +3 -3
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +3 -3
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/editor.cjs +2 -2
- package/dist/cjs/editor.cjs.map +1 -1
- package/dist/cjs/fill/fill.cjs +12 -12
- package/dist/cjs/fill/fill.cjs.map +1 -1
- package/dist/cjs/fill/listTranslationsTasks.cjs +15 -15
- package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
- package/dist/cjs/fill/translateDictionary.cjs +36 -36
- package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
- package/dist/cjs/fill/writeFill.cjs +11 -11
- package/dist/cjs/fill/writeFill.cjs.map +1 -1
- package/dist/cjs/getTargetDictionary.cjs +6 -6
- package/dist/cjs/getTargetDictionary.cjs.map +1 -1
- package/dist/cjs/listContentDeclaration.cjs +9 -9
- package/dist/cjs/listContentDeclaration.cjs.map +1 -1
- package/dist/cjs/liveSync.cjs +16 -16
- package/dist/cjs/liveSync.cjs.map +1 -1
- package/dist/cjs/pull.cjs +14 -14
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push/pullLog.cjs +6 -6
- package/dist/cjs/push/pullLog.cjs.map +1 -1
- package/dist/cjs/push/push.cjs +23 -23
- package/dist/cjs/push/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +5 -5
- package/dist/cjs/pushConfig.cjs.map +1 -1
- package/dist/cjs/pushLog.cjs +6 -6
- package/dist/cjs/pushLog.cjs.map +1 -1
- package/dist/cjs/reviewDoc.cjs +13 -13
- package/dist/cjs/reviewDoc.cjs.map +1 -1
- package/dist/cjs/reviewDocBlockAware.cjs +19 -19
- package/dist/cjs/reviewDocBlockAware.cjs.map +1 -1
- package/dist/cjs/test/listMissingTranslations.cjs +9 -9
- package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
- package/dist/cjs/test/test.cjs +22 -22
- package/dist/cjs/test/test.cjs.map +1 -1
- package/dist/cjs/transform.cjs +8 -8
- package/dist/cjs/transform.cjs.map +1 -1
- package/dist/cjs/translateDoc.cjs +29 -29
- package/dist/cjs/translateDoc.cjs.map +1 -1
- package/dist/cjs/utils/calculateChunks.cjs +4 -4
- package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
- package/dist/cjs/utils/checkAccess.cjs +13 -13
- package/dist/cjs/utils/checkAccess.cjs.map +1 -1
- package/dist/cjs/utils/chunkInference.cjs +4 -4
- package/dist/cjs/utils/chunkInference.cjs.map +1 -1
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs +4 -4
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
- package/dist/cjs/utils/setupAI.cjs +5 -5
- package/dist/cjs/utils/setupAI.cjs.map +1 -1
- package/dist/cjs/watch.cjs +26 -5
- package/dist/cjs/watch.cjs.map +1 -1
- package/dist/esm/auth/login.mjs +1 -1
- package/dist/esm/auth/login.mjs.map +1 -1
- package/dist/esm/watch.mjs +23 -2
- package/dist/esm/watch.mjs.map +1 -1
- package/dist/types/pull.d.ts.map +1 -1
- package/package.json +12 -12
|
@@ -6,8 +6,8 @@ const require_utils_fixChunkStartEndChars = require('./utils/fixChunkStartEndCha
|
|
|
6
6
|
const require_utils_checkFileModifiedRange = require('./utils/checkFileModifiedRange.cjs');
|
|
7
7
|
const require_utils_getOutputFilePath = require('./utils/getOutputFilePath.cjs');
|
|
8
8
|
const require_utils_calculateChunks = require('./utils/calculateChunks.cjs');
|
|
9
|
-
let
|
|
10
|
-
let
|
|
9
|
+
let _intlayer_chokidar = require("@intlayer/chokidar");
|
|
10
|
+
let _intlayer_config = require("@intlayer/config");
|
|
11
11
|
let node_path = require("node:path");
|
|
12
12
|
let node_fs = require("node:fs");
|
|
13
13
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -20,20 +20,20 @@ fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
|
20
20
|
*/
|
|
21
21
|
const translateFile = async (baseFilePath, outputFilePath, locale, baseLocale, configuration, aiOptions, customInstructions, aiClient, aiConfig) => {
|
|
22
22
|
try {
|
|
23
|
-
const appLogger = (0,
|
|
23
|
+
const appLogger = (0, _intlayer_config.getAppLogger)(configuration, { config: { prefix: "" } });
|
|
24
24
|
const fileContent = await (0, node_fs_promises.readFile)(baseFilePath, "utf-8");
|
|
25
25
|
let fileResultContent = fileContent;
|
|
26
|
-
const basePrompt = require__utils_asset.readAsset("./prompts/TRANSLATE_PROMPT.md", "utf-8").replaceAll("{{localeName}}", `${(0,
|
|
27
|
-
const filePrefix = [(0,
|
|
28
|
-
const prefix = [(0,
|
|
26
|
+
const basePrompt = require__utils_asset.readAsset("./prompts/TRANSLATE_PROMPT.md", "utf-8").replaceAll("{{localeName}}", `${(0, _intlayer_chokidar.formatLocale)(locale, false)}`).replaceAll("{{baseLocaleName}}", `${(0, _intlayer_chokidar.formatLocale)(baseLocale, false)}`).replace("{{applicationContext}}", aiOptions?.applicationContext ?? "-").replace("{{customInstructions}}", customInstructions ?? "-");
|
|
27
|
+
const filePrefix = [(0, _intlayer_config.colon)(`${_intlayer_config.ANSIColors.GREY_DARK}[${(0, _intlayer_chokidar.formatPath)(baseFilePath)}${_intlayer_config.ANSIColors.GREY_DARK}] `, { colSize: 40 }), `→ ${_intlayer_config.ANSIColors.RESET}`].join("");
|
|
28
|
+
const prefix = [(0, _intlayer_config.colon)(`${_intlayer_config.ANSIColors.GREY_DARK}[${(0, _intlayer_chokidar.formatPath)(baseFilePath)}${_intlayer_config.ANSIColors.GREY_DARK}][${(0, _intlayer_chokidar.formatLocale)(locale)}${_intlayer_config.ANSIColors.GREY_DARK}] `, { colSize: 40 }), `→ ${_intlayer_config.ANSIColors.RESET}`].join("");
|
|
29
29
|
const chunks = require_utils_calculateChunks.chunkText(fileContent);
|
|
30
|
-
appLogger(`${filePrefix}Base file splitted into ${(0,
|
|
30
|
+
appLogger(`${filePrefix}Base file splitted into ${(0, _intlayer_config.colorizeNumber)(chunks.length)} chunks`);
|
|
31
31
|
for await (const [i, chunk] of chunks.entries()) {
|
|
32
32
|
const isFirstChunk = i === 0;
|
|
33
|
-
const getPrevChunkPrompt = () => `**CHUNK ${i} of ${chunks.length}** that has been translated in ${(0,
|
|
34
|
-
const getBaseChunkContextPrompt = () => `**CHUNK ${i + 1} to ${Math.min(i + 3, chunks.length)} of ${chunks.length}** is the base chunk in ${(0,
|
|
33
|
+
const getPrevChunkPrompt = () => `**CHUNK ${i} of ${chunks.length}** that has been translated in ${(0, _intlayer_chokidar.formatLocale)(locale)}:\n///chunkStart///` + (0, _intlayer_chokidar.getChunk)(fileResultContent, chunks[i - 1]) + `///chunkEnd///`;
|
|
34
|
+
const getBaseChunkContextPrompt = () => `**CHUNK ${i + 1} to ${Math.min(i + 3, chunks.length)} of ${chunks.length}** is the base chunk in ${(0, _intlayer_chokidar.formatLocale)(baseLocale, false)} as reference.\n///chunksStart///` + (chunks[i - 1]?.content ?? "") + chunks[i].content + (chunks[i + 1]?.content ?? "") + `///chunksEnd///`;
|
|
35
35
|
const fileToTranslateCurrentChunk = chunk.content;
|
|
36
|
-
const chunkTranslation = await (0,
|
|
36
|
+
const chunkTranslation = await (0, _intlayer_config.retryManager)(async () => {
|
|
37
37
|
const result = await require_utils_chunkInference.chunkInference([
|
|
38
38
|
{
|
|
39
39
|
role: "system",
|
|
@@ -49,7 +49,7 @@ const translateFile = async (baseFilePath, outputFilePath, locale, baseLocale, c
|
|
|
49
49
|
}],
|
|
50
50
|
{
|
|
51
51
|
role: "system",
|
|
52
|
-
content: `The next user message will be the **CHUNK ${(0,
|
|
52
|
+
content: `The next user message will be the **CHUNK ${(0, _intlayer_config.colorizeNumber)(i + 1)} of ${(0, _intlayer_config.colorizeNumber)(chunks.length)}** in ${(0, _intlayer_chokidar.formatLocale)(baseLocale, false)} to translate in ${(0, _intlayer_chokidar.formatLocale)(locale, false)}:`
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
role: "user",
|
|
@@ -58,12 +58,12 @@ const translateFile = async (baseFilePath, outputFilePath, locale, baseLocale, c
|
|
|
58
58
|
], aiOptions, configuration, aiClient, aiConfig);
|
|
59
59
|
appLogger([
|
|
60
60
|
`${prefix}`,
|
|
61
|
-
`${
|
|
62
|
-
(0,
|
|
63
|
-
`${
|
|
64
|
-
(0,
|
|
65
|
-
`${
|
|
66
|
-
`${(0,
|
|
61
|
+
`${_intlayer_config.ANSIColors.GREY_DARK}[Chunk `,
|
|
62
|
+
(0, _intlayer_config.colorizeNumber)(i + 1),
|
|
63
|
+
`${_intlayer_config.ANSIColors.GREY_DARK} of `,
|
|
64
|
+
(0, _intlayer_config.colorizeNumber)(chunks.length),
|
|
65
|
+
`${_intlayer_config.ANSIColors.GREY_DARK}] →${_intlayer_config.ANSIColors.RESET} `,
|
|
66
|
+
`${(0, _intlayer_config.colorizeNumber)(result.tokenUsed)} tokens used`
|
|
67
67
|
].join(""));
|
|
68
68
|
return require_utils_fixChunkStartEndChars.fixChunkStartEndChars(result?.fileContent, fileToTranslateCurrentChunk);
|
|
69
69
|
})();
|
|
@@ -72,7 +72,7 @@ const translateFile = async (baseFilePath, outputFilePath, locale, baseLocale, c
|
|
|
72
72
|
(0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
|
|
73
73
|
(0, node_fs.writeFileSync)(outputFilePath, fileResultContent);
|
|
74
74
|
const relativePath = (0, node_path.relative)(configuration.content.baseDir, outputFilePath);
|
|
75
|
-
appLogger(`${(0,
|
|
75
|
+
appLogger(`${(0, _intlayer_config.colorize)("✔", _intlayer_config.ANSIColors.GREEN)} File ${(0, _intlayer_chokidar.formatPath)(relativePath)} created/updated successfully.`);
|
|
76
76
|
} catch (error) {
|
|
77
77
|
console.error(error);
|
|
78
78
|
}
|
|
@@ -82,8 +82,8 @@ const translateFile = async (baseFilePath, outputFilePath, locale, baseLocale, c
|
|
|
82
82
|
* then translates them to each locale in LOCALE_LIST.
|
|
83
83
|
*/
|
|
84
84
|
const translateDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale, aiOptions, nbSimultaneousFileProcessed, configOptions, customInstructions, skipIfModifiedBefore, skipIfModifiedAfter, skipIfExists, gitOptions }) => {
|
|
85
|
-
const configuration = (0,
|
|
86
|
-
const appLogger = (0,
|
|
85
|
+
const configuration = (0, _intlayer_config.getConfiguration)(configOptions);
|
|
86
|
+
const appLogger = (0, _intlayer_config.getAppLogger)(configuration);
|
|
87
87
|
if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {
|
|
88
88
|
appLogger(`Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`);
|
|
89
89
|
nbSimultaneousFileProcessed = 10;
|
|
@@ -93,24 +93,24 @@ const translateDoc = async ({ docPattern, locales, excludedGlobPattern, baseLoca
|
|
|
93
93
|
if (!aiResult?.hasAIAccess) return;
|
|
94
94
|
const { aiClient, aiConfig } = aiResult;
|
|
95
95
|
if (gitOptions) {
|
|
96
|
-
const gitChangedFiles = await (0,
|
|
96
|
+
const gitChangedFiles = await (0, _intlayer_chokidar.listGitFiles)(gitOptions);
|
|
97
97
|
if (gitChangedFiles) docList = docList.filter((path) => gitChangedFiles.some((gitFile) => (0, node_path.join)(process.cwd(), path) === gitFile));
|
|
98
98
|
}
|
|
99
|
-
appLogger(`Base locale is ${(0,
|
|
100
|
-
appLogger(`Translating ${(0,
|
|
101
|
-
appLogger(`Translating ${(0,
|
|
102
|
-
appLogger(docList.map((path) => ` - ${(0,
|
|
103
|
-
await (0,
|
|
104
|
-
appLogger(`Translating file: ${(0,
|
|
99
|
+
appLogger(`Base locale is ${(0, _intlayer_chokidar.formatLocale)(baseLocale)}`);
|
|
100
|
+
appLogger(`Translating ${(0, _intlayer_config.colorizeNumber)(locales.length)} locales: [ ${(0, _intlayer_chokidar.formatLocale)(locales)} ]`);
|
|
101
|
+
appLogger(`Translating ${(0, _intlayer_config.colorizeNumber)(docList.length)} files:`);
|
|
102
|
+
appLogger(docList.map((path) => ` - ${(0, _intlayer_chokidar.formatPath)(path)}\n`));
|
|
103
|
+
await (0, _intlayer_chokidar.parallelize)(docList.flatMap((docPath) => locales.map((locale) => async () => {
|
|
104
|
+
appLogger(`Translating file: ${(0, _intlayer_chokidar.formatPath)(docPath)} to ${(0, _intlayer_chokidar.formatLocale)(locale)}`);
|
|
105
105
|
const absoluteBaseFilePath = (0, node_path.join)(configuration.content.baseDir, docPath);
|
|
106
106
|
const outputFilePath = require_utils_getOutputFilePath.getOutputFilePath(absoluteBaseFilePath, locale, baseLocale);
|
|
107
107
|
if (skipIfExists && (0, node_fs.existsSync)(outputFilePath)) {
|
|
108
108
|
const relativePath = (0, node_path.relative)(configuration.content.baseDir, outputFilePath);
|
|
109
|
-
appLogger(`${(0,
|
|
109
|
+
appLogger(`${(0, _intlayer_config.colorize)("⊘", _intlayer_config.ANSIColors.YELLOW)} File ${(0, _intlayer_chokidar.formatPath)(relativePath)} already exists, skipping.`);
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
if (!(0, node_fs.existsSync)(outputFilePath)) {
|
|
113
|
-
appLogger(`File ${(0,
|
|
113
|
+
appLogger(`File ${(0, _intlayer_chokidar.formatPath)((0, node_path.relative)(configuration.content.baseDir, outputFilePath))} does not exist, creating it...`);
|
|
114
114
|
(0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
|
|
115
115
|
(0, node_fs.writeFileSync)(outputFilePath, "");
|
|
116
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translateDoc.cjs","names":["readAsset","ANSIColors","chunkText","chunkInference","fixChunkStartEndChars","docList: string[]","setupAI","getOutputFilePath","checkFileModifiedRange"],"sources":["../../src/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIConfig, AIOptions } from '@intlayer/ai';\nimport {\n formatLocale,\n formatPath,\n getChunk,\n type ListGitFilesOptions,\n listGitFiles,\n parallelize,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n retryManager,\n} from '@intlayer/config';\nimport type { IntlayerConfig, Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { chunkText } from './utils/calculateChunks';\nimport { checkFileModifiedRange } from './utils/checkFileModifiedRange';\nimport { chunkInference } from './utils/chunkInference';\nimport { fixChunkStartEndChars } from './utils/fixChunkStartEndChars';\nimport { getOutputFilePath } from './utils/getOutputFilePath';\nimport { type AIClient, setupAI } from './utils/setupAI';\n\n/**\n * Translate a single file for a given locale\n */\nexport const translateFile = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locale,\n baseLocale: Locale,\n configuration: IntlayerConfig,\n aiOptions?: AIOptions,\n customInstructions?: string,\n aiClient?: AIClient,\n aiConfig?: AIConfig\n) => {\n try {\n const appLogger = getAppLogger(configuration, {\n config: {\n prefix: '',\n },\n });\n\n // Determine the target locale file path\n const fileContent = await readFile(baseFilePath, 'utf-8');\n\n let fileResultContent = fileContent;\n\n // Prepare the base prompt for ChatGPT\n const basePrompt = readAsset('./prompts/TRANSLATE_PROMPT.md', 'utf-8')\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const filePrefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = [\n colon(filePrefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = [\n colon(prefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n // 1. Chunk the file by number of lines instead of characters\n const chunks = chunkText(fileContent);\n appLogger(\n `${filePrefix}Base file splitted into ${colorizeNumber(chunks.length)} chunks`\n );\n\n for await (const [i, chunk] of chunks.entries()) {\n const isFirstChunk = i === 0;\n\n // Build the chunk-specific prompt\n const getPrevChunkPrompt = () =>\n `**CHUNK ${i} of ${chunks.length}** that has been translated in ${formatLocale(locale)}:\\n` +\n `///chunkStart///` +\n getChunk(fileResultContent, chunks[i - 1]) +\n `///chunkEnd///`;\n\n const getBaseChunkContextPrompt = () =>\n `**CHUNK ${i + 1} to ${Math.min(i + 3, chunks.length)} of ${chunks.length}** is the base chunk in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///` +\n (chunks[i - 1]?.content ?? '') +\n chunks[i].content +\n (chunks[i + 1]?.content ?? '') +\n `///chunksEnd///`;\n\n const fileToTranslateCurrentChunk = chunk.content;\n\n // Make the actual translation call\n const chunkTranslation = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n\n { role: 'system', content: getBaseChunkContextPrompt() },\n ...(isFirstChunk\n ? []\n : [{ role: 'system', content: getPrevChunkPrompt() } as const]),\n {\n role: 'system',\n content: `The next user message will be the **CHUNK ${colorizeNumber(i + 1)} of ${colorizeNumber(chunks.length)}** in ${formatLocale(baseLocale, false)} to translate in ${formatLocale(locale, false)}:`,\n },\n { role: 'user', content: fileToTranslateCurrentChunk },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n appLogger(\n [\n `${prefix}`,\n `${ANSIColors.GREY_DARK}[Chunk `,\n colorizeNumber(i + 1),\n `${ANSIColors.GREY_DARK} of `,\n colorizeNumber(chunks.length),\n `${ANSIColors.GREY_DARK}] →${ANSIColors.RESET} `,\n `${colorizeNumber(result.tokenUsed)} tokens used`,\n ].join('')\n );\n\n const fixedTranslatedChunkResult = fixChunkStartEndChars(\n result?.fileContent,\n fileToTranslateCurrentChunk\n );\n\n return fixedTranslatedChunkResult;\n })();\n\n // Replace the chunk in the file content\n fileResultContent = fileResultContent.replace(\n fileToTranslateCurrentChunk,\n chunkTranslation\n );\n }\n\n // 4. Write the final translation to the appropriate file path\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, fileResultContent);\n\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(relativePath)} created/updated successfully.`\n );\n } catch (error) {\n console.error(error);\n }\n};\n\ntype TranslateDocOptions = {\n docPattern: string[];\n locales: Locale[];\n excludedGlobPattern: string[];\n baseLocale: Locale;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n skipIfExists?: boolean;\n gitOptions?: ListGitFilesOptions;\n};\n\n/**\n * Main translate function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then translates them to each locale in LOCALE_LIST.\n */\nexport const translateDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n const aiResult = await setupAI(configuration, aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n // OAuth handled by API proxy internally\n\n appLogger(`Base locale is ${formatLocale(baseLocale)}`);\n appLogger(\n `Translating ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Translating ${colorizeNumber(docList.length)} files:`);\n appLogger(docList.map((path) => ` - ${formatPath(path)}\\n`));\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n appLogger(\n `Translating file: ${formatPath(docPath)} to ${formatLocale(locale)}`\n );\n\n const absoluteBaseFilePath = join(configuration.content.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip if file exists and skipIfExists option is enabled\n if (skipIfExists && existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n appLogger(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n return;\n }\n\n // check if the file exist, otherwise create it\n if (!existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n appLogger(\n `File ${formatPath(relativePath)} does not exist, creating it...`\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n await translateFile(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n configuration,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task) => task(),\n nbSimultaneousFileProcessed ?? 3\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,gBAAgB,OAC3B,cACA,gBACA,QACA,YACA,eACA,WACA,oBACA,UACA,aACG;AACH,KAAI;EACF,MAAM,gDAAyB,eAAe,EAC5C,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;EAGF,MAAM,cAAc,qCAAe,cAAc,QAAQ;EAEzD,IAAI,oBAAoB;EAGxB,MAAM,aAAaA,+BAAU,iCAAiC,QAAQ,CACnE,WAAW,kBAAkB,yCAAgB,QAAQ,MAAM,GAAG,CAC9D,WAAW,sBAAsB,yCAAgB,YAAY,MAAM,GAAG,CACtE,QAAQ,0BAA0B,WAAW,sBAAsB,IAAI,CACvE,QAAQ,0BAA0B,sBAAsB,IAAI;EAG/D,MAAM,aAAa,8BADI,GAAGC,6BAAW,UAAU,uCAAc,aAAa,GAAGA,6BAAW,UAAU,KAE1E,EAAE,SAAS,IAAI,CAAC,EACtC,KAAKA,6BAAW,QACjB,CAAC,KAAK,GAAG;EAGV,MAAM,SAAS,8BADI,GAAGA,6BAAW,UAAU,uCAAc,aAAa,GAAGA,6BAAW,UAAU,0CAAiB,OAAO,GAAGA,6BAAW,UAAU,KAE1H,EAAE,SAAS,IAAI,CAAC,EAClC,KAAKA,6BAAW,QACjB,CAAC,KAAK,GAAG;EAGV,MAAM,SAASC,wCAAU,YAAY;AACrC,YACE,GAAG,WAAW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Ae,EAAE;GAC9C,MAAM,uCACJ,cAAc,QAAQ,SACtB,eACD;AACD,aACE,mCAAY,KAAKN,6BAAW,OAAO,CAAC,4CAAmB,aAAa,CAAC,4BACtE;AACD;;AAIF,MAAI,yBAAY,eAAe,EAAE;AAK/B,aACE,oEAJA,cAAc,QAAQ,SACtB,eACD,CAEiC,CAAC,iCAClC;AACD,iDAAkB,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC;AACvD,8BAAc,gBAAgB,GAAG;;EAGnC,MAAM,uBAAuBO,4DAAuB,gBAAgB;GAClE;GACA;GACD,CAAC;AAEF,MAAI,qBAAqB,WAAW;AAClC,aAAU,qBAAqB,QAAQ;AACvC;;AAGF,QAAM,cACJ,sBACA,gBACA,QACA,YACA,eACA,WACA,oBACA,UACA,SACD;GACD,CACH,GAIE,SAAS,MAAM,EAChB,+BAA+B,EAChC"}
|
|
1
|
+
{"version":3,"file":"translateDoc.cjs","names":["readAsset","ANSIColors","chunkText","chunkInference","fixChunkStartEndChars","docList: string[]","setupAI","getOutputFilePath","checkFileModifiedRange"],"sources":["../../src/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIConfig, AIOptions } from '@intlayer/ai';\nimport {\n formatLocale,\n formatPath,\n getChunk,\n type ListGitFilesOptions,\n listGitFiles,\n parallelize,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n retryManager,\n} from '@intlayer/config';\nimport type { IntlayerConfig, Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { chunkText } from './utils/calculateChunks';\nimport { checkFileModifiedRange } from './utils/checkFileModifiedRange';\nimport { chunkInference } from './utils/chunkInference';\nimport { fixChunkStartEndChars } from './utils/fixChunkStartEndChars';\nimport { getOutputFilePath } from './utils/getOutputFilePath';\nimport { type AIClient, setupAI } from './utils/setupAI';\n\n/**\n * Translate a single file for a given locale\n */\nexport const translateFile = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locale,\n baseLocale: Locale,\n configuration: IntlayerConfig,\n aiOptions?: AIOptions,\n customInstructions?: string,\n aiClient?: AIClient,\n aiConfig?: AIConfig\n) => {\n try {\n const appLogger = getAppLogger(configuration, {\n config: {\n prefix: '',\n },\n });\n\n // Determine the target locale file path\n const fileContent = await readFile(baseFilePath, 'utf-8');\n\n let fileResultContent = fileContent;\n\n // Prepare the base prompt for ChatGPT\n const basePrompt = readAsset('./prompts/TRANSLATE_PROMPT.md', 'utf-8')\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const filePrefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = [\n colon(filePrefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = [\n colon(prefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n // 1. Chunk the file by number of lines instead of characters\n const chunks = chunkText(fileContent);\n appLogger(\n `${filePrefix}Base file splitted into ${colorizeNumber(chunks.length)} chunks`\n );\n\n for await (const [i, chunk] of chunks.entries()) {\n const isFirstChunk = i === 0;\n\n // Build the chunk-specific prompt\n const getPrevChunkPrompt = () =>\n `**CHUNK ${i} of ${chunks.length}** that has been translated in ${formatLocale(locale)}:\\n` +\n `///chunkStart///` +\n getChunk(fileResultContent, chunks[i - 1]) +\n `///chunkEnd///`;\n\n const getBaseChunkContextPrompt = () =>\n `**CHUNK ${i + 1} to ${Math.min(i + 3, chunks.length)} of ${chunks.length}** is the base chunk in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///` +\n (chunks[i - 1]?.content ?? '') +\n chunks[i].content +\n (chunks[i + 1]?.content ?? '') +\n `///chunksEnd///`;\n\n const fileToTranslateCurrentChunk = chunk.content;\n\n // Make the actual translation call\n const chunkTranslation = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n\n { role: 'system', content: getBaseChunkContextPrompt() },\n ...(isFirstChunk\n ? []\n : [{ role: 'system', content: getPrevChunkPrompt() } as const]),\n {\n role: 'system',\n content: `The next user message will be the **CHUNK ${colorizeNumber(i + 1)} of ${colorizeNumber(chunks.length)}** in ${formatLocale(baseLocale, false)} to translate in ${formatLocale(locale, false)}:`,\n },\n { role: 'user', content: fileToTranslateCurrentChunk },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n appLogger(\n [\n `${prefix}`,\n `${ANSIColors.GREY_DARK}[Chunk `,\n colorizeNumber(i + 1),\n `${ANSIColors.GREY_DARK} of `,\n colorizeNumber(chunks.length),\n `${ANSIColors.GREY_DARK}] →${ANSIColors.RESET} `,\n `${colorizeNumber(result.tokenUsed)} tokens used`,\n ].join('')\n );\n\n const fixedTranslatedChunkResult = fixChunkStartEndChars(\n result?.fileContent,\n fileToTranslateCurrentChunk\n );\n\n return fixedTranslatedChunkResult;\n })();\n\n // Replace the chunk in the file content\n fileResultContent = fileResultContent.replace(\n fileToTranslateCurrentChunk,\n chunkTranslation\n );\n }\n\n // 4. Write the final translation to the appropriate file path\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, fileResultContent);\n\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(relativePath)} created/updated successfully.`\n );\n } catch (error) {\n console.error(error);\n }\n};\n\ntype TranslateDocOptions = {\n docPattern: string[];\n locales: Locale[];\n excludedGlobPattern: string[];\n baseLocale: Locale;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n skipIfExists?: boolean;\n gitOptions?: ListGitFilesOptions;\n};\n\n/**\n * Main translate function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then translates them to each locale in LOCALE_LIST.\n */\nexport const translateDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n const aiResult = await setupAI(configuration, aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n // OAuth handled by API proxy internally\n\n appLogger(`Base locale is ${formatLocale(baseLocale)}`);\n appLogger(\n `Translating ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Translating ${colorizeNumber(docList.length)} files:`);\n appLogger(docList.map((path) => ` - ${formatPath(path)}\\n`));\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n appLogger(\n `Translating file: ${formatPath(docPath)} to ${formatLocale(locale)}`\n );\n\n const absoluteBaseFilePath = join(configuration.content.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip if file exists and skipIfExists option is enabled\n if (skipIfExists && existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n appLogger(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n return;\n }\n\n // check if the file exist, otherwise create it\n if (!existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n appLogger(\n `File ${formatPath(relativePath)} does not exist, creating it...`\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n await translateFile(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n configuration,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task) => task(),\n nbSimultaneousFileProcessed ?? 3\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,gBAAgB,OAC3B,cACA,gBACA,QACA,YACA,eACA,WACA,oBACA,UACA,aACG;AACH,KAAI;EACF,MAAM,+CAAyB,eAAe,EAC5C,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;EAGF,MAAM,cAAc,qCAAe,cAAc,QAAQ;EAEzD,IAAI,oBAAoB;EAGxB,MAAM,aAAaA,+BAAU,iCAAiC,QAAQ,CACnE,WAAW,kBAAkB,w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AAEtD,MAAI,gBAIF,WAAU,QAAQ,QAAQ,SACxB,gBAAgB,MAAM,gCAAiB,QAAQ,KAAK,EAAE,KAAK,KAAK,QAAQ,CACzE;;AAML,WAAU,uDAA+B,WAAW,GAAG;AACvD,WACE,oDAA8B,QAAQ,OAAO,CAAC,mDAA2B,QAAQ,CAAC,IACnF;AAED,WAAU,oDAA8B,QAAQ,OAAO,CAAC,SAAS;AACjE,WAAU,QAAQ,KAAK,SAAS,yCAAiB,KAAK,CAAC,IAAI,CAAC;AAiE5D,2CA9DiB,QAAQ,SAAS,YAChC,QAAQ,KAAK,WAAW,YAAY;AAClC,YACE,wDAAgC,QAAQ,CAAC,2CAAmB,OAAO,GACpE;EAED,MAAM,2CAA4B,cAAc,QAAQ,SAAS,QAAQ;EACzE,MAAM,iBAAiBC,kDACrB,sBACA,QACA,WACD;AAGD,MAAI,wCAA2B,eAAe,EAAE;GAC9C,MAAM,uCACJ,cAAc,QAAQ,SACtB,eACD;AACD,aACE,kCAAY,KAAKN,4BAAW,OAAO,CAAC,2CAAmB,aAAa,CAAC,4BACtE;AACD;;AAIF,MAAI,yBAAY,eAAe,EAAE;AAK/B,aACE,mEAJA,cAAc,QAAQ,SACtB,eACD,CAEiC,CAAC,iCAClC;AACD,iDAAkB,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC;AACvD,8BAAc,gBAAgB,GAAG;;EAGnC,MAAM,uBAAuBO,4DAAuB,gBAAgB;GAClE;GACA;GACD,CAAC;AAEF,MAAI,qBAAqB,WAAW;AAClC,aAAU,qBAAqB,QAAQ;AACvC;;AAGF,QAAM,cACJ,sBACA,gBACA,QACA,YACA,eACA,WACA,oBACA,UACA,SACD;GACD,CACH,GAIE,SAAS,MAAM,EAChB,+BAA+B,EAChC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _intlayer_chokidar = require("@intlayer/chokidar");
|
|
3
3
|
|
|
4
4
|
//#region src/utils/calculateChunks.ts
|
|
5
5
|
const DEFAULT_MAX_CHARS_PER_CHUNK = 800;
|
|
6
6
|
const DEFAULT_OVERLAP_CHARS = 0;
|
|
7
7
|
const chunkText = (text, maxCharsPerChunk = DEFAULT_MAX_CHARS_PER_CHUNK, overlapChars = DEFAULT_OVERLAP_CHARS) => {
|
|
8
8
|
if (maxCharsPerChunk <= 0) throw new Error("maxCharsPerChunk must be greater than 0");
|
|
9
|
-
const splittedText = (0,
|
|
9
|
+
const splittedText = (0, _intlayer_chokidar.splitTextByLines)(text);
|
|
10
10
|
const lines = [];
|
|
11
11
|
let charStartAcc = 0;
|
|
12
12
|
splittedText.forEach((line, index) => {
|
|
@@ -67,10 +67,10 @@ const chunkText = (text, maxCharsPerChunk = DEFAULT_MAX_CHARS_PER_CHUNK, overlap
|
|
|
67
67
|
const previousChunk = splittedLines[i - 1];
|
|
68
68
|
const chunk = splittedLines[i];
|
|
69
69
|
const overlapContent = previousChunk.content.slice(-overlapChars);
|
|
70
|
-
const overlapLineNb = (0,
|
|
70
|
+
const overlapLineNb = (0, _intlayer_chokidar.splitTextByLines)(overlapContent).length;
|
|
71
71
|
const overlapContentWithoutPartialLine = overlapContent.slice(overlapLineNb > 1 ? overlapContent.indexOf("\n") + 1 : 0, overlapContent.length);
|
|
72
72
|
const newContent = overlapContentWithoutPartialLine + chunk.content;
|
|
73
|
-
const newLineLength = (0,
|
|
73
|
+
const newLineLength = (0, _intlayer_chokidar.splitTextByLines)(newContent).length;
|
|
74
74
|
const lineDiff = chunk.lineLength - newLineLength;
|
|
75
75
|
const overlappedChunk = {
|
|
76
76
|
content: newContent,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateChunks.cjs","names":["lines: ChunkLineResult[]","splittedLines: ChunkLineResult[]","chunk: ChunkLineResult[]","overlapChunks: ChunkLineResult[]"],"sources":["../../../src/utils/calculateChunks.ts"],"sourcesContent":["import { splitTextByLines } from '@intlayer/chokidar';\n\nexport type ChunkLineResult = {\n lineStart: number;\n lineLength: number;\n charStart: number;\n charLength: number;\n content: string;\n};\n\nconst DEFAULT_MAX_CHARS_PER_CHUNK = 800;\nconst DEFAULT_OVERLAP_CHARS = 0;\n\nexport const chunkText = (\n text: string,\n maxCharsPerChunk: number = DEFAULT_MAX_CHARS_PER_CHUNK,\n overlapChars: number = DEFAULT_OVERLAP_CHARS\n): ChunkLineResult[] => {\n if (maxCharsPerChunk <= 0) {\n throw new Error('maxCharsPerChunk must be greater than 0');\n }\n\n const splittedText = splitTextByLines(text);\n\n // Split text into lines to facilitate the translation\n const lines: ChunkLineResult[] = [];\n let charStartAcc = 0;\n\n splittedText.forEach((line, index) => {\n lines.push({\n content: line,\n lineStart: index,\n lineLength: 1,\n charStart: charStartAcc,\n charLength: line.length,\n });\n charStartAcc += line.length;\n });\n\n // Group lines\n // as long as the chunk length is less than maxCharsPerChunk\n // if a line longer than maxCharsPerChunk, keep it alone\n // if a line is not longer than maxCharsPerChunk, it is grouped\n const groupedLines: ChunkLineResult[] = lines.reduce(\n (acc: ChunkLineResult[], line) => {\n // If this line alone exceeds maxCharsPerChunk, keep it separate\n if (line.content.length > maxCharsPerChunk) {\n acc.push(line);\n return acc;\n }\n\n // If we have no chunks yet, start with this line\n if (acc.length === 0) {\n acc.push(line);\n return acc;\n }\n\n // Get the last chunk\n const lastChunk = acc[acc.length - 1];\n\n // Calculate what the combined length would be (including newline character)\n const combinedLength = lastChunk.content.length + line.content.length;\n\n // If combining would exceed the limit, start a new chunk\n if (combinedLength > maxCharsPerChunk) {\n acc.push(line);\n return acc;\n }\n\n // Otherwise, combine with the last chunk\n const combinedContent = lastChunk.content + line.content;\n const updatedChunk = {\n content: combinedContent,\n lineStart: lastChunk.lineStart,\n lineLength: lastChunk.lineLength + line.lineLength,\n charStart: lastChunk.charStart,\n charLength: combinedContent.length,\n };\n\n acc[acc.length - 1] = updatedChunk;\n return acc;\n },\n []\n );\n\n // If one line is longer than maxCharsPerChunk, split it into multiple chunks\n const splittedLines: ChunkLineResult[] = groupedLines.flatMap((line) => {\n const chunk: ChunkLineResult[] = [];\n\n if (line.content.length <= maxCharsPerChunk) {\n chunk.push(line);\n return chunk;\n }\n\n for (let i = 0; i < line.content.length; i += maxCharsPerChunk) {\n const slicedContent = line.content.slice(i, i + maxCharsPerChunk);\n chunk.push({\n content: slicedContent,\n lineStart: line.lineStart,\n lineLength: 1,\n charStart: line.charStart + i,\n charLength: slicedContent.length,\n });\n }\n return chunk;\n });\n\n if (overlapChars === 0) return splittedLines;\n\n const overlapChunks: ChunkLineResult[] =\n splittedLines.length > 0 ? [splittedLines[0]] : [];\n\n for (let i = 1; i < splittedLines.length; i++) {\n const previousChunk = splittedLines[i - 1];\n const chunk = splittedLines[i];\n\n const overlapContent = previousChunk.content.slice(-overlapChars);\n const overlapLineNb = splitTextByLines(overlapContent).length;\n\n const overlapContentWithoutPartialLine = overlapContent.slice(\n overlapLineNb > 1 ? overlapContent.indexOf('\\n') + 1 : 0,\n overlapContent.length\n );\n\n const newContent = overlapContentWithoutPartialLine + chunk.content;\n const newLineLength = splitTextByLines(newContent).length;\n const lineDiff = chunk.lineLength - newLineLength;\n\n const overlappedChunk = {\n content: newContent,\n lineStart: chunk.lineStart + lineDiff,\n lineLength: chunk.lineLength - lineDiff,\n charStart: chunk.charStart - overlapContentWithoutPartialLine.length,\n charLength: newContent.length,\n };\n\n overlapChunks.push(overlappedChunk);\n }\n\n return overlapChunks;\n};\n"],"mappings":";;;;AAUA,MAAM,8BAA8B;AACpC,MAAM,wBAAwB;AAE9B,MAAa,aACX,MACA,mBAA2B,6BAC3B,eAAuB,0BACD;AACtB,KAAI,oBAAoB,EACtB,OAAM,IAAI,MAAM,0CAA0C;CAG5D,MAAM,
|
|
1
|
+
{"version":3,"file":"calculateChunks.cjs","names":["lines: ChunkLineResult[]","splittedLines: ChunkLineResult[]","chunk: ChunkLineResult[]","overlapChunks: ChunkLineResult[]"],"sources":["../../../src/utils/calculateChunks.ts"],"sourcesContent":["import { splitTextByLines } from '@intlayer/chokidar';\n\nexport type ChunkLineResult = {\n lineStart: number;\n lineLength: number;\n charStart: number;\n charLength: number;\n content: string;\n};\n\nconst DEFAULT_MAX_CHARS_PER_CHUNK = 800;\nconst DEFAULT_OVERLAP_CHARS = 0;\n\nexport const chunkText = (\n text: string,\n maxCharsPerChunk: number = DEFAULT_MAX_CHARS_PER_CHUNK,\n overlapChars: number = DEFAULT_OVERLAP_CHARS\n): ChunkLineResult[] => {\n if (maxCharsPerChunk <= 0) {\n throw new Error('maxCharsPerChunk must be greater than 0');\n }\n\n const splittedText = splitTextByLines(text);\n\n // Split text into lines to facilitate the translation\n const lines: ChunkLineResult[] = [];\n let charStartAcc = 0;\n\n splittedText.forEach((line, index) => {\n lines.push({\n content: line,\n lineStart: index,\n lineLength: 1,\n charStart: charStartAcc,\n charLength: line.length,\n });\n charStartAcc += line.length;\n });\n\n // Group lines\n // as long as the chunk length is less than maxCharsPerChunk\n // if a line longer than maxCharsPerChunk, keep it alone\n // if a line is not longer than maxCharsPerChunk, it is grouped\n const groupedLines: ChunkLineResult[] = lines.reduce(\n (acc: ChunkLineResult[], line) => {\n // If this line alone exceeds maxCharsPerChunk, keep it separate\n if (line.content.length > maxCharsPerChunk) {\n acc.push(line);\n return acc;\n }\n\n // If we have no chunks yet, start with this line\n if (acc.length === 0) {\n acc.push(line);\n return acc;\n }\n\n // Get the last chunk\n const lastChunk = acc[acc.length - 1];\n\n // Calculate what the combined length would be (including newline character)\n const combinedLength = lastChunk.content.length + line.content.length;\n\n // If combining would exceed the limit, start a new chunk\n if (combinedLength > maxCharsPerChunk) {\n acc.push(line);\n return acc;\n }\n\n // Otherwise, combine with the last chunk\n const combinedContent = lastChunk.content + line.content;\n const updatedChunk = {\n content: combinedContent,\n lineStart: lastChunk.lineStart,\n lineLength: lastChunk.lineLength + line.lineLength,\n charStart: lastChunk.charStart,\n charLength: combinedContent.length,\n };\n\n acc[acc.length - 1] = updatedChunk;\n return acc;\n },\n []\n );\n\n // If one line is longer than maxCharsPerChunk, split it into multiple chunks\n const splittedLines: ChunkLineResult[] = groupedLines.flatMap((line) => {\n const chunk: ChunkLineResult[] = [];\n\n if (line.content.length <= maxCharsPerChunk) {\n chunk.push(line);\n return chunk;\n }\n\n for (let i = 0; i < line.content.length; i += maxCharsPerChunk) {\n const slicedContent = line.content.slice(i, i + maxCharsPerChunk);\n chunk.push({\n content: slicedContent,\n lineStart: line.lineStart,\n lineLength: 1,\n charStart: line.charStart + i,\n charLength: slicedContent.length,\n });\n }\n return chunk;\n });\n\n if (overlapChars === 0) return splittedLines;\n\n const overlapChunks: ChunkLineResult[] =\n splittedLines.length > 0 ? [splittedLines[0]] : [];\n\n for (let i = 1; i < splittedLines.length; i++) {\n const previousChunk = splittedLines[i - 1];\n const chunk = splittedLines[i];\n\n const overlapContent = previousChunk.content.slice(-overlapChars);\n const overlapLineNb = splitTextByLines(overlapContent).length;\n\n const overlapContentWithoutPartialLine = overlapContent.slice(\n overlapLineNb > 1 ? overlapContent.indexOf('\\n') + 1 : 0,\n overlapContent.length\n );\n\n const newContent = overlapContentWithoutPartialLine + chunk.content;\n const newLineLength = splitTextByLines(newContent).length;\n const lineDiff = chunk.lineLength - newLineLength;\n\n const overlappedChunk = {\n content: newContent,\n lineStart: chunk.lineStart + lineDiff,\n lineLength: chunk.lineLength - lineDiff,\n charStart: chunk.charStart - overlapContentWithoutPartialLine.length,\n charLength: newContent.length,\n };\n\n overlapChunks.push(overlappedChunk);\n }\n\n return overlapChunks;\n};\n"],"mappings":";;;;AAUA,MAAM,8BAA8B;AACpC,MAAM,wBAAwB;AAE9B,MAAa,aACX,MACA,mBAA2B,6BAC3B,eAAuB,0BACD;AACtB,KAAI,oBAAoB,EACtB,OAAM,IAAI,MAAM,0CAA0C;CAG5D,MAAM,wDAAgC,KAAK;CAG3C,MAAMA,QAA2B,EAAE;CACnC,IAAI,eAAe;AAEnB,cAAa,SAAS,MAAM,UAAU;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gB,cAAc,IAAI;EACxC,MAAM,QAAQ,cAAc;EAE5B,MAAM,iBAAiB,cAAc,QAAQ,MAAM,CAAC,aAAa;EACjE,MAAM,yDAAiC,eAAe,CAAC;EAEvD,MAAM,mCAAmC,eAAe,MACtD,gBAAgB,IAAI,eAAe,QAAQ,KAAK,GAAG,IAAI,GACvD,eAAe,OAChB;EAED,MAAM,aAAa,mCAAmC,MAAM;EAC5D,MAAM,yDAAiC,WAAW,CAAC;EACnD,MAAM,WAAW,MAAM,aAAa;EAEpC,MAAM,kBAAkB;GACtB,SAAS;GACT,WAAW,MAAM,YAAY;GAC7B,YAAY,MAAM,aAAa;GAC/B,WAAW,MAAM,YAAY,iCAAiC;GAC9D,YAAY,WAAW;GACxB;AAED,gBAAc,KAAK,gBAAgB;;AAGrC,QAAO"}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
3
|
-
let
|
|
2
|
+
let _intlayer_api = require("@intlayer/api");
|
|
3
|
+
let _intlayer_config = require("@intlayer/config");
|
|
4
4
|
|
|
5
5
|
//#region src/utils/checkAccess.ts
|
|
6
6
|
const checkCMSAuth = async (configuration) => {
|
|
7
|
-
const appLogger = (0,
|
|
7
|
+
const appLogger = (0, _intlayer_config.getAppLogger)(configuration, { config: { prefix: "" } });
|
|
8
8
|
if (!(configuration.editor.clientId && configuration.editor.clientSecret)) {
|
|
9
9
|
appLogger("CMS auth not provided.", { level: "error" });
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
|
-
const intlayerAPI = (0,
|
|
12
|
+
const intlayerAPI = (0, _intlayer_api.getIntlayerAPIProxy)(void 0, configuration);
|
|
13
13
|
try {
|
|
14
14
|
await intlayerAPI.oAuth.getOAuth2AccessToken();
|
|
15
15
|
} catch (error) {
|
|
16
|
-
appLogger((0,
|
|
16
|
+
appLogger((0, _intlayer_config.extractErrorMessage)(error), { level: "error" });
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
return true;
|
|
20
20
|
};
|
|
21
21
|
const checkAIAccess = async (configuration, aiOptions) => {
|
|
22
|
-
const appLogger = (0,
|
|
22
|
+
const appLogger = (0, _intlayer_config.getAppLogger)(configuration);
|
|
23
23
|
const hasCMSAuth = Boolean(configuration.editor.clientId && configuration.editor.clientSecret);
|
|
24
24
|
if (Boolean(configuration.ai?.apiKey || aiOptions?.apiKey)) return true;
|
|
25
25
|
if (!hasCMSAuth) {
|
|
26
26
|
appLogger([
|
|
27
27
|
"AI options or API key not provided. You can either retreive the CMS access key on",
|
|
28
|
-
(0,
|
|
29
|
-
(0,
|
|
30
|
-
(0,
|
|
31
|
-
(0,
|
|
28
|
+
(0, _intlayer_config.colorize)("https://intlayer.org/dahboard", _intlayer_config.ANSIColors.GREY),
|
|
29
|
+
(0, _intlayer_config.colorize)("(see doc:", _intlayer_config.ANSIColors.GREY_DARK),
|
|
30
|
+
(0, _intlayer_config.colorize)("https://intlayer.org/doc/concept/cms", _intlayer_config.ANSIColors.GREY),
|
|
31
|
+
(0, _intlayer_config.colorize)(")", _intlayer_config.ANSIColors.GREY_DARK),
|
|
32
32
|
". Alternatively, you can add your own OpenAI API key in the settings",
|
|
33
|
-
(0,
|
|
34
|
-
(0,
|
|
35
|
-
(0,
|
|
33
|
+
(0, _intlayer_config.colorize)("(see doc:", _intlayer_config.ANSIColors.GREY_DARK),
|
|
34
|
+
(0, _intlayer_config.colorize)("https://intlayer.org/doc/concept/configuration", _intlayer_config.ANSIColors.GREY),
|
|
35
|
+
(0, _intlayer_config.colorize)(")", _intlayer_config.ANSIColors.GREY_DARK),
|
|
36
36
|
"."
|
|
37
37
|
], { level: "error" });
|
|
38
38
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkAccess.cjs","names":["ANSIColors"],"sources":["../../../src/utils/checkAccess.ts"],"sourcesContent":["import type { AIOptions } from '@intlayer/api';\nimport { getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n ANSIColors,\n colorize,\n extractErrorMessage,\n getAppLogger,\n} from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const checkCMSAuth = async (\n configuration: IntlayerConfig\n): Promise<boolean> => {\n const appLogger = getAppLogger(configuration, {\n config: {\n prefix: '',\n },\n });\n\n const hasCMSAuth =\n configuration.editor.clientId && configuration.editor.clientSecret;\n if (!hasCMSAuth) {\n appLogger('CMS auth not provided.', {\n level: 'error',\n });\n\n return false;\n }\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n try {\n await intlayerAPI.oAuth.getOAuth2AccessToken();\n } catch (error) {\n const message = extractErrorMessage(error);\n\n appLogger(message, {\n level: 'error',\n });\n return false;\n }\n\n return true;\n};\n\nexport const checkAIAccess = async (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions\n): Promise<boolean> => {\n const appLogger = getAppLogger(configuration);\n\n const hasCMSAuth = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n const hasHisOwnAIAPIKey = Boolean(\n configuration.ai?.apiKey || aiOptions?.apiKey\n );\n\n if (hasHisOwnAIAPIKey) {\n return true;\n }\n\n // User need to provide either his own AI API key or the CMS auth\n if (!hasCMSAuth) {\n appLogger(\n [\n 'AI options or API key not provided. You can either retreive the CMS access key on',\n colorize('https://intlayer.org/dahboard', ANSIColors.GREY),\n colorize('(see doc:', ANSIColors.GREY_DARK),\n colorize('https://intlayer.org/doc/concept/cms', ANSIColors.GREY),\n colorize(')', ANSIColors.GREY_DARK),\n '. Alternatively, you can add your own OpenAI API key in the settings',\n colorize('(see doc:', ANSIColors.GREY_DARK),\n colorize(\n 'https://intlayer.org/doc/concept/configuration',\n ANSIColors.GREY\n ),\n colorize(')', ANSIColors.GREY_DARK),\n '.',\n ],\n {\n level: 'error',\n }\n );\n\n return false;\n }\n\n // If the user do not have his own AI API key, we need to check the CMS auth\n return await checkCMSAuth(configuration);\n};\n"],"mappings":";;;;;AAUA,MAAa,eAAe,OAC1B,kBACqB;CACrB,MAAM,
|
|
1
|
+
{"version":3,"file":"checkAccess.cjs","names":["ANSIColors"],"sources":["../../../src/utils/checkAccess.ts"],"sourcesContent":["import type { AIOptions } from '@intlayer/api';\nimport { getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n ANSIColors,\n colorize,\n extractErrorMessage,\n getAppLogger,\n} from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const checkCMSAuth = async (\n configuration: IntlayerConfig\n): Promise<boolean> => {\n const appLogger = getAppLogger(configuration, {\n config: {\n prefix: '',\n },\n });\n\n const hasCMSAuth =\n configuration.editor.clientId && configuration.editor.clientSecret;\n if (!hasCMSAuth) {\n appLogger('CMS auth not provided.', {\n level: 'error',\n });\n\n return false;\n }\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n try {\n await intlayerAPI.oAuth.getOAuth2AccessToken();\n } catch (error) {\n const message = extractErrorMessage(error);\n\n appLogger(message, {\n level: 'error',\n });\n return false;\n }\n\n return true;\n};\n\nexport const checkAIAccess = async (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions\n): Promise<boolean> => {\n const appLogger = getAppLogger(configuration);\n\n const hasCMSAuth = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n const hasHisOwnAIAPIKey = Boolean(\n configuration.ai?.apiKey || aiOptions?.apiKey\n );\n\n if (hasHisOwnAIAPIKey) {\n return true;\n }\n\n // User need to provide either his own AI API key or the CMS auth\n if (!hasCMSAuth) {\n appLogger(\n [\n 'AI options or API key not provided. You can either retreive the CMS access key on',\n colorize('https://intlayer.org/dahboard', ANSIColors.GREY),\n colorize('(see doc:', ANSIColors.GREY_DARK),\n colorize('https://intlayer.org/doc/concept/cms', ANSIColors.GREY),\n colorize(')', ANSIColors.GREY_DARK),\n '. Alternatively, you can add your own OpenAI API key in the settings',\n colorize('(see doc:', ANSIColors.GREY_DARK),\n colorize(\n 'https://intlayer.org/doc/concept/configuration',\n ANSIColors.GREY\n ),\n colorize(')', ANSIColors.GREY_DARK),\n '.',\n ],\n {\n level: 'error',\n }\n );\n\n return false;\n }\n\n // If the user do not have his own AI API key, we need to check the CMS auth\n return await checkCMSAuth(configuration);\n};\n"],"mappings":";;;;;AAUA,MAAa,eAAe,OAC1B,kBACqB;CACrB,MAAM,+CAAyB,eAAe,EAC5C,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;AAIF,KAAI,EADF,cAAc,OAAO,YAAY,cAAc,OAAO,eACvC;AACf,YAAU,0BAA0B,EAClC,OAAO,SACR,CAAC;AAEF,SAAO;;CAET,MAAM,qDAAkC,QAAW,cAAc;AAEjE,KAAI;AACF,QAAM,YAAY,MAAM,sBAAsB;UACvC,OAAO;AAGd,sDAFoC,MAAM,EAEvB,EACjB,OAAO,SACR,CAAC;AACF,SAAO;;AAGT,QAAO;;AAGT,MAAa,gBAAgB,OAC3B,eACA,cACqB;CACrB,MAAM,+CAAyB,cAAc;CAE7C,MAAM,aAAa,QACjB,cAAc,OAAO,YAAY,cAAc,OAAO,aACvD;AAKD,KAJ0B,QACxB,cAAc,IAAI,UAAU,WAAW,OACxC,CAGC,QAAO;AAIT,KAAI,CAAC,YAAY;AACf,YACE;GACE;kCACS,iCAAiCA,4BAAW,KAAK;kCACjD,aAAaA,4BAAW,UAAU;kCAClC,wCAAwCA,4BAAW,KAAK;kCACxD,KAAKA,4BAAW,UAAU;GACnC;kCACS,aAAaA,4BAAW,UAAU;kCAEzC,kDACAA,4BAAW,KACZ;kCACQ,KAAKA,4BAAW,UAAU;GACnC;GACD,EACD,EACE,OAAO,SACR,CACF;AAED,SAAO;;AAIT,QAAO,MAAM,aAAa,cAAc"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
3
|
-
let
|
|
2
|
+
let _intlayer_api = require("@intlayer/api");
|
|
3
|
+
let _intlayer_config = require("@intlayer/config");
|
|
4
4
|
|
|
5
5
|
//#region src/utils/chunkInference.ts
|
|
6
6
|
/**
|
|
@@ -9,7 +9,7 @@ let __intlayer_config = require("@intlayer/config");
|
|
|
9
9
|
*/
|
|
10
10
|
const chunkInference = async (messages, aiOptions, configuration, aiClient, aiConfig) => {
|
|
11
11
|
let lastResult;
|
|
12
|
-
await (0,
|
|
12
|
+
await (0, _intlayer_config.retryManager)(async () => {
|
|
13
13
|
if (aiClient && aiConfig) {
|
|
14
14
|
const response$1 = await aiClient.customQuery({
|
|
15
15
|
aiConfig,
|
|
@@ -23,7 +23,7 @@ const chunkInference = async (messages, aiOptions, configuration, aiClient, aiCo
|
|
|
23
23
|
};
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const response = await (0,
|
|
26
|
+
const response = await (0, _intlayer_api.getIntlayerAPIProxy)(void 0, configuration).ai.customQuery({
|
|
27
27
|
aiOptions,
|
|
28
28
|
messages
|
|
29
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkInference.cjs","names":["lastResult: ChunkInferenceResult","response","fileContent"],"sources":["../../../src/utils/chunkInference.ts"],"sourcesContent":["import type { AIConfig, AIOptions } from '@intlayer/ai';\nimport { getIntlayerAPIProxy, type Messages } from '@intlayer/api';\nimport { retryManager } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport type { AIClient } from './setupAI';\n\ntype ChunkInferenceResult = {\n fileContent: string;\n tokenUsed: number;\n};\n\n/**\n * Translates a single chunk via the OpenAI API.\n * Includes retry logic if the call fails.\n */\nexport const chunkInference = async (\n messages: Messages,\n aiOptions?: AIOptions,\n configuration?: IntlayerConfig,\n aiClient?: AIClient,\n aiConfig?: AIConfig\n): Promise<ChunkInferenceResult> => {\n let lastResult: ChunkInferenceResult;\n\n await retryManager(async () => {\n if (aiClient && aiConfig) {\n const response = await aiClient.customQuery({\n aiConfig,\n messages,\n });\n\n if (!response) {\n throw new Error('No response from AI API');\n }\n\n const { fileContent, tokenUsed } = response;\n\n lastResult = {\n fileContent: processContent(fileContent),\n tokenUsed,\n };\n\n return;\n }\n\n const api = getIntlayerAPIProxy(undefined, configuration);\n\n const response = await api.ai.customQuery({\n aiOptions,\n messages,\n });\n\n if (!response.data) {\n throw new Error('No response from AI API');\n }\n\n const { fileContent, tokenUsed } = response.data;\n\n lastResult = {\n fileContent: processContent(fileContent),\n tokenUsed,\n };\n })();\n\n return lastResult!;\n};\n\nconst processContent = (content: string) => {\n return content\n .replaceAll('///chunksStart///', '')\n .replaceAll('///chunkStart///', '')\n .replaceAll('///chunksEnd///', '')\n .replaceAll('///chunkEnd///', '')\n .replaceAll('///chunksStart///', '')\n .replaceAll('chunkStart///', '')\n .replaceAll('chunksEnd///', '')\n .replaceAll('chunkEnd///', '')\n .replaceAll('///chunksStart', '')\n .replaceAll('///chunkStart', '')\n .replaceAll('///chunksEnd', '')\n .replaceAll('///chunkEnd', '')\n .replaceAll('chunksStart', '')\n .replaceAll('chunkStart', '')\n .replaceAll('chunksEnd', '')\n .replaceAll('chunkEnd', '');\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,iBAAiB,OAC5B,UACA,WACA,eACA,UACA,aACkC;CAClC,IAAIA;AAEJ,
|
|
1
|
+
{"version":3,"file":"chunkInference.cjs","names":["lastResult: ChunkInferenceResult","response","fileContent"],"sources":["../../../src/utils/chunkInference.ts"],"sourcesContent":["import type { AIConfig, AIOptions } from '@intlayer/ai';\nimport { getIntlayerAPIProxy, type Messages } from '@intlayer/api';\nimport { retryManager } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport type { AIClient } from './setupAI';\n\ntype ChunkInferenceResult = {\n fileContent: string;\n tokenUsed: number;\n};\n\n/**\n * Translates a single chunk via the OpenAI API.\n * Includes retry logic if the call fails.\n */\nexport const chunkInference = async (\n messages: Messages,\n aiOptions?: AIOptions,\n configuration?: IntlayerConfig,\n aiClient?: AIClient,\n aiConfig?: AIConfig\n): Promise<ChunkInferenceResult> => {\n let lastResult: ChunkInferenceResult;\n\n await retryManager(async () => {\n if (aiClient && aiConfig) {\n const response = await aiClient.customQuery({\n aiConfig,\n messages,\n });\n\n if (!response) {\n throw new Error('No response from AI API');\n }\n\n const { fileContent, tokenUsed } = response;\n\n lastResult = {\n fileContent: processContent(fileContent),\n tokenUsed,\n };\n\n return;\n }\n\n const api = getIntlayerAPIProxy(undefined, configuration);\n\n const response = await api.ai.customQuery({\n aiOptions,\n messages,\n });\n\n if (!response.data) {\n throw new Error('No response from AI API');\n }\n\n const { fileContent, tokenUsed } = response.data;\n\n lastResult = {\n fileContent: processContent(fileContent),\n tokenUsed,\n };\n })();\n\n return lastResult!;\n};\n\nconst processContent = (content: string) => {\n return content\n .replaceAll('///chunksStart///', '')\n .replaceAll('///chunkStart///', '')\n .replaceAll('///chunksEnd///', '')\n .replaceAll('///chunkEnd///', '')\n .replaceAll('///chunksStart///', '')\n .replaceAll('chunkStart///', '')\n .replaceAll('chunksEnd///', '')\n .replaceAll('chunkEnd///', '')\n .replaceAll('///chunksStart', '')\n .replaceAll('///chunkStart', '')\n .replaceAll('///chunksEnd', '')\n .replaceAll('///chunkEnd', '')\n .replaceAll('chunksStart', '')\n .replaceAll('chunkStart', '')\n .replaceAll('chunksEnd', '')\n .replaceAll('chunkEnd', '');\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,iBAAiB,OAC5B,UACA,WACA,eACA,UACA,aACkC;CAClC,IAAIA;AAEJ,0CAAmB,YAAY;AAC7B,MAAI,YAAY,UAAU;GACxB,MAAMC,aAAW,MAAM,SAAS,YAAY;IAC1C;IACA;IACD,CAAC;AAEF,OAAI,CAACA,WACH,OAAM,IAAI,MAAM,0BAA0B;GAG5C,MAAM,EAAE,4BAAa,2BAAcA;AAEnC,gBAAa;IACX,aAAa,eAAeC,cAAY;IACxC;IACD;AAED;;EAKF,MAAM,WAAW,6CAFe,QAAW,cAAc,CAE9B,GAAG,YAAY;GACxC;GACA;GACD,CAAC;AAEF,MAAI,CAAC,SAAS,KACZ,OAAM,IAAI,MAAM,0BAA0B;EAG5C,MAAM,EAAE,aAAa,cAAc,SAAS;AAE5C,eAAa;GACX,aAAa,eAAe,YAAY;GACxC;GACD;GACD,EAAE;AAEJ,QAAO;;AAGT,MAAM,kBAAkB,YAAoB;AAC1C,QAAO,QACJ,WAAW,qBAAqB,GAAG,CACnC,WAAW,oBAAoB,GAAG,CAClC,WAAW,mBAAmB,GAAG,CACjC,WAAW,kBAAkB,GAAG,CAChC,WAAW,qBAAqB,GAAG,CACnC,WAAW,iBAAiB,GAAG,CAC/B,WAAW,gBAAgB,GAAG,CAC9B,WAAW,eAAe,GAAG,CAC7B,WAAW,kBAAkB,GAAG,CAChC,WAAW,iBAAiB,GAAG,CAC/B,WAAW,gBAAgB,GAAG,CAC9B,WAAW,eAAe,GAAG,CAC7B,WAAW,eAAe,GAAG,CAC7B,WAAW,cAAc,GAAG,CAC5B,WAAW,aAAa,GAAG,CAC3B,WAAW,YAAY,GAAG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_utils_calculateChunks = require('./calculateChunks.cjs');
|
|
3
|
-
let
|
|
3
|
+
let _intlayer_chokidar = require("@intlayer/chokidar");
|
|
4
4
|
|
|
5
5
|
//#region src/utils/mapChunksBetweenFiles.ts
|
|
6
6
|
/**
|
|
@@ -9,8 +9,8 @@ let __intlayer_chokidar = require("@intlayer/chokidar");
|
|
|
9
9
|
*/
|
|
10
10
|
const mapChunksBetweenFiles = (baseFileContent, updatedFileContent, maxCharsPerChunk = 800, changedLines) => {
|
|
11
11
|
const baseChunks = require_utils_calculateChunks.chunkText(baseFileContent, maxCharsPerChunk, 0);
|
|
12
|
-
const baseLines = (0,
|
|
13
|
-
const updatedLines = (0,
|
|
12
|
+
const baseLines = (0, _intlayer_chokidar.splitTextByLines)(baseFileContent);
|
|
13
|
+
const updatedLines = (0, _intlayer_chokidar.splitTextByLines)(updatedFileContent);
|
|
14
14
|
const lineMapping = createLineMapping(baseLines, updatedLines);
|
|
15
15
|
return baseChunks.map((baseChunk) => {
|
|
16
16
|
const mappedRange = mapLineRange(baseChunk.lineStart, baseChunk.lineLength, lineMapping);
|
|
@@ -84,7 +84,7 @@ const extractLinesFromRange = (lines, start, length) => {
|
|
|
84
84
|
* Gets the character position where a line starts in the text
|
|
85
85
|
*/
|
|
86
86
|
const getCharStartForLine = (text, lineNumber) => {
|
|
87
|
-
const lines = (0,
|
|
87
|
+
const lines = (0, _intlayer_chokidar.splitTextByLines)(text);
|
|
88
88
|
let charStart = 0;
|
|
89
89
|
for (let i = 0; i < Math.min(lineNumber, lines.length); i++) charStart += lines[i].length;
|
|
90
90
|
return charStart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapChunksBetweenFiles.cjs","names":["chunkText","updatedChunk: ChunkLineResult","dp: number[][]","i","j","mappedLines: number[]"],"sources":["../../../src/utils/mapChunksBetweenFiles.ts"],"sourcesContent":["import { splitTextByLines } from '@intlayer/chokidar';\nimport { type ChunkLineResult, chunkText } from './calculateChunks';\n\nexport interface ChunkMapping {\n baseChunk: ChunkLineResult;\n updatedChunk: ChunkLineResult | null; // null if the chunk was deleted\n hasChanges: boolean;\n}\n\n/**\n * Maps chunks from base file to corresponding chunks in updated file,\n * handling insertions, deletions, and modifications properly.\n */\nexport const mapChunksBetweenFiles = (\n baseFileContent: string,\n updatedFileContent: string,\n maxCharsPerChunk: number = 800,\n changedLines?: number[]\n): ChunkMapping[] => {\n const baseChunks = chunkText(baseFileContent, maxCharsPerChunk, 0);\n const baseLines = splitTextByLines(baseFileContent);\n const updatedLines = splitTextByLines(updatedFileContent);\n\n // Create a simple line mapping using LCS (Longest Common Subsequence) approach\n const lineMapping = createLineMapping(baseLines, updatedLines);\n\n return baseChunks.map((baseChunk): ChunkMapping => {\n // Map the base chunk's line range to the updated file\n const mappedRange = mapLineRange(\n baseChunk.lineStart,\n baseChunk.lineLength,\n lineMapping\n );\n\n if (!mappedRange) {\n // This chunk was completely deleted\n return {\n baseChunk,\n updatedChunk: null,\n hasChanges: true,\n };\n }\n\n // Create the corresponding chunk in the updated file\n const updatedChunk: ChunkLineResult = {\n lineStart: mappedRange.start,\n lineLength: mappedRange.length,\n charStart: 0, // Will be calculated when needed\n charLength: 0, // Will be calculated when needed\n content: extractLinesFromRange(\n updatedLines,\n mappedRange.start,\n mappedRange.length\n ),\n };\n\n // Calculate character positions\n updatedChunk.charStart = getCharStartForLine(\n updatedFileContent,\n updatedChunk.lineStart\n );\n updatedChunk.charLength = updatedChunk.content.length;\n\n // Determine if this chunk has changes\n const hasChanges = determineIfChunkHasChanges(\n baseChunk,\n updatedChunk,\n changedLines\n );\n\n return {\n baseChunk,\n updatedChunk,\n hasChanges,\n };\n });\n};\n\n/**\n * Creates a mapping between line numbers in base file and updated file\n * Returns a map where key = base line number, value = updated line number (or null if deleted)\n */\nconst createLineMapping = (\n baseLines: string[],\n updatedLines: string[]\n): Map<number, number | null> => {\n const mapping = new Map<number, number | null>();\n\n // Use a simple diff algorithm (similar to Myers algorithm but simplified)\n const dp: number[][] = Array(baseLines.length + 1)\n .fill(null)\n .map(() => Array(updatedLines.length + 1).fill(0));\n\n // Fill the DP table\n for (let i = 1; i <= baseLines.length; i++) {\n for (let j = 1; j <= updatedLines.length; j++) {\n if (baseLines[i - 1] === updatedLines[j - 1]) {\n dp[i][j] = dp[i - 1][j - 1] + 1;\n } else {\n dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);\n }\n }\n }\n\n // Backtrack to create the mapping\n let i = baseLines.length;\n let j = updatedLines.length;\n\n while (i > 0 || j > 0) {\n if (i > 0 && j > 0 && baseLines[i - 1] === updatedLines[j - 1]) {\n // Lines match\n mapping.set(i - 1, j - 1);\n i--;\n j--;\n } else if (i > 0 && (j === 0 || dp[i - 1][j] >= dp[i][j - 1])) {\n // Line was deleted from base\n mapping.set(i - 1, null);\n i--;\n } else {\n // Line was added to updated (no mapping needed for base)\n j--;\n }\n }\n\n return mapping;\n};\n\n/**\n * Maps a line range from base file to updated file using the line mapping\n */\nconst mapLineRange = (\n baseStart: number,\n baseLength: number,\n lineMapping: Map<number, number | null>\n): { start: number; length: number } | null => {\n const mappedLines: number[] = [];\n\n for (let i = baseStart; i < baseStart + baseLength; i++) {\n const mappedLine = lineMapping.get(i);\n if (mappedLine !== null && mappedLine !== undefined) {\n mappedLines.push(mappedLine);\n }\n }\n\n if (mappedLines.length === 0) {\n return null; // All lines were deleted\n }\n\n // Find the continuous range in the mapped lines\n mappedLines.sort((a, b) => a - b);\n const start = mappedLines[0];\n const end = mappedLines[mappedLines.length - 1];\n\n return {\n start,\n length: end - start + 1,\n };\n};\n\n/**\n * Extracts lines from a range in the lines array\n */\nconst extractLinesFromRange = (\n lines: string[],\n start: number,\n length: number\n): string => {\n const endIndex = Math.min(start + length, lines.length);\n return lines.slice(start, endIndex).join('');\n};\n\n/**\n * Gets the character position where a line starts in the text\n */\nconst getCharStartForLine = (text: string, lineNumber: number): number => {\n const lines = splitTextByLines(text);\n let charStart = 0;\n\n for (let i = 0; i < Math.min(lineNumber, lines.length); i++) {\n charStart += lines[i].length;\n }\n\n return charStart;\n};\n\n/**\n * Determines if a chunk has changes based on git changed lines or content comparison\n */\nconst determineIfChunkHasChanges = (\n baseChunk: ChunkLineResult,\n updatedChunk: ChunkLineResult,\n changedLines?: number[]\n): boolean => {\n // If we have git changed lines, use them for precise detection\n if (changedLines && changedLines.length > 0) {\n return changedLines.some(\n (line) =>\n line >= updatedChunk.lineStart &&\n line < updatedChunk.lineStart + updatedChunk.lineLength\n );\n }\n\n // Fallback to content comparison\n return baseChunk.content !== updatedChunk.content;\n};\n"],"mappings":";;;;;;;;;AAaA,MAAa,yBACX,iBACA,oBACA,mBAA2B,KAC3B,iBACmB;CACnB,MAAM,aAAaA,wCAAU,iBAAiB,kBAAkB,EAAE;CAClE,MAAM,
|
|
1
|
+
{"version":3,"file":"mapChunksBetweenFiles.cjs","names":["chunkText","updatedChunk: ChunkLineResult","dp: number[][]","i","j","mappedLines: number[]"],"sources":["../../../src/utils/mapChunksBetweenFiles.ts"],"sourcesContent":["import { splitTextByLines } from '@intlayer/chokidar';\nimport { type ChunkLineResult, chunkText } from './calculateChunks';\n\nexport interface ChunkMapping {\n baseChunk: ChunkLineResult;\n updatedChunk: ChunkLineResult | null; // null if the chunk was deleted\n hasChanges: boolean;\n}\n\n/**\n * Maps chunks from base file to corresponding chunks in updated file,\n * handling insertions, deletions, and modifications properly.\n */\nexport const mapChunksBetweenFiles = (\n baseFileContent: string,\n updatedFileContent: string,\n maxCharsPerChunk: number = 800,\n changedLines?: number[]\n): ChunkMapping[] => {\n const baseChunks = chunkText(baseFileContent, maxCharsPerChunk, 0);\n const baseLines = splitTextByLines(baseFileContent);\n const updatedLines = splitTextByLines(updatedFileContent);\n\n // Create a simple line mapping using LCS (Longest Common Subsequence) approach\n const lineMapping = createLineMapping(baseLines, updatedLines);\n\n return baseChunks.map((baseChunk): ChunkMapping => {\n // Map the base chunk's line range to the updated file\n const mappedRange = mapLineRange(\n baseChunk.lineStart,\n baseChunk.lineLength,\n lineMapping\n );\n\n if (!mappedRange) {\n // This chunk was completely deleted\n return {\n baseChunk,\n updatedChunk: null,\n hasChanges: true,\n };\n }\n\n // Create the corresponding chunk in the updated file\n const updatedChunk: ChunkLineResult = {\n lineStart: mappedRange.start,\n lineLength: mappedRange.length,\n charStart: 0, // Will be calculated when needed\n charLength: 0, // Will be calculated when needed\n content: extractLinesFromRange(\n updatedLines,\n mappedRange.start,\n mappedRange.length\n ),\n };\n\n // Calculate character positions\n updatedChunk.charStart = getCharStartForLine(\n updatedFileContent,\n updatedChunk.lineStart\n );\n updatedChunk.charLength = updatedChunk.content.length;\n\n // Determine if this chunk has changes\n const hasChanges = determineIfChunkHasChanges(\n baseChunk,\n updatedChunk,\n changedLines\n );\n\n return {\n baseChunk,\n updatedChunk,\n hasChanges,\n };\n });\n};\n\n/**\n * Creates a mapping between line numbers in base file and updated file\n * Returns a map where key = base line number, value = updated line number (or null if deleted)\n */\nconst createLineMapping = (\n baseLines: string[],\n updatedLines: string[]\n): Map<number, number | null> => {\n const mapping = new Map<number, number | null>();\n\n // Use a simple diff algorithm (similar to Myers algorithm but simplified)\n const dp: number[][] = Array(baseLines.length + 1)\n .fill(null)\n .map(() => Array(updatedLines.length + 1).fill(0));\n\n // Fill the DP table\n for (let i = 1; i <= baseLines.length; i++) {\n for (let j = 1; j <= updatedLines.length; j++) {\n if (baseLines[i - 1] === updatedLines[j - 1]) {\n dp[i][j] = dp[i - 1][j - 1] + 1;\n } else {\n dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);\n }\n }\n }\n\n // Backtrack to create the mapping\n let i = baseLines.length;\n let j = updatedLines.length;\n\n while (i > 0 || j > 0) {\n if (i > 0 && j > 0 && baseLines[i - 1] === updatedLines[j - 1]) {\n // Lines match\n mapping.set(i - 1, j - 1);\n i--;\n j--;\n } else if (i > 0 && (j === 0 || dp[i - 1][j] >= dp[i][j - 1])) {\n // Line was deleted from base\n mapping.set(i - 1, null);\n i--;\n } else {\n // Line was added to updated (no mapping needed for base)\n j--;\n }\n }\n\n return mapping;\n};\n\n/**\n * Maps a line range from base file to updated file using the line mapping\n */\nconst mapLineRange = (\n baseStart: number,\n baseLength: number,\n lineMapping: Map<number, number | null>\n): { start: number; length: number } | null => {\n const mappedLines: number[] = [];\n\n for (let i = baseStart; i < baseStart + baseLength; i++) {\n const mappedLine = lineMapping.get(i);\n if (mappedLine !== null && mappedLine !== undefined) {\n mappedLines.push(mappedLine);\n }\n }\n\n if (mappedLines.length === 0) {\n return null; // All lines were deleted\n }\n\n // Find the continuous range in the mapped lines\n mappedLines.sort((a, b) => a - b);\n const start = mappedLines[0];\n const end = mappedLines[mappedLines.length - 1];\n\n return {\n start,\n length: end - start + 1,\n };\n};\n\n/**\n * Extracts lines from a range in the lines array\n */\nconst extractLinesFromRange = (\n lines: string[],\n start: number,\n length: number\n): string => {\n const endIndex = Math.min(start + length, lines.length);\n return lines.slice(start, endIndex).join('');\n};\n\n/**\n * Gets the character position where a line starts in the text\n */\nconst getCharStartForLine = (text: string, lineNumber: number): number => {\n const lines = splitTextByLines(text);\n let charStart = 0;\n\n for (let i = 0; i < Math.min(lineNumber, lines.length); i++) {\n charStart += lines[i].length;\n }\n\n return charStart;\n};\n\n/**\n * Determines if a chunk has changes based on git changed lines or content comparison\n */\nconst determineIfChunkHasChanges = (\n baseChunk: ChunkLineResult,\n updatedChunk: ChunkLineResult,\n changedLines?: number[]\n): boolean => {\n // If we have git changed lines, use them for precise detection\n if (changedLines && changedLines.length > 0) {\n return changedLines.some(\n (line) =>\n line >= updatedChunk.lineStart &&\n line < updatedChunk.lineStart + updatedChunk.lineLength\n );\n }\n\n // Fallback to content comparison\n return baseChunk.content !== updatedChunk.content;\n};\n"],"mappings":";;;;;;;;;AAaA,MAAa,yBACX,iBACA,oBACA,mBAA2B,KAC3B,iBACmB;CACnB,MAAM,aAAaA,wCAAU,iBAAiB,kBAAkB,EAAE;CAClE,MAAM,qDAA6B,gBAAgB;CACnD,MAAM,wDAAgC,mBAAmB;CAGzD,MAAM,cAAc,kBAAkB,WAAW,aAAa;AAE9D,QAAO,WAAW,KAAK,cAA4B;EAEjD,MAAM,cAAc,aAClB,UAAU,WACV,UAAU,YACV,YACD;AAED,MAAI,CAAC,YAEH,QAAO;GACL;GACA,cAAc;GACd,YAAY;GACb;EAIH,MAAMC,eAAgC;GACpC,WAAW,YAAY;GACvB,YAAY,YAAY;GACxB,WAAW;GACX,YAAY;GACZ,SAAS,sBACP,cACA,YAAY,OACZ,YAAY,OACb;GACF;AAGD,eAAa,YAAY,oBACvB,oBACA,aAAa,UACd;AACD,eAAa,aAAa,aAAa,QAAQ;AAS/C,SAAO;GACL;GACA;GACA,YATiB,2BACjB,WACA,cACA,aACD;GAMA;GACD;;;;;;AAOJ,MAAM,qBACJ,WACA,iBAC+B;CAC/B,MAAM,0BAA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,KAAK,IAAI,QAAQ,QAAQ,MAAM,OAAO;AACvD,QAAO,MAAM,MAAM,OAAO,SAAS,CAAC,KAAK,GAAG;;;;;AAM9C,MAAM,uBAAuB,MAAc,eAA+B;CACxE,MAAM,iDAAyB,KAAK;CACpC,IAAI,YAAY;AAEhB,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IAAI,YAAY,MAAM,OAAO,EAAE,IACtD,cAAa,MAAM,GAAG;AAGxB,QAAO;;;;;AAMT,MAAM,8BACJ,WACA,cACA,iBACY;AAEZ,KAAI,gBAAgB,aAAa,SAAS,EACxC,QAAO,aAAa,MACjB,SACC,QAAQ,aAAa,aACrB,OAAO,aAAa,YAAY,aAAa,WAChD;AAIH,QAAO,UAAU,YAAY,aAAa"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_utils_checkAccess = require('./checkAccess.cjs');
|
|
3
|
-
let
|
|
3
|
+
let _intlayer_config = require("@intlayer/config");
|
|
4
4
|
|
|
5
5
|
//#region src/utils/setupAI.ts
|
|
6
6
|
globalThis.AI_SDK_LOG_WARNINGS = false;
|
|
@@ -10,7 +10,7 @@ globalThis.AI_SDK_LOG_WARNINGS = false;
|
|
|
10
10
|
* Also checks if the user has access to AI (either via local key or CMS auth).
|
|
11
11
|
*/
|
|
12
12
|
const setupAI = async (configuration, aiOptions) => {
|
|
13
|
-
const appLogger = (0,
|
|
13
|
+
const appLogger = (0, _intlayer_config.getAppLogger)(configuration);
|
|
14
14
|
const hasAIAccess = await require_utils_checkAccess.checkAIAccess(configuration, aiOptions);
|
|
15
15
|
if (aiOptions?.apiKey) try {
|
|
16
16
|
const aiClient = await import("@intlayer/ai");
|
|
@@ -25,9 +25,9 @@ const setupAI = async (configuration, aiOptions) => {
|
|
|
25
25
|
};
|
|
26
26
|
} catch {
|
|
27
27
|
appLogger([
|
|
28
|
-
(0,
|
|
29
|
-
(0,
|
|
30
|
-
(0,
|
|
28
|
+
(0, _intlayer_config.colorize)("Using your API key, you can install the", _intlayer_config.ANSIColors.GREY),
|
|
29
|
+
(0, _intlayer_config.colorize)("@intlayer/ai", _intlayer_config.ANSIColors.GREY_LIGHT),
|
|
30
|
+
(0, _intlayer_config.colorize)("package to run the process locally, with no dependency on the Intlayer server", _intlayer_config.ANSIColors.GREY)
|
|
31
31
|
], { level: "warn" });
|
|
32
32
|
}
|
|
33
33
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupAI.cjs","names":["checkAIAccess","ANSIColors"],"sources":["../../../src/utils/setupAI.ts"],"sourcesContent":["import type { AIConfig, AIOptions } from '@intlayer/ai';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { checkAIAccess } from './checkAccess';\n\nexport type AIClient = typeof import('@intlayer/ai');\n\ntype SetupAIResult = {\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n isCustomAI: boolean;\n hasAIAccess: boolean;\n};\n\n// Disable warnings from the AI SDK\nglobalThis.AI_SDK_LOG_WARNINGS = false;\n\n/**\n * Checks if the @intlayer/ai package is available and configured when an API key is provided.\n * If API key is present but package is missing, logs a warning.\n * Also checks if the user has access to AI (either via local key or CMS auth).\n */\nexport const setupAI = async (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions\n): Promise<SetupAIResult | undefined> => {\n const appLogger = getAppLogger(configuration);\n\n const hasAIAccess = await checkAIAccess(configuration, aiOptions);\n\n if (aiOptions?.apiKey) {\n try {\n // Dynamically import the AI package if an API key is provided\n const aiClient = await import('@intlayer/ai');\n\n const aiConfig = await aiClient.getAIConfig({\n userOptions: aiOptions,\n accessType: ['public'],\n });\n\n return {\n aiClient,\n aiConfig,\n isCustomAI: true,\n hasAIAccess,\n };\n } catch {\n appLogger(\n [\n colorize('Using your API key, you can install the', ANSIColors.GREY),\n colorize('@intlayer/ai', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to run the process locally, with no dependency on the Intlayer server',\n ANSIColors.GREY\n ),\n ],\n {\n level: 'warn',\n }\n );\n }\n }\n\n return {\n isCustomAI: false,\n hasAIAccess,\n };\n};\n"],"mappings":";;;;;AAeA,WAAW,sBAAsB;;;;;;AAOjC,MAAa,UAAU,OACrB,eACA,cACuC;CACvC,MAAM,
|
|
1
|
+
{"version":3,"file":"setupAI.cjs","names":["checkAIAccess","ANSIColors"],"sources":["../../../src/utils/setupAI.ts"],"sourcesContent":["import type { AIConfig, AIOptions } from '@intlayer/ai';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { checkAIAccess } from './checkAccess';\n\nexport type AIClient = typeof import('@intlayer/ai');\n\ntype SetupAIResult = {\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n isCustomAI: boolean;\n hasAIAccess: boolean;\n};\n\n// Disable warnings from the AI SDK\nglobalThis.AI_SDK_LOG_WARNINGS = false;\n\n/**\n * Checks if the @intlayer/ai package is available and configured when an API key is provided.\n * If API key is present but package is missing, logs a warning.\n * Also checks if the user has access to AI (either via local key or CMS auth).\n */\nexport const setupAI = async (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions\n): Promise<SetupAIResult | undefined> => {\n const appLogger = getAppLogger(configuration);\n\n const hasAIAccess = await checkAIAccess(configuration, aiOptions);\n\n if (aiOptions?.apiKey) {\n try {\n // Dynamically import the AI package if an API key is provided\n const aiClient = await import('@intlayer/ai');\n\n const aiConfig = await aiClient.getAIConfig({\n userOptions: aiOptions,\n accessType: ['public'],\n });\n\n return {\n aiClient,\n aiConfig,\n isCustomAI: true,\n hasAIAccess,\n };\n } catch {\n appLogger(\n [\n colorize('Using your API key, you can install the', ANSIColors.GREY),\n colorize('@intlayer/ai', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to run the process locally, with no dependency on the Intlayer server',\n ANSIColors.GREY\n ),\n ],\n {\n level: 'warn',\n }\n );\n }\n }\n\n return {\n isCustomAI: false,\n hasAIAccess,\n };\n};\n"],"mappings":";;;;;AAeA,WAAW,sBAAsB;;;;;;AAOjC,MAAa,UAAU,OACrB,eACA,cACuC;CACvC,MAAM,+CAAyB,cAAc;CAE7C,MAAM,cAAc,MAAMA,wCAAc,eAAe,UAAU;AAEjE,KAAI,WAAW,OACb,KAAI;EAEF,MAAM,WAAW,MAAM,OAAO;AAO9B,SAAO;GACL;GACA,UAPe,MAAM,SAAS,YAAY;IAC1C,aAAa;IACb,YAAY,CAAC,SAAS;IACvB,CAAC;GAKA,YAAY;GACZ;GACD;SACK;AACN,YACE;kCACW,2CAA2CC,4BAAW,KAAK;kCAC3D,gBAAgBA,4BAAW,WAAW;kCAE7C,iFACAA,4BAAW,KACZ;GACF,EACD,EACE,OAAO,QACR,CACF;;AAIL,QAAO;EACL,YAAY;EACZ;EACD"}
|
package/dist/cjs/watch.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
3
|
-
let
|
|
2
|
+
let _intlayer_chokidar = require("@intlayer/chokidar");
|
|
3
|
+
let _intlayer_config = require("@intlayer/config");
|
|
4
4
|
|
|
5
5
|
//#region src/watch.ts
|
|
6
6
|
/**
|
|
@@ -8,13 +8,34 @@ let __intlayer_config = require("@intlayer/config");
|
|
|
8
8
|
* Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}
|
|
9
9
|
*/
|
|
10
10
|
const watchContentDeclaration = async (options) => {
|
|
11
|
-
const appLogger = (0,
|
|
12
|
-
|
|
11
|
+
const appLogger = (0, _intlayer_config.getAppLogger)((0, _intlayer_config.getConfiguration)(options?.configOptions));
|
|
12
|
+
let parallelProcess;
|
|
13
|
+
if (options?.with) {
|
|
14
|
+
parallelProcess = (0, _intlayer_chokidar.runParallel)(options.with);
|
|
15
|
+
parallelProcess.result.catch(() => {
|
|
16
|
+
process.exit(1);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
13
19
|
appLogger("Watching Intlayer content declarations");
|
|
14
|
-
(0,
|
|
20
|
+
const watcher = (0, _intlayer_chokidar.watch)({
|
|
15
21
|
persistent: true,
|
|
16
22
|
skipPrepare: options?.skipPrepare ?? false
|
|
17
23
|
});
|
|
24
|
+
const handleShutdown = async () => {
|
|
25
|
+
process.off("SIGINT", handleShutdown);
|
|
26
|
+
process.off("SIGTERM", handleShutdown);
|
|
27
|
+
appLogger("Stopping Intlayer watcher...");
|
|
28
|
+
try {
|
|
29
|
+
await watcher.close();
|
|
30
|
+
if (parallelProcess && "child" in parallelProcess) parallelProcess.child?.kill("SIGTERM");
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error("Error during shutdown:", error);
|
|
33
|
+
} finally {
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
process.on("SIGINT", handleShutdown);
|
|
38
|
+
process.on("SIGTERM", handleShutdown);
|
|
18
39
|
};
|
|
19
40
|
|
|
20
41
|
//#endregion
|
package/dist/cjs/watch.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.cjs","names":[],"sources":["../../src/watch.ts"],"sourcesContent":["import { runParallel, watch } from '@intlayer/chokidar';\nimport {\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\n\ntype WatchOptions = {\n skipPrepare?: boolean;\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\n/**\n * Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.\n * Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}\n */\nexport const watchContentDeclaration = async (options?: WatchOptions) => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n if (options?.with) {\n
|
|
1
|
+
{"version":3,"file":"watch.cjs","names":["parallelProcess: ReturnType<typeof runParallel> | undefined"],"sources":["../../src/watch.ts"],"sourcesContent":["import { runParallel, watch } from '@intlayer/chokidar';\nimport {\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\n\ntype WatchOptions = {\n skipPrepare?: boolean;\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\n/**\n * Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.\n * Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}\n */\nexport const watchContentDeclaration = async (options?: WatchOptions) => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n // Store references to the child process\n let parallelProcess: ReturnType<typeof runParallel> | undefined;\n\n if (options?.with) {\n parallelProcess = runParallel(options.with);\n // Handle the promise to avoid unhandled rejection\n parallelProcess.result.catch(() => {\n // Parallel process failed or was terminated\n process.exit(1);\n });\n }\n\n appLogger('Watching Intlayer content declarations');\n\n // Capture the watcher instance\n const watcher = watch({\n persistent: true,\n skipPrepare: options?.skipPrepare ?? false,\n });\n\n // Define a Graceful Shutdown function\n const handleShutdown = async () => {\n // Prevent multiple calls\n process.off('SIGINT', handleShutdown);\n process.off('SIGTERM', handleShutdown);\n\n appLogger('Stopping Intlayer watcher...');\n\n try {\n // Close the file watcher immediately to stop \"esbuild service not running\" errors\n await watcher.close();\n\n // If runParallel exposes the child process, we can try to kill it explicitly.\n // Even if it doesn't, process.exit() below usually cleans up attached children.\n if (parallelProcess && 'child' in parallelProcess) {\n // @ts-ignore - Assuming child exists on the return type if runParallel is based on spawn/exec\n parallelProcess.child?.kill('SIGTERM');\n }\n } catch (error) {\n console.error('Error during shutdown:', error);\n } finally {\n process.exit(0);\n }\n };\n\n // Attach Signal Listeners\n process.on('SIGINT', handleShutdown);\n process.on('SIGTERM', handleShutdown);\n};\n"],"mappings":";;;;;;;;;AAiBA,MAAa,0BAA0B,OAAO,YAA2B;CAEvE,MAAM,sFAD0B,SAAS,cAAc,CACjB;CAGtC,IAAIA;AAEJ,KAAI,SAAS,MAAM;AACjB,wDAA8B,QAAQ,KAAK;AAE3C,kBAAgB,OAAO,YAAY;AAEjC,WAAQ,KAAK,EAAE;IACf;;AAGJ,WAAU,yCAAyC;CAGnD,MAAM,wCAAgB;EACpB,YAAY;EACZ,aAAa,SAAS,eAAe;EACtC,CAAC;CAGF,MAAM,iBAAiB,YAAY;AAEjC,UAAQ,IAAI,UAAU,eAAe;AACrC,UAAQ,IAAI,WAAW,eAAe;AAEtC,YAAU,+BAA+B;AAEzC,MAAI;AAEF,SAAM,QAAQ,OAAO;AAIrB,OAAI,mBAAmB,WAAW,gBAEhC,iBAAgB,OAAO,KAAK,UAAU;WAEjC,OAAO;AACd,WAAQ,MAAM,0BAA0B,MAAM;YACtC;AACR,WAAQ,KAAK,EAAE;;;AAKnB,SAAQ,GAAG,UAAU,eAAe;AACpC,SAAQ,GAAG,WAAW,eAAe"}
|
package/dist/esm/auth/login.mjs
CHANGED
|
@@ -64,7 +64,7 @@ const login = async (options) => {
|
|
|
64
64
|
--color-card: rgba(39, 39, 39);
|
|
65
65
|
--color-text: rgba(255, 245, 237);
|
|
66
66
|
--color-neutral: rgba(93, 93, 93);
|
|
67
|
-
--font-sans: "
|
|
67
|
+
--font-sans: "Inter", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
* {
|