browser-extension-manager 1.3.32 → 1.3.34

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.
@@ -76,7 +76,7 @@ function readConfigMessages() {
76
76
  }
77
77
  }
78
78
 
79
- // Helper: Call Claude Agent SDK with a prompt and parse JSON from the response
79
+ // Helper: Call Claude Agent SDK and return raw text
80
80
  async function callClaude(prompt) {
81
81
  let result = '';
82
82
 
@@ -101,8 +101,12 @@ async function callClaude(prompt) {
101
101
 
102
102
  logger.log(`Claude responded (${result.length} chars)`);
103
103
 
104
- // Parse JSON from response
105
- const jsonMatch = result.match(/\{[\s\S]*\}/);
104
+ return result;
105
+ }
106
+
107
+ // Helper: Parse JSON from Claude response text
108
+ function parseJsonResponse(text) {
109
+ const jsonMatch = text.match(/\{[\s\S]*\}/);
106
110
  if (!jsonMatch) {
107
111
  throw new Error('No JSON found in Claude response');
108
112
  }
@@ -110,6 +114,23 @@ async function callClaude(prompt) {
110
114
  return JSON.parse(jsonMatch[0]);
111
115
  }
112
116
 
117
+ // Helper: Parse delimited sections from Claude response
118
+ // Expects format: ===LANG_CODE===\ncontent\n===LANG_CODE===\ncontent
119
+ function parseDelimitedResponse(text, langCodes) {
120
+ const result = {};
121
+
122
+ for (const code of langCodes) {
123
+ const pattern = new RegExp(`===${code}===\\n([\\s\\S]*?)(?=====[a-z]{2}===|$)`);
124
+ const match = text.match(pattern);
125
+
126
+ if (match) {
127
+ result[code] = match[1].trim();
128
+ }
129
+ }
130
+
131
+ return result;
132
+ }
133
+
113
134
  // Helper: Split an object into chunks of a given size
114
135
  function chunkObject(obj, size) {
115
136
  const entries = Object.entries(obj);
@@ -205,7 +226,7 @@ async function translateMessages(complete) {
205
226
  logger.log(`Translating messages into ${Object.keys(LANGUAGES).length} languages...`);
206
227
 
207
228
  try {
208
- const translations = await callClaude(`Translate the following Chrome extension messages.json content from English to multiple languages.
229
+ const translations = parseJsonResponse(await callClaude(`Translate the following Chrome extension messages.json content from English to multiple languages.
209
230
 
210
231
  TARGET LANGUAGES:
211
232
  ${languageList}
@@ -232,7 +253,7 @@ OUTPUT FORMAT:
232
253
  ...
233
254
  }
234
255
 
235
- Output the translated JSON:`);
256
+ Output the translated JSON:`));
236
257
 
237
258
  // Ensure cache directory exists
238
259
  jetpack.dir(cacheMessagesDir);
@@ -330,7 +351,8 @@ async function translateDescription(complete) {
330
351
 
331
352
  logger.log(`Batch ${i + 1}/${batches.length}: translating ${Object.keys(batch).join(', ')}...`);
332
353
 
333
- const translations = await callClaude(`Translate the following Chrome extension store description from English to multiple languages.
354
+ const langCodes = Object.keys(batch);
355
+ const translations = parseDelimitedResponse(await callClaude(`Translate the following Chrome extension store description from English to multiple languages.
334
356
 
335
357
  TARGET LANGUAGES:
336
358
  ${languageList}
@@ -341,21 +363,19 @@ IMPORTANT RULES:
341
363
  3. Preserve the markdown formatting (headers, bold, bullet points, etc.)
342
364
  4. Keep brand names, product names, and company names in English (e.g., Amazon, Capital One, NordVPN)
343
365
  5. Maintain the same tone — enthusiastic, conversational, and persuasive
344
- 6. Return ONLY valid JSON, no markdown code fences, no explanation
345
- 7. Return a JSON object where each key is the language code and the value is the full translated description as a string
366
+ 6. Output each translation separated by a delimiter line: ==={lang_code}===
367
+ 7. Do NOT wrap in JSON or code fences just raw translated text between delimiters
346
368
 
347
369
  INPUT (English):
348
370
  ${enDescription}
349
371
 
350
- OUTPUT FORMAT:
351
- {
352
- ${Object.keys(batch).map((code) => ` "${code}": "full translated description here..."`).join(',\n')}
353
- }
372
+ OUTPUT FORMAT (use exactly this delimiter format):
373
+ ${langCodes.map((code) => `===${code}===\nFull translated description here...`).join('\n')}
354
374
 
355
- Output the translated JSON:`);
375
+ Output the translations now:`), langCodes);
356
376
 
357
377
  // Write each translation in this batch to cache
358
- for (const lang of Object.keys(batch)) {
378
+ for (const lang of langCodes) {
359
379
  if (!translations[lang]) {
360
380
  logger.warn(`[${lang}] No description translation returned`);
361
381
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-extension-manager",
3
- "version": "1.3.32",
3
+ "version": "1.3.34",
4
4
  "description": "Browser Extension Manager dependency manager",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -66,15 +66,15 @@
66
66
  },
67
67
  "homepage": "https://template.itwcreativeworks.com",
68
68
  "dependencies": {
69
- "@anthropic-ai/claude-agent-sdk": "^0.2.20",
69
+ "@anthropic-ai/claude-agent-sdk": "^0.2.44",
70
70
  "@babel/core": "^7.29.0",
71
71
  "@babel/preset-env": "^7.29.0",
72
72
  "@popperjs/core": "^2.11.8",
73
73
  "babel-loader": "^10.0.0",
74
74
  "chalk": "^5.6.2",
75
- "dotenv": "^17.2.4",
75
+ "dotenv": "^17.3.1",
76
76
  "fs-jetpack": "^5.1.0",
77
- "glob": "^13.0.1",
77
+ "glob": "^13.0.3",
78
78
  "gulp-clean-css": "^4.3.0",
79
79
  "gulp-filter": "^9.0.1",
80
80
  "gulp-rename": "^2.1.0",
@@ -83,13 +83,13 @@
83
83
  "itwcw-package-analytics": "^1.0.8",
84
84
  "json5": "^2.2.3",
85
85
  "lodash": "^4.17.23",
86
- "minimatch": "^10.1.2",
86
+ "minimatch": "^10.2.0",
87
87
  "node-powertools": "^2.3.2",
88
88
  "npm-api": "^1.0.1",
89
89
  "sass": "^1.97.3",
90
90
  "through2": "^4.0.2",
91
- "web-manager": "^4.1.6",
92
- "webpack": "^5.105.0",
91
+ "web-manager": "^4.1.9",
92
+ "webpack": "^5.105.2",
93
93
  "wonderful-fetch": "^1.3.4",
94
94
  "wonderful-version": "^1.3.2",
95
95
  "ws": "^8.19.0",