scribe-cms 0.0.15 → 0.0.17

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/index.js CHANGED
@@ -2448,6 +2448,11 @@ function computePageEnHash(translatableFrontmatter, body) {
2448
2448
  }
2449
2449
 
2450
2450
  // src/translate/worklist.ts
2451
+ function parseContentTypeFilter(contentType) {
2452
+ if (!contentType) return void 0;
2453
+ const ids = contentType.split(",").map((id) => id.trim()).filter(Boolean);
2454
+ return ids.length > 0 ? new Set(ids) : void 0;
2455
+ }
2451
2456
  function listEnSlugs4(rootDir, contentDir) {
2452
2457
  const dir = path3.join(rootDir, contentDir);
2453
2458
  if (!fs2.existsSync(dir)) return [];
@@ -2457,8 +2462,9 @@ function buildWorklist(config, options = {}) {
2457
2462
  const db = openStore(config, "readonly");
2458
2463
  const items = [];
2459
2464
  const locales = options.locales ?? config.locales.filter((locale) => locale !== config.defaultLocale);
2465
+ const contentTypes = parseContentTypeFilter(options.contentType);
2460
2466
  for (const type of config.types) {
2461
- if (options.contentType && type.id !== options.contentType) continue;
2467
+ if (contentTypes && !contentTypes.has(type.id)) continue;
2462
2468
  const enSlugs = options.enSlug ? [options.enSlug] : listEnSlugs4(config.rootDir, type.contentDir);
2463
2469
  for (const enSlug of enSlugs) {
2464
2470
  const enDoc = readEnDocument(config, type, enSlug);
@@ -2478,12 +2484,13 @@ function buildWorklist(config, options = {}) {
2478
2484
  });
2479
2485
  continue;
2480
2486
  }
2481
- if (existing.en_hash !== currentEnHash) {
2487
+ const stale = existing.en_hash !== currentEnHash;
2488
+ if (stale || options.force) {
2482
2489
  items.push({
2483
2490
  contentType: type.id,
2484
2491
  enSlug,
2485
2492
  locale,
2486
- reason: "stale",
2493
+ reason: stale ? "stale" : "forced",
2487
2494
  currentEnHash,
2488
2495
  storedEnHash: existing.en_hash
2489
2496
  });
@@ -2820,6 +2827,13 @@ function defaultLocalizationPrompt(localeName, locale) {
2820
2827
  "Write as if a native speaker authored it for the target market."
2821
2828
  ].join(" ");
2822
2829
  }
2830
+ function buildLocalizationPrompt(promptOverride, localeName, locale) {
2831
+ const localeDirective = defaultLocalizationPrompt(localeName, locale);
2832
+ if (!promptOverride) return localeDirective;
2833
+ return `${promptOverride}
2834
+
2835
+ ${localeDirective}`;
2836
+ }
2823
2837
  var TASK_FRAMING = "You are localizing the content below into a target language specified at the end of this prompt.";
2824
2838
  function buildOutputFormatLine(hasFrontmatter, slugStrategy) {
2825
2839
  if (!hasFrontmatter) {
@@ -2836,7 +2850,11 @@ function buildRetryContextSection(previousError) {
2836
2850
  }
2837
2851
  function buildPageTranslationPrompt(input) {
2838
2852
  const localeName = LOCALE_NAMES[input.targetLocale] ?? input.targetLocale;
2839
- const localizationPrompt = input.resolved.promptOverride ?? defaultLocalizationPrompt(localeName, input.targetLocale);
2853
+ const localizationPrompt = buildLocalizationPrompt(
2854
+ input.resolved.promptOverride,
2855
+ localeName,
2856
+ input.targetLocale
2857
+ );
2840
2858
  const prefix = [
2841
2859
  TASK_FRAMING,
2842
2860
  "",