@gobing-ai/knowledge-kit 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +418 -114
  3. package/package.json +5 -5
  4. package/plugins/generations/content-gen/dist/index.js +9 -9
  5. package/plugins/generations/core-facts-gen/dist/index.js +12 -12
  6. package/plugins/generations/daily-article-gen/dist/index.js +12 -12
  7. package/plugins/generations/dailynews-gen/dist/index.js +11 -11
  8. package/plugins/generations/dailynews-gen/src/script-plan.ts +2 -2
  9. package/plugins/generations/episode-plan-gen/dist/index.js +59 -18
  10. package/plugins/generations/episode-plan-gen/src/index.ts +71 -7
  11. package/plugins/generations/gemini-tts/dist/index.js +9 -9
  12. package/plugins/generations/image-gen/dist/index.js +9 -9
  13. package/plugins/generations/music-gen/dist/index.js +33 -29
  14. package/plugins/generations/music-gen/src/audio/measure.ts +25 -20
  15. package/plugins/generations/news-report-gen/dist/index.js +12 -12
  16. package/plugins/generations/vibe-voice-tts/dist/index.js +9 -9
  17. package/plugins/generations/voice-gen/dist/index.js +9 -9
  18. package/plugins/generations/voxcpm-tts/dist/index.js +9 -9
  19. package/plugins/ingestions/aihot-ingest/dist/index.js +12 -12
  20. package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
  21. package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
  22. package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
  23. package/plugins/ingestions/web-search/dist/index.js +10 -10
  24. package/plugins/kk/decisions/extract/ai-news.yaml +8 -1
  25. package/plugins/kk/plugin.json +1 -1
  26. package/plugins/kk/publish-presets/daily-ai-voice.json +20 -20
  27. package/plugins/kk/publish-presets/itc-main.json +39 -23
  28. package/plugins/kk/scripts/cover-compositor.ts +104 -26
  29. package/plugins/kk/scripts/daily-stages.ts +704 -53
  30. package/plugins/kk/scripts/kk-workflow-stages.ts +149 -6
  31. package/plugins/kk/scripts/series-names.ts +16 -3
  32. package/plugins/kk/skills/content-safety/references/platforms/apple-podcasts.md +12 -5
  33. package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +8 -0
  34. package/plugins/kk/skills/content-safety/references/platforms/xiaoyuzhou.md +5 -0
  35. package/plugins/kk/skills/daily-news-cover/SKILL.md +96 -0
  36. package/plugins/kk/skills/daily-news-illustrations/SKILL.md +123 -0
  37. package/plugins/kk/skills/news-editorial/SKILL.md +5 -3
  38. package/plugins/kk/skills/news-editorial/references/daily-visual-composition.md +150 -0
  39. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
  40. package/plugins/kk/workflows/kk-article-generate.yaml +13 -1
  41. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +6 -3
  42. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -4
  43. package/plugins/kk/workflows/kk-news-generate.yaml +74 -1
  44. package/plugins/publishings/bilibili-pub/dist/index.js +25 -24
  45. package/plugins/publishings/bilibili-pub/dist/profile-check.js +25 -24
  46. package/plugins/publishings/cnblogs-pub/dist/index.js +25 -24
  47. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +25 -24
  48. package/plugins/publishings/csdn-pub/dist/index.js +25 -24
  49. package/plugins/publishings/csdn-pub/dist/profile-check.js +25 -24
  50. package/plugins/publishings/emdash-pub/dist/index.js +9 -9
  51. package/plugins/publishings/infoq-pub/dist/index.js +25 -24
  52. package/plugins/publishings/infoq-pub/dist/profile-check.js +25 -24
  53. package/plugins/publishings/jike-pub/dist/index.js +25 -24
  54. package/plugins/publishings/jike-pub/dist/profile-check.js +25 -24
  55. package/plugins/publishings/juejin-pub/dist/index.js +25 -24
  56. package/plugins/publishings/juejin-pub/dist/profile-check.js +25 -24
  57. package/plugins/publishings/linkedin-pub/dist/index.js +85 -26
  58. package/plugins/publishings/linkedin-pub/dist/profile-check.js +25 -24
  59. package/plugins/publishings/linkedin-pub/src/index.ts +93 -6
  60. package/plugins/publishings/medium-pub/dist/index.js +9206 -287
  61. package/plugins/publishings/medium-pub/dist/profile-check.js +21174 -0
  62. package/plugins/publishings/medium-pub/package.json +3 -1
  63. package/plugins/publishings/medium-pub/plugin.json +6 -1
  64. package/plugins/publishings/medium-pub/src/browser-rail.ts +280 -0
  65. package/plugins/publishings/medium-pub/src/index.ts +17 -1
  66. package/plugins/publishings/medium-pub/src/profile-check.ts +27 -0
  67. package/plugins/publishings/podcast-pub/dist/index.js +240 -37
  68. package/plugins/publishings/podcast-pub/src/index.ts +154 -3
  69. package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
  70. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
  71. package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
  72. package/plugins/publishings/qiita-pub/dist/index.js +9 -9
  73. package/plugins/publishings/shipinhao-pub/dist/index.js +29 -26
  74. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +28 -26
  75. package/plugins/publishings/shipinhao-pub/src/flow.ts +5 -0
  76. package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -5
  77. package/plugins/publishings/sspai-pub/dist/index.js +25 -24
  78. package/plugins/publishings/sspai-pub/dist/profile-check.js +25 -24
  79. package/plugins/publishings/substack-pub/dist/index.js +25 -24
  80. package/plugins/publishings/substack-pub/dist/profile-check.js +25 -24
  81. package/plugins/publishings/surfdash-pub/dist/index.js +200 -92
  82. package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
  83. package/plugins/publishings/surfdash-pub/src/index.ts +94 -75
  84. package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
  85. package/plugins/publishings/surfdash-pub/src/patch.ts +28 -23
  86. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
  87. package/plugins/publishings/threads-pub/dist/index.js +39 -24
  88. package/plugins/publishings/threads-pub/dist/profile-check.js +30 -24
  89. package/plugins/publishings/threads-pub/src/post-rail.ts +20 -0
  90. package/plugins/publishings/wechatmp-pub/dist/index.js +438 -102
  91. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +30 -25
  92. package/plugins/publishings/wechatmp-pub/src/enrich.ts +56 -10
  93. package/plugins/publishings/wechatmp-pub/src/flow.ts +589 -83
  94. package/plugins/publishings/wechatmp-pub/src/index.ts +4 -1
  95. package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
  96. package/plugins/publishings/wechatmp-pub/src/page.ts +8 -0
  97. package/plugins/publishings/weibo-pub/dist/index.js +25 -24
  98. package/plugins/publishings/weibo-pub/dist/profile-check.js +25 -24
  99. package/plugins/publishings/x-pub/dist/index.js +54 -47
  100. package/plugins/publishings/x-pub/dist/profile-check.js +25 -24
  101. package/plugins/publishings/x-pub/src/post-rail.ts +40 -47
  102. package/plugins/publishings/xhs-pub/dist/index.js +25 -24
  103. package/plugins/publishings/xhs-pub/dist/profile-check.js +25 -24
  104. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +25 -24
  105. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +25 -24
  106. package/plugins/publishings/zenn-pub/dist/index.js +9 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobing-ai/knowledge-kit",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "An ingest → create → publish content pipeline CLI (Bun).",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,10 +46,10 @@
46
46
  "typecheck": "tsc --noEmit"
47
47
  },
48
48
  "dependencies": {
49
- "@gobing-ai/ts-ai-decision": "^0.5.32",
50
- "@gobing-ai/ts-infra": "^0.5.32",
51
- "@gobing-ai/ts-runtime": "^0.5.32",
52
- "@gobing-ai/ts-utils": "^0.5.32",
49
+ "@gobing-ai/ts-ai-decision": "^0.8.4",
50
+ "@gobing-ai/ts-infra": "^0.8.4",
51
+ "@gobing-ai/ts-runtime": "^0.8.4",
52
+ "@gobing-ai/ts-utils": "^0.8.4",
53
53
  "commander": "15.0.0",
54
54
  "playwright": "1.55.0",
55
55
  "zod": "4.4.3"
@@ -4813,7 +4813,7 @@ var init_zod = __esm(() => {
4813
4813
  init_external();
4814
4814
  });
4815
4815
 
4816
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/errors.js
4816
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
4817
4817
  var ErrorCode;
4818
4818
  var init_errors3 = __esm(() => {
4819
4819
  ErrorCode = {
@@ -4824,7 +4824,7 @@ var init_errors3 = __esm(() => {
4824
4824
  };
4825
4825
  });
4826
4826
 
4827
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4827
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4828
4828
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
4829
4829
  var init_api_response = __esm(() => {
4830
4830
  init_errors3();
@@ -4847,13 +4847,13 @@ var init_api_response = __esm(() => {
4847
4847
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
4848
4848
  });
4849
4849
 
4850
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4850
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4851
4851
  var init_cursor = () => {};
4852
4852
 
4853
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4853
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4854
4854
  var init_event_severity = () => {};
4855
4855
 
4856
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/output.js
4856
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
4857
4857
  function processStream(name) {
4858
4858
  const proc = globalThis.process;
4859
4859
  const stream = proc?.[name];
@@ -4871,7 +4871,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
4871
4871
  }
4872
4872
  var defaultStderrTarget;
4873
4873
 
4874
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/index.js
4874
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
4875
4875
  var init_dist = __esm(() => {
4876
4876
  init_api_response();
4877
4877
  init_cursor();
@@ -11869,7 +11869,7 @@ var init_dist2 = __esm(() => {
11869
11869
  $visitAsync = visit.visitAsync;
11870
11870
  });
11871
11871
 
11872
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/config.js
11872
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
11873
11873
  var configSchema;
11874
11874
  var init_config = __esm(() => {
11875
11875
  init_dist2();
@@ -11893,7 +11893,7 @@ var init_config = __esm(() => {
11893
11893
  });
11894
11894
  });
11895
11895
 
11896
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
11896
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
11897
11897
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
11898
11898
  import { dirname, resolve as resolvePath } from "path";
11899
11899
  function createNodeFileSystem(root, paths) {
@@ -12247,7 +12247,7 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
12247
12247
  });
12248
12248
  }
12249
12249
  });
12250
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
12250
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
12251
12251
  init_file_system_node();
12252
12252
  init_config();
12253
12253
 
@@ -4813,7 +4813,7 @@ var init_zod = __esm(() => {
4813
4813
  init_external();
4814
4814
  });
4815
4815
 
4816
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/errors.js
4816
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
4817
4817
  var ErrorCode;
4818
4818
  var init_errors3 = __esm(() => {
4819
4819
  ErrorCode = {
@@ -4824,7 +4824,7 @@ var init_errors3 = __esm(() => {
4824
4824
  };
4825
4825
  });
4826
4826
 
4827
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4827
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4828
4828
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
4829
4829
  var init_api_response = __esm(() => {
4830
4830
  init_errors3();
@@ -4847,13 +4847,13 @@ var init_api_response = __esm(() => {
4847
4847
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
4848
4848
  });
4849
4849
 
4850
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4850
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4851
4851
  var init_cursor = () => {};
4852
4852
 
4853
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4853
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4854
4854
  var init_event_severity = () => {};
4855
4855
 
4856
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/output.js
4856
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
4857
4857
  function processStream(name) {
4858
4858
  const proc = globalThis.process;
4859
4859
  const stream = proc?.[name];
@@ -4871,7 +4871,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
4871
4871
  }
4872
4872
  var defaultStderrTarget;
4873
4873
 
4874
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/index.js
4874
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
4875
4875
  var init_dist = __esm(() => {
4876
4876
  init_api_response();
4877
4877
  init_cursor();
@@ -11869,7 +11869,7 @@ var init_dist2 = __esm(() => {
11869
11869
  $visitAsync = visit.visitAsync;
11870
11870
  });
11871
11871
 
11872
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/config.js
11872
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
11873
11873
  var configSchema;
11874
11874
  var init_config = __esm(() => {
11875
11875
  init_dist2();
@@ -11893,7 +11893,7 @@ var init_config = __esm(() => {
11893
11893
  });
11894
11894
  });
11895
11895
 
11896
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
11896
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
11897
11897
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
11898
11898
  import { dirname, resolve as resolvePath } from "path";
11899
11899
  function createNodeFileSystem(root, paths) {
@@ -12248,14 +12248,14 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
12248
12248
  });
12249
12249
  }
12250
12250
  });
12251
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
12251
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
12252
12252
  init_file_system_node();
12253
12253
  init_config();
12254
12254
 
12255
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12255
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12256
12256
  init_file_system_node();
12257
12257
 
12258
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/path.js
12258
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
12259
12259
  function normalizeSeparators(path) {
12260
12260
  return path.replaceAll("\\", "/");
12261
12261
  }
@@ -12289,7 +12289,7 @@ function dirnamePath(path) {
12289
12289
  return normalized.slice(0, index);
12290
12290
  }
12291
12291
 
12292
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12292
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12293
12293
  async function ensureDirForFile(path, fs = createNodeFileSystem()) {
12294
12294
  await fs.ensureDir(dirnamePath(path));
12295
12295
  }
@@ -4813,7 +4813,7 @@ var init_zod = __esm(() => {
4813
4813
  init_external();
4814
4814
  });
4815
4815
 
4816
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/errors.js
4816
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
4817
4817
  var ErrorCode;
4818
4818
  var init_errors3 = __esm(() => {
4819
4819
  ErrorCode = {
@@ -4824,7 +4824,7 @@ var init_errors3 = __esm(() => {
4824
4824
  };
4825
4825
  });
4826
4826
 
4827
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4827
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4828
4828
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
4829
4829
  var init_api_response = __esm(() => {
4830
4830
  init_errors3();
@@ -4847,13 +4847,13 @@ var init_api_response = __esm(() => {
4847
4847
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
4848
4848
  });
4849
4849
 
4850
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4850
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4851
4851
  var init_cursor = () => {};
4852
4852
 
4853
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4853
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4854
4854
  var init_event_severity = () => {};
4855
4855
 
4856
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/output.js
4856
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
4857
4857
  function processStream(name) {
4858
4858
  const proc = globalThis.process;
4859
4859
  const stream = proc?.[name];
@@ -4871,7 +4871,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
4871
4871
  }
4872
4872
  var defaultStderrTarget;
4873
4873
 
4874
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/index.js
4874
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
4875
4875
  var init_dist = __esm(() => {
4876
4876
  init_api_response();
4877
4877
  init_cursor();
@@ -11869,7 +11869,7 @@ var init_dist2 = __esm(() => {
11869
11869
  $visitAsync = visit.visitAsync;
11870
11870
  });
11871
11871
 
11872
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/config.js
11872
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
11873
11873
  var configSchema;
11874
11874
  var init_config = __esm(() => {
11875
11875
  init_dist2();
@@ -11893,7 +11893,7 @@ var init_config = __esm(() => {
11893
11893
  });
11894
11894
  });
11895
11895
 
11896
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
11896
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
11897
11897
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
11898
11898
  import { dirname, resolve as resolvePath } from "path";
11899
11899
  function createNodeFileSystem(root, paths) {
@@ -12248,14 +12248,14 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
12248
12248
  });
12249
12249
  }
12250
12250
  });
12251
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
12251
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
12252
12252
  init_file_system_node();
12253
12253
  init_config();
12254
12254
 
12255
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12255
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12256
12256
  init_file_system_node();
12257
12257
 
12258
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/path.js
12258
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
12259
12259
  function normalizeSeparators(path) {
12260
12260
  return path.replaceAll("\\", "/");
12261
12261
  }
@@ -12289,7 +12289,7 @@ function dirnamePath(path) {
12289
12289
  return normalized.slice(0, index);
12290
12290
  }
12291
12291
 
12292
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12292
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12293
12293
  async function ensureDirForFile(path, fs = createNodeFileSystem()) {
12294
12294
  await fs.ensureDir(dirnamePath(path));
12295
12295
  }
@@ -4813,7 +4813,7 @@ var init_zod = __esm(() => {
4813
4813
  init_external();
4814
4814
  });
4815
4815
 
4816
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/errors.js
4816
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
4817
4817
  var ErrorCode;
4818
4818
  var init_errors3 = __esm(() => {
4819
4819
  ErrorCode = {
@@ -4824,7 +4824,7 @@ var init_errors3 = __esm(() => {
4824
4824
  };
4825
4825
  });
4826
4826
 
4827
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4827
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4828
4828
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
4829
4829
  var init_api_response = __esm(() => {
4830
4830
  init_errors3();
@@ -4847,13 +4847,13 @@ var init_api_response = __esm(() => {
4847
4847
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
4848
4848
  });
4849
4849
 
4850
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4850
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4851
4851
  var init_cursor = () => {};
4852
4852
 
4853
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4853
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4854
4854
  var init_event_severity = () => {};
4855
4855
 
4856
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/output.js
4856
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
4857
4857
  function processStream(name) {
4858
4858
  const proc = globalThis.process;
4859
4859
  const stream = proc?.[name];
@@ -4871,7 +4871,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
4871
4871
  }
4872
4872
  var defaultStderrTarget;
4873
4873
 
4874
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/index.js
4874
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
4875
4875
  var init_dist = __esm(() => {
4876
4876
  init_api_response();
4877
4877
  init_cursor();
@@ -11869,7 +11869,7 @@ var init_dist2 = __esm(() => {
11869
11869
  $visitAsync = visit.visitAsync;
11870
11870
  });
11871
11871
 
11872
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/config.js
11872
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
11873
11873
  var configSchema;
11874
11874
  var init_config = __esm(() => {
11875
11875
  init_dist2();
@@ -11893,7 +11893,7 @@ var init_config = __esm(() => {
11893
11893
  });
11894
11894
  });
11895
11895
 
11896
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
11896
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
11897
11897
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
11898
11898
  import { dirname, resolve as resolvePath } from "path";
11899
11899
  function createNodeFileSystem(root, paths) {
@@ -12248,7 +12248,7 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
12248
12248
  });
12249
12249
  }
12250
12250
  });
12251
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
12251
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
12252
12252
  init_file_system_node();
12253
12253
  init_config();
12254
12254
 
@@ -13056,10 +13056,10 @@ function validateScriptPlan(plan, docs, style, preExcludedIds) {
13056
13056
  errors.push({ itemId: "episode", rule: "cap:cardTitle" });
13057
13057
  }
13058
13058
  if (valid.social !== undefined) {
13059
- if (valid.social.short.length > (style.caps.socialShort ?? 140)) {
13059
+ if (valid.social.short.length > (style.caps.socialShort ?? 100)) {
13060
13060
  errors.push({ itemId: "episode", rule: "cap:socialShort" });
13061
13061
  }
13062
- if (valid.social.long.length > (style.caps.socialLong ?? 500)) {
13062
+ if (valid.social.long.length > (style.caps.socialLong ?? 300)) {
13063
13063
  errors.push({ itemId: "episode", rule: "cap:socialLong" });
13064
13064
  }
13065
13065
  }
@@ -270,10 +270,10 @@ export function validateScriptPlan(
270
270
  errors.push({ itemId: 'episode', rule: 'cap:cardTitle' });
271
271
  }
272
272
  if (valid.social !== undefined) {
273
- if (valid.social.short.length > (style.caps.socialShort ?? 140)) {
273
+ if (valid.social.short.length > (style.caps.socialShort ?? 100)) {
274
274
  errors.push({ itemId: 'episode', rule: 'cap:socialShort' });
275
275
  }
276
- if (valid.social.long.length > (style.caps.socialLong ?? 500)) {
276
+ if (valid.social.long.length > (style.caps.socialLong ?? 300)) {
277
277
  errors.push({ itemId: 'episode', rule: 'cap:socialLong' });
278
278
  }
279
279
  }
@@ -4813,7 +4813,7 @@ var init_zod = __esm(() => {
4813
4813
  init_external();
4814
4814
  });
4815
4815
 
4816
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/errors.js
4816
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
4817
4817
  var ErrorCode;
4818
4818
  var init_errors3 = __esm(() => {
4819
4819
  ErrorCode = {
@@ -4824,7 +4824,7 @@ var init_errors3 = __esm(() => {
4824
4824
  };
4825
4825
  });
4826
4826
 
4827
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4827
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4828
4828
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
4829
4829
  var init_api_response = __esm(() => {
4830
4830
  init_errors3();
@@ -4847,13 +4847,13 @@ var init_api_response = __esm(() => {
4847
4847
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
4848
4848
  });
4849
4849
 
4850
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4850
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4851
4851
  var init_cursor = () => {};
4852
4852
 
4853
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4853
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4854
4854
  var init_event_severity = () => {};
4855
4855
 
4856
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/output.js
4856
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
4857
4857
  function processStream(name) {
4858
4858
  const proc = globalThis.process;
4859
4859
  const stream = proc?.[name];
@@ -4871,7 +4871,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
4871
4871
  }
4872
4872
  var defaultStderrTarget;
4873
4873
 
4874
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/index.js
4874
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
4875
4875
  var init_dist = __esm(() => {
4876
4876
  init_api_response();
4877
4877
  init_cursor();
@@ -11869,7 +11869,7 @@ var init_dist2 = __esm(() => {
11869
11869
  $visitAsync = visit.visitAsync;
11870
11870
  });
11871
11871
 
11872
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/config.js
11872
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
11873
11873
  var configSchema;
11874
11874
  var init_config = __esm(() => {
11875
11875
  init_dist2();
@@ -11893,7 +11893,7 @@ var init_config = __esm(() => {
11893
11893
  });
11894
11894
  });
11895
11895
 
11896
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
11896
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
11897
11897
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
11898
11898
  import { dirname, resolve as resolvePath } from "path";
11899
11899
  function createNodeFileSystem(root, paths) {
@@ -12248,14 +12248,14 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
12248
12248
  });
12249
12249
  }
12250
12250
  });
12251
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
12251
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
12252
12252
  init_file_system_node();
12253
12253
  init_config();
12254
12254
 
12255
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12255
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12256
12256
  init_file_system_node();
12257
12257
 
12258
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/path.js
12258
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
12259
12259
  function normalizeSeparators(path) {
12260
12260
  return path.replaceAll("\\", "/");
12261
12261
  }
@@ -12289,7 +12289,7 @@ function dirnamePath(path) {
12289
12289
  return normalized.slice(0, index);
12290
12290
  }
12291
12291
 
12292
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12292
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/fs.js
12293
12293
  async function ensureDirForFile(path, fs = createNodeFileSystem()) {
12294
12294
  await fs.ensureDir(dirnamePath(path));
12295
12295
  }
@@ -12582,6 +12582,11 @@ function cleanBody(body) {
12582
12582
 
12583
12583
  `).trim();
12584
12584
  }
12585
+ var TRACKING_PARAMS = new Set(["ref", "ref_src", "fbclid", "gclid"]);
12586
+ function isTrackingParam(name) {
12587
+ const lower = name.toLowerCase();
12588
+ return lower.startsWith("utm_") || TRACKING_PARAMS.has(lower);
12589
+ }
12585
12590
  function normalizeUrl(raw) {
12586
12591
  if (!raw)
12587
12592
  return null;
@@ -12593,7 +12598,9 @@ function normalizeUrl(raw) {
12593
12598
  }
12594
12599
  const host = url.hostname.replace(/^(www|amp)\./, "");
12595
12600
  const path = url.pathname.replace(/\/+$/, "");
12596
- return `${url.protocol}//${host}${path}`;
12601
+ const kept = [...url.searchParams.entries()].filter(([name]) => !isTrackingParam(name)).sort(([aName, aValue], [bName, bValue]) => aName.localeCompare(bName) || aValue.localeCompare(bValue));
12602
+ const search = kept.length === 0 ? "" : `?${new URLSearchParams(kept).toString()}`;
12603
+ return `${url.protocol}//${host}${path}${search}`;
12597
12604
  }
12598
12605
  function asciiRatio(text) {
12599
12606
  const chars = [...text].filter((c) => !/\s/.test(c));
@@ -12808,12 +12815,13 @@ function planEpisode(docs, options) {
12808
12815
  }
12809
12816
  }
12810
12817
  const candidates = scored.filter((r) => !absorbed.has(r)).sort((a, b) => b.score - a.score);
12818
+ const perSourceCap = Math.max(1, options.perSourceCap ?? PER_SOURCE_CAP);
12811
12819
  const perSource = new Map;
12812
12820
  const selected = [];
12813
12821
  for (const record of candidates) {
12814
12822
  const source = sourceOf(record.doc);
12815
12823
  const count = perSource.get(source) ?? 0;
12816
- if (count >= PER_SOURCE_CAP) {
12824
+ if (count >= perSourceCap) {
12817
12825
  const row = rows?.get(record.doc);
12818
12826
  if (row)
12819
12827
  row.disposition = "cap";
@@ -12873,7 +12881,12 @@ ${items}
12873
12881
  `;
12874
12882
  }
12875
12883
  function docsToContent(docs, date, audit) {
12876
- const planned = planEpisode(docs, { maxItems: maxItemsFromEnv(), date, audit });
12884
+ const planned = planEpisode(docs, {
12885
+ maxItems: maxItemsFromEnv(),
12886
+ perSourceCap: perSourceCapFromEnv(),
12887
+ date,
12888
+ audit
12889
+ });
12877
12890
  return planContent(planned, date);
12878
12891
  }
12879
12892
  function planContent(docs, date) {
@@ -12896,6 +12909,13 @@ function maxItemsFromEnv() {
12896
12909
  const n = Number.parseInt(raw, 10);
12897
12910
  return Number.isFinite(n) && n > 0 ? n : 20;
12898
12911
  }
12912
+ function perSourceCapFromEnv() {
12913
+ const raw = process.env.EPISODE_PLAN_PER_SOURCE_CAP;
12914
+ if (raw === undefined || raw.trim() === "")
12915
+ return PER_SOURCE_CAP;
12916
+ const n = Number.parseInt(raw, 10);
12917
+ return Number.isFinite(n) && n > 0 ? n : PER_SOURCE_CAP;
12918
+ }
12899
12919
  function resolvePlanDate() {
12900
12920
  const raw = process.env.EPISODE_PLAN_DATE ?? new Date().toISOString().slice(0, 10);
12901
12921
  return raw.length === 8 ? `${raw.slice(0, 4)}-${raw.slice(4, 6)}-${raw.slice(6, 8)}` : raw;
@@ -12950,9 +12970,16 @@ function filterConfigFromEnv(env = process.env) {
12950
12970
  minImportance: parseFilterThreshold(env.QC_MIN_IMPORTANCE, "QC_MIN_IMPORTANCE", DEFAULT_FILTER_CONFIG.minImportance),
12951
12971
  minUrgency: parseFilterThreshold(env.QC_MIN_URGENCY, "QC_MIN_URGENCY", DEFAULT_FILTER_CONFIG.minUrgency),
12952
12972
  minImpact: parseFilterThreshold(env.QC_MIN_IMPACT, "QC_MIN_IMPACT", DEFAULT_FILTER_CONFIG.minImpact),
12953
- minEpisodeItems: parseFloorCount(env.QC_MIN_EPISODE_ITEMS, "QC_MIN_EPISODE_ITEMS", DEFAULT_FILTER_CONFIG.minEpisodeItems)
12973
+ minEpisodeItems: parseFloorCount(env.QC_MIN_EPISODE_ITEMS, "QC_MIN_EPISODE_ITEMS", DEFAULT_FILTER_CONFIG.minEpisodeItems),
12974
+ ...env.QC_MIN_CHARS !== undefined && env.QC_MIN_CHARS.trim() !== "" ? { minChars: parseOptionalNonNegativeInt(env.QC_MIN_CHARS, "QC_MIN_CHARS") } : {}
12954
12975
  };
12955
12976
  }
12977
+ function parseOptionalNonNegativeInt(raw, name) {
12978
+ const value = raw.trim();
12979
+ if (!/^\d+$/.test(value))
12980
+ throw new Error(`${name}='${raw}' is not a non-negative integer`);
12981
+ return Number.parseInt(value, 10);
12982
+ }
12956
12983
  function requireAnnotation(doc) {
12957
12984
  const meta = asRecord(doc.metadata);
12958
12985
  const category = meta.category;
@@ -13003,9 +13030,15 @@ function planScoreOf(doc) {
13003
13030
  const value = asRecord(doc.metadata).planScore;
13004
13031
  return typeof value === "number" ? value : 0;
13005
13032
  }
13033
+ function docChars(doc) {
13034
+ return (doc.title ?? "").length + (doc.body ?? "").length;
13035
+ }
13006
13036
  function backfillToFloor(kept, rejected, config) {
13007
- if (kept.length >= config.minEpisodeItems)
13037
+ const minChars = config.minChars ?? 0;
13038
+ let currentChars = kept.reduce((sum, doc) => sum + docChars(doc), 0);
13039
+ if (kept.length >= config.minEpisodeItems && (minChars <= 0 || currentChars >= minChars)) {
13008
13040
  return { kept, rejected, admitted: [] };
13041
+ }
13009
13042
  const eligible = rejected.map((entry, index) => ({ entry, index })).filter(({ entry }) => entry.reasons.length > 0 && entry.reasons.every((r) => r.startsWith("importance:")));
13010
13043
  eligible.sort((a, b) => {
13011
13044
  const byImportance = importanceOf(b.entry.doc) - importanceOf(a.entry.doc);
@@ -13016,7 +13049,15 @@ function backfillToFloor(kept, rejected, config) {
13016
13049
  return byPlanScore;
13017
13050
  return a.index - b.index;
13018
13051
  });
13019
- const taken = eligible.slice(0, config.minEpisodeItems - kept.length);
13052
+ const taken = [];
13053
+ for (const item of eligible) {
13054
+ const countMet = kept.length + taken.length >= config.minEpisodeItems;
13055
+ const charsMet = minChars <= 0 || currentChars >= minChars;
13056
+ if (countMet && charsMet)
13057
+ break;
13058
+ taken.push(item);
13059
+ currentChars += docChars(item.entry.doc);
13060
+ }
13020
13061
  const takenIds = new Set(taken.map(({ entry }) => entry.doc.id));
13021
13062
  const admitted = taken.map(({ entry }) => ({
13022
13063
  ...entry.doc,