@fluenti/cli 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -4,5 +4,5 @@ const e=require(`./compile-DK1UYkah.cjs`);let t=require(`citty`),n=require(`cons
|
|
|
4
4
|
... (truncated)`:n})}let s=await(0,r.default)(e.sourcePatterns,{absolute:!1});for(let e of s.slice(0,5)){let n=(0,i.readFileSync)((0,a.resolve)(e),`utf-8`);t.sampleSources.push({path:e,content:n.length>3e3?n.slice(0,3e3)+`
|
|
5
5
|
... (truncated)`:n})}return t}function b(e){let t=[(0,a.resolve)(`node_modules`,`@fluenti`,`cli`,`..`,`..`,e),(0,a.join)(__dirname,`..`,`..`,`..`,e),(0,a.join)(__dirname,`..`,`..`,e)];for(let e of t)if((0,i.existsSync)(e))return(0,i.readFileSync)(e,`utf-8`);return``}function x(e,t,n){let r=[];if(r.push(`You are a migration assistant helping convert a ${e.framework} project from "${e.name}" to Fluenti (@fluenti).`,``,`Your task:`,"1. Generate a `fluenti.config.ts` file based on the existing i18n configuration",`2. Convert each locale/translation file to Fluenti PO format`,`3. List the code changes needed (file by file) to migrate source code from the old API to Fluenti API`,``),n&&r.push(`=== MIGRATION GUIDE ===`,n,``),t.packageJson&&r.push(`=== package.json ===`,t.packageJson,``),t.configFiles.length>0){r.push(`=== EXISTING CONFIG FILES ===`);for(let e of t.configFiles)r.push(`--- ${e.path} ---`,e.content,``)}if(t.localeFiles.length>0){r.push(`=== EXISTING LOCALE FILES ===`);for(let e of t.localeFiles)r.push(`--- ${e.path} ---`,e.content,``)}if(t.sampleSources.length>0){r.push(`=== SAMPLE SOURCE FILES ===`);for(let e of t.sampleSources)r.push(`--- ${e.path} ---`,e.content,``)}return r.push(``,`=== OUTPUT FORMAT ===`,`Respond with the following sections, each starting with the exact header shown:`,``,`### FLUENTI_CONFIG`,"```ts",`// The fluenti.config.ts content`,"```",``,`### LOCALE_FILES`,`For each locale file, output:`,`#### LOCALE: {locale_code}`,"```po",`// The PO file content`,"```",``,`### MIGRATION_STEPS`,`A numbered checklist of specific code changes needed, with before/after examples.`,``,`### INSTALL_COMMANDS`,"```bash",`// The install and uninstall commands`,"```"),r.join(`
|
|
6
6
|
`)}async function S(e,t){let n=10*1024*1024;try{if(e===`claude`){let{stdout:e}=await h(`claude`,[`-p`,t],{maxBuffer:n});return e}else{let{stdout:e}=await h(`codex`,[`-p`,t,`--full-auto`],{maxBuffer:n});return e}}catch(t){throw t.code===`ENOENT`?Error(`"${e}" CLI not found. Please install it first:\n`+(e===`claude`?` npm install -g @anthropic-ai/claude-code`:` npm install -g @openai/codex`)):t}}function C(e){let t={config:void 0,localeFiles:[],steps:void 0,installCommands:void 0},n=e.match(/### FLUENTI_CONFIG[\s\S]*?```(?:ts|typescript)?\n([\s\S]*?)```/);n&&(t.config=n[1].trim());let r=e.match(/### LOCALE_FILES([\s\S]*?)(?=### MIGRATION_STEPS|### INSTALL_COMMANDS|$)/);if(r){let e=/#### LOCALE:\s*(\S+)\s*\n```(?:po)?\n([\s\S]*?)```/g,n;for(;(n=e.exec(r[1]))!==null;)t.localeFiles.push({locale:n[1],content:n[2].trim()})}let i=e.match(/### MIGRATION_STEPS\s*\n([\s\S]*?)(?=### INSTALL_COMMANDS|$)/);i&&(t.steps=i[1].trim());let a=e.match(/### INSTALL_COMMANDS[\s\S]*?```(?:bash|sh)?\n([\s\S]*?)```/);return a&&(t.installCommands=a[1].trim()),t}async function w(e){let{from:t,provider:r,write:i}=e,o=v(t);if(!o){n.default.error(`Unsupported library "${t}". Supported libraries:`);for(let e of _)n.default.log(` - ${e}`);return}let s=g[o];n.default.info(`Migrating from ${s.name} (${s.framework}) to Fluenti`),n.default.info(`Scanning project for existing i18n files...`);let c=await y(s);if(c.configFiles.length===0&&c.localeFiles.length===0){n.default.warn(`No ${s.name} configuration or locale files found.`),n.default.info(`Make sure you are running this command from the project root directory.`);return}n.default.info(`Found: ${c.configFiles.length} config file(s), ${c.localeFiles.length} locale file(s), ${c.sampleSources.length} source file(s)`);let l=b(s.migrationGuide);n.default.info(`Generating migration plan with ${r}...`);let u=C(await S(r,x(s,c,l)));if(u.installCommands&&(n.default.log(``),n.default.box({title:`Install Commands`,message:u.installCommands})),u.config)if(i){let{writeFileSync:e}=await import(`node:fs`),t=(0,a.resolve)(`fluenti.config.ts`);e(t,u.config,`utf-8`),n.default.success(`Written: ${t}`)}else n.default.log(``),n.default.box({title:`fluenti.config.ts`,message:u.config});if(u.localeFiles.length>0)if(i){let{writeFileSync:e,mkdirSync:t}=await import(`node:fs`),r=`./locales`;t((0,a.resolve)(r),{recursive:!0});for(let t of u.localeFiles){let i=(0,a.resolve)(r,`${t.locale}.po`);e(i,t.content,`utf-8`),n.default.success(`Written: ${i}`)}}else for(let e of u.localeFiles)n.default.log(``),n.default.box({title:`locales/${e.locale}.po`,message:e.content.length>500?e.content.slice(0,500)+`
|
|
7
|
-
... (use --write to save full file)`:e.content});u.steps&&(n.default.log(``),n.default.box({title:`Migration Steps`,message:u.steps})),!i&&(u.config||u.localeFiles.length>0)&&(n.default.log(``),n.default.info(`Run with --write to save generated files to disk:`),n.default.log(` fluenti migrate --from ${t} --write`))}var T={sourceLocale:`en`,locales:[`en`],catalogDir:`./locales`,format:`po`,include:[`./src/**/*.{vue,tsx,jsx,ts,js}`],compileOutDir:`./locales/compiled`};async function E(e){let t=e?[(0,a.resolve)(e)]:[(0,a.resolve)(`fluenti.config.ts`),(0,a.resolve)(`fluenti.config.js`),(0,a.resolve)(`fluenti.config.mjs`)];for(let e of t)if((0,i.existsSync)(e))try{let{createJiti:t}=await import(`jiti`),n=await t({}.url).import(e),r=n.default??n;return{...T,...r}}catch{n.default.warn(`Failed to load config from ${e}, using defaults`)}return T}function D(t,n){if(!(0,i.existsSync)(t))return{};let r=(0,i.readFileSync)(t,`utf-8`);return n===`json`?e.o(r):e.i(r)}function O(t,n,r){(0,i.mkdirSync)((0,a.dirname)(t),{recursive:!0}),(0,i.writeFileSync)(t,r===`json`?e.s(n):e.a(n),`utf-8`)}function k(t,n){return(0,a.extname)(t)===`.vue`?e.l(n,t):e.u(n,t)}(0,t.runMain)((0,t.defineCommand)({meta:{name:`fluenti`,version:`0.0.1`,description:`Compile-time i18n for modern frameworks`},subCommands:{extract:(0,t.defineCommand)({meta:{name:`extract`,description:`Extract messages from source files`},args:{config:{type:`string`,description:`Path to config file`},clean:{type:`boolean`,description:`Remove obsolete entries instead of marking them`,default:!1}},async run({args:t}){let o=await E(t.config);n.default.info(`Extracting messages from ${o.include.join(`, `)}`);let s=await(0,r.default)(o.include
|
|
7
|
+
... (use --write to save full file)`:e.content});u.steps&&(n.default.log(``),n.default.box({title:`Migration Steps`,message:u.steps})),!i&&(u.config||u.localeFiles.length>0)&&(n.default.log(``),n.default.info(`Run with --write to save generated files to disk:`),n.default.log(` fluenti migrate --from ${t} --write`))}var T={sourceLocale:`en`,locales:[`en`],catalogDir:`./locales`,format:`po`,include:[`./src/**/*.{vue,tsx,jsx,ts,js}`],compileOutDir:`./locales/compiled`};async function E(e){let t=e?[(0,a.resolve)(e)]:[(0,a.resolve)(`fluenti.config.ts`),(0,a.resolve)(`fluenti.config.js`),(0,a.resolve)(`fluenti.config.mjs`)];for(let e of t)if((0,i.existsSync)(e))try{let{createJiti:t}=await import(`jiti`),n=await t({}.url).import(e),r=n.default??n;return{...T,...r}}catch{n.default.warn(`Failed to load config from ${e}, using defaults`)}return T}function D(t,n){if(!(0,i.existsSync)(t))return{};let r=(0,i.readFileSync)(t,`utf-8`);return n===`json`?e.o(r):e.i(r)}function O(t,n,r){(0,i.mkdirSync)((0,a.dirname)(t),{recursive:!0}),(0,i.writeFileSync)(t,r===`json`?e.s(n):e.a(n),`utf-8`)}function k(t,n){return(0,a.extname)(t)===`.vue`?e.l(n,t):e.u(n,t)}(0,t.runMain)((0,t.defineCommand)({meta:{name:`fluenti`,version:`0.0.1`,description:`Compile-time i18n for modern frameworks`},subCommands:{extract:(0,t.defineCommand)({meta:{name:`extract`,description:`Extract messages from source files`},args:{config:{type:`string`,description:`Path to config file`},clean:{type:`boolean`,description:`Remove obsolete entries instead of marking them`,default:!1}},async run({args:t}){let o=await E(t.config);n.default.info(`Extracting messages from ${o.include.join(`, `)}`);let s=await(0,r.default)(o.include),c=[];for(let e of s){let t=k(e,(0,i.readFileSync)(e,`utf-8`));c.push(...t)}n.default.info(`Found ${c.length} messages in ${s.length} files`);let l=o.format===`json`?`.json`:`.po`,u=t.clean??!1;for(let t of o.locales){let r=(0,a.resolve)(o.catalogDir,`${t}${l}`),{catalog:i,result:s}=e.c(D(r,o.format),c);O(r,u?Object.fromEntries(Object.entries(i).filter(([,e])=>!e.obsolete)):i,o.format);let d=u?`${s.obsolete} removed`:`${s.obsolete} obsolete`;n.default.success(`${t}: ${s.added} added, ${s.unchanged} unchanged, ${d}`)}}}),compile:(0,t.defineCommand)({meta:{name:`compile`,description:`Compile message catalogs to JS modules`},args:{config:{type:`string`,description:`Path to config file`}},async run({args:t}){let r=await E(t.config),o=r.format===`json`?`.json`:`.po`;(0,i.mkdirSync)(r.compileOutDir,{recursive:!0});let s={};for(let e of r.locales)s[e]=D((0,a.resolve)(r.catalogDir,`${e}${o}`),r.format);let c=e.t(s);n.default.info(`Compiling ${c.length} messages across ${r.locales.length} locales`);for(let t of r.locales){let{code:o,stats:l}=e.n(s[t],t,c,r.sourceLocale),u=(0,a.resolve)(r.compileOutDir,`${t}.js`);if((0,i.writeFileSync)(u,o,`utf-8`),l.missing.length>0){n.default.warn(`${t}: ${l.compiled} compiled, ${l.missing.length} missing translations`);for(let e of l.missing)n.default.warn(` ⤷ ${e}`)}else n.default.success(`Compiled ${t}: ${l.compiled} messages → ${u}`)}let l=e.r(r.locales,r.compileOutDir),u=(0,a.resolve)(r.compileOutDir,`index.js`);(0,i.writeFileSync)(u,l,`utf-8`),n.default.success(`Generated index → ${u}`)}}),stats:(0,t.defineCommand)({meta:{name:`stats`,description:`Show translation progress`},args:{config:{type:`string`,description:`Path to config file`}},async run({args:e}){let t=await E(e.config),r=t.format===`json`?`.json`:`.po`,i=[];for(let e of t.locales){let n=D((0,a.resolve)(t.catalogDir,`${e}${r}`),t.format),o=Object.values(n).filter(e=>!e.obsolete),s=o.length,c=o.filter(e=>e.translation&&e.translation.length>0).length,l=s>0?(c/s*100).toFixed(1)+`%`:`—`;i.push({locale:e,total:s,translated:c,pct:l})}n.default.log(``),n.default.log(` Locale │ Total │ Translated │ Progress`),n.default.log(` ────────┼───────┼────────────┼─────────`);for(let e of i)n.default.log(` ${e.locale.padEnd(8)}│ ${String(e.total).padStart(5)} │ ${String(e.translated).padStart(10)} │ ${e.pct}`);n.default.log(``)}}),translate:(0,t.defineCommand)({meta:{name:`translate`,description:`Translate messages using AI (Claude Code or Codex CLI)`},args:{config:{type:`string`,description:`Path to config file`},provider:{type:`string`,description:`AI provider: claude or codex`,default:`claude`},locale:{type:`string`,description:`Translate a specific locale only`},"batch-size":{type:`string`,description:`Messages per batch`,default:`50`}},async run({args:e}){let t=await E(e.config),r=e.provider;if(r!==`claude`&&r!==`codex`){n.default.error(`Invalid provider "${r}". Use "claude" or "codex".`);return}let i=parseInt(e[`batch-size`]??`50`,10);if(isNaN(i)||i<1){n.default.error(`Invalid batch-size. Must be a positive integer.`);return}let o=e.locale?[e.locale]:t.locales.filter(e=>e!==t.sourceLocale);if(o.length===0){n.default.warn(`No target locales to translate.`);return}n.default.info(`Translating with ${r} (batch size: ${i})`);let s=t.format===`json`?`.json`:`.po`;for(let e of o){n.default.info(`\n[${e}]`);let o=(0,a.resolve)(t.catalogDir,`${e}${s}`),c=D(o,t.format),{catalog:l,translated:u}=await m({provider:r,sourceLocale:t.sourceLocale,targetLocale:e,catalog:c,batchSize:i});u>0?(O(o,l,t.format),n.default.success(` ${e}: ${u} messages translated`)):n.default.success(` ${e}: already fully translated`)}}}),migrate:(0,t.defineCommand)({meta:{name:`migrate`,description:`Migrate from another i18n library using AI`},args:{from:{type:`string`,description:`Source library: vue-i18n, nuxt-i18n, react-i18next, next-intl, next-i18next, lingui`,required:!0},provider:{type:`string`,description:`AI provider: claude or codex`,default:`claude`},write:{type:`boolean`,description:`Write generated files to disk`,default:!1}},async run({args:e}){let t=e.provider;if(t!==`claude`&&t!==`codex`){n.default.error(`Invalid provider "${t}". Use "claude" or "codex".`);return}await w({from:e.from,provider:t,write:e.write??!1})}})}}));
|
|
8
8
|
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":[],"sources":["../src/translate.ts","../src/migrate.ts","../src/cli.ts"],"sourcesContent":["import { execFile } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport consola from 'consola'\nimport type { CatalogData } from './catalog'\n\nconst execFileAsync = promisify(execFile)\n\nexport type AIProvider = 'claude' | 'codex'\n\nfunction buildPrompt(\n sourceLocale: string,\n targetLocale: string,\n messages: Record<string, string>,\n): string {\n const json = JSON.stringify(messages, null, 2)\n return [\n `You are a professional translator. Translate the following messages from \"${sourceLocale}\" to \"${targetLocale}\".`,\n '',\n `Input (JSON):`,\n json,\n '',\n 'Rules:',\n '- Output ONLY valid JSON with the same keys and translated values.',\n '- Keep ICU MessageFormat placeholders like {name}, {count}, {gender} unchanged.',\n '- Keep HTML tags unchanged.',\n '- Do not add any explanation or markdown formatting, output raw JSON only.',\n ].join('\\n')\n}\n\nasync function invokeAI(provider: AIProvider, prompt: string): Promise<string> {\n const maxBuffer = 10 * 1024 * 1024\n\n try {\n if (provider === 'claude') {\n const { stdout } = await execFileAsync('claude', ['-p', prompt], { maxBuffer })\n return stdout\n } else {\n const { stdout } = await execFileAsync('codex', ['-p', prompt, '--full-auto'], { maxBuffer })\n return stdout\n }\n } catch (error: unknown) {\n const err = error as Error & { code?: string }\n if (err.code === 'ENOENT') {\n throw new Error(\n `\"${provider}\" CLI not found. Please install it first:\\n` +\n (provider === 'claude'\n ? ' npm install -g @anthropic-ai/claude-code'\n : ' npm install -g @openai/codex'),\n )\n }\n throw error\n }\n}\n\nfunction extractJSON(text: string): Record<string, string> {\n // Try to find a JSON object in the response\n const match = text.match(/\\{[\\s\\S]*\\}/)\n if (!match) {\n throw new Error('No JSON object found in AI response')\n }\n const parsed = JSON.parse(match[0])\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new Error('AI response is not a valid JSON object')\n }\n return parsed as Record<string, string>\n}\n\nfunction getUntranslatedEntries(catalog: CatalogData): Record<string, string> {\n const entries: Record<string, string> = {}\n for (const [id, entry] of Object.entries(catalog)) {\n if (entry.obsolete) continue\n if (!entry.translation || entry.translation.length === 0) {\n entries[id] = entry.message ?? id\n }\n }\n return entries\n}\n\nfunction chunkEntries(\n entries: Record<string, string>,\n batchSize: number,\n): Array<Record<string, string>> {\n const keys = Object.keys(entries)\n const chunks: Array<Record<string, string>> = []\n\n for (let i = 0; i < keys.length; i += batchSize) {\n const chunk: Record<string, string> = {}\n for (const key of keys.slice(i, i + batchSize)) {\n chunk[key] = entries[key]!\n }\n chunks.push(chunk)\n }\n\n return chunks\n}\n\nexport interface TranslateOptions {\n provider: AIProvider\n sourceLocale: string\n targetLocale: string\n catalog: CatalogData\n batchSize: number\n}\n\nexport async function translateCatalog(options: TranslateOptions): Promise<{\n catalog: CatalogData\n translated: number\n}> {\n const { provider, sourceLocale, targetLocale, catalog, batchSize } = options\n\n const untranslated = getUntranslatedEntries(catalog)\n const count = Object.keys(untranslated).length\n\n if (count === 0) {\n return { catalog, translated: 0 }\n }\n\n consola.info(` ${count} untranslated messages, translating with ${provider}...`)\n\n const batches = chunkEntries(untranslated, batchSize)\n let totalTranslated = 0\n\n for (let i = 0; i < batches.length; i++) {\n const batch = batches[i]!\n const batchKeys = Object.keys(batch)\n\n if (batches.length > 1) {\n consola.info(` Batch ${i + 1}/${batches.length} (${batchKeys.length} messages)`)\n }\n\n const prompt = buildPrompt(sourceLocale, targetLocale, batch)\n const response = await invokeAI(provider, prompt)\n const translations = extractJSON(response)\n\n for (const key of batchKeys) {\n if (translations[key] && typeof translations[key] === 'string') {\n catalog[key] = {\n ...catalog[key],\n translation: translations[key],\n }\n totalTranslated++\n } else {\n consola.warn(` Missing translation for key: ${key}`)\n }\n }\n }\n\n return { catalog, translated: totalTranslated }\n}\n","import { execFile } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport { readFileSync, existsSync } from 'node:fs'\nimport { resolve, join } from 'node:path'\nimport fg from 'fast-glob'\nimport consola from 'consola'\nimport type { AIProvider } from './translate'\n\nconst execFileAsync = promisify(execFile)\n\nexport type SupportedLibrary =\n | 'vue-i18n'\n | 'nuxt-i18n'\n | 'react-i18next'\n | 'next-intl'\n | 'next-i18next'\n | 'lingui'\n\ninterface LibraryInfo {\n name: SupportedLibrary\n framework: string\n configPatterns: string[]\n localePatterns: string[]\n sourcePatterns: string[]\n migrationGuide: string // relative path from packages/\n}\n\nconst LIBRARY_INFO: Record<SupportedLibrary, LibraryInfo> = {\n 'vue-i18n': {\n name: 'vue-i18n',\n framework: 'Vue',\n configPatterns: ['i18n.ts', 'i18n.js', 'i18n/index.ts', 'i18n/index.js', 'src/i18n.ts', 'src/i18n.js', 'src/i18n/index.ts', 'src/plugins/i18n.ts'],\n localePatterns: ['locales/*.json', 'src/locales/*.json', 'i18n/*.json', 'src/i18n/*.json', 'lang/*.json', 'src/lang/*.json', 'locales/*.yaml', 'locales/*.yml'],\n sourcePatterns: ['src/**/*.vue'],\n migrationGuide: 'vue/llms-migration.txt',\n },\n 'nuxt-i18n': {\n name: 'nuxt-i18n',\n framework: 'Nuxt',\n configPatterns: ['nuxt.config.ts', 'nuxt.config.js', 'i18n.config.ts', 'i18n.config.js'],\n localePatterns: ['locales/*.json', 'lang/*.json', 'i18n/*.json', 'locales/*.yaml', 'locales/*.yml'],\n sourcePatterns: ['pages/**/*.vue', 'components/**/*.vue', 'layouts/**/*.vue'],\n migrationGuide: 'nuxt/llms-migration.txt',\n },\n 'react-i18next': {\n name: 'react-i18next',\n framework: 'React',\n configPatterns: ['i18n.ts', 'i18n.js', 'src/i18n.ts', 'src/i18n.js', 'src/i18n/index.ts', 'src/i18n/config.ts'],\n localePatterns: ['locales/*.json', 'src/locales/*.json', 'public/locales/**/*.json', 'translations/*.json', 'src/translations/*.json'],\n sourcePatterns: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts'],\n migrationGuide: 'react/llms-migration.txt',\n },\n 'next-intl': {\n name: 'next-intl',\n framework: 'Next.js',\n configPatterns: ['next.config.ts', 'next.config.js', 'next.config.mjs', 'i18n.ts', 'src/i18n.ts', 'i18n/request.ts', 'src/i18n/request.ts'],\n localePatterns: ['messages/*.json', 'locales/*.json', 'src/messages/*.json', 'src/locales/*.json'],\n sourcePatterns: ['app/**/*.tsx', 'src/app/**/*.tsx', 'pages/**/*.tsx', 'components/**/*.tsx'],\n migrationGuide: 'next-plugin/llms-migration.txt',\n },\n 'next-i18next': {\n name: 'next-i18next',\n framework: 'Next.js',\n configPatterns: ['next-i18next.config.js', 'next-i18next.config.mjs', 'next.config.ts', 'next.config.js'],\n localePatterns: ['public/locales/**/*.json'],\n sourcePatterns: ['pages/**/*.tsx', 'src/pages/**/*.tsx', 'components/**/*.tsx', 'src/components/**/*.tsx'],\n migrationGuide: 'next-plugin/llms-migration.txt',\n },\n 'lingui': {\n name: 'lingui',\n framework: 'React',\n configPatterns: ['lingui.config.ts', 'lingui.config.js', '.linguirc'],\n localePatterns: ['locales/*.po', 'src/locales/*.po', 'locales/*/messages.po', 'src/locales/*/messages.po'],\n sourcePatterns: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts'],\n migrationGuide: 'react/llms-migration.txt',\n },\n}\n\nconst SUPPORTED_NAMES = Object.keys(LIBRARY_INFO) as SupportedLibrary[]\n\nfunction resolveLibrary(from: string): SupportedLibrary | undefined {\n const normalized = from.toLowerCase().replace(/^@nuxtjs\\//, 'nuxt-').replace(/^@/, '')\n return SUPPORTED_NAMES.find((name) => name === normalized)\n}\n\ninterface DetectedFiles {\n configFiles: Array<{ path: string; content: string }>\n localeFiles: Array<{ path: string; content: string }>\n sampleSources: Array<{ path: string; content: string }>\n packageJson: string | undefined\n}\n\nasync function detectFiles(info: LibraryInfo): Promise<DetectedFiles> {\n const result: DetectedFiles = {\n configFiles: [],\n localeFiles: [],\n sampleSources: [],\n packageJson: undefined,\n }\n\n // Read package.json\n const pkgPath = resolve('package.json')\n if (existsSync(pkgPath)) {\n result.packageJson = readFileSync(pkgPath, 'utf-8')\n }\n\n // Find config files\n for (const pattern of info.configPatterns) {\n const fullPath = resolve(pattern)\n if (existsSync(fullPath)) {\n result.configFiles.push({\n path: pattern,\n content: readFileSync(fullPath, 'utf-8'),\n })\n }\n }\n\n // Find locale files (limit to 10 to avoid huge prompts)\n const localeGlobs = await fg(info.localePatterns, { absolute: false })\n for (const file of localeGlobs.slice(0, 10)) {\n const fullPath = resolve(file)\n const content = readFileSync(fullPath, 'utf-8')\n // Truncate large files\n result.localeFiles.push({\n path: file,\n content: content.length > 5000 ? content.slice(0, 5000) + '\\n... (truncated)' : content,\n })\n }\n\n // Find sample source files (limit to 5 for prompt size)\n const sourceGlobs = await fg(info.sourcePatterns, { absolute: false })\n for (const file of sourceGlobs.slice(0, 5)) {\n const fullPath = resolve(file)\n const content = readFileSync(fullPath, 'utf-8')\n result.sampleSources.push({\n path: file,\n content: content.length > 3000 ? content.slice(0, 3000) + '\\n... (truncated)' : content,\n })\n }\n\n return result\n}\n\nfunction loadMigrationGuide(guidePath: string): string {\n // Try to find the migration guide relative to the CLI package\n const candidates = [\n resolve('node_modules', '@fluenti', 'cli', '..', '..', guidePath),\n join(__dirname, '..', '..', '..', guidePath),\n join(__dirname, '..', '..', guidePath),\n ]\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n return readFileSync(candidate, 'utf-8')\n }\n }\n\n return ''\n}\n\nfunction buildMigratePrompt(\n library: LibraryInfo,\n detected: DetectedFiles,\n migrationGuide: string,\n): string {\n const sections: string[] = []\n\n sections.push(\n `You are a migration assistant helping convert a ${library.framework} project from \"${library.name}\" to Fluenti (@fluenti).`,\n '',\n 'Your task:',\n '1. Generate a `fluenti.config.ts` file based on the existing i18n configuration',\n '2. Convert each locale/translation file to Fluenti PO format',\n '3. List the code changes needed (file by file) to migrate source code from the old API to Fluenti API',\n '',\n )\n\n if (migrationGuide) {\n sections.push(\n '=== MIGRATION GUIDE ===',\n migrationGuide,\n '',\n )\n }\n\n if (detected.packageJson) {\n sections.push(\n '=== package.json ===',\n detected.packageJson,\n '',\n )\n }\n\n if (detected.configFiles.length > 0) {\n sections.push('=== EXISTING CONFIG FILES ===')\n for (const file of detected.configFiles) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n if (detected.localeFiles.length > 0) {\n sections.push('=== EXISTING LOCALE FILES ===')\n for (const file of detected.localeFiles) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n if (detected.sampleSources.length > 0) {\n sections.push('=== SAMPLE SOURCE FILES ===')\n for (const file of detected.sampleSources) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n sections.push(\n '',\n '=== OUTPUT FORMAT ===',\n 'Respond with the following sections, each starting with the exact header shown:',\n '',\n '### FLUENTI_CONFIG',\n '```ts',\n '// The fluenti.config.ts content',\n '```',\n '',\n '### LOCALE_FILES',\n 'For each locale file, output:',\n '#### LOCALE: {locale_code}',\n '```po',\n '// The PO file content',\n '```',\n '',\n '### MIGRATION_STEPS',\n 'A numbered checklist of specific code changes needed, with before/after examples.',\n '',\n '### INSTALL_COMMANDS',\n '```bash',\n '// The install and uninstall commands',\n '```',\n )\n\n return sections.join('\\n')\n}\n\nasync function invokeAI(provider: AIProvider, prompt: string): Promise<string> {\n const maxBuffer = 10 * 1024 * 1024\n\n try {\n if (provider === 'claude') {\n const { stdout } = await execFileAsync('claude', ['-p', prompt], { maxBuffer })\n return stdout\n } else {\n const { stdout } = await execFileAsync('codex', ['-p', prompt, '--full-auto'], { maxBuffer })\n return stdout\n }\n } catch (error: unknown) {\n const err = error as Error & { code?: string }\n if (err.code === 'ENOENT') {\n throw new Error(\n `\"${provider}\" CLI not found. Please install it first:\\n` +\n (provider === 'claude'\n ? ' npm install -g @anthropic-ai/claude-code'\n : ' npm install -g @openai/codex'),\n )\n }\n throw error\n }\n}\n\ninterface MigrateResult {\n config: string | undefined\n localeFiles: Array<{ locale: string; content: string }>\n steps: string | undefined\n installCommands: string | undefined\n}\n\nfunction parseResponse(response: string): MigrateResult {\n const result: MigrateResult = {\n config: undefined,\n localeFiles: [],\n steps: undefined,\n installCommands: undefined,\n }\n\n // Extract fluenti.config.ts\n const configMatch = response.match(/### FLUENTI_CONFIG[\\s\\S]*?```(?:ts|typescript)?\\n([\\s\\S]*?)```/)\n if (configMatch) {\n result.config = configMatch[1]!.trim()\n }\n\n // Extract locale files\n const localeSection = response.match(/### LOCALE_FILES([\\s\\S]*?)(?=### MIGRATION_STEPS|### INSTALL_COMMANDS|$)/)\n if (localeSection) {\n const localeRegex = /#### LOCALE:\\s*(\\S+)\\s*\\n```(?:po)?\\n([\\s\\S]*?)```/g\n let match\n while ((match = localeRegex.exec(localeSection[1]!)) !== null) {\n result.localeFiles.push({\n locale: match[1]!,\n content: match[2]!.trim(),\n })\n }\n }\n\n // Extract migration steps\n const stepsMatch = response.match(/### MIGRATION_STEPS\\s*\\n([\\s\\S]*?)(?=### INSTALL_COMMANDS|$)/)\n if (stepsMatch) {\n result.steps = stepsMatch[1]!.trim()\n }\n\n // Extract install commands\n const installMatch = response.match(/### INSTALL_COMMANDS[\\s\\S]*?```(?:bash|sh)?\\n([\\s\\S]*?)```/)\n if (installMatch) {\n result.installCommands = installMatch[1]!.trim()\n }\n\n return result\n}\n\nexport interface MigrateOptions {\n from: string\n provider: AIProvider\n write: boolean\n}\n\nexport async function runMigrate(options: MigrateOptions): Promise<void> {\n const { from, provider, write } = options\n\n const library = resolveLibrary(from)\n if (!library) {\n consola.error(`Unsupported library \"${from}\". Supported libraries:`)\n for (const name of SUPPORTED_NAMES) {\n consola.log(` - ${name}`)\n }\n return\n }\n\n const info = LIBRARY_INFO[library]\n consola.info(`Migrating from ${info.name} (${info.framework}) to Fluenti`)\n\n // Detect existing files\n consola.info('Scanning project for existing i18n files...')\n const detected = await detectFiles(info)\n\n if (detected.configFiles.length === 0 && detected.localeFiles.length === 0) {\n consola.warn(`No ${info.name} configuration or locale files found.`)\n consola.info('Make sure you are running this command from the project root directory.')\n return\n }\n\n consola.info(`Found: ${detected.configFiles.length} config file(s), ${detected.localeFiles.length} locale file(s), ${detected.sampleSources.length} source file(s)`)\n\n // Load migration guide\n const migrationGuide = loadMigrationGuide(info.migrationGuide)\n\n // Build prompt and invoke AI\n consola.info(`Generating migration plan with ${provider}...`)\n const prompt = buildMigratePrompt(info, detected, migrationGuide)\n const response = await invokeAI(provider, prompt)\n const result = parseResponse(response)\n\n // Display install commands\n if (result.installCommands) {\n consola.log('')\n consola.box({\n title: 'Install Commands',\n message: result.installCommands,\n })\n }\n\n // Write or display fluenti.config.ts\n if (result.config) {\n if (write) {\n const { writeFileSync } = await import('node:fs')\n const configPath = resolve('fluenti.config.ts')\n writeFileSync(configPath, result.config, 'utf-8')\n consola.success(`Written: ${configPath}`)\n } else {\n consola.log('')\n consola.box({\n title: 'fluenti.config.ts',\n message: result.config,\n })\n }\n }\n\n // Write or display locale files\n if (result.localeFiles.length > 0) {\n if (write) {\n const { writeFileSync, mkdirSync } = await import('node:fs')\n const catalogDir = './locales'\n mkdirSync(resolve(catalogDir), { recursive: true })\n for (const file of result.localeFiles) {\n const outPath = resolve(catalogDir, `${file.locale}.po`)\n writeFileSync(outPath, file.content, 'utf-8')\n consola.success(`Written: ${outPath}`)\n }\n } else {\n for (const file of result.localeFiles) {\n consola.log('')\n consola.box({\n title: `locales/${file.locale}.po`,\n message: file.content.length > 500\n ? file.content.slice(0, 500) + '\\n... (use --write to save full file)'\n : file.content,\n })\n }\n }\n }\n\n // Display migration steps\n if (result.steps) {\n consola.log('')\n consola.box({\n title: 'Migration Steps',\n message: result.steps,\n })\n }\n\n if (!write && (result.config || result.localeFiles.length > 0)) {\n consola.log('')\n consola.info('Run with --write to save generated files to disk:')\n consola.log(` fluenti migrate --from ${from} --write`)\n }\n}\n","#!/usr/bin/env node\nimport { defineCommand, runMain } from 'citty'\nimport consola from 'consola'\nimport fg from 'fast-glob'\nimport { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'\nimport { resolve, dirname, extname } from 'node:path'\nimport { extractFromVue } from './vue-extractor'\nimport { extractFromTsx } from './tsx-extractor'\nimport { updateCatalog } from './catalog'\nimport type { CatalogData } from './catalog'\nimport { readJsonCatalog, writeJsonCatalog } from './json-format'\nimport { readPoCatalog, writePoCatalog } from './po-format'\nimport { compileCatalog, compileIndex, collectAllIds } from './compile'\nimport { translateCatalog } from './translate'\nimport type { AIProvider } from './translate'\nimport { runMigrate } from './migrate'\nimport type { ExtractedMessage, FluentiConfig } from '@fluenti/core'\n\nconst defaultConfig: FluentiConfig = {\n sourceLocale: 'en',\n locales: ['en'],\n catalogDir: './locales',\n format: 'po',\n include: ['./src/**/*.{vue,tsx,jsx,ts,js}'],\n compileOutDir: './locales/compiled',\n}\n\nasync function loadConfig(configPath?: string): Promise<FluentiConfig> {\n const paths = configPath\n ? [resolve(configPath)]\n : [\n resolve('fluenti.config.ts'),\n resolve('fluenti.config.js'),\n resolve('fluenti.config.mjs'),\n ]\n\n for (const p of paths) {\n if (existsSync(p)) {\n try {\n const { createJiti } = await import('jiti')\n const jiti = createJiti(import.meta.url)\n const mod = await jiti.import(p) as { default?: Partial<FluentiConfig> }\n const userConfig = mod.default ?? mod as unknown as Partial<FluentiConfig>\n return { ...defaultConfig, ...userConfig }\n } catch {\n consola.warn(`Failed to load config from ${p}, using defaults`)\n }\n }\n }\n\n return defaultConfig\n}\n\nfunction readCatalog(filePath: string, format: 'json' | 'po'): CatalogData {\n if (!existsSync(filePath)) return {}\n const content = readFileSync(filePath, 'utf-8')\n return format === 'json' ? readJsonCatalog(content) : readPoCatalog(content)\n}\n\nfunction writeCatalog(filePath: string, catalog: CatalogData, format: 'json' | 'po'): void {\n mkdirSync(dirname(filePath), { recursive: true })\n const content = format === 'json' ? writeJsonCatalog(catalog) : writePoCatalog(catalog)\n writeFileSync(filePath, content, 'utf-8')\n}\n\nfunction extractFromFile(filePath: string, code: string): ExtractedMessage[] {\n const ext = extname(filePath)\n if (ext === '.vue') return extractFromVue(code, filePath)\n return extractFromTsx(code, filePath)\n}\n\nconst extract = defineCommand({\n meta: { name: 'extract', description: 'Extract messages from source files' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n clean: { type: 'boolean', description: 'Remove obsolete entries instead of marking them', default: false },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n consola.info(`Extracting messages from ${config.include.join(', ')}`)\n\n const files = await fg(config.include, { absolute: true })\n const allMessages: ExtractedMessage[] = []\n\n for (const file of files) {\n const code = readFileSync(file, 'utf-8')\n const messages = extractFromFile(file, code)\n allMessages.push(...messages)\n }\n\n consola.info(`Found ${allMessages.length} messages in ${files.length} files`)\n\n const ext = config.format === 'json' ? '.json' : '.po'\n const clean = args.clean ?? false\n\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const existing = readCatalog(catalogPath, config.format)\n const { catalog, result } = updateCatalog(existing, allMessages)\n\n const finalCatalog = clean\n ? Object.fromEntries(Object.entries(catalog).filter(([, entry]) => !entry.obsolete))\n : catalog\n\n writeCatalog(catalogPath, finalCatalog, config.format)\n\n const obsoleteLabel = clean\n ? `${result.obsolete} removed`\n : `${result.obsolete} obsolete`\n consola.success(\n `${locale}: ${result.added} added, ${result.unchanged} unchanged, ${obsoleteLabel}`,\n )\n }\n },\n})\n\nconst compile = defineCommand({\n meta: { name: 'compile', description: 'Compile message catalogs to JS modules' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n mkdirSync(config.compileOutDir, { recursive: true })\n\n // Collect all catalogs and build union of IDs\n const allCatalogs: Record<string, CatalogData> = {}\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n allCatalogs[locale] = readCatalog(catalogPath, config.format)\n }\n\n const allIds = collectAllIds(allCatalogs)\n consola.info(`Compiling ${allIds.length} messages across ${config.locales.length} locales`)\n\n for (const locale of config.locales) {\n const { code, stats } = compileCatalog(\n allCatalogs[locale]!,\n locale,\n allIds,\n config.sourceLocale,\n )\n const outPath = resolve(config.compileOutDir, `${locale}.js`)\n writeFileSync(outPath, code, 'utf-8')\n\n if (stats.missing.length > 0) {\n consola.warn(\n `${locale}: ${stats.compiled} compiled, ${stats.missing.length} missing translations`,\n )\n for (const id of stats.missing) {\n consola.warn(` ⤷ ${id}`)\n }\n } else {\n consola.success(`Compiled ${locale}: ${stats.compiled} messages → ${outPath}`)\n }\n }\n\n // Generate index.js with locale list and lazy loaders\n const indexCode = compileIndex(config.locales, config.compileOutDir)\n const indexPath = resolve(config.compileOutDir, 'index.js')\n writeFileSync(indexPath, indexCode, 'utf-8')\n consola.success(`Generated index → ${indexPath}`)\n },\n})\n\nconst stats = defineCommand({\n meta: { name: 'stats', description: 'Show translation progress' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n const rows: Array<{ locale: string; total: number; translated: number; pct: string }> = []\n\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const catalog = readCatalog(catalogPath, config.format)\n const entries = Object.values(catalog).filter((e) => !e.obsolete)\n const total = entries.length\n const translated = entries.filter((e) => e.translation && e.translation.length > 0).length\n const pct = total > 0 ? ((translated / total) * 100).toFixed(1) + '%' : '—'\n rows.push({ locale, total, translated, pct })\n }\n\n consola.log('')\n consola.log(' Locale │ Total │ Translated │ Progress')\n consola.log(' ────────┼───────┼────────────┼─────────')\n for (const row of rows) {\n consola.log(\n ` ${row.locale.padEnd(8)}│ ${String(row.total).padStart(5)} │ ${String(row.translated).padStart(10)} │ ${row.pct}`,\n )\n }\n consola.log('')\n },\n})\n\nconst translate = defineCommand({\n meta: { name: 'translate', description: 'Translate messages using AI (Claude Code or Codex CLI)' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n provider: { type: 'string', description: 'AI provider: claude or codex', default: 'claude' },\n locale: { type: 'string', description: 'Translate a specific locale only' },\n 'batch-size': { type: 'string', description: 'Messages per batch', default: '50' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const provider = args.provider as AIProvider\n\n if (provider !== 'claude' && provider !== 'codex') {\n consola.error(`Invalid provider \"${provider}\". Use \"claude\" or \"codex\".`)\n return\n }\n\n const batchSize = parseInt(args['batch-size'] ?? '50', 10)\n if (isNaN(batchSize) || batchSize < 1) {\n consola.error('Invalid batch-size. Must be a positive integer.')\n return\n }\n\n const targetLocales = args.locale\n ? [args.locale]\n : config.locales.filter((l: string) => l !== config.sourceLocale)\n\n if (targetLocales.length === 0) {\n consola.warn('No target locales to translate.')\n return\n }\n\n consola.info(`Translating with ${provider} (batch size: ${batchSize})`)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n for (const locale of targetLocales) {\n consola.info(`\\n[${locale}]`)\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const catalog = readCatalog(catalogPath, config.format)\n\n const { catalog: updated, translated } = await translateCatalog({\n provider,\n sourceLocale: config.sourceLocale,\n targetLocale: locale,\n catalog,\n batchSize,\n })\n\n if (translated > 0) {\n writeCatalog(catalogPath, updated, config.format)\n consola.success(` ${locale}: ${translated} messages translated`)\n } else {\n consola.success(` ${locale}: already fully translated`)\n }\n }\n },\n})\n\nconst migrate = defineCommand({\n meta: { name: 'migrate', description: 'Migrate from another i18n library using AI' },\n args: {\n from: { type: 'string', description: 'Source library: vue-i18n, nuxt-i18n, react-i18next, next-intl, next-i18next, lingui', required: true },\n provider: { type: 'string', description: 'AI provider: claude or codex', default: 'claude' },\n write: { type: 'boolean', description: 'Write generated files to disk', default: false },\n },\n async run({ args }) {\n const provider = args.provider as AIProvider\n if (provider !== 'claude' && provider !== 'codex') {\n consola.error(`Invalid provider \"${provider}\". Use \"claude\" or \"codex\".`)\n return\n }\n\n await runMigrate({\n from: args.from!,\n provider,\n write: args.write ?? false,\n })\n },\n})\n\nconst main = defineCommand({\n meta: {\n name: 'fluenti',\n version: '0.0.1',\n description: 'Compile-time i18n for modern frameworks',\n },\n subCommands: { extract, compile, stats, translate, migrate },\n})\n\nrunMain(main)\n"],"mappings":";0OAKA,IAAM,GAAA,EAAA,EAAA,WAA0B,EAAA,SAAS,CAIzC,SAAS,EACP,EACA,EACA,EACQ,CACR,IAAM,EAAO,KAAK,UAAU,EAAU,KAAM,EAAE,CAC9C,MAAO,CACL,6EAA6E,EAAa,QAAQ,EAAa,IAC/G,GACA,gBACA,EACA,GACA,SACA,qEACA,kFACA,8BACA,6EACD,CAAC,KAAK;EAAK,CAGd,eAAe,EAAS,EAAsB,EAAiC,CAC7E,IAAM,EAAY,GAAK,KAAO,KAE9B,GAAI,CACF,GAAI,IAAa,SAAU,CACzB,GAAM,CAAE,UAAW,MAAM,EAAc,SAAU,CAAC,KAAM,EAAO,CAAE,CAAE,YAAW,CAAC,CAC/E,OAAO,MACF,CACL,GAAM,CAAE,UAAW,MAAM,EAAc,QAAS,CAAC,KAAM,EAAQ,cAAc,CAAE,CAAE,YAAW,CAAC,CAC7F,OAAO,SAEF,EAAgB,CAUvB,MATY,EACJ,OAAS,SACL,MACR,IAAI,EAAS,8CACZ,IAAa,SACV,6CACA,kCACL,CAEG,GAIV,SAAS,EAAY,EAAsC,CAEzD,IAAM,EAAQ,EAAK,MAAM,cAAc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M,qBAAqB,EAAS,6BAA6B,CACzE,OAGF,MAAM,EAAW,CACf,KAAM,EAAK,KACX,WACA,MAAO,EAAK,OAAS,GACtB,CAAC,EAEL,CAAC,CAQ4D,CAC7D,CAAC,CAEW"}
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":[],"sources":["../src/translate.ts","../src/migrate.ts","../src/cli.ts"],"sourcesContent":["import { execFile } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport consola from 'consola'\nimport type { CatalogData } from './catalog'\n\nconst execFileAsync = promisify(execFile)\n\nexport type AIProvider = 'claude' | 'codex'\n\nfunction buildPrompt(\n sourceLocale: string,\n targetLocale: string,\n messages: Record<string, string>,\n): string {\n const json = JSON.stringify(messages, null, 2)\n return [\n `You are a professional translator. Translate the following messages from \"${sourceLocale}\" to \"${targetLocale}\".`,\n '',\n `Input (JSON):`,\n json,\n '',\n 'Rules:',\n '- Output ONLY valid JSON with the same keys and translated values.',\n '- Keep ICU MessageFormat placeholders like {name}, {count}, {gender} unchanged.',\n '- Keep HTML tags unchanged.',\n '- Do not add any explanation or markdown formatting, output raw JSON only.',\n ].join('\\n')\n}\n\nasync function invokeAI(provider: AIProvider, prompt: string): Promise<string> {\n const maxBuffer = 10 * 1024 * 1024\n\n try {\n if (provider === 'claude') {\n const { stdout } = await execFileAsync('claude', ['-p', prompt], { maxBuffer })\n return stdout\n } else {\n const { stdout } = await execFileAsync('codex', ['-p', prompt, '--full-auto'], { maxBuffer })\n return stdout\n }\n } catch (error: unknown) {\n const err = error as Error & { code?: string }\n if (err.code === 'ENOENT') {\n throw new Error(\n `\"${provider}\" CLI not found. Please install it first:\\n` +\n (provider === 'claude'\n ? ' npm install -g @anthropic-ai/claude-code'\n : ' npm install -g @openai/codex'),\n )\n }\n throw error\n }\n}\n\nfunction extractJSON(text: string): Record<string, string> {\n // Try to find a JSON object in the response\n const match = text.match(/\\{[\\s\\S]*\\}/)\n if (!match) {\n throw new Error('No JSON object found in AI response')\n }\n const parsed = JSON.parse(match[0])\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new Error('AI response is not a valid JSON object')\n }\n return parsed as Record<string, string>\n}\n\nfunction getUntranslatedEntries(catalog: CatalogData): Record<string, string> {\n const entries: Record<string, string> = {}\n for (const [id, entry] of Object.entries(catalog)) {\n if (entry.obsolete) continue\n if (!entry.translation || entry.translation.length === 0) {\n entries[id] = entry.message ?? id\n }\n }\n return entries\n}\n\nfunction chunkEntries(\n entries: Record<string, string>,\n batchSize: number,\n): Array<Record<string, string>> {\n const keys = Object.keys(entries)\n const chunks: Array<Record<string, string>> = []\n\n for (let i = 0; i < keys.length; i += batchSize) {\n const chunk: Record<string, string> = {}\n for (const key of keys.slice(i, i + batchSize)) {\n chunk[key] = entries[key]!\n }\n chunks.push(chunk)\n }\n\n return chunks\n}\n\nexport interface TranslateOptions {\n provider: AIProvider\n sourceLocale: string\n targetLocale: string\n catalog: CatalogData\n batchSize: number\n}\n\nexport async function translateCatalog(options: TranslateOptions): Promise<{\n catalog: CatalogData\n translated: number\n}> {\n const { provider, sourceLocale, targetLocale, catalog, batchSize } = options\n\n const untranslated = getUntranslatedEntries(catalog)\n const count = Object.keys(untranslated).length\n\n if (count === 0) {\n return { catalog, translated: 0 }\n }\n\n consola.info(` ${count} untranslated messages, translating with ${provider}...`)\n\n const batches = chunkEntries(untranslated, batchSize)\n let totalTranslated = 0\n\n for (let i = 0; i < batches.length; i++) {\n const batch = batches[i]!\n const batchKeys = Object.keys(batch)\n\n if (batches.length > 1) {\n consola.info(` Batch ${i + 1}/${batches.length} (${batchKeys.length} messages)`)\n }\n\n const prompt = buildPrompt(sourceLocale, targetLocale, batch)\n const response = await invokeAI(provider, prompt)\n const translations = extractJSON(response)\n\n for (const key of batchKeys) {\n if (translations[key] && typeof translations[key] === 'string') {\n catalog[key] = {\n ...catalog[key],\n translation: translations[key],\n }\n totalTranslated++\n } else {\n consola.warn(` Missing translation for key: ${key}`)\n }\n }\n }\n\n return { catalog, translated: totalTranslated }\n}\n","import { execFile } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport { readFileSync, existsSync } from 'node:fs'\nimport { resolve, join } from 'node:path'\nimport fg from 'fast-glob'\nimport consola from 'consola'\nimport type { AIProvider } from './translate'\n\nconst execFileAsync = promisify(execFile)\n\nexport type SupportedLibrary =\n | 'vue-i18n'\n | 'nuxt-i18n'\n | 'react-i18next'\n | 'next-intl'\n | 'next-i18next'\n | 'lingui'\n\ninterface LibraryInfo {\n name: SupportedLibrary\n framework: string\n configPatterns: string[]\n localePatterns: string[]\n sourcePatterns: string[]\n migrationGuide: string // relative path from packages/\n}\n\nconst LIBRARY_INFO: Record<SupportedLibrary, LibraryInfo> = {\n 'vue-i18n': {\n name: 'vue-i18n',\n framework: 'Vue',\n configPatterns: ['i18n.ts', 'i18n.js', 'i18n/index.ts', 'i18n/index.js', 'src/i18n.ts', 'src/i18n.js', 'src/i18n/index.ts', 'src/plugins/i18n.ts'],\n localePatterns: ['locales/*.json', 'src/locales/*.json', 'i18n/*.json', 'src/i18n/*.json', 'lang/*.json', 'src/lang/*.json', 'locales/*.yaml', 'locales/*.yml'],\n sourcePatterns: ['src/**/*.vue'],\n migrationGuide: 'vue/llms-migration.txt',\n },\n 'nuxt-i18n': {\n name: 'nuxt-i18n',\n framework: 'Nuxt',\n configPatterns: ['nuxt.config.ts', 'nuxt.config.js', 'i18n.config.ts', 'i18n.config.js'],\n localePatterns: ['locales/*.json', 'lang/*.json', 'i18n/*.json', 'locales/*.yaml', 'locales/*.yml'],\n sourcePatterns: ['pages/**/*.vue', 'components/**/*.vue', 'layouts/**/*.vue'],\n migrationGuide: 'nuxt/llms-migration.txt',\n },\n 'react-i18next': {\n name: 'react-i18next',\n framework: 'React',\n configPatterns: ['i18n.ts', 'i18n.js', 'src/i18n.ts', 'src/i18n.js', 'src/i18n/index.ts', 'src/i18n/config.ts'],\n localePatterns: ['locales/*.json', 'src/locales/*.json', 'public/locales/**/*.json', 'translations/*.json', 'src/translations/*.json'],\n sourcePatterns: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts'],\n migrationGuide: 'react/llms-migration.txt',\n },\n 'next-intl': {\n name: 'next-intl',\n framework: 'Next.js',\n configPatterns: ['next.config.ts', 'next.config.js', 'next.config.mjs', 'i18n.ts', 'src/i18n.ts', 'i18n/request.ts', 'src/i18n/request.ts'],\n localePatterns: ['messages/*.json', 'locales/*.json', 'src/messages/*.json', 'src/locales/*.json'],\n sourcePatterns: ['app/**/*.tsx', 'src/app/**/*.tsx', 'pages/**/*.tsx', 'components/**/*.tsx'],\n migrationGuide: 'next-plugin/llms-migration.txt',\n },\n 'next-i18next': {\n name: 'next-i18next',\n framework: 'Next.js',\n configPatterns: ['next-i18next.config.js', 'next-i18next.config.mjs', 'next.config.ts', 'next.config.js'],\n localePatterns: ['public/locales/**/*.json'],\n sourcePatterns: ['pages/**/*.tsx', 'src/pages/**/*.tsx', 'components/**/*.tsx', 'src/components/**/*.tsx'],\n migrationGuide: 'next-plugin/llms-migration.txt',\n },\n 'lingui': {\n name: 'lingui',\n framework: 'React',\n configPatterns: ['lingui.config.ts', 'lingui.config.js', '.linguirc'],\n localePatterns: ['locales/*.po', 'src/locales/*.po', 'locales/*/messages.po', 'src/locales/*/messages.po'],\n sourcePatterns: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts'],\n migrationGuide: 'react/llms-migration.txt',\n },\n}\n\nconst SUPPORTED_NAMES = Object.keys(LIBRARY_INFO) as SupportedLibrary[]\n\nfunction resolveLibrary(from: string): SupportedLibrary | undefined {\n const normalized = from.toLowerCase().replace(/^@nuxtjs\\//, 'nuxt-').replace(/^@/, '')\n return SUPPORTED_NAMES.find((name) => name === normalized)\n}\n\ninterface DetectedFiles {\n configFiles: Array<{ path: string; content: string }>\n localeFiles: Array<{ path: string; content: string }>\n sampleSources: Array<{ path: string; content: string }>\n packageJson: string | undefined\n}\n\nasync function detectFiles(info: LibraryInfo): Promise<DetectedFiles> {\n const result: DetectedFiles = {\n configFiles: [],\n localeFiles: [],\n sampleSources: [],\n packageJson: undefined,\n }\n\n // Read package.json\n const pkgPath = resolve('package.json')\n if (existsSync(pkgPath)) {\n result.packageJson = readFileSync(pkgPath, 'utf-8')\n }\n\n // Find config files\n for (const pattern of info.configPatterns) {\n const fullPath = resolve(pattern)\n if (existsSync(fullPath)) {\n result.configFiles.push({\n path: pattern,\n content: readFileSync(fullPath, 'utf-8'),\n })\n }\n }\n\n // Find locale files (limit to 10 to avoid huge prompts)\n const localeGlobs = await fg(info.localePatterns, { absolute: false })\n for (const file of localeGlobs.slice(0, 10)) {\n const fullPath = resolve(file)\n const content = readFileSync(fullPath, 'utf-8')\n // Truncate large files\n result.localeFiles.push({\n path: file,\n content: content.length > 5000 ? content.slice(0, 5000) + '\\n... (truncated)' : content,\n })\n }\n\n // Find sample source files (limit to 5 for prompt size)\n const sourceGlobs = await fg(info.sourcePatterns, { absolute: false })\n for (const file of sourceGlobs.slice(0, 5)) {\n const fullPath = resolve(file)\n const content = readFileSync(fullPath, 'utf-8')\n result.sampleSources.push({\n path: file,\n content: content.length > 3000 ? content.slice(0, 3000) + '\\n... (truncated)' : content,\n })\n }\n\n return result\n}\n\nfunction loadMigrationGuide(guidePath: string): string {\n // Try to find the migration guide relative to the CLI package\n const candidates = [\n resolve('node_modules', '@fluenti', 'cli', '..', '..', guidePath),\n join(__dirname, '..', '..', '..', guidePath),\n join(__dirname, '..', '..', guidePath),\n ]\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n return readFileSync(candidate, 'utf-8')\n }\n }\n\n return ''\n}\n\nfunction buildMigratePrompt(\n library: LibraryInfo,\n detected: DetectedFiles,\n migrationGuide: string,\n): string {\n const sections: string[] = []\n\n sections.push(\n `You are a migration assistant helping convert a ${library.framework} project from \"${library.name}\" to Fluenti (@fluenti).`,\n '',\n 'Your task:',\n '1. Generate a `fluenti.config.ts` file based on the existing i18n configuration',\n '2. Convert each locale/translation file to Fluenti PO format',\n '3. List the code changes needed (file by file) to migrate source code from the old API to Fluenti API',\n '',\n )\n\n if (migrationGuide) {\n sections.push(\n '=== MIGRATION GUIDE ===',\n migrationGuide,\n '',\n )\n }\n\n if (detected.packageJson) {\n sections.push(\n '=== package.json ===',\n detected.packageJson,\n '',\n )\n }\n\n if (detected.configFiles.length > 0) {\n sections.push('=== EXISTING CONFIG FILES ===')\n for (const file of detected.configFiles) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n if (detected.localeFiles.length > 0) {\n sections.push('=== EXISTING LOCALE FILES ===')\n for (const file of detected.localeFiles) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n if (detected.sampleSources.length > 0) {\n sections.push('=== SAMPLE SOURCE FILES ===')\n for (const file of detected.sampleSources) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n sections.push(\n '',\n '=== OUTPUT FORMAT ===',\n 'Respond with the following sections, each starting with the exact header shown:',\n '',\n '### FLUENTI_CONFIG',\n '```ts',\n '// The fluenti.config.ts content',\n '```',\n '',\n '### LOCALE_FILES',\n 'For each locale file, output:',\n '#### LOCALE: {locale_code}',\n '```po',\n '// The PO file content',\n '```',\n '',\n '### MIGRATION_STEPS',\n 'A numbered checklist of specific code changes needed, with before/after examples.',\n '',\n '### INSTALL_COMMANDS',\n '```bash',\n '// The install and uninstall commands',\n '```',\n )\n\n return sections.join('\\n')\n}\n\nasync function invokeAI(provider: AIProvider, prompt: string): Promise<string> {\n const maxBuffer = 10 * 1024 * 1024\n\n try {\n if (provider === 'claude') {\n const { stdout } = await execFileAsync('claude', ['-p', prompt], { maxBuffer })\n return stdout\n } else {\n const { stdout } = await execFileAsync('codex', ['-p', prompt, '--full-auto'], { maxBuffer })\n return stdout\n }\n } catch (error: unknown) {\n const err = error as Error & { code?: string }\n if (err.code === 'ENOENT') {\n throw new Error(\n `\"${provider}\" CLI not found. Please install it first:\\n` +\n (provider === 'claude'\n ? ' npm install -g @anthropic-ai/claude-code'\n : ' npm install -g @openai/codex'),\n )\n }\n throw error\n }\n}\n\ninterface MigrateResult {\n config: string | undefined\n localeFiles: Array<{ locale: string; content: string }>\n steps: string | undefined\n installCommands: string | undefined\n}\n\nfunction parseResponse(response: string): MigrateResult {\n const result: MigrateResult = {\n config: undefined,\n localeFiles: [],\n steps: undefined,\n installCommands: undefined,\n }\n\n // Extract fluenti.config.ts\n const configMatch = response.match(/### FLUENTI_CONFIG[\\s\\S]*?```(?:ts|typescript)?\\n([\\s\\S]*?)```/)\n if (configMatch) {\n result.config = configMatch[1]!.trim()\n }\n\n // Extract locale files\n const localeSection = response.match(/### LOCALE_FILES([\\s\\S]*?)(?=### MIGRATION_STEPS|### INSTALL_COMMANDS|$)/)\n if (localeSection) {\n const localeRegex = /#### LOCALE:\\s*(\\S+)\\s*\\n```(?:po)?\\n([\\s\\S]*?)```/g\n let match\n while ((match = localeRegex.exec(localeSection[1]!)) !== null) {\n result.localeFiles.push({\n locale: match[1]!,\n content: match[2]!.trim(),\n })\n }\n }\n\n // Extract migration steps\n const stepsMatch = response.match(/### MIGRATION_STEPS\\s*\\n([\\s\\S]*?)(?=### INSTALL_COMMANDS|$)/)\n if (stepsMatch) {\n result.steps = stepsMatch[1]!.trim()\n }\n\n // Extract install commands\n const installMatch = response.match(/### INSTALL_COMMANDS[\\s\\S]*?```(?:bash|sh)?\\n([\\s\\S]*?)```/)\n if (installMatch) {\n result.installCommands = installMatch[1]!.trim()\n }\n\n return result\n}\n\nexport interface MigrateOptions {\n from: string\n provider: AIProvider\n write: boolean\n}\n\nexport async function runMigrate(options: MigrateOptions): Promise<void> {\n const { from, provider, write } = options\n\n const library = resolveLibrary(from)\n if (!library) {\n consola.error(`Unsupported library \"${from}\". Supported libraries:`)\n for (const name of SUPPORTED_NAMES) {\n consola.log(` - ${name}`)\n }\n return\n }\n\n const info = LIBRARY_INFO[library]\n consola.info(`Migrating from ${info.name} (${info.framework}) to Fluenti`)\n\n // Detect existing files\n consola.info('Scanning project for existing i18n files...')\n const detected = await detectFiles(info)\n\n if (detected.configFiles.length === 0 && detected.localeFiles.length === 0) {\n consola.warn(`No ${info.name} configuration or locale files found.`)\n consola.info('Make sure you are running this command from the project root directory.')\n return\n }\n\n consola.info(`Found: ${detected.configFiles.length} config file(s), ${detected.localeFiles.length} locale file(s), ${detected.sampleSources.length} source file(s)`)\n\n // Load migration guide\n const migrationGuide = loadMigrationGuide(info.migrationGuide)\n\n // Build prompt and invoke AI\n consola.info(`Generating migration plan with ${provider}...`)\n const prompt = buildMigratePrompt(info, detected, migrationGuide)\n const response = await invokeAI(provider, prompt)\n const result = parseResponse(response)\n\n // Display install commands\n if (result.installCommands) {\n consola.log('')\n consola.box({\n title: 'Install Commands',\n message: result.installCommands,\n })\n }\n\n // Write or display fluenti.config.ts\n if (result.config) {\n if (write) {\n const { writeFileSync } = await import('node:fs')\n const configPath = resolve('fluenti.config.ts')\n writeFileSync(configPath, result.config, 'utf-8')\n consola.success(`Written: ${configPath}`)\n } else {\n consola.log('')\n consola.box({\n title: 'fluenti.config.ts',\n message: result.config,\n })\n }\n }\n\n // Write or display locale files\n if (result.localeFiles.length > 0) {\n if (write) {\n const { writeFileSync, mkdirSync } = await import('node:fs')\n const catalogDir = './locales'\n mkdirSync(resolve(catalogDir), { recursive: true })\n for (const file of result.localeFiles) {\n const outPath = resolve(catalogDir, `${file.locale}.po`)\n writeFileSync(outPath, file.content, 'utf-8')\n consola.success(`Written: ${outPath}`)\n }\n } else {\n for (const file of result.localeFiles) {\n consola.log('')\n consola.box({\n title: `locales/${file.locale}.po`,\n message: file.content.length > 500\n ? file.content.slice(0, 500) + '\\n... (use --write to save full file)'\n : file.content,\n })\n }\n }\n }\n\n // Display migration steps\n if (result.steps) {\n consola.log('')\n consola.box({\n title: 'Migration Steps',\n message: result.steps,\n })\n }\n\n if (!write && (result.config || result.localeFiles.length > 0)) {\n consola.log('')\n consola.info('Run with --write to save generated files to disk:')\n consola.log(` fluenti migrate --from ${from} --write`)\n }\n}\n","#!/usr/bin/env node\nimport { defineCommand, runMain } from 'citty'\nimport consola from 'consola'\nimport fg from 'fast-glob'\nimport { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'\nimport { resolve, dirname, extname } from 'node:path'\nimport { extractFromVue } from './vue-extractor'\nimport { extractFromTsx } from './tsx-extractor'\nimport { updateCatalog } from './catalog'\nimport type { CatalogData } from './catalog'\nimport { readJsonCatalog, writeJsonCatalog } from './json-format'\nimport { readPoCatalog, writePoCatalog } from './po-format'\nimport { compileCatalog, compileIndex, collectAllIds } from './compile'\nimport { translateCatalog } from './translate'\nimport type { AIProvider } from './translate'\nimport { runMigrate } from './migrate'\nimport type { ExtractedMessage, FluentiConfig } from '@fluenti/core'\n\nconst defaultConfig: FluentiConfig = {\n sourceLocale: 'en',\n locales: ['en'],\n catalogDir: './locales',\n format: 'po',\n include: ['./src/**/*.{vue,tsx,jsx,ts,js}'],\n compileOutDir: './locales/compiled',\n}\n\nasync function loadConfig(configPath?: string): Promise<FluentiConfig> {\n const paths = configPath\n ? [resolve(configPath)]\n : [\n resolve('fluenti.config.ts'),\n resolve('fluenti.config.js'),\n resolve('fluenti.config.mjs'),\n ]\n\n for (const p of paths) {\n if (existsSync(p)) {\n try {\n const { createJiti } = await import('jiti')\n const jiti = createJiti(import.meta.url)\n const mod = await jiti.import(p) as { default?: Partial<FluentiConfig> }\n const userConfig = mod.default ?? mod as unknown as Partial<FluentiConfig>\n return { ...defaultConfig, ...userConfig }\n } catch {\n consola.warn(`Failed to load config from ${p}, using defaults`)\n }\n }\n }\n\n return defaultConfig\n}\n\nfunction readCatalog(filePath: string, format: 'json' | 'po'): CatalogData {\n if (!existsSync(filePath)) return {}\n const content = readFileSync(filePath, 'utf-8')\n return format === 'json' ? readJsonCatalog(content) : readPoCatalog(content)\n}\n\nfunction writeCatalog(filePath: string, catalog: CatalogData, format: 'json' | 'po'): void {\n mkdirSync(dirname(filePath), { recursive: true })\n const content = format === 'json' ? writeJsonCatalog(catalog) : writePoCatalog(catalog)\n writeFileSync(filePath, content, 'utf-8')\n}\n\nfunction extractFromFile(filePath: string, code: string): ExtractedMessage[] {\n const ext = extname(filePath)\n if (ext === '.vue') return extractFromVue(code, filePath)\n return extractFromTsx(code, filePath)\n}\n\nconst extract = defineCommand({\n meta: { name: 'extract', description: 'Extract messages from source files' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n clean: { type: 'boolean', description: 'Remove obsolete entries instead of marking them', default: false },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n consola.info(`Extracting messages from ${config.include.join(', ')}`)\n\n const files = await fg(config.include)\n const allMessages: ExtractedMessage[] = []\n\n for (const file of files) {\n const code = readFileSync(file, 'utf-8')\n const messages = extractFromFile(file, code)\n allMessages.push(...messages)\n }\n\n consola.info(`Found ${allMessages.length} messages in ${files.length} files`)\n\n const ext = config.format === 'json' ? '.json' : '.po'\n const clean = args.clean ?? false\n\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const existing = readCatalog(catalogPath, config.format)\n const { catalog, result } = updateCatalog(existing, allMessages)\n\n const finalCatalog = clean\n ? Object.fromEntries(Object.entries(catalog).filter(([, entry]) => !entry.obsolete))\n : catalog\n\n writeCatalog(catalogPath, finalCatalog, config.format)\n\n const obsoleteLabel = clean\n ? `${result.obsolete} removed`\n : `${result.obsolete} obsolete`\n consola.success(\n `${locale}: ${result.added} added, ${result.unchanged} unchanged, ${obsoleteLabel}`,\n )\n }\n },\n})\n\nconst compile = defineCommand({\n meta: { name: 'compile', description: 'Compile message catalogs to JS modules' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n mkdirSync(config.compileOutDir, { recursive: true })\n\n // Collect all catalogs and build union of IDs\n const allCatalogs: Record<string, CatalogData> = {}\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n allCatalogs[locale] = readCatalog(catalogPath, config.format)\n }\n\n const allIds = collectAllIds(allCatalogs)\n consola.info(`Compiling ${allIds.length} messages across ${config.locales.length} locales`)\n\n for (const locale of config.locales) {\n const { code, stats } = compileCatalog(\n allCatalogs[locale]!,\n locale,\n allIds,\n config.sourceLocale,\n )\n const outPath = resolve(config.compileOutDir, `${locale}.js`)\n writeFileSync(outPath, code, 'utf-8')\n\n if (stats.missing.length > 0) {\n consola.warn(\n `${locale}: ${stats.compiled} compiled, ${stats.missing.length} missing translations`,\n )\n for (const id of stats.missing) {\n consola.warn(` ⤷ ${id}`)\n }\n } else {\n consola.success(`Compiled ${locale}: ${stats.compiled} messages → ${outPath}`)\n }\n }\n\n // Generate index.js with locale list and lazy loaders\n const indexCode = compileIndex(config.locales, config.compileOutDir)\n const indexPath = resolve(config.compileOutDir, 'index.js')\n writeFileSync(indexPath, indexCode, 'utf-8')\n consola.success(`Generated index → ${indexPath}`)\n },\n})\n\nconst stats = defineCommand({\n meta: { name: 'stats', description: 'Show translation progress' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n const rows: Array<{ locale: string; total: number; translated: number; pct: string }> = []\n\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const catalog = readCatalog(catalogPath, config.format)\n const entries = Object.values(catalog).filter((e) => !e.obsolete)\n const total = entries.length\n const translated = entries.filter((e) => e.translation && e.translation.length > 0).length\n const pct = total > 0 ? ((translated / total) * 100).toFixed(1) + '%' : '—'\n rows.push({ locale, total, translated, pct })\n }\n\n consola.log('')\n consola.log(' Locale │ Total │ Translated │ Progress')\n consola.log(' ────────┼───────┼────────────┼─────────')\n for (const row of rows) {\n consola.log(\n ` ${row.locale.padEnd(8)}│ ${String(row.total).padStart(5)} │ ${String(row.translated).padStart(10)} │ ${row.pct}`,\n )\n }\n consola.log('')\n },\n})\n\nconst translate = defineCommand({\n meta: { name: 'translate', description: 'Translate messages using AI (Claude Code or Codex CLI)' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n provider: { type: 'string', description: 'AI provider: claude or codex', default: 'claude' },\n locale: { type: 'string', description: 'Translate a specific locale only' },\n 'batch-size': { type: 'string', description: 'Messages per batch', default: '50' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const provider = args.provider as AIProvider\n\n if (provider !== 'claude' && provider !== 'codex') {\n consola.error(`Invalid provider \"${provider}\". Use \"claude\" or \"codex\".`)\n return\n }\n\n const batchSize = parseInt(args['batch-size'] ?? '50', 10)\n if (isNaN(batchSize) || batchSize < 1) {\n consola.error('Invalid batch-size. Must be a positive integer.')\n return\n }\n\n const targetLocales = args.locale\n ? [args.locale]\n : config.locales.filter((l: string) => l !== config.sourceLocale)\n\n if (targetLocales.length === 0) {\n consola.warn('No target locales to translate.')\n return\n }\n\n consola.info(`Translating with ${provider} (batch size: ${batchSize})`)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n for (const locale of targetLocales) {\n consola.info(`\\n[${locale}]`)\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const catalog = readCatalog(catalogPath, config.format)\n\n const { catalog: updated, translated } = await translateCatalog({\n provider,\n sourceLocale: config.sourceLocale,\n targetLocale: locale,\n catalog,\n batchSize,\n })\n\n if (translated > 0) {\n writeCatalog(catalogPath, updated, config.format)\n consola.success(` ${locale}: ${translated} messages translated`)\n } else {\n consola.success(` ${locale}: already fully translated`)\n }\n }\n },\n})\n\nconst migrate = defineCommand({\n meta: { name: 'migrate', description: 'Migrate from another i18n library using AI' },\n args: {\n from: { type: 'string', description: 'Source library: vue-i18n, nuxt-i18n, react-i18next, next-intl, next-i18next, lingui', required: true },\n provider: { type: 'string', description: 'AI provider: claude or codex', default: 'claude' },\n write: { type: 'boolean', description: 'Write generated files to disk', default: false },\n },\n async run({ args }) {\n const provider = args.provider as AIProvider\n if (provider !== 'claude' && provider !== 'codex') {\n consola.error(`Invalid provider \"${provider}\". Use \"claude\" or \"codex\".`)\n return\n }\n\n await runMigrate({\n from: args.from!,\n provider,\n write: args.write ?? false,\n })\n },\n})\n\nconst main = defineCommand({\n meta: {\n name: 'fluenti',\n version: '0.0.1',\n description: 'Compile-time i18n for modern frameworks',\n },\n subCommands: { extract, compile, stats, translate, migrate },\n})\n\nrunMain(main)\n"],"mappings":";0OAKA,IAAM,GAAA,EAAA,EAAA,WAA0B,EAAA,SAAS,CAIzC,SAAS,EACP,EACA,EACA,EACQ,CACR,IAAM,EAAO,KAAK,UAAU,EAAU,KAAM,EAAE,CAC9C,MAAO,CACL,6EAA6E,EAAa,QAAQ,EAAa,IAC/G,GACA,gBACA,EACA,GACA,SACA,qEACA,kFACA,8BACA,6EACD,CAAC,KAAK;EAAK,CAGd,eAAe,EAAS,EAAsB,EAAiC,CAC7E,IAAM,EAAY,GAAK,KAAO,KAE9B,GAAI,CACF,GAAI,IAAa,SAAU,CACzB,GAAM,CAAE,UAAW,MAAM,EAAc,SAAU,CAAC,KAAM,EAAO,CAAE,CAAE,YAAW,CAAC,CAC/E,OAAO,MACF,CACL,GAAM,CAAE,UAAW,MAAM,EAAc,QAAS,CAAC,KAAM,EAAQ,cAAc,CAAE,CAAE,YAAW,CAAC,CAC7F,OAAO,SAEF,EAAgB,CAUvB,MATY,EACJ,OAAS,SACL,MACR,IAAI,EAAS,8CACZ,IAAa,SACV,6CACA,kCACL,CAEG,GAIV,SAAS,EAAY,EAAsC,CAEzD,IAAM,EAAQ,EAAK,MAAM,cAAc,CACvC,GAAI,CAAC,EACH,MAAU,MAAM,sCAAsC,CAExD,IAAM,EAAS,KAAK,MAAM,EAAM,GAAG,CACnC,GAAI,OAAO,GAAW,WAAY,GAAmB,MAAM,QAAQ,EAAO,CACxE,MAAU,MAAM,yCAAyC,CAE3D,OAAO,EAGT,SAAS,EAAuB,EAA8C,CAC5E,IAAM,EAAkC,EAAE,CAC1C,IAAK,GAAM,CAAC,EAAI,KAAU,OAAO,QAAQ,EAAQ,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KAAK,oBAAoB,EAAS,gBAAgB,EAAU,GAAG,CACvE,IAAM,EAAM,EAAO,SAAW,OAAS,QAAU,MAEjD,IAAK,IAAM,KAAU,EAAe,CAClC,EAAA,QAAQ,KAAK,MAAM,EAAO,GAAG,CAC7B,IAAM,GAAA,EAAA,EAAA,SAAsB,EAAO,WAAY,GAAG,IAAS,IAAM,CAC3D,EAAU,EAAY,EAAa,EAAO,OAAO,CAEjD,CAAE,QAAS,EAAS,cAAe,MAAM,EAAiB,CAC9D,WACA,aAAc,EAAO,aACrB,aAAc,EACd,UACA,YACD,CAAC,CAEE,EAAa,GACf,EAAa,EAAa,EAAS,EAAO,OAAO,CACjD,EAAA,QAAQ,QAAQ,KAAK,EAAO,IAAI,EAAW,sBAAsB,EAEjE,EAAA,QAAQ,QAAQ,KAAK,EAAO,4BAA4B,GAI/D,CAAC,CA8BmD,SAAA,EAAA,EAAA,eA5BvB,CAC5B,KAAM,CAAE,KAAM,UAAW,YAAa,6CAA8C,CACpF,KAAM,CACJ,KAAM,CAAE,KAAM,SAAU,YAAa,sFAAuF,SAAU,GAAM,CAC5I,SAAU,CAAE,KAAM,SAAU,YAAa,+BAAgC,QAAS,SAAU,CAC5F,MAAO,CAAE,KAAM,UAAW,YAAa,gCAAiC,QAAS,GAAO,CACzF,CACD,MAAM,IAAI,CAAE,QAAQ,CAClB,IAAM,EAAW,EAAK,SACtB,GAAI,IAAa,UAAY,IAAa,QAAS,CACjD,EAAA,QAAQ,MAAM,qBAAqB,EAAS,6BAA6B,CACzE,OAGF,MAAM,EAAW,CACf,KAAM,EAAK,KACX,WACA,MAAO,EAAK,OAAS,GACtB,CAAC,EAEL,CAAC,CAQ4D,CAC7D,CAAC,CAEW"}
|
package/dist/cli.js
CHANGED
|
@@ -437,7 +437,7 @@ d(u({
|
|
|
437
437
|
async run({ args: e }) {
|
|
438
438
|
let n = await H(e.config);
|
|
439
439
|
f.info(`Extracting messages from ${n.include.join(", ")}`);
|
|
440
|
-
let r = await p(n.include
|
|
440
|
+
let r = await p(n.include), i = [];
|
|
441
441
|
for (let e of r) {
|
|
442
442
|
let t = G(e, g(e, "utf-8"));
|
|
443
443
|
i.push(...t);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/translate.ts","../src/migrate.ts","../src/cli.ts"],"sourcesContent":["import { execFile } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport consola from 'consola'\nimport type { CatalogData } from './catalog'\n\nconst execFileAsync = promisify(execFile)\n\nexport type AIProvider = 'claude' | 'codex'\n\nfunction buildPrompt(\n sourceLocale: string,\n targetLocale: string,\n messages: Record<string, string>,\n): string {\n const json = JSON.stringify(messages, null, 2)\n return [\n `You are a professional translator. Translate the following messages from \"${sourceLocale}\" to \"${targetLocale}\".`,\n '',\n `Input (JSON):`,\n json,\n '',\n 'Rules:',\n '- Output ONLY valid JSON with the same keys and translated values.',\n '- Keep ICU MessageFormat placeholders like {name}, {count}, {gender} unchanged.',\n '- Keep HTML tags unchanged.',\n '- Do not add any explanation or markdown formatting, output raw JSON only.',\n ].join('\\n')\n}\n\nasync function invokeAI(provider: AIProvider, prompt: string): Promise<string> {\n const maxBuffer = 10 * 1024 * 1024\n\n try {\n if (provider === 'claude') {\n const { stdout } = await execFileAsync('claude', ['-p', prompt], { maxBuffer })\n return stdout\n } else {\n const { stdout } = await execFileAsync('codex', ['-p', prompt, '--full-auto'], { maxBuffer })\n return stdout\n }\n } catch (error: unknown) {\n const err = error as Error & { code?: string }\n if (err.code === 'ENOENT') {\n throw new Error(\n `\"${provider}\" CLI not found. Please install it first:\\n` +\n (provider === 'claude'\n ? ' npm install -g @anthropic-ai/claude-code'\n : ' npm install -g @openai/codex'),\n )\n }\n throw error\n }\n}\n\nfunction extractJSON(text: string): Record<string, string> {\n // Try to find a JSON object in the response\n const match = text.match(/\\{[\\s\\S]*\\}/)\n if (!match) {\n throw new Error('No JSON object found in AI response')\n }\n const parsed = JSON.parse(match[0])\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new Error('AI response is not a valid JSON object')\n }\n return parsed as Record<string, string>\n}\n\nfunction getUntranslatedEntries(catalog: CatalogData): Record<string, string> {\n const entries: Record<string, string> = {}\n for (const [id, entry] of Object.entries(catalog)) {\n if (entry.obsolete) continue\n if (!entry.translation || entry.translation.length === 0) {\n entries[id] = entry.message ?? id\n }\n }\n return entries\n}\n\nfunction chunkEntries(\n entries: Record<string, string>,\n batchSize: number,\n): Array<Record<string, string>> {\n const keys = Object.keys(entries)\n const chunks: Array<Record<string, string>> = []\n\n for (let i = 0; i < keys.length; i += batchSize) {\n const chunk: Record<string, string> = {}\n for (const key of keys.slice(i, i + batchSize)) {\n chunk[key] = entries[key]!\n }\n chunks.push(chunk)\n }\n\n return chunks\n}\n\nexport interface TranslateOptions {\n provider: AIProvider\n sourceLocale: string\n targetLocale: string\n catalog: CatalogData\n batchSize: number\n}\n\nexport async function translateCatalog(options: TranslateOptions): Promise<{\n catalog: CatalogData\n translated: number\n}> {\n const { provider, sourceLocale, targetLocale, catalog, batchSize } = options\n\n const untranslated = getUntranslatedEntries(catalog)\n const count = Object.keys(untranslated).length\n\n if (count === 0) {\n return { catalog, translated: 0 }\n }\n\n consola.info(` ${count} untranslated messages, translating with ${provider}...`)\n\n const batches = chunkEntries(untranslated, batchSize)\n let totalTranslated = 0\n\n for (let i = 0; i < batches.length; i++) {\n const batch = batches[i]!\n const batchKeys = Object.keys(batch)\n\n if (batches.length > 1) {\n consola.info(` Batch ${i + 1}/${batches.length} (${batchKeys.length} messages)`)\n }\n\n const prompt = buildPrompt(sourceLocale, targetLocale, batch)\n const response = await invokeAI(provider, prompt)\n const translations = extractJSON(response)\n\n for (const key of batchKeys) {\n if (translations[key] && typeof translations[key] === 'string') {\n catalog[key] = {\n ...catalog[key],\n translation: translations[key],\n }\n totalTranslated++\n } else {\n consola.warn(` Missing translation for key: ${key}`)\n }\n }\n }\n\n return { catalog, translated: totalTranslated }\n}\n","import { execFile } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport { readFileSync, existsSync } from 'node:fs'\nimport { resolve, join } from 'node:path'\nimport fg from 'fast-glob'\nimport consola from 'consola'\nimport type { AIProvider } from './translate'\n\nconst execFileAsync = promisify(execFile)\n\nexport type SupportedLibrary =\n | 'vue-i18n'\n | 'nuxt-i18n'\n | 'react-i18next'\n | 'next-intl'\n | 'next-i18next'\n | 'lingui'\n\ninterface LibraryInfo {\n name: SupportedLibrary\n framework: string\n configPatterns: string[]\n localePatterns: string[]\n sourcePatterns: string[]\n migrationGuide: string // relative path from packages/\n}\n\nconst LIBRARY_INFO: Record<SupportedLibrary, LibraryInfo> = {\n 'vue-i18n': {\n name: 'vue-i18n',\n framework: 'Vue',\n configPatterns: ['i18n.ts', 'i18n.js', 'i18n/index.ts', 'i18n/index.js', 'src/i18n.ts', 'src/i18n.js', 'src/i18n/index.ts', 'src/plugins/i18n.ts'],\n localePatterns: ['locales/*.json', 'src/locales/*.json', 'i18n/*.json', 'src/i18n/*.json', 'lang/*.json', 'src/lang/*.json', 'locales/*.yaml', 'locales/*.yml'],\n sourcePatterns: ['src/**/*.vue'],\n migrationGuide: 'vue/llms-migration.txt',\n },\n 'nuxt-i18n': {\n name: 'nuxt-i18n',\n framework: 'Nuxt',\n configPatterns: ['nuxt.config.ts', 'nuxt.config.js', 'i18n.config.ts', 'i18n.config.js'],\n localePatterns: ['locales/*.json', 'lang/*.json', 'i18n/*.json', 'locales/*.yaml', 'locales/*.yml'],\n sourcePatterns: ['pages/**/*.vue', 'components/**/*.vue', 'layouts/**/*.vue'],\n migrationGuide: 'nuxt/llms-migration.txt',\n },\n 'react-i18next': {\n name: 'react-i18next',\n framework: 'React',\n configPatterns: ['i18n.ts', 'i18n.js', 'src/i18n.ts', 'src/i18n.js', 'src/i18n/index.ts', 'src/i18n/config.ts'],\n localePatterns: ['locales/*.json', 'src/locales/*.json', 'public/locales/**/*.json', 'translations/*.json', 'src/translations/*.json'],\n sourcePatterns: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts'],\n migrationGuide: 'react/llms-migration.txt',\n },\n 'next-intl': {\n name: 'next-intl',\n framework: 'Next.js',\n configPatterns: ['next.config.ts', 'next.config.js', 'next.config.mjs', 'i18n.ts', 'src/i18n.ts', 'i18n/request.ts', 'src/i18n/request.ts'],\n localePatterns: ['messages/*.json', 'locales/*.json', 'src/messages/*.json', 'src/locales/*.json'],\n sourcePatterns: ['app/**/*.tsx', 'src/app/**/*.tsx', 'pages/**/*.tsx', 'components/**/*.tsx'],\n migrationGuide: 'next-plugin/llms-migration.txt',\n },\n 'next-i18next': {\n name: 'next-i18next',\n framework: 'Next.js',\n configPatterns: ['next-i18next.config.js', 'next-i18next.config.mjs', 'next.config.ts', 'next.config.js'],\n localePatterns: ['public/locales/**/*.json'],\n sourcePatterns: ['pages/**/*.tsx', 'src/pages/**/*.tsx', 'components/**/*.tsx', 'src/components/**/*.tsx'],\n migrationGuide: 'next-plugin/llms-migration.txt',\n },\n 'lingui': {\n name: 'lingui',\n framework: 'React',\n configPatterns: ['lingui.config.ts', 'lingui.config.js', '.linguirc'],\n localePatterns: ['locales/*.po', 'src/locales/*.po', 'locales/*/messages.po', 'src/locales/*/messages.po'],\n sourcePatterns: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts'],\n migrationGuide: 'react/llms-migration.txt',\n },\n}\n\nconst SUPPORTED_NAMES = Object.keys(LIBRARY_INFO) as SupportedLibrary[]\n\nfunction resolveLibrary(from: string): SupportedLibrary | undefined {\n const normalized = from.toLowerCase().replace(/^@nuxtjs\\//, 'nuxt-').replace(/^@/, '')\n return SUPPORTED_NAMES.find((name) => name === normalized)\n}\n\ninterface DetectedFiles {\n configFiles: Array<{ path: string; content: string }>\n localeFiles: Array<{ path: string; content: string }>\n sampleSources: Array<{ path: string; content: string }>\n packageJson: string | undefined\n}\n\nasync function detectFiles(info: LibraryInfo): Promise<DetectedFiles> {\n const result: DetectedFiles = {\n configFiles: [],\n localeFiles: [],\n sampleSources: [],\n packageJson: undefined,\n }\n\n // Read package.json\n const pkgPath = resolve('package.json')\n if (existsSync(pkgPath)) {\n result.packageJson = readFileSync(pkgPath, 'utf-8')\n }\n\n // Find config files\n for (const pattern of info.configPatterns) {\n const fullPath = resolve(pattern)\n if (existsSync(fullPath)) {\n result.configFiles.push({\n path: pattern,\n content: readFileSync(fullPath, 'utf-8'),\n })\n }\n }\n\n // Find locale files (limit to 10 to avoid huge prompts)\n const localeGlobs = await fg(info.localePatterns, { absolute: false })\n for (const file of localeGlobs.slice(0, 10)) {\n const fullPath = resolve(file)\n const content = readFileSync(fullPath, 'utf-8')\n // Truncate large files\n result.localeFiles.push({\n path: file,\n content: content.length > 5000 ? content.slice(0, 5000) + '\\n... (truncated)' : content,\n })\n }\n\n // Find sample source files (limit to 5 for prompt size)\n const sourceGlobs = await fg(info.sourcePatterns, { absolute: false })\n for (const file of sourceGlobs.slice(0, 5)) {\n const fullPath = resolve(file)\n const content = readFileSync(fullPath, 'utf-8')\n result.sampleSources.push({\n path: file,\n content: content.length > 3000 ? content.slice(0, 3000) + '\\n... (truncated)' : content,\n })\n }\n\n return result\n}\n\nfunction loadMigrationGuide(guidePath: string): string {\n // Try to find the migration guide relative to the CLI package\n const candidates = [\n resolve('node_modules', '@fluenti', 'cli', '..', '..', guidePath),\n join(__dirname, '..', '..', '..', guidePath),\n join(__dirname, '..', '..', guidePath),\n ]\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n return readFileSync(candidate, 'utf-8')\n }\n }\n\n return ''\n}\n\nfunction buildMigratePrompt(\n library: LibraryInfo,\n detected: DetectedFiles,\n migrationGuide: string,\n): string {\n const sections: string[] = []\n\n sections.push(\n `You are a migration assistant helping convert a ${library.framework} project from \"${library.name}\" to Fluenti (@fluenti).`,\n '',\n 'Your task:',\n '1. Generate a `fluenti.config.ts` file based on the existing i18n configuration',\n '2. Convert each locale/translation file to Fluenti PO format',\n '3. List the code changes needed (file by file) to migrate source code from the old API to Fluenti API',\n '',\n )\n\n if (migrationGuide) {\n sections.push(\n '=== MIGRATION GUIDE ===',\n migrationGuide,\n '',\n )\n }\n\n if (detected.packageJson) {\n sections.push(\n '=== package.json ===',\n detected.packageJson,\n '',\n )\n }\n\n if (detected.configFiles.length > 0) {\n sections.push('=== EXISTING CONFIG FILES ===')\n for (const file of detected.configFiles) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n if (detected.localeFiles.length > 0) {\n sections.push('=== EXISTING LOCALE FILES ===')\n for (const file of detected.localeFiles) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n if (detected.sampleSources.length > 0) {\n sections.push('=== SAMPLE SOURCE FILES ===')\n for (const file of detected.sampleSources) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n sections.push(\n '',\n '=== OUTPUT FORMAT ===',\n 'Respond with the following sections, each starting with the exact header shown:',\n '',\n '### FLUENTI_CONFIG',\n '```ts',\n '// The fluenti.config.ts content',\n '```',\n '',\n '### LOCALE_FILES',\n 'For each locale file, output:',\n '#### LOCALE: {locale_code}',\n '```po',\n '// The PO file content',\n '```',\n '',\n '### MIGRATION_STEPS',\n 'A numbered checklist of specific code changes needed, with before/after examples.',\n '',\n '### INSTALL_COMMANDS',\n '```bash',\n '// The install and uninstall commands',\n '```',\n )\n\n return sections.join('\\n')\n}\n\nasync function invokeAI(provider: AIProvider, prompt: string): Promise<string> {\n const maxBuffer = 10 * 1024 * 1024\n\n try {\n if (provider === 'claude') {\n const { stdout } = await execFileAsync('claude', ['-p', prompt], { maxBuffer })\n return stdout\n } else {\n const { stdout } = await execFileAsync('codex', ['-p', prompt, '--full-auto'], { maxBuffer })\n return stdout\n }\n } catch (error: unknown) {\n const err = error as Error & { code?: string }\n if (err.code === 'ENOENT') {\n throw new Error(\n `\"${provider}\" CLI not found. Please install it first:\\n` +\n (provider === 'claude'\n ? ' npm install -g @anthropic-ai/claude-code'\n : ' npm install -g @openai/codex'),\n )\n }\n throw error\n }\n}\n\ninterface MigrateResult {\n config: string | undefined\n localeFiles: Array<{ locale: string; content: string }>\n steps: string | undefined\n installCommands: string | undefined\n}\n\nfunction parseResponse(response: string): MigrateResult {\n const result: MigrateResult = {\n config: undefined,\n localeFiles: [],\n steps: undefined,\n installCommands: undefined,\n }\n\n // Extract fluenti.config.ts\n const configMatch = response.match(/### FLUENTI_CONFIG[\\s\\S]*?```(?:ts|typescript)?\\n([\\s\\S]*?)```/)\n if (configMatch) {\n result.config = configMatch[1]!.trim()\n }\n\n // Extract locale files\n const localeSection = response.match(/### LOCALE_FILES([\\s\\S]*?)(?=### MIGRATION_STEPS|### INSTALL_COMMANDS|$)/)\n if (localeSection) {\n const localeRegex = /#### LOCALE:\\s*(\\S+)\\s*\\n```(?:po)?\\n([\\s\\S]*?)```/g\n let match\n while ((match = localeRegex.exec(localeSection[1]!)) !== null) {\n result.localeFiles.push({\n locale: match[1]!,\n content: match[2]!.trim(),\n })\n }\n }\n\n // Extract migration steps\n const stepsMatch = response.match(/### MIGRATION_STEPS\\s*\\n([\\s\\S]*?)(?=### INSTALL_COMMANDS|$)/)\n if (stepsMatch) {\n result.steps = stepsMatch[1]!.trim()\n }\n\n // Extract install commands\n const installMatch = response.match(/### INSTALL_COMMANDS[\\s\\S]*?```(?:bash|sh)?\\n([\\s\\S]*?)```/)\n if (installMatch) {\n result.installCommands = installMatch[1]!.trim()\n }\n\n return result\n}\n\nexport interface MigrateOptions {\n from: string\n provider: AIProvider\n write: boolean\n}\n\nexport async function runMigrate(options: MigrateOptions): Promise<void> {\n const { from, provider, write } = options\n\n const library = resolveLibrary(from)\n if (!library) {\n consola.error(`Unsupported library \"${from}\". Supported libraries:`)\n for (const name of SUPPORTED_NAMES) {\n consola.log(` - ${name}`)\n }\n return\n }\n\n const info = LIBRARY_INFO[library]\n consola.info(`Migrating from ${info.name} (${info.framework}) to Fluenti`)\n\n // Detect existing files\n consola.info('Scanning project for existing i18n files...')\n const detected = await detectFiles(info)\n\n if (detected.configFiles.length === 0 && detected.localeFiles.length === 0) {\n consola.warn(`No ${info.name} configuration or locale files found.`)\n consola.info('Make sure you are running this command from the project root directory.')\n return\n }\n\n consola.info(`Found: ${detected.configFiles.length} config file(s), ${detected.localeFiles.length} locale file(s), ${detected.sampleSources.length} source file(s)`)\n\n // Load migration guide\n const migrationGuide = loadMigrationGuide(info.migrationGuide)\n\n // Build prompt and invoke AI\n consola.info(`Generating migration plan with ${provider}...`)\n const prompt = buildMigratePrompt(info, detected, migrationGuide)\n const response = await invokeAI(provider, prompt)\n const result = parseResponse(response)\n\n // Display install commands\n if (result.installCommands) {\n consola.log('')\n consola.box({\n title: 'Install Commands',\n message: result.installCommands,\n })\n }\n\n // Write or display fluenti.config.ts\n if (result.config) {\n if (write) {\n const { writeFileSync } = await import('node:fs')\n const configPath = resolve('fluenti.config.ts')\n writeFileSync(configPath, result.config, 'utf-8')\n consola.success(`Written: ${configPath}`)\n } else {\n consola.log('')\n consola.box({\n title: 'fluenti.config.ts',\n message: result.config,\n })\n }\n }\n\n // Write or display locale files\n if (result.localeFiles.length > 0) {\n if (write) {\n const { writeFileSync, mkdirSync } = await import('node:fs')\n const catalogDir = './locales'\n mkdirSync(resolve(catalogDir), { recursive: true })\n for (const file of result.localeFiles) {\n const outPath = resolve(catalogDir, `${file.locale}.po`)\n writeFileSync(outPath, file.content, 'utf-8')\n consola.success(`Written: ${outPath}`)\n }\n } else {\n for (const file of result.localeFiles) {\n consola.log('')\n consola.box({\n title: `locales/${file.locale}.po`,\n message: file.content.length > 500\n ? file.content.slice(0, 500) + '\\n... (use --write to save full file)'\n : file.content,\n })\n }\n }\n }\n\n // Display migration steps\n if (result.steps) {\n consola.log('')\n consola.box({\n title: 'Migration Steps',\n message: result.steps,\n })\n }\n\n if (!write && (result.config || result.localeFiles.length > 0)) {\n consola.log('')\n consola.info('Run with --write to save generated files to disk:')\n consola.log(` fluenti migrate --from ${from} --write`)\n }\n}\n","#!/usr/bin/env node\nimport { defineCommand, runMain } from 'citty'\nimport consola from 'consola'\nimport fg from 'fast-glob'\nimport { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'\nimport { resolve, dirname, extname } from 'node:path'\nimport { extractFromVue } from './vue-extractor'\nimport { extractFromTsx } from './tsx-extractor'\nimport { updateCatalog } from './catalog'\nimport type { CatalogData } from './catalog'\nimport { readJsonCatalog, writeJsonCatalog } from './json-format'\nimport { readPoCatalog, writePoCatalog } from './po-format'\nimport { compileCatalog, compileIndex, collectAllIds } from './compile'\nimport { translateCatalog } from './translate'\nimport type { AIProvider } from './translate'\nimport { runMigrate } from './migrate'\nimport type { ExtractedMessage, FluentiConfig } from '@fluenti/core'\n\nconst defaultConfig: FluentiConfig = {\n sourceLocale: 'en',\n locales: ['en'],\n catalogDir: './locales',\n format: 'po',\n include: ['./src/**/*.{vue,tsx,jsx,ts,js}'],\n compileOutDir: './locales/compiled',\n}\n\nasync function loadConfig(configPath?: string): Promise<FluentiConfig> {\n const paths = configPath\n ? [resolve(configPath)]\n : [\n resolve('fluenti.config.ts'),\n resolve('fluenti.config.js'),\n resolve('fluenti.config.mjs'),\n ]\n\n for (const p of paths) {\n if (existsSync(p)) {\n try {\n const { createJiti } = await import('jiti')\n const jiti = createJiti(import.meta.url)\n const mod = await jiti.import(p) as { default?: Partial<FluentiConfig> }\n const userConfig = mod.default ?? mod as unknown as Partial<FluentiConfig>\n return { ...defaultConfig, ...userConfig }\n } catch {\n consola.warn(`Failed to load config from ${p}, using defaults`)\n }\n }\n }\n\n return defaultConfig\n}\n\nfunction readCatalog(filePath: string, format: 'json' | 'po'): CatalogData {\n if (!existsSync(filePath)) return {}\n const content = readFileSync(filePath, 'utf-8')\n return format === 'json' ? readJsonCatalog(content) : readPoCatalog(content)\n}\n\nfunction writeCatalog(filePath: string, catalog: CatalogData, format: 'json' | 'po'): void {\n mkdirSync(dirname(filePath), { recursive: true })\n const content = format === 'json' ? writeJsonCatalog(catalog) : writePoCatalog(catalog)\n writeFileSync(filePath, content, 'utf-8')\n}\n\nfunction extractFromFile(filePath: string, code: string): ExtractedMessage[] {\n const ext = extname(filePath)\n if (ext === '.vue') return extractFromVue(code, filePath)\n return extractFromTsx(code, filePath)\n}\n\nconst extract = defineCommand({\n meta: { name: 'extract', description: 'Extract messages from source files' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n clean: { type: 'boolean', description: 'Remove obsolete entries instead of marking them', default: false },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n consola.info(`Extracting messages from ${config.include.join(', ')}`)\n\n const files = await fg(config.include, { absolute: true })\n const allMessages: ExtractedMessage[] = []\n\n for (const file of files) {\n const code = readFileSync(file, 'utf-8')\n const messages = extractFromFile(file, code)\n allMessages.push(...messages)\n }\n\n consola.info(`Found ${allMessages.length} messages in ${files.length} files`)\n\n const ext = config.format === 'json' ? '.json' : '.po'\n const clean = args.clean ?? false\n\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const existing = readCatalog(catalogPath, config.format)\n const { catalog, result } = updateCatalog(existing, allMessages)\n\n const finalCatalog = clean\n ? Object.fromEntries(Object.entries(catalog).filter(([, entry]) => !entry.obsolete))\n : catalog\n\n writeCatalog(catalogPath, finalCatalog, config.format)\n\n const obsoleteLabel = clean\n ? `${result.obsolete} removed`\n : `${result.obsolete} obsolete`\n consola.success(\n `${locale}: ${result.added} added, ${result.unchanged} unchanged, ${obsoleteLabel}`,\n )\n }\n },\n})\n\nconst compile = defineCommand({\n meta: { name: 'compile', description: 'Compile message catalogs to JS modules' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n mkdirSync(config.compileOutDir, { recursive: true })\n\n // Collect all catalogs and build union of IDs\n const allCatalogs: Record<string, CatalogData> = {}\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n allCatalogs[locale] = readCatalog(catalogPath, config.format)\n }\n\n const allIds = collectAllIds(allCatalogs)\n consola.info(`Compiling ${allIds.length} messages across ${config.locales.length} locales`)\n\n for (const locale of config.locales) {\n const { code, stats } = compileCatalog(\n allCatalogs[locale]!,\n locale,\n allIds,\n config.sourceLocale,\n )\n const outPath = resolve(config.compileOutDir, `${locale}.js`)\n writeFileSync(outPath, code, 'utf-8')\n\n if (stats.missing.length > 0) {\n consola.warn(\n `${locale}: ${stats.compiled} compiled, ${stats.missing.length} missing translations`,\n )\n for (const id of stats.missing) {\n consola.warn(` ⤷ ${id}`)\n }\n } else {\n consola.success(`Compiled ${locale}: ${stats.compiled} messages → ${outPath}`)\n }\n }\n\n // Generate index.js with locale list and lazy loaders\n const indexCode = compileIndex(config.locales, config.compileOutDir)\n const indexPath = resolve(config.compileOutDir, 'index.js')\n writeFileSync(indexPath, indexCode, 'utf-8')\n consola.success(`Generated index → ${indexPath}`)\n },\n})\n\nconst stats = defineCommand({\n meta: { name: 'stats', description: 'Show translation progress' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n const rows: Array<{ locale: string; total: number; translated: number; pct: string }> = []\n\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const catalog = readCatalog(catalogPath, config.format)\n const entries = Object.values(catalog).filter((e) => !e.obsolete)\n const total = entries.length\n const translated = entries.filter((e) => e.translation && e.translation.length > 0).length\n const pct = total > 0 ? ((translated / total) * 100).toFixed(1) + '%' : '—'\n rows.push({ locale, total, translated, pct })\n }\n\n consola.log('')\n consola.log(' Locale │ Total │ Translated │ Progress')\n consola.log(' ────────┼───────┼────────────┼─────────')\n for (const row of rows) {\n consola.log(\n ` ${row.locale.padEnd(8)}│ ${String(row.total).padStart(5)} │ ${String(row.translated).padStart(10)} │ ${row.pct}`,\n )\n }\n consola.log('')\n },\n})\n\nconst translate = defineCommand({\n meta: { name: 'translate', description: 'Translate messages using AI (Claude Code or Codex CLI)' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n provider: { type: 'string', description: 'AI provider: claude or codex', default: 'claude' },\n locale: { type: 'string', description: 'Translate a specific locale only' },\n 'batch-size': { type: 'string', description: 'Messages per batch', default: '50' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const provider = args.provider as AIProvider\n\n if (provider !== 'claude' && provider !== 'codex') {\n consola.error(`Invalid provider \"${provider}\". Use \"claude\" or \"codex\".`)\n return\n }\n\n const batchSize = parseInt(args['batch-size'] ?? '50', 10)\n if (isNaN(batchSize) || batchSize < 1) {\n consola.error('Invalid batch-size. Must be a positive integer.')\n return\n }\n\n const targetLocales = args.locale\n ? [args.locale]\n : config.locales.filter((l: string) => l !== config.sourceLocale)\n\n if (targetLocales.length === 0) {\n consola.warn('No target locales to translate.')\n return\n }\n\n consola.info(`Translating with ${provider} (batch size: ${batchSize})`)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n for (const locale of targetLocales) {\n consola.info(`\\n[${locale}]`)\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const catalog = readCatalog(catalogPath, config.format)\n\n const { catalog: updated, translated } = await translateCatalog({\n provider,\n sourceLocale: config.sourceLocale,\n targetLocale: locale,\n catalog,\n batchSize,\n })\n\n if (translated > 0) {\n writeCatalog(catalogPath, updated, config.format)\n consola.success(` ${locale}: ${translated} messages translated`)\n } else {\n consola.success(` ${locale}: already fully translated`)\n }\n }\n },\n})\n\nconst migrate = defineCommand({\n meta: { name: 'migrate', description: 'Migrate from another i18n library using AI' },\n args: {\n from: { type: 'string', description: 'Source library: vue-i18n, nuxt-i18n, react-i18next, next-intl, next-i18next, lingui', required: true },\n provider: { type: 'string', description: 'AI provider: claude or codex', default: 'claude' },\n write: { type: 'boolean', description: 'Write generated files to disk', default: false },\n },\n async run({ args }) {\n const provider = args.provider as AIProvider\n if (provider !== 'claude' && provider !== 'codex') {\n consola.error(`Invalid provider \"${provider}\". Use \"claude\" or \"codex\".`)\n return\n }\n\n await runMigrate({\n from: args.from!,\n provider,\n write: args.write ?? false,\n })\n },\n})\n\nconst main = defineCommand({\n meta: {\n name: 'fluenti',\n version: '0.0.1',\n description: 'Compile-time i18n for modern frameworks',\n },\n subCommands: { extract, compile, stats, translate, migrate },\n})\n\nrunMain(main)\n"],"mappings":";;;;;;;;;;AAKA,IAAM,IAAgB,EAAU,EAAS;AAIzC,SAAS,EACP,GACA,GACA,GACQ;CACR,IAAM,IAAO,KAAK,UAAU,GAAU,MAAM,EAAE;AAC9C,QAAO;EACL,6EAA6E,EAAa,QAAQ,EAAa;EAC/G;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK;;AAGd,eAAe,EAAS,GAAsB,GAAiC;CAC7E,IAAM,IAAY,KAAK,OAAO;AAE9B,KAAI;AACF,MAAI,MAAa,UAAU;GACzB,IAAM,EAAE,cAAW,MAAM,EAAc,UAAU,CAAC,MAAM,EAAO,EAAE,EAAE,cAAW,CAAC;AAC/E,UAAO;SACF;GACL,IAAM,EAAE,cAAW,MAAM,EAAc,SAAS;IAAC;IAAM;IAAQ;IAAc,EAAE,EAAE,cAAW,CAAC;AAC7F,UAAO;;UAEF,GAAgB;AAUvB,QATY,EACJ,SAAS,WACL,MACR,IAAI,EAAS,gDACZ,MAAa,WACV,+CACA,kCACL,GAEG;;;AAIV,SAAS,EAAY,GAAsC;CAEzD,IAAM,IAAQ,EAAK,MAAM,cAAc;AACvC,KAAI,CAAC,EACH,OAAU,MAAM,sCAAsC;CAExD,IAAM,IAAS,KAAK,MAAM,EAAM,GAAG;AACnC,KAAI,OAAO,KAAW,aAAY,KAAmB,MAAM,QAAQ,EAAO,CACxE,OAAU,MAAM,yCAAyC;AAE3D,QAAO;;AAGT,SAAS,EAAuB,GAA8C;CAC5E,IAAM,IAAkC,EAAE;AAC1C,MAAK,IAAM,CAAC,GAAI,MAAU,OAAO,QAAQ,EA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AAuF,UAAU;KAAM;IAC5I,UAAU;KAAE,MAAM;KAAU,aAAa;KAAgC,SAAS;KAAU;IAC5F,OAAO;KAAE,MAAM;KAAW,aAAa;KAAiC,SAAS;KAAO;IACzF;GACD,MAAM,IAAI,EAAE,WAAQ;IAClB,IAAM,IAAW,EAAK;AACtB,QAAI,MAAa,YAAY,MAAa,SAAS;AACjD,OAAQ,MAAM,qBAAqB,EAAS,6BAA6B;AACzE;;AAGF,UAAM,EAAW;KACf,MAAM,EAAK;KACX;KACA,OAAO,EAAK,SAAS;KACtB,CAAC;;GAEL,CAAC;EAQ4D;CAC7D,CAAC,CAEW"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/translate.ts","../src/migrate.ts","../src/cli.ts"],"sourcesContent":["import { execFile } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport consola from 'consola'\nimport type { CatalogData } from './catalog'\n\nconst execFileAsync = promisify(execFile)\n\nexport type AIProvider = 'claude' | 'codex'\n\nfunction buildPrompt(\n sourceLocale: string,\n targetLocale: string,\n messages: Record<string, string>,\n): string {\n const json = JSON.stringify(messages, null, 2)\n return [\n `You are a professional translator. Translate the following messages from \"${sourceLocale}\" to \"${targetLocale}\".`,\n '',\n `Input (JSON):`,\n json,\n '',\n 'Rules:',\n '- Output ONLY valid JSON with the same keys and translated values.',\n '- Keep ICU MessageFormat placeholders like {name}, {count}, {gender} unchanged.',\n '- Keep HTML tags unchanged.',\n '- Do not add any explanation or markdown formatting, output raw JSON only.',\n ].join('\\n')\n}\n\nasync function invokeAI(provider: AIProvider, prompt: string): Promise<string> {\n const maxBuffer = 10 * 1024 * 1024\n\n try {\n if (provider === 'claude') {\n const { stdout } = await execFileAsync('claude', ['-p', prompt], { maxBuffer })\n return stdout\n } else {\n const { stdout } = await execFileAsync('codex', ['-p', prompt, '--full-auto'], { maxBuffer })\n return stdout\n }\n } catch (error: unknown) {\n const err = error as Error & { code?: string }\n if (err.code === 'ENOENT') {\n throw new Error(\n `\"${provider}\" CLI not found. Please install it first:\\n` +\n (provider === 'claude'\n ? ' npm install -g @anthropic-ai/claude-code'\n : ' npm install -g @openai/codex'),\n )\n }\n throw error\n }\n}\n\nfunction extractJSON(text: string): Record<string, string> {\n // Try to find a JSON object in the response\n const match = text.match(/\\{[\\s\\S]*\\}/)\n if (!match) {\n throw new Error('No JSON object found in AI response')\n }\n const parsed = JSON.parse(match[0])\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new Error('AI response is not a valid JSON object')\n }\n return parsed as Record<string, string>\n}\n\nfunction getUntranslatedEntries(catalog: CatalogData): Record<string, string> {\n const entries: Record<string, string> = {}\n for (const [id, entry] of Object.entries(catalog)) {\n if (entry.obsolete) continue\n if (!entry.translation || entry.translation.length === 0) {\n entries[id] = entry.message ?? id\n }\n }\n return entries\n}\n\nfunction chunkEntries(\n entries: Record<string, string>,\n batchSize: number,\n): Array<Record<string, string>> {\n const keys = Object.keys(entries)\n const chunks: Array<Record<string, string>> = []\n\n for (let i = 0; i < keys.length; i += batchSize) {\n const chunk: Record<string, string> = {}\n for (const key of keys.slice(i, i + batchSize)) {\n chunk[key] = entries[key]!\n }\n chunks.push(chunk)\n }\n\n return chunks\n}\n\nexport interface TranslateOptions {\n provider: AIProvider\n sourceLocale: string\n targetLocale: string\n catalog: CatalogData\n batchSize: number\n}\n\nexport async function translateCatalog(options: TranslateOptions): Promise<{\n catalog: CatalogData\n translated: number\n}> {\n const { provider, sourceLocale, targetLocale, catalog, batchSize } = options\n\n const untranslated = getUntranslatedEntries(catalog)\n const count = Object.keys(untranslated).length\n\n if (count === 0) {\n return { catalog, translated: 0 }\n }\n\n consola.info(` ${count} untranslated messages, translating with ${provider}...`)\n\n const batches = chunkEntries(untranslated, batchSize)\n let totalTranslated = 0\n\n for (let i = 0; i < batches.length; i++) {\n const batch = batches[i]!\n const batchKeys = Object.keys(batch)\n\n if (batches.length > 1) {\n consola.info(` Batch ${i + 1}/${batches.length} (${batchKeys.length} messages)`)\n }\n\n const prompt = buildPrompt(sourceLocale, targetLocale, batch)\n const response = await invokeAI(provider, prompt)\n const translations = extractJSON(response)\n\n for (const key of batchKeys) {\n if (translations[key] && typeof translations[key] === 'string') {\n catalog[key] = {\n ...catalog[key],\n translation: translations[key],\n }\n totalTranslated++\n } else {\n consola.warn(` Missing translation for key: ${key}`)\n }\n }\n }\n\n return { catalog, translated: totalTranslated }\n}\n","import { execFile } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport { readFileSync, existsSync } from 'node:fs'\nimport { resolve, join } from 'node:path'\nimport fg from 'fast-glob'\nimport consola from 'consola'\nimport type { AIProvider } from './translate'\n\nconst execFileAsync = promisify(execFile)\n\nexport type SupportedLibrary =\n | 'vue-i18n'\n | 'nuxt-i18n'\n | 'react-i18next'\n | 'next-intl'\n | 'next-i18next'\n | 'lingui'\n\ninterface LibraryInfo {\n name: SupportedLibrary\n framework: string\n configPatterns: string[]\n localePatterns: string[]\n sourcePatterns: string[]\n migrationGuide: string // relative path from packages/\n}\n\nconst LIBRARY_INFO: Record<SupportedLibrary, LibraryInfo> = {\n 'vue-i18n': {\n name: 'vue-i18n',\n framework: 'Vue',\n configPatterns: ['i18n.ts', 'i18n.js', 'i18n/index.ts', 'i18n/index.js', 'src/i18n.ts', 'src/i18n.js', 'src/i18n/index.ts', 'src/plugins/i18n.ts'],\n localePatterns: ['locales/*.json', 'src/locales/*.json', 'i18n/*.json', 'src/i18n/*.json', 'lang/*.json', 'src/lang/*.json', 'locales/*.yaml', 'locales/*.yml'],\n sourcePatterns: ['src/**/*.vue'],\n migrationGuide: 'vue/llms-migration.txt',\n },\n 'nuxt-i18n': {\n name: 'nuxt-i18n',\n framework: 'Nuxt',\n configPatterns: ['nuxt.config.ts', 'nuxt.config.js', 'i18n.config.ts', 'i18n.config.js'],\n localePatterns: ['locales/*.json', 'lang/*.json', 'i18n/*.json', 'locales/*.yaml', 'locales/*.yml'],\n sourcePatterns: ['pages/**/*.vue', 'components/**/*.vue', 'layouts/**/*.vue'],\n migrationGuide: 'nuxt/llms-migration.txt',\n },\n 'react-i18next': {\n name: 'react-i18next',\n framework: 'React',\n configPatterns: ['i18n.ts', 'i18n.js', 'src/i18n.ts', 'src/i18n.js', 'src/i18n/index.ts', 'src/i18n/config.ts'],\n localePatterns: ['locales/*.json', 'src/locales/*.json', 'public/locales/**/*.json', 'translations/*.json', 'src/translations/*.json'],\n sourcePatterns: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts'],\n migrationGuide: 'react/llms-migration.txt',\n },\n 'next-intl': {\n name: 'next-intl',\n framework: 'Next.js',\n configPatterns: ['next.config.ts', 'next.config.js', 'next.config.mjs', 'i18n.ts', 'src/i18n.ts', 'i18n/request.ts', 'src/i18n/request.ts'],\n localePatterns: ['messages/*.json', 'locales/*.json', 'src/messages/*.json', 'src/locales/*.json'],\n sourcePatterns: ['app/**/*.tsx', 'src/app/**/*.tsx', 'pages/**/*.tsx', 'components/**/*.tsx'],\n migrationGuide: 'next-plugin/llms-migration.txt',\n },\n 'next-i18next': {\n name: 'next-i18next',\n framework: 'Next.js',\n configPatterns: ['next-i18next.config.js', 'next-i18next.config.mjs', 'next.config.ts', 'next.config.js'],\n localePatterns: ['public/locales/**/*.json'],\n sourcePatterns: ['pages/**/*.tsx', 'src/pages/**/*.tsx', 'components/**/*.tsx', 'src/components/**/*.tsx'],\n migrationGuide: 'next-plugin/llms-migration.txt',\n },\n 'lingui': {\n name: 'lingui',\n framework: 'React',\n configPatterns: ['lingui.config.ts', 'lingui.config.js', '.linguirc'],\n localePatterns: ['locales/*.po', 'src/locales/*.po', 'locales/*/messages.po', 'src/locales/*/messages.po'],\n sourcePatterns: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts'],\n migrationGuide: 'react/llms-migration.txt',\n },\n}\n\nconst SUPPORTED_NAMES = Object.keys(LIBRARY_INFO) as SupportedLibrary[]\n\nfunction resolveLibrary(from: string): SupportedLibrary | undefined {\n const normalized = from.toLowerCase().replace(/^@nuxtjs\\//, 'nuxt-').replace(/^@/, '')\n return SUPPORTED_NAMES.find((name) => name === normalized)\n}\n\ninterface DetectedFiles {\n configFiles: Array<{ path: string; content: string }>\n localeFiles: Array<{ path: string; content: string }>\n sampleSources: Array<{ path: string; content: string }>\n packageJson: string | undefined\n}\n\nasync function detectFiles(info: LibraryInfo): Promise<DetectedFiles> {\n const result: DetectedFiles = {\n configFiles: [],\n localeFiles: [],\n sampleSources: [],\n packageJson: undefined,\n }\n\n // Read package.json\n const pkgPath = resolve('package.json')\n if (existsSync(pkgPath)) {\n result.packageJson = readFileSync(pkgPath, 'utf-8')\n }\n\n // Find config files\n for (const pattern of info.configPatterns) {\n const fullPath = resolve(pattern)\n if (existsSync(fullPath)) {\n result.configFiles.push({\n path: pattern,\n content: readFileSync(fullPath, 'utf-8'),\n })\n }\n }\n\n // Find locale files (limit to 10 to avoid huge prompts)\n const localeGlobs = await fg(info.localePatterns, { absolute: false })\n for (const file of localeGlobs.slice(0, 10)) {\n const fullPath = resolve(file)\n const content = readFileSync(fullPath, 'utf-8')\n // Truncate large files\n result.localeFiles.push({\n path: file,\n content: content.length > 5000 ? content.slice(0, 5000) + '\\n... (truncated)' : content,\n })\n }\n\n // Find sample source files (limit to 5 for prompt size)\n const sourceGlobs = await fg(info.sourcePatterns, { absolute: false })\n for (const file of sourceGlobs.slice(0, 5)) {\n const fullPath = resolve(file)\n const content = readFileSync(fullPath, 'utf-8')\n result.sampleSources.push({\n path: file,\n content: content.length > 3000 ? content.slice(0, 3000) + '\\n... (truncated)' : content,\n })\n }\n\n return result\n}\n\nfunction loadMigrationGuide(guidePath: string): string {\n // Try to find the migration guide relative to the CLI package\n const candidates = [\n resolve('node_modules', '@fluenti', 'cli', '..', '..', guidePath),\n join(__dirname, '..', '..', '..', guidePath),\n join(__dirname, '..', '..', guidePath),\n ]\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n return readFileSync(candidate, 'utf-8')\n }\n }\n\n return ''\n}\n\nfunction buildMigratePrompt(\n library: LibraryInfo,\n detected: DetectedFiles,\n migrationGuide: string,\n): string {\n const sections: string[] = []\n\n sections.push(\n `You are a migration assistant helping convert a ${library.framework} project from \"${library.name}\" to Fluenti (@fluenti).`,\n '',\n 'Your task:',\n '1. Generate a `fluenti.config.ts` file based on the existing i18n configuration',\n '2. Convert each locale/translation file to Fluenti PO format',\n '3. List the code changes needed (file by file) to migrate source code from the old API to Fluenti API',\n '',\n )\n\n if (migrationGuide) {\n sections.push(\n '=== MIGRATION GUIDE ===',\n migrationGuide,\n '',\n )\n }\n\n if (detected.packageJson) {\n sections.push(\n '=== package.json ===',\n detected.packageJson,\n '',\n )\n }\n\n if (detected.configFiles.length > 0) {\n sections.push('=== EXISTING CONFIG FILES ===')\n for (const file of detected.configFiles) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n if (detected.localeFiles.length > 0) {\n sections.push('=== EXISTING LOCALE FILES ===')\n for (const file of detected.localeFiles) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n if (detected.sampleSources.length > 0) {\n sections.push('=== SAMPLE SOURCE FILES ===')\n for (const file of detected.sampleSources) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n sections.push(\n '',\n '=== OUTPUT FORMAT ===',\n 'Respond with the following sections, each starting with the exact header shown:',\n '',\n '### FLUENTI_CONFIG',\n '```ts',\n '// The fluenti.config.ts content',\n '```',\n '',\n '### LOCALE_FILES',\n 'For each locale file, output:',\n '#### LOCALE: {locale_code}',\n '```po',\n '// The PO file content',\n '```',\n '',\n '### MIGRATION_STEPS',\n 'A numbered checklist of specific code changes needed, with before/after examples.',\n '',\n '### INSTALL_COMMANDS',\n '```bash',\n '// The install and uninstall commands',\n '```',\n )\n\n return sections.join('\\n')\n}\n\nasync function invokeAI(provider: AIProvider, prompt: string): Promise<string> {\n const maxBuffer = 10 * 1024 * 1024\n\n try {\n if (provider === 'claude') {\n const { stdout } = await execFileAsync('claude', ['-p', prompt], { maxBuffer })\n return stdout\n } else {\n const { stdout } = await execFileAsync('codex', ['-p', prompt, '--full-auto'], { maxBuffer })\n return stdout\n }\n } catch (error: unknown) {\n const err = error as Error & { code?: string }\n if (err.code === 'ENOENT') {\n throw new Error(\n `\"${provider}\" CLI not found. Please install it first:\\n` +\n (provider === 'claude'\n ? ' npm install -g @anthropic-ai/claude-code'\n : ' npm install -g @openai/codex'),\n )\n }\n throw error\n }\n}\n\ninterface MigrateResult {\n config: string | undefined\n localeFiles: Array<{ locale: string; content: string }>\n steps: string | undefined\n installCommands: string | undefined\n}\n\nfunction parseResponse(response: string): MigrateResult {\n const result: MigrateResult = {\n config: undefined,\n localeFiles: [],\n steps: undefined,\n installCommands: undefined,\n }\n\n // Extract fluenti.config.ts\n const configMatch = response.match(/### FLUENTI_CONFIG[\\s\\S]*?```(?:ts|typescript)?\\n([\\s\\S]*?)```/)\n if (configMatch) {\n result.config = configMatch[1]!.trim()\n }\n\n // Extract locale files\n const localeSection = response.match(/### LOCALE_FILES([\\s\\S]*?)(?=### MIGRATION_STEPS|### INSTALL_COMMANDS|$)/)\n if (localeSection) {\n const localeRegex = /#### LOCALE:\\s*(\\S+)\\s*\\n```(?:po)?\\n([\\s\\S]*?)```/g\n let match\n while ((match = localeRegex.exec(localeSection[1]!)) !== null) {\n result.localeFiles.push({\n locale: match[1]!,\n content: match[2]!.trim(),\n })\n }\n }\n\n // Extract migration steps\n const stepsMatch = response.match(/### MIGRATION_STEPS\\s*\\n([\\s\\S]*?)(?=### INSTALL_COMMANDS|$)/)\n if (stepsMatch) {\n result.steps = stepsMatch[1]!.trim()\n }\n\n // Extract install commands\n const installMatch = response.match(/### INSTALL_COMMANDS[\\s\\S]*?```(?:bash|sh)?\\n([\\s\\S]*?)```/)\n if (installMatch) {\n result.installCommands = installMatch[1]!.trim()\n }\n\n return result\n}\n\nexport interface MigrateOptions {\n from: string\n provider: AIProvider\n write: boolean\n}\n\nexport async function runMigrate(options: MigrateOptions): Promise<void> {\n const { from, provider, write } = options\n\n const library = resolveLibrary(from)\n if (!library) {\n consola.error(`Unsupported library \"${from}\". Supported libraries:`)\n for (const name of SUPPORTED_NAMES) {\n consola.log(` - ${name}`)\n }\n return\n }\n\n const info = LIBRARY_INFO[library]\n consola.info(`Migrating from ${info.name} (${info.framework}) to Fluenti`)\n\n // Detect existing files\n consola.info('Scanning project for existing i18n files...')\n const detected = await detectFiles(info)\n\n if (detected.configFiles.length === 0 && detected.localeFiles.length === 0) {\n consola.warn(`No ${info.name} configuration or locale files found.`)\n consola.info('Make sure you are running this command from the project root directory.')\n return\n }\n\n consola.info(`Found: ${detected.configFiles.length} config file(s), ${detected.localeFiles.length} locale file(s), ${detected.sampleSources.length} source file(s)`)\n\n // Load migration guide\n const migrationGuide = loadMigrationGuide(info.migrationGuide)\n\n // Build prompt and invoke AI\n consola.info(`Generating migration plan with ${provider}...`)\n const prompt = buildMigratePrompt(info, detected, migrationGuide)\n const response = await invokeAI(provider, prompt)\n const result = parseResponse(response)\n\n // Display install commands\n if (result.installCommands) {\n consola.log('')\n consola.box({\n title: 'Install Commands',\n message: result.installCommands,\n })\n }\n\n // Write or display fluenti.config.ts\n if (result.config) {\n if (write) {\n const { writeFileSync } = await import('node:fs')\n const configPath = resolve('fluenti.config.ts')\n writeFileSync(configPath, result.config, 'utf-8')\n consola.success(`Written: ${configPath}`)\n } else {\n consola.log('')\n consola.box({\n title: 'fluenti.config.ts',\n message: result.config,\n })\n }\n }\n\n // Write or display locale files\n if (result.localeFiles.length > 0) {\n if (write) {\n const { writeFileSync, mkdirSync } = await import('node:fs')\n const catalogDir = './locales'\n mkdirSync(resolve(catalogDir), { recursive: true })\n for (const file of result.localeFiles) {\n const outPath = resolve(catalogDir, `${file.locale}.po`)\n writeFileSync(outPath, file.content, 'utf-8')\n consola.success(`Written: ${outPath}`)\n }\n } else {\n for (const file of result.localeFiles) {\n consola.log('')\n consola.box({\n title: `locales/${file.locale}.po`,\n message: file.content.length > 500\n ? file.content.slice(0, 500) + '\\n... (use --write to save full file)'\n : file.content,\n })\n }\n }\n }\n\n // Display migration steps\n if (result.steps) {\n consola.log('')\n consola.box({\n title: 'Migration Steps',\n message: result.steps,\n })\n }\n\n if (!write && (result.config || result.localeFiles.length > 0)) {\n consola.log('')\n consola.info('Run with --write to save generated files to disk:')\n consola.log(` fluenti migrate --from ${from} --write`)\n }\n}\n","#!/usr/bin/env node\nimport { defineCommand, runMain } from 'citty'\nimport consola from 'consola'\nimport fg from 'fast-glob'\nimport { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'\nimport { resolve, dirname, extname } from 'node:path'\nimport { extractFromVue } from './vue-extractor'\nimport { extractFromTsx } from './tsx-extractor'\nimport { updateCatalog } from './catalog'\nimport type { CatalogData } from './catalog'\nimport { readJsonCatalog, writeJsonCatalog } from './json-format'\nimport { readPoCatalog, writePoCatalog } from './po-format'\nimport { compileCatalog, compileIndex, collectAllIds } from './compile'\nimport { translateCatalog } from './translate'\nimport type { AIProvider } from './translate'\nimport { runMigrate } from './migrate'\nimport type { ExtractedMessage, FluentiConfig } from '@fluenti/core'\n\nconst defaultConfig: FluentiConfig = {\n sourceLocale: 'en',\n locales: ['en'],\n catalogDir: './locales',\n format: 'po',\n include: ['./src/**/*.{vue,tsx,jsx,ts,js}'],\n compileOutDir: './locales/compiled',\n}\n\nasync function loadConfig(configPath?: string): Promise<FluentiConfig> {\n const paths = configPath\n ? [resolve(configPath)]\n : [\n resolve('fluenti.config.ts'),\n resolve('fluenti.config.js'),\n resolve('fluenti.config.mjs'),\n ]\n\n for (const p of paths) {\n if (existsSync(p)) {\n try {\n const { createJiti } = await import('jiti')\n const jiti = createJiti(import.meta.url)\n const mod = await jiti.import(p) as { default?: Partial<FluentiConfig> }\n const userConfig = mod.default ?? mod as unknown as Partial<FluentiConfig>\n return { ...defaultConfig, ...userConfig }\n } catch {\n consola.warn(`Failed to load config from ${p}, using defaults`)\n }\n }\n }\n\n return defaultConfig\n}\n\nfunction readCatalog(filePath: string, format: 'json' | 'po'): CatalogData {\n if (!existsSync(filePath)) return {}\n const content = readFileSync(filePath, 'utf-8')\n return format === 'json' ? readJsonCatalog(content) : readPoCatalog(content)\n}\n\nfunction writeCatalog(filePath: string, catalog: CatalogData, format: 'json' | 'po'): void {\n mkdirSync(dirname(filePath), { recursive: true })\n const content = format === 'json' ? writeJsonCatalog(catalog) : writePoCatalog(catalog)\n writeFileSync(filePath, content, 'utf-8')\n}\n\nfunction extractFromFile(filePath: string, code: string): ExtractedMessage[] {\n const ext = extname(filePath)\n if (ext === '.vue') return extractFromVue(code, filePath)\n return extractFromTsx(code, filePath)\n}\n\nconst extract = defineCommand({\n meta: { name: 'extract', description: 'Extract messages from source files' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n clean: { type: 'boolean', description: 'Remove obsolete entries instead of marking them', default: false },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n consola.info(`Extracting messages from ${config.include.join(', ')}`)\n\n const files = await fg(config.include)\n const allMessages: ExtractedMessage[] = []\n\n for (const file of files) {\n const code = readFileSync(file, 'utf-8')\n const messages = extractFromFile(file, code)\n allMessages.push(...messages)\n }\n\n consola.info(`Found ${allMessages.length} messages in ${files.length} files`)\n\n const ext = config.format === 'json' ? '.json' : '.po'\n const clean = args.clean ?? false\n\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const existing = readCatalog(catalogPath, config.format)\n const { catalog, result } = updateCatalog(existing, allMessages)\n\n const finalCatalog = clean\n ? Object.fromEntries(Object.entries(catalog).filter(([, entry]) => !entry.obsolete))\n : catalog\n\n writeCatalog(catalogPath, finalCatalog, config.format)\n\n const obsoleteLabel = clean\n ? `${result.obsolete} removed`\n : `${result.obsolete} obsolete`\n consola.success(\n `${locale}: ${result.added} added, ${result.unchanged} unchanged, ${obsoleteLabel}`,\n )\n }\n },\n})\n\nconst compile = defineCommand({\n meta: { name: 'compile', description: 'Compile message catalogs to JS modules' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n mkdirSync(config.compileOutDir, { recursive: true })\n\n // Collect all catalogs and build union of IDs\n const allCatalogs: Record<string, CatalogData> = {}\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n allCatalogs[locale] = readCatalog(catalogPath, config.format)\n }\n\n const allIds = collectAllIds(allCatalogs)\n consola.info(`Compiling ${allIds.length} messages across ${config.locales.length} locales`)\n\n for (const locale of config.locales) {\n const { code, stats } = compileCatalog(\n allCatalogs[locale]!,\n locale,\n allIds,\n config.sourceLocale,\n )\n const outPath = resolve(config.compileOutDir, `${locale}.js`)\n writeFileSync(outPath, code, 'utf-8')\n\n if (stats.missing.length > 0) {\n consola.warn(\n `${locale}: ${stats.compiled} compiled, ${stats.missing.length} missing translations`,\n )\n for (const id of stats.missing) {\n consola.warn(` ⤷ ${id}`)\n }\n } else {\n consola.success(`Compiled ${locale}: ${stats.compiled} messages → ${outPath}`)\n }\n }\n\n // Generate index.js with locale list and lazy loaders\n const indexCode = compileIndex(config.locales, config.compileOutDir)\n const indexPath = resolve(config.compileOutDir, 'index.js')\n writeFileSync(indexPath, indexCode, 'utf-8')\n consola.success(`Generated index → ${indexPath}`)\n },\n})\n\nconst stats = defineCommand({\n meta: { name: 'stats', description: 'Show translation progress' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n const rows: Array<{ locale: string; total: number; translated: number; pct: string }> = []\n\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const catalog = readCatalog(catalogPath, config.format)\n const entries = Object.values(catalog).filter((e) => !e.obsolete)\n const total = entries.length\n const translated = entries.filter((e) => e.translation && e.translation.length > 0).length\n const pct = total > 0 ? ((translated / total) * 100).toFixed(1) + '%' : '—'\n rows.push({ locale, total, translated, pct })\n }\n\n consola.log('')\n consola.log(' Locale │ Total │ Translated │ Progress')\n consola.log(' ────────┼───────┼────────────┼─────────')\n for (const row of rows) {\n consola.log(\n ` ${row.locale.padEnd(8)}│ ${String(row.total).padStart(5)} │ ${String(row.translated).padStart(10)} │ ${row.pct}`,\n )\n }\n consola.log('')\n },\n})\n\nconst translate = defineCommand({\n meta: { name: 'translate', description: 'Translate messages using AI (Claude Code or Codex CLI)' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n provider: { type: 'string', description: 'AI provider: claude or codex', default: 'claude' },\n locale: { type: 'string', description: 'Translate a specific locale only' },\n 'batch-size': { type: 'string', description: 'Messages per batch', default: '50' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const provider = args.provider as AIProvider\n\n if (provider !== 'claude' && provider !== 'codex') {\n consola.error(`Invalid provider \"${provider}\". Use \"claude\" or \"codex\".`)\n return\n }\n\n const batchSize = parseInt(args['batch-size'] ?? '50', 10)\n if (isNaN(batchSize) || batchSize < 1) {\n consola.error('Invalid batch-size. Must be a positive integer.')\n return\n }\n\n const targetLocales = args.locale\n ? [args.locale]\n : config.locales.filter((l: string) => l !== config.sourceLocale)\n\n if (targetLocales.length === 0) {\n consola.warn('No target locales to translate.')\n return\n }\n\n consola.info(`Translating with ${provider} (batch size: ${batchSize})`)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n for (const locale of targetLocales) {\n consola.info(`\\n[${locale}]`)\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const catalog = readCatalog(catalogPath, config.format)\n\n const { catalog: updated, translated } = await translateCatalog({\n provider,\n sourceLocale: config.sourceLocale,\n targetLocale: locale,\n catalog,\n batchSize,\n })\n\n if (translated > 0) {\n writeCatalog(catalogPath, updated, config.format)\n consola.success(` ${locale}: ${translated} messages translated`)\n } else {\n consola.success(` ${locale}: already fully translated`)\n }\n }\n },\n})\n\nconst migrate = defineCommand({\n meta: { name: 'migrate', description: 'Migrate from another i18n library using AI' },\n args: {\n from: { type: 'string', description: 'Source library: vue-i18n, nuxt-i18n, react-i18next, next-intl, next-i18next, lingui', required: true },\n provider: { type: 'string', description: 'AI provider: claude or codex', default: 'claude' },\n write: { type: 'boolean', description: 'Write generated files to disk', default: false },\n },\n async run({ args }) {\n const provider = args.provider as AIProvider\n if (provider !== 'claude' && provider !== 'codex') {\n consola.error(`Invalid provider \"${provider}\". Use \"claude\" or \"codex\".`)\n return\n }\n\n await runMigrate({\n from: args.from!,\n provider,\n write: args.write ?? false,\n })\n },\n})\n\nconst main = defineCommand({\n meta: {\n name: 'fluenti',\n version: '0.0.1',\n description: 'Compile-time i18n for modern frameworks',\n },\n subCommands: { extract, compile, stats, translate, migrate },\n})\n\nrunMain(main)\n"],"mappings":";;;;;;;;;;AAKA,IAAM,IAAgB,EAAU,EAAS;AAIzC,SAAS,EACP,GACA,GACA,GACQ;CACR,IAAM,IAAO,KAAK,UAAU,GAAU,MAAM,EAAE;AAC9C,QAAO;EACL,6EAA6E,EAAa,QAAQ,EAAa;EAC/G;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK;;AAGd,eAAe,EAAS,GAAsB,GAAiC;CAC7E,IAAM,IAAY,KAAK,OAAO;AAE9B,KAAI;AACF,MAAI,MAAa,UAAU;GACzB,IAAM,EAAE,cAAW,MAAM,EAAc,UAAU,CAAC,MAAM,EAAO,EAAE,EAAE,cAAW,CAAC;AAC/E,UAAO;SACF;GACL,IAAM,EAAE,cAAW,MAAM,EAAc,SAAS;IAAC;IAAM;IAAQ;IAAc,EAAE,EAAE,cAAW,CAAC;AAC7F,UAAO;;UAEF,GAAgB;AAUvB,QATY,EACJ,SAAS,WACL,MACR,IAAI,EAAS,gDACZ,MAAa,WACV,+CACA,kCACL,GAEG;;;AAIV,SAAS,EAAY,GAAsC;CAEzD,IAAM,IAAQ,EAAK,MAAM,cAAc;AACvC,KAAI,CAAC,EACH,OAAU,MAAM,sCAAsC;CAExD,IAAM,IA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,KAAK,EAAO,IAAI,EAAW,sBAAsB,IAEjE,EAAQ,QAAQ,KAAK,EAAO,4BAA4B;;;GAI/D,CAAC;EA8BmD,SA5BrC,EAAc;GAC5B,MAAM;IAAE,MAAM;IAAW,aAAa;IAA8C;GACpF,MAAM;IACJ,MAAM;KAAE,MAAM;KAAU,aAAa;KAAuF,UAAU;KAAM;IAC5I,UAAU;KAAE,MAAM;KAAU,aAAa;KAAgC,SAAS;KAAU;IAC5F,OAAO;KAAE,MAAM;KAAW,aAAa;KAAiC,SAAS;KAAO;IACzF;GACD,MAAM,IAAI,EAAE,WAAQ;IAClB,IAAM,IAAW,EAAK;AACtB,QAAI,MAAa,YAAY,MAAa,SAAS;AACjD,OAAQ,MAAM,qBAAqB,EAAS,6BAA6B;AACzE;;AAGF,UAAM,EAAW;KACf,MAAM,EAAK;KACX;KACA,OAAO,EAAK,SAAS;KACtB,CAAC;;GAEL,CAAC;EAQ4D;CAC7D,CAAC,CAEW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluenti/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Fluenti CLI — message extraction from Vue SFC & TSX, PO/JSON catalog compilation",
|
|
6
6
|
"homepage": "https://fluenti.dev",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"fast-glob": "^3",
|
|
55
55
|
"gettext-parser": "^9",
|
|
56
56
|
"jiti": "^2",
|
|
57
|
-
"@fluenti/core": "0.1.
|
|
57
|
+
"@fluenti/core": "0.1.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"typescript": "^5.9",
|