@gobing-ai/knowledge-kit 0.1.15 → 0.1.16

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 (103) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +1603 -1
  3. package/package.json +1 -1
  4. package/plugins/generations/content-gen/dist/index.js +58 -52
  5. package/plugins/generations/content-gen/src/storm.ts +94 -61
  6. package/plugins/generations/core-facts-gen/dist/index.js +1 -1
  7. package/plugins/generations/daily-article-gen/dist/index.js +1 -1
  8. package/plugins/generations/dailynews-gen/dist/index.js +1 -1
  9. package/plugins/generations/episode-plan-gen/dist/index.js +1 -1
  10. package/plugins/generations/gemini-tts/dist/index.js +1 -1
  11. package/plugins/generations/image-gen/README.md +31 -10
  12. package/plugins/generations/image-gen/assets/sample/cover__quasi-news-podcast.jpg +0 -0
  13. package/plugins/generations/image-gen/assets/sample/daily-news-cover__quasi-news-podcast.jpg +0 -0
  14. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__clean-webapp-ui.jpg +0 -0
  15. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__cute.jpg +0 -0
  16. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__daily-news.jpg +0 -0
  17. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__editorial.jpg +0 -0
  18. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__fresh.jpg +0 -0
  19. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__minimalist.jpg +0 -0
  20. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__photorealistic.jpg +0 -0
  21. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__quasi-news-podcast.jpg +0 -0
  22. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__sketch.jpg +0 -0
  23. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__technical-diagram.jpg +0 -0
  24. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__vibrant.jpg +0 -0
  25. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__warm.jpg +0 -0
  26. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__xhs-knowledge.jpg +0 -0
  27. package/plugins/generations/image-gen/assets/sample/free__quasi-news-podcast.jpg +0 -0
  28. package/plugins/generations/image-gen/assets/sample/illustration__quasi-news-podcast.jpg +0 -0
  29. package/plugins/generations/image-gen/assets/sample/xhs-card__quasi-news-podcast.jpg +0 -0
  30. package/plugins/generations/image-gen/dist/index.js +1 -1
  31. package/plugins/generations/image-gen/presets/formats/daily-news-podcast-cover.yaml +18 -0
  32. package/plugins/generations/image-gen/presets/styles/quasi-news-podcast.yaml +9 -0
  33. package/plugins/generations/news-report-gen/dist/index.js +1 -1
  34. package/plugins/generations/voice-gen/dist/index.js +1 -1
  35. package/plugins/generations/voxcpm-tts/dist/index.js +1 -1
  36. package/plugins/ingestions/aihot-ingest/dist/index.js +1 -1
  37. package/plugins/ingestions/horizon-ingest/dist/index.js +1 -1
  38. package/plugins/ingestions/last30days-ingest/dist/index.js +1 -1
  39. package/plugins/ingestions/web-search/dist/index.js +1 -1
  40. package/plugins/kk/plugin.json +1 -1
  41. package/plugins/kk/publish-presets/daily-ai-voice-migration.json +12 -3
  42. package/plugins/kk/publish-presets/daily-ai-voice.json +11 -3
  43. package/plugins/kk/scripts/cover-compositor.ts +152 -0
  44. package/plugins/kk/scripts/daily-cover-mock.ts +164 -0
  45. package/plugins/kk/scripts/daily-scheduled-run.ts +188 -3
  46. package/plugins/kk/scripts/daily-stages.ts +134 -26
  47. package/plugins/kk/scripts/daily-triage-core.ts +451 -0
  48. package/plugins/kk/scripts/daily-triage.ts +74 -0
  49. package/plugins/kk/scripts/kk-workflow-stages.ts +31 -2
  50. package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +16 -10
  51. package/plugins/kk/skills/news-editorial/SKILL.md +3 -3
  52. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +2 -1
  53. package/plugins/kk/skills/publish/SKILL.md +1 -1
  54. package/plugins/kk/skills/wiki-authoring/SKILL.md +53 -0
  55. package/plugins/kk/skills/wiki-authoring/references/page-shapes.md +44 -0
  56. package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +3 -3
  57. package/plugins/kk/workflows/kk-daily-safety.yaml +32 -7
  58. package/plugins/publishings/bilibili-pub/dist/index.js +1 -1
  59. package/plugins/publishings/cnblogs-pub/dist/index.js +1 -1
  60. package/plugins/publishings/csdn-pub/dist/index.js +1 -1
  61. package/plugins/publishings/csdn-pub/dist/profile-check.js +1 -1
  62. package/plugins/publishings/emdash-pub/dist/index.js +1 -1
  63. package/plugins/publishings/infoq-pub/dist/index.js +1 -1
  64. package/plugins/publishings/infoq-pub/dist/profile-check.js +1 -1
  65. package/plugins/publishings/jike-pub/dist/index.js +1 -1
  66. package/plugins/publishings/jike-pub/dist/profile-check.js +1 -1
  67. package/plugins/publishings/juejin-pub/dist/index.js +1 -1
  68. package/plugins/publishings/juejin-pub/dist/profile-check.js +1 -1
  69. package/plugins/publishings/linkedin-pub/dist/index.js +1 -1
  70. package/plugins/publishings/linkedin-pub/dist/profile-check.js +1 -1
  71. package/plugins/publishings/medium-pub/dist/index.js +1 -1
  72. package/plugins/publishings/podcast-pub/dist/index.js +1 -1
  73. package/plugins/publishings/qiita-pub/dist/index.js +1 -1
  74. package/plugins/publishings/shipinhao-pub/dist/index.js +222 -50
  75. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +48 -1
  76. package/plugins/publishings/shipinhao-pub/plugin.json +2 -2
  77. package/plugins/publishings/shipinhao-pub/src/flow.ts +335 -79
  78. package/plugins/publishings/shipinhao-pub/src/index.ts +16 -8
  79. package/plugins/publishings/shipinhao-pub/src/profile-check.ts +1 -1
  80. package/plugins/publishings/shipinhao-pub/src/selectors.ts +103 -5
  81. package/plugins/publishings/sspai-pub/dist/index.js +1 -1
  82. package/plugins/publishings/substack-pub/dist/index.js +1 -1
  83. package/plugins/publishings/substack-pub/dist/profile-check.js +1 -1
  84. package/plugins/publishings/surfdash-pub/dist/index.js +235 -12
  85. package/plugins/publishings/surfdash-pub/src/index.ts +127 -6
  86. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +189 -0
  87. package/plugins/publishings/threads-pub/dist/index.js +1 -1
  88. package/plugins/publishings/wechatmp-pub/dist/index.js +10 -7
  89. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +1 -1
  90. package/plugins/publishings/wechatmp-pub/src/enrich.ts +10 -3
  91. package/plugins/publishings/wechatmp-pub/src/flow.ts +3 -4
  92. package/plugins/publishings/wechatmp-pub/src/page.ts +14 -0
  93. package/plugins/publishings/weibo-pub/dist/index.js +1 -1
  94. package/plugins/publishings/weibo-pub/dist/profile-check.js +1 -1
  95. package/plugins/publishings/x-pub/dist/index.js +1 -1
  96. package/plugins/publishings/x-pub/dist/profile-check.js +1 -1
  97. package/plugins/publishings/xhs-pub/dist/index.js +557 -31
  98. package/plugins/publishings/xhs-pub/dist/profile-check.js +20 -1
  99. package/plugins/publishings/xhs-pub/src/errors.ts +45 -0
  100. package/plugins/publishings/xhs-pub/src/flow.ts +773 -45
  101. package/plugins/publishings/xhs-pub/src/page.ts +33 -0
  102. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +1 -1
  103. package/plugins/publishings/zenn-pub/dist/index.js +1 -1
@@ -19905,7 +19905,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
19905
19905
  shortVideo: Object.freeze({
19906
19906
  douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
19907
19907
  kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
19908
- shipinhao: Object.freeze({ max: 1000, unit: "unicode_code_points" })
19908
+ shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
19909
19909
  })
19910
19910
  })
19911
19911
  });
@@ -20875,7 +20875,21 @@ function errorMessage2(error) {
20875
20875
 
20876
20876
  // ../../plugins/publishings/shipinhao-pub/src/selectors.ts
20877
20877
  var SHP_TARGET = "shipinhao";
20878
- var SHP_HOME_URL = "https://channels.weixin.qq.com/platform/post/video";
20878
+ var SHP_HOME_URL = "https://channels.weixin.qq.com/platform";
20879
+ var SHP_OPERATION_NAMES = ["shortVideo", "audio", "image", "music"];
20880
+ var SHP_CREATE_ENTRY_SELECTORS = ['button:text-is("\u53D1\u8868\u89C6\u9891")'];
20881
+ var SHP_DESCRIPTION_MAX_CHARS = 100;
20882
+ var SHP_DRAFT_CONFIRM_DIALOG_TEXT = "\u4F7F\u7528\u5B9A\u65F6\u53D1\u8868\u5C06\u65E0\u6CD5\u4FDD\u5B58\u8349\u7A3F";
20883
+ var SHP_DRAFT_CONFIRM_PROCEED_LABEL = "\u4FDD\u5B58";
20884
+ var SHP_AUDIO_HOME_URL = SHP_HOME_URL;
20885
+ var SHP_IMAGE_HOME_URL = SHP_HOME_URL;
20886
+ var SHP_MUSIC_HOME_URL = SHP_HOME_URL;
20887
+ var SHP_HOME_URL_BY_OPERATION = {
20888
+ shortVideo: SHP_HOME_URL,
20889
+ audio: SHP_AUDIO_HOME_URL,
20890
+ image: SHP_IMAGE_HOME_URL,
20891
+ music: SHP_MUSIC_HOME_URL
20892
+ };
20879
20893
  var SHP_LOGIN_URL_RE = /(open\.weixin\.qq\.com|channels\.weixin\.qq\.com\/platform\/(login|scan))/;
20880
20894
  var ROOT_SNAPSHOT_SCRIPT = `(() => { // kk-shp-root-snapshot
20881
20895
  const wujieApp = document.querySelector('wujie-app');
@@ -20912,6 +20926,7 @@ async function readRootSnapshot(page) {
20912
20926
  var SHP_ROOT_WAIT_MS = 30000;
20913
20927
  var SHP_COVER_SAVE_WAIT_MS = 60000;
20914
20928
  var SHP_VIDEO_SELECTORS = {
20929
+ createEntry: SHP_CREATE_ENTRY_SELECTORS,
20915
20930
  videoInput: [
20916
20931
  'input[type="file"][accept*="video"]',
20917
20932
  'input[type="file"][accept*=".mp4"]',
@@ -20942,9 +20957,26 @@ var SHP_VIDEO_SELECTORS = {
20942
20957
  saveButton: ['button:text-is("\u4FDD\u5B58\u8349\u7A3F")'],
20943
20958
  publishButton: ['button:text-is("\u53D1\u8868")', '[role="button"]:text-is("\u53D1\u8868")']
20944
20959
  };
20960
+ var SHP_AUDIO_SELECTORS = {
20961
+ ...SHP_VIDEO_SELECTORS,
20962
+ audioInput: ['input[type="file"][accept*="video"]', 'input[type="file"]']
20963
+ };
20964
+ var SHP_MUSIC_SELECTORS = { ...SHP_AUDIO_SELECTORS };
20965
+ var SHP_IMAGE_SELECTORS = {
20966
+ ...SHP_VIDEO_SELECTORS,
20967
+ imagesInput: [
20968
+ 'input[type="file"][multiple]',
20969
+ 'input[type="file"][accept*="image"]',
20970
+ 'section:has(input[type="file"]):has-text("\u4E0A\u4F20\u56FE\u7247") input[type="file"]',
20971
+ 'input[type="file"]'
20972
+ ]
20973
+ };
20945
20974
  var SHP_RECEIPT_URL_RES = [
20946
20975
  /channels\.weixin\.qq\.com\/platform\/record\/detail\/[0-9a-zA-Z_-]+/,
20947
- /channels\.weixin\.qq\.com\/platform\/post\/video\/[0-9a-zA-Z_-]+/
20976
+ /channels\.weixin\.qq\.com\/platform\/post\/video\/[0-9a-zA-Z_-]+/,
20977
+ /channels\.weixin\.qq\.com\/platform\/post\/audio\/[0-9a-zA-Z_-]+/,
20978
+ /channels\.weixin\.qq\.com\/platform\/post\/image\/[0-9a-zA-Z_-]+/,
20979
+ /channels\.weixin\.qq\.com\/platform\/post\/music\/[0-9a-zA-Z_-]+/
20948
20980
  ];
20949
20981
  var SHP_UPLOAD_TIMEOUT_MS = 600000;
20950
20982
  var SHP_LOGIN_TIMEOUT_MS = 180000;
@@ -20998,6 +21030,20 @@ function needsLogin(error) {
20998
21030
  function normalizeText(value) {
20999
21031
  return value.replace(/\s+/g, "");
21000
21032
  }
21033
+ function htmlToPlainText(html) {
21034
+ return html.replace(/<\/(p|h[1-6]|li|blockquote|div)>/gi, `
21035
+ `).replace(/<br\s*\/?>/gi, `
21036
+ `).replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").trim();
21037
+ }
21038
+ function buildShipinhaoDescription(body, tags) {
21039
+ const bodyPlain = htmlToPlainText(sanitizeShipinhaoHtml(markdownToHtml(body)));
21040
+ const topicLine = tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ");
21041
+ const budget = SHP_DESCRIPTION_MAX_CHARS - (tags.length > 0 ? Array.from(topicLine).length + 1 : 0);
21042
+ const clipped = Array.from(bodyPlain).slice(0, Math.max(budget, 0)).join("").trim();
21043
+ const description = tags.length > 0 ? `${clipped}
21044
+ ${topicLine}` : clipped;
21045
+ return { description, html: sanitizeShipinhaoHtml(markdownToHtml(description)) };
21046
+ }
21001
21047
  function sanitizeShipinhaoHtml(html) {
21002
21048
  return html.replace(/<\s*(script|style|iframe|embed|object)\b[\s\S]*?<\s*\/\s*\1\s*>/gi, "").replace(/<\s*(script|style|iframe|embed|object)\b[^>]*>/gi, "").replace(/\son[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/(\s(?:href|src)\s*=\s*)(["'])\s*(?:javascript|data):[^"']*\2/gi, "$1$2$2").replace(/(\s(?:href|src)\s*=\s*)(?:javascript|data):[^\s>]*/gi, '$1""');
21003
21049
  }
@@ -21092,6 +21138,34 @@ function editorTextScript(mode, selector) {
21092
21138
  return el === null ? '' : String(el.innerText ?? el.textContent ?? '');
21093
21139
  })()`;
21094
21140
  }
21141
+ function draftConfirmClickScript(mode) {
21142
+ return `${rootScriptPrefix(mode)} // kk-shp-draft-confirm
21143
+ const mark = ${JSON.stringify(SHP_DRAFT_CONFIRM_DIALOG_TEXT)};
21144
+ const proceed = ${JSON.stringify(SHP_DRAFT_CONFIRM_PROCEED_LABEL)};
21145
+ for (const scope of [document, root]) {
21146
+ if (!scope) continue;
21147
+ // Anchor from the button side: the dialog text repeats across nested toast/dialog spans and
21148
+ // the last text-bearing element is a leaf without buttons (Grounded live probe 2026-11-11).
21149
+ for (const button of scope.querySelectorAll('button')) {
21150
+ if (String(button.textContent || '').trim() !== proceed || button.disabled) continue;
21151
+ // Only click a genuinely rendered dialog button: the vendor ships this dialog as a
21152
+ // permanently hidden 0\xD70 template inside the form (Grounded live probe 2026-11-11) \u2014
21153
+ // clicking the hidden copy is a silent no-op that would otherwise satisfy the rail.
21154
+ const rect = button.getBoundingClientRect();
21155
+ if (!(rect.width > 0 && rect.height > 0)) continue;
21156
+ let ancestor = button;
21157
+ for (let depth = 0; depth < 6 && ancestor; depth++) {
21158
+ if (String(ancestor.textContent || '').includes(mark)) {
21159
+ button.click();
21160
+ return JSON.stringify({ ok: true });
21161
+ }
21162
+ ancestor = ancestor.parentElement;
21163
+ }
21164
+ }
21165
+ }
21166
+ return JSON.stringify({ ok: false, reason: 'absent' });
21167
+ })()`;
21168
+ }
21095
21169
  async function readReceiptUrls(page) {
21096
21170
  const raw = await page.evaluate(`(() => { // kk-shp-receipt-urls
21097
21171
  const patterns = [${SHP_RECEIPT_URL_RES.map((re) => re.toString()).join(", ")}];
@@ -21114,30 +21188,71 @@ async function readReceiptUrls(page) {
21114
21188
  }
21115
21189
  }
21116
21190
  function receiptIdFrom(url) {
21117
- return /\/(?:detail|video)\/([0-9a-zA-Z_-]+)/.exec(url)?.[1];
21191
+ return /\/(?:detail|video|audio|image|music)\/([0-9a-zA-Z_-]+)/.exec(url)?.[1];
21118
21192
  }
21119
- async function resolveVideoPath(raw) {
21193
+ async function resolveMediaPath(raw, spec) {
21120
21194
  if (typeof raw !== "string" || raw.trim().length === 0) {
21121
- return { error: `metadata.videoPath must be a non-empty local video file path, got '${bounded(raw)}'` };
21195
+ return {
21196
+ error: `metadata.${spec.field} must be a non-empty local ${spec.kindLabel} file path, got '${bounded(raw)}'`
21197
+ };
21122
21198
  }
21123
21199
  const path = raw.trim();
21124
- if (!/\.(mp4|mov)$/i.test(path)) {
21200
+ if (!spec.extRe.test(path)) {
21125
21201
  return {
21126
- error: `metadata.videoPath must be a local MP4/MOV file, got unsupported extension in '${bounded(path)}'`
21202
+ error: `metadata.${spec.field} must be a local ${spec.extLabel} file, got unsupported extension in '${bounded(path)}'`
21127
21203
  };
21128
21204
  }
21129
21205
  const file = Bun.file(path);
21130
21206
  const readable = await file.exists().catch(() => false);
21131
21207
  if (!readable || file.size === 0) {
21132
- return { error: "metadata.videoPath does not resolve to a readable nonempty local video file" };
21208
+ return {
21209
+ error: `metadata.${spec.field} does not resolve to a readable nonempty local ${spec.kindLabel} file`
21210
+ };
21133
21211
  }
21134
21212
  if (file.size > MAX_VIDEO_BYTES) {
21135
21213
  return {
21136
- error: `metadata.videoPath exceeds the KK v1 local video cap of 2 GiB (${file.size} bytes; a local product bound, not a platform limit)`
21214
+ error: `metadata.${spec.field} exceeds the KK v1 local ${spec.kindLabel} cap of 2 GiB (${file.size} bytes; a local product bound, not a platform limit)`
21137
21215
  };
21138
21216
  }
21139
21217
  return { path };
21140
21218
  }
21219
+ function resolveVideoPath(raw) {
21220
+ return resolveMediaPath(raw, {
21221
+ field: "videoPath",
21222
+ kindLabel: "video",
21223
+ extLabel: "MP4/MOV",
21224
+ extRe: /\.(mp4|mov)$/i
21225
+ });
21226
+ }
21227
+ function resolveAudioPath(raw) {
21228
+ return resolveMediaPath(raw, {
21229
+ field: "audio (or audioFile)",
21230
+ kindLabel: "audio",
21231
+ extLabel: "MP3/M4A/WAV/AAC/FLAC",
21232
+ extRe: /\.(mp3|m4a|wav|aac|flac)$/i
21233
+ });
21234
+ }
21235
+ async function resolveImagesPath(raw) {
21236
+ if (!Array.isArray(raw) || raw.length === 0) {
21237
+ return {
21238
+ error: `metadata.images must be a non-empty array of local image file paths, got '${bounded(raw)}'`
21239
+ };
21240
+ }
21241
+ const paths = [];
21242
+ for (const entry of raw) {
21243
+ const candidate = typeof entry === "object" && entry !== null && "path" in entry ? entry.path : entry;
21244
+ const one = await resolveMediaPath(candidate, {
21245
+ field: "images[]",
21246
+ kindLabel: "image",
21247
+ extLabel: "PNG/JPEG/WebP",
21248
+ extRe: /\.(png|jpe?g|webp)$/i
21249
+ });
21250
+ if (one.error !== undefined)
21251
+ return { error: one.error };
21252
+ paths.push(one.path);
21253
+ }
21254
+ return { paths };
21255
+ }
21141
21256
  async function resolveCoverPath(raw) {
21142
21257
  if (raw === undefined)
21143
21258
  return {};
@@ -21182,21 +21297,33 @@ function resolveOriginal(raw) {
21182
21297
  }
21183
21298
  return { original: raw };
21184
21299
  }
21185
- function unsupportedFields(payload) {
21300
+ function unsupportedFields(payload, operation) {
21301
+ const perOperation = {
21302
+ shortVideo: ["images", "categories", "publishTime", "scheduling"],
21303
+ audio: ["videoPath", "images", "categories", "publishTime", "scheduling"],
21304
+ music: ["videoPath", "images", "categories", "publishTime", "scheduling"],
21305
+ image: ["videoPath", "coverPath", "categories", "publishTime", "scheduling"]
21306
+ };
21186
21307
  const refused = [];
21187
- for (const [container, keys] of [
21188
- ["options", ["images", "categories", "publishTime", "scheduling"]],
21189
- ["metadata", ["images", "categories", "publishTime", "scheduling"]]
21308
+ for (const [container, source] of [
21309
+ ["options", payload.options],
21310
+ ["metadata", payload.content.metadata]
21190
21311
  ]) {
21191
- const source = container === "options" ? payload.options : payload.content.metadata;
21192
- for (const key of keys) {
21193
- if (source !== undefined && source !== null && typeof source === "object" && key in source) {
21312
+ if (source === undefined || source === null || typeof source !== "object")
21313
+ continue;
21314
+ for (const key of perOperation[operation]) {
21315
+ if (key in source)
21194
21316
  refused.push(`${container}.${key}`);
21195
- }
21196
21317
  }
21197
21318
  }
21198
21319
  return refused;
21199
21320
  }
21321
+ var POST_FLOW_SPECS = {
21322
+ shortVideo: { selectors: SHP_VIDEO_SELECTORS, fileSelectors: SHP_VIDEO_SELECTORS.videoInput, mediaLabel: "video" },
21323
+ audio: { selectors: SHP_AUDIO_SELECTORS, fileSelectors: SHP_AUDIO_SELECTORS.audioInput, mediaLabel: "audio" },
21324
+ music: { selectors: SHP_MUSIC_SELECTORS, fileSelectors: SHP_MUSIC_SELECTORS.audioInput, mediaLabel: "music" },
21325
+ image: { selectors: SHP_IMAGE_SELECTORS, fileSelectors: SHP_IMAGE_SELECTORS.imagesInput, mediaLabel: "image" }
21326
+ };
21200
21327
  function editingFormReadyScript(mode, titleSelector, editorSelector) {
21201
21328
  return `${rootScriptPrefix(mode)}
21202
21329
  const title = root === null ? null : root.querySelector(${JSON.stringify(titleSelector)});
@@ -21357,32 +21484,53 @@ class ShipinhaoBrowserTransport {
21357
21484
  if (requested !== undefined && requested !== "draft" && requested !== "public") {
21358
21485
  return fail(SHP_TARGET, `unknown publishStatus '${bounded(requested)}' for ${SHP_TARGET}: expected 'draft', 'public' or absent (absent defaults to draft)`);
21359
21486
  }
21360
- if (payload.content.format !== "video") {
21487
+ if (this.operation === "shortVideo" && payload.content.format !== "video") {
21361
21488
  return fail(SHP_TARGET, `shipinhao shortVideo requires Content.format 'video', got '${bounded(payload.content.format)}'`);
21362
21489
  }
21363
21490
  const title = payload.content.title?.trim() ?? "";
21364
21491
  if (title.length === 0) {
21365
- return fail(SHP_TARGET, "shipinhao shortVideo requires a non-empty Content.title (the \u77ED\u6807\u9898 input, shipinhao.js:638-654)");
21492
+ return fail(SHP_TARGET, `shipinhao ${this.operation} requires a non-empty Content.title (the \u77ED\u6807\u9898 input, shipinhao.js:638-654)`);
21366
21493
  }
21367
21494
  const body = payload.content.body.trim();
21368
21495
  if (body.length === 0) {
21369
- return fail(SHP_TARGET, "shipinhao shortVideo requires non-empty Content.body Markdown (the \u6DFB\u52A0\u63CF\u8FF0 description is pasted as sanitized text/html, shipinhao.js:669-674)");
21370
- }
21371
- const video = await resolveVideoPath(payload.content.metadata?.videoPath);
21372
- if (video.error !== undefined)
21373
- return fail(SHP_TARGET, video.error);
21374
- const cover = await resolveCoverPath(payload.content.metadata?.coverPath ?? payload.options?.coverPath);
21375
- if (cover.error !== undefined)
21376
- return fail(SHP_TARGET, cover.error);
21496
+ return fail(SHP_TARGET, `shipinhao ${this.operation} requires non-empty Content.body Markdown (the \u6DFB\u52A0\u63CF\u8FF0 description is pasted as sanitized text/html, shipinhao.js:669-674)`);
21497
+ }
21498
+ const metadataRecord = payload.content.metadata ?? {};
21499
+ let media;
21500
+ let coverPath;
21501
+ if (this.operation === "shortVideo") {
21502
+ const video = await resolveVideoPath(metadataRecord.videoPath);
21503
+ if (video.error !== undefined)
21504
+ return fail(SHP_TARGET, video.error);
21505
+ media = [video.path];
21506
+ const cover = await resolveCoverPath(payload.content.metadata?.coverPath ?? payload.options?.coverPath);
21507
+ if (cover.error !== undefined)
21508
+ return fail(SHP_TARGET, cover.error);
21509
+ coverPath = cover.path;
21510
+ } else if (this.operation === "audio" || this.operation === "music") {
21511
+ const audio = await resolveAudioPath(metadataRecord.audio ?? metadataRecord.audioFile);
21512
+ if (audio.error !== undefined)
21513
+ return fail(SHP_TARGET, audio.error);
21514
+ media = [audio.path];
21515
+ const cover = await resolveCoverPath(payload.content.metadata?.coverPath ?? payload.options?.coverPath);
21516
+ if (cover.error !== undefined)
21517
+ return fail(SHP_TARGET, cover.error);
21518
+ coverPath = cover.path;
21519
+ } else {
21520
+ const images = await resolveImagesPath(metadataRecord.images);
21521
+ if (images.error !== undefined)
21522
+ return fail(SHP_TARGET, images.error);
21523
+ media = images.paths;
21524
+ }
21377
21525
  const tags = resolveTags(payload.content.metadata?.tags ?? payload.options?.tags);
21378
21526
  if (tags.error !== undefined)
21379
21527
  return fail(SHP_TARGET, tags.error);
21380
21528
  const original = resolveOriginal(payload.content.metadata?.original);
21381
21529
  if (original.error !== undefined)
21382
21530
  return fail(SHP_TARGET, original.error);
21383
- const unsupported = unsupportedFields(payload);
21531
+ const unsupported = unsupportedFields(payload, this.operation);
21384
21532
  if (unsupported.length > 0) {
21385
- return fail(SHP_TARGET, `unsupported field(s) ${unsupported.join(", ")} for shipinhao: this flow implements title/description/tags/video/cover/original declaration only, and scheduling/publishTime is an unported vendor enhancement (shipinhao.js:7-9)`);
21533
+ return fail(SHP_TARGET, `unsupported field(s) ${unsupported.join(", ")} for shipinhao ${this.operation}: implemented fields are title/description/tags/media/cover/original declaration only, and scheduling/publishTime is an unported vendor enhancement (shipinhao.js:7-9)`);
21386
21534
  }
21387
21535
  const override = typeof payload.options?.profileDir === "string" ? payload.options.profileDir : undefined;
21388
21536
  const profileDir = resolveChannelProfileDir(SHP_TARGET, override);
@@ -21398,18 +21546,18 @@ class ShipinhaoBrowserTransport {
21398
21546
  try {
21399
21547
  return await withProfilePage({
21400
21548
  profileDir,
21401
- url: SHP_HOME_URL,
21549
+ url: SHP_HOME_URL_BY_OPERATION[this.operation],
21402
21550
  isAuthenticated: isShipinhaoAuthenticated,
21403
21551
  headless: payload.options?.headless === true,
21404
21552
  launcher: this.launcher,
21405
21553
  timeoutMs: this.stepTimeoutMs
21406
- }, async ({ page }) => this.runShortVideoFlow(page, title, body, tags.tags, original.original === true, video.path, cover.path, requested === "public", profileDir));
21554
+ }, async ({ page }) => this.runPostFlow(page, POST_FLOW_SPECS[this.operation], title, body, tags.tags, original.original === true, media, coverPath, requested === "public", profileDir));
21407
21555
  } catch (error) {
21408
21556
  const detail = errorMessage3(error);
21409
21557
  return fail(SHP_TARGET, needsLogin(error) ? `${SHP_TARGET} session failed \u2014 run: ${SHP_LOGIN_INSTRUCTION} \u2014 detail: ${detail}` : detail);
21410
21558
  }
21411
21559
  }
21412
- async runShortVideoFlow(page, title, body, tags, declareOriginal, videoPath, coverPath, publishPublic, profileDir) {
21560
+ async runPostFlow(page, spec, title, body, tags, declareOriginal, media, coverPath, publishPublic, profileDir) {
21413
21561
  const publishStatus = publishPublic ? "public" : "draft";
21414
21562
  const metadata = {
21415
21563
  operation: this.operation,
@@ -21418,36 +21566,56 @@ class ShipinhaoBrowserTransport {
21418
21566
  profileDir,
21419
21567
  ...declareOriginal ? { original: true } : {}
21420
21568
  };
21569
+ const entrySnapshot = await readRootSnapshot(page);
21570
+ if (entrySnapshot.shadowFileInputs + entrySnapshot.directFileInputs === 0) {
21571
+ const entryRoot = await resolveCreatorRoot(page);
21572
+ if (entryRoot.error !== undefined)
21573
+ return stageFail(SHP_TARGET, entryRoot.error, "root-resolve", metadata);
21574
+ try {
21575
+ const entry = (await resolveRootLocator(page, entryRoot.mode, spec.selectors.createEntry, "shipinhao create entry", this.stepTimeoutMs)).locator;
21576
+ await entry.click();
21577
+ } catch (error) {
21578
+ return stageFail(SHP_TARGET, `shipinhao create entry click failed \u2014 ${errorMessage3(error)}`, "entry-open", metadata);
21579
+ }
21580
+ const opened = await expectOutcome(async () => {
21581
+ const snapshot = await readRootSnapshot(page);
21582
+ return snapshot.shadowFileInputs + snapshot.directFileInputs > 0 ? "create surface open" : null;
21583
+ }, { timeoutMs: this.stepTimeoutMs, label: "shipinhao create surface" });
21584
+ if (!opened.ok)
21585
+ return stageFail(SHP_TARGET, `shipinhao create surface never opened after the entry click \u2014 no media file input appeared in the active root \u2014 ${opened.error}`, "entry-open", metadata);
21586
+ }
21421
21587
  const root = await resolveCreatorRoot(page);
21422
21588
  if (root.error !== undefined)
21423
21589
  return stageFail(SHP_TARGET, root.error, "root-resolve", metadata);
21424
21590
  const mode = root.mode;
21425
21591
  try {
21426
- const resolved = await resolveRootLocator(page, mode, SHP_VIDEO_SELECTORS.videoInput, "shipinhao video file input", this.stepTimeoutMs);
21592
+ const resolved = await resolveRootLocator(page, mode, spec.fileSelectors, `shipinhao ${spec.mediaLabel} file input`, this.stepTimeoutMs);
21427
21593
  if (resolved.selector === 'input[type="file"]' && await resolved.locator.count() !== 1) {
21428
- return stageFail(SHP_TARGET, `shipinhao video file input ambiguous: the untyped input[type=file] candidate matched more than one input in the ${mode === "wujie" ? "wujie shadowRoot" : "document"} root \u2014 the vendor resolves a unique untyped input or nothing (shipinhao.js:580-583)`, "root-resolve", metadata);
21594
+ return stageFail(SHP_TARGET, `shipinhao ${spec.mediaLabel} file input ambiguous: the untyped input[type=file] candidate matched more than one input in the ${mode === "wujie" ? "wujie shadowRoot" : "document"} root \u2014 the vendor resolves a unique untyped input or nothing (shipinhao.js:580-583)`, "root-resolve", metadata);
21429
21595
  }
21430
- await resolved.locator.setInputFiles(videoPath, { timeout: this.stepTimeoutMs });
21596
+ await resolved.locator.setInputFiles(media.length === 1 ? media[0] : media, {
21597
+ timeout: this.stepTimeoutMs
21598
+ });
21431
21599
  } catch (error) {
21432
- return stageFail(SHP_TARGET, `shipinhao video file input/attach failed on ${page.url()}: ${errorMessage3(error)}`, "upload-timeout", metadata);
21600
+ return stageFail(SHP_TARGET, `shipinhao ${spec.mediaLabel} file input/attach failed on ${page.url()}: ${errorMessage3(error)}`, "upload-timeout", metadata);
21433
21601
  }
21434
21602
  let titleSelector;
21435
21603
  let editorSelector;
21436
21604
  try {
21437
- titleSelector = (await resolveRootLocator(page, mode, SHP_VIDEO_SELECTORS.titleInput, "shipinhao title input", this.stepTimeoutMs)).selector;
21438
- editorSelector = (await resolveRootLocator(page, mode, SHP_VIDEO_SELECTORS.descriptionEditor, "shipinhao description editor", this.stepTimeoutMs)).selector;
21605
+ titleSelector = (await resolveRootLocator(page, mode, spec.selectors.titleInput, "shipinhao title input", this.stepTimeoutMs)).selector;
21606
+ editorSelector = (await resolveRootLocator(page, mode, spec.selectors.descriptionEditor, "shipinhao description editor", this.stepTimeoutMs)).selector;
21439
21607
  } catch (error) {
21440
- return stageFail(SHP_TARGET, `shipinhao media processing not confirmed: the file was assigned but the post-upload editing form never appeared \u2014 ${errorMessage3(error)}; refusing to claim an uploaded video`, "upload-processing", metadata);
21608
+ return stageFail(SHP_TARGET, `shipinhao media processing not confirmed: the file was assigned but the post-upload editing form never appeared \u2014 ${errorMessage3(error)}; refusing to claim an uploaded ${spec.mediaLabel}`, "upload-processing", metadata);
21441
21609
  }
21442
21610
  const formReady = await expectOutcome(async () => {
21443
21611
  const raw = String(await page.evaluate(editingFormReadyScript(mode, titleSelector, editorSelector)));
21444
21612
  return JSON.parse(raw).ready === true ? "editing form observed in the active root" : null;
21445
21613
  }, { timeoutMs: SHP_UPLOAD_TIMEOUT_MS, label: "shipinhao media processing" });
21446
21614
  if (!formReady.ok) {
21447
- return stageFail(SHP_TARGET, `shipinhao media processing not confirmed within the ${SHP_UPLOAD_TIMEOUT_MS}ms ceiling \u2014 the file was assigned but no editing form appeared; refusing to claim an uploaded video`, "upload-processing", metadata);
21615
+ return stageFail(SHP_TARGET, `shipinhao media processing not confirmed within the ${SHP_UPLOAD_TIMEOUT_MS}ms ceiling \u2014 the file was assigned but no editing form appeared; refusing to claim an uploaded ${spec.mediaLabel}`, "upload-processing", metadata);
21448
21616
  }
21449
21617
  try {
21450
- const titleInput = (await resolveRootLocator(page, mode, SHP_VIDEO_SELECTORS.titleInput, "shipinhao title input", this.stepTimeoutMs)).locator;
21618
+ const titleInput = (await resolveRootLocator(page, mode, spec.selectors.titleInput, "shipinhao title input", this.stepTimeoutMs)).locator;
21451
21619
  await titleInput.fill(title);
21452
21620
  const readback = await expectOutcome(async () => normalizeText(String(await page.evaluate(titleValueScript(mode, titleSelector)))) === normalizeText(title) ? "title read back" : null, { timeoutMs: this.stepTimeoutMs, label: "shipinhao title readback" });
21453
21621
  if (!readback.ok)
@@ -21455,15 +21623,13 @@ class ShipinhaoBrowserTransport {
21455
21623
  } catch (error) {
21456
21624
  return stageFail(SHP_TARGET, `shipinhao title fill failed \u2014 ${errorMessage3(error)}`, "title-readback", metadata);
21457
21625
  }
21458
- const html = sanitizeShipinhaoHtml(markdownToHtml(tags.length === 0 ? body : `${body}
21459
-
21460
- ${tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ")}`));
21626
+ const { description, html } = buildShipinhaoDescription(body, tags);
21461
21627
  try {
21462
- const editorSelector = (await resolveRootLocator(page, mode, SHP_VIDEO_SELECTORS.descriptionEditor, "shipinhao description editor", this.stepTimeoutMs)).selector;
21628
+ const editorSelector = (await resolveRootLocator(page, mode, spec.selectors.descriptionEditor, "shipinhao description editor", this.stepTimeoutMs)).selector;
21463
21629
  await pasteRichText(page, mode, editorSelector, html);
21464
21630
  const readback = await expectOutcome(async () => {
21465
21631
  const editorText = String(await page.evaluate(editorTextScript(mode, editorSelector)));
21466
- return editorText.length > 0 && normalizeText(editorText).includes(normalizeText(body)) && tags.every((tag) => editorText.includes(`#${tag.replace(/^#/, "")}`)) ? "description and topics read back" : null;
21632
+ return editorText.length > 0 && normalizeText(editorText).includes(normalizeText(description)) && tags.every((tag) => editorText.includes(`#${tag.replace(/^#/, "")}`)) ? "description and topics read back" : null;
21467
21633
  }, { timeoutMs: this.stepTimeoutMs, label: "shipinhao description paste readback" });
21468
21634
  if (!readback.ok)
21469
21635
  return stageFail(SHP_TARGET, `shipinhao description readback failed \u2014 the editor did not retain the pasted description/topics \u2014 ${readback.error}`, "description-paste-readback", metadata);
@@ -21481,7 +21647,7 @@ ${tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ")}`));
21481
21647
  return coverOutcome;
21482
21648
  }
21483
21649
  const stage = publishPublic ? "publish-click" : "draft-save";
21484
- const submitSelectors = publishPublic ? SHP_VIDEO_SELECTORS.publishButton : SHP_VIDEO_SELECTORS.saveButton;
21650
+ const submitSelectors = publishPublic ? spec.selectors.publishButton : spec.selectors.saveButton;
21485
21651
  let submitLocator;
21486
21652
  try {
21487
21653
  const resolved = await resolveRootLocator(page, mode, submitSelectors, "shipinhao submit control", this.stepTimeoutMs);
@@ -21503,6 +21669,12 @@ ${tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ")}`));
21503
21669
  const beforeReceipts = new Set(await readReceiptUrls(page));
21504
21670
  await submitLocator.click();
21505
21671
  const confirmed = await expectOutcome(async () => {
21672
+ if (!publishPublic) {
21673
+ const confirmRaw = String(await page.evaluate(draftConfirmClickScript(mode)));
21674
+ const confirm = JSON.parse(confirmRaw);
21675
+ if (confirm.ok)
21676
+ return null;
21677
+ }
21506
21678
  const fresh = (await readReceiptUrls(page)).filter((candidate) => !beforeReceipts.has(candidate));
21507
21679
  if (fresh.length === 0)
21508
21680
  return null;
@@ -21536,7 +21708,7 @@ ${tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ")}`));
21536
21708
  target: SHP_TARGET,
21537
21709
  id: receiptIdFrom(url),
21538
21710
  url,
21539
- message: `shipinhao shortVideo ${publishStatus} confirmed in profile ${profileDir}`,
21711
+ message: `shipinhao ${this.operation} ${publishStatus} confirmed in profile ${profileDir}`,
21540
21712
  metadata: { ...metadata, confirmedBy: receiptStage }
21541
21713
  });
21542
21714
  }
@@ -21629,7 +21801,7 @@ ${tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ")}`));
21629
21801
  }
21630
21802
 
21631
21803
  // ../../plugins/publishings/shipinhao-pub/src/index.ts
21632
- var SHP_OPERATIONS = ["shortVideo"];
21804
+ var SHP_OPERATIONS = SHP_OPERATION_NAMES;
21633
21805
  function resolveOperation(options, content) {
21634
21806
  const raw = options?.operation ?? content?.metadata?.operation ?? "shortVideo";
21635
21807
  if (typeof raw !== "string" || !SHP_OPERATIONS.includes(raw)) {
@@ -20426,7 +20426,8 @@ function errorMessage2(error) {
20426
20426
 
20427
20427
  // ../../plugins/publishings/shipinhao-pub/src/selectors.ts
20428
20428
  var SHP_TARGET = "shipinhao";
20429
- var SHP_HOME_URL = "https://channels.weixin.qq.com/platform/post/video";
20429
+ var SHP_HOME_URL = "https://channels.weixin.qq.com/platform";
20430
+ var SHP_CREATE_ENTRY_SELECTORS = ['button:text-is("\u53D1\u8868\u89C6\u9891")'];
20430
20431
  var SHP_LOGIN_URL_RE = /(open\.weixin\.qq\.com|channels\.weixin\.qq\.com\/platform\/(login|scan))/;
20431
20432
  var ROOT_SNAPSHOT_SCRIPT = `(() => { // kk-shp-root-snapshot
20432
20433
  const wujieApp = document.querySelector('wujie-app');
@@ -20460,6 +20461,52 @@ async function readRootSnapshot(page) {
20460
20461
  shadowTextEvidence: 0
20461
20462
  };
20462
20463
  }
20464
+ var SHP_VIDEO_SELECTORS = {
20465
+ createEntry: SHP_CREATE_ENTRY_SELECTORS,
20466
+ videoInput: [
20467
+ 'input[type="file"][accept*="video"]',
20468
+ 'input[type="file"][accept*=".mp4"]',
20469
+ 'input[type="file"][accept*=".mov"]',
20470
+ 'section:has(input[type="file"]):has-text("\u4E0A\u4F20\u89C6\u9891") input[type="file"]',
20471
+ 'section:has(input[type="file"]):has-text("\u89C6\u9891\u6587\u4EF6") input[type="file"]',
20472
+ 'input[type="file"]'
20473
+ ],
20474
+ titleInput: ['input[placeholder*="\u77ED\u6807\u9898"]', 'input[placeholder*="\u586B\u5199\u6807\u9898"]', 'input[placeholder*="\u6807\u9898"]'],
20475
+ descriptionEditor: [
20476
+ '[data-placeholder^="\u6DFB\u52A0\u63CF\u8FF0"]',
20477
+ '[placeholder^="\u6DFB\u52A0\u63CF\u8FF0"]',
20478
+ '[role="textbox"][aria-label^="\u6DFB\u52A0\u63CF\u8FF0"]',
20479
+ '[placeholder*="\u8BDD\u9898\u548C\u63CF\u8FF0"]'
20480
+ ],
20481
+ coverEditEntry: ["div.cover-preview-wrap > div"],
20482
+ coverDialog: [
20483
+ "div.cover-control-wrap",
20484
+ 'div[class*="cover"][class*="dialog"]',
20485
+ 'div[class*="cover"][class*="modal"]',
20486
+ '[role="dialog"]'
20487
+ ],
20488
+ coverDialogFileInputSuffix: 'input[type="file"]',
20489
+ coverConfirmLabels: ["\u786E\u8BA4", "\u5B8C\u6210", "\u4FDD\u5B58", "\u5E94\u7528", "\u786E\u5B9A"],
20490
+ coverConfirmFooter: "div.finder-dialog-footer button",
20491
+ originalAgreementCheckbox: 'div.declare-body-wrapper input[type="checkbox"].ant-checkbox-input',
20492
+ originalConfirmLabel: "\u58F0\u660E\u539F\u521B",
20493
+ saveButton: ['button:text-is("\u4FDD\u5B58\u8349\u7A3F")'],
20494
+ publishButton: ['button:text-is("\u53D1\u8868")', '[role="button"]:text-is("\u53D1\u8868")']
20495
+ };
20496
+ var SHP_AUDIO_SELECTORS = {
20497
+ ...SHP_VIDEO_SELECTORS,
20498
+ audioInput: ['input[type="file"][accept*="video"]', 'input[type="file"]']
20499
+ };
20500
+ var SHP_MUSIC_SELECTORS = { ...SHP_AUDIO_SELECTORS };
20501
+ var SHP_IMAGE_SELECTORS = {
20502
+ ...SHP_VIDEO_SELECTORS,
20503
+ imagesInput: [
20504
+ 'input[type="file"][multiple]',
20505
+ 'input[type="file"][accept*="image"]',
20506
+ 'section:has(input[type="file"]):has-text("\u4E0A\u4F20\u56FE\u7247") input[type="file"]',
20507
+ 'input[type="file"]'
20508
+ ]
20509
+ };
20463
20510
  var SHP_LOGIN_TIMEOUT_MS = 180000;
20464
20511
  var isShipinhaoAuthenticated = async (page) => {
20465
20512
  if (SHP_LOGIN_URL_RE.test(page.url()))
@@ -4,9 +4,9 @@
4
4
  "entry": "./dist/index.js",
5
5
  "check": "./dist/profile-check.js",
6
6
  "version": "1.0.0",
7
- "description": "shipinhao (channels.weixin.qq.com) short-video publish via a script browser transport with wujie-app shadowRoot traversal; draft by default, public only on an explicit publishStatus with a fresh works receipt, requested-only 声明原创 declaration",
7
+ "description": "shipinhao (channels.weixin.qq.com) publish via a script browser transport with wujie-app shadowRoot traversal; four post kinds (shortVideo 视频, audio 音频, image 图文, music 音乐 — audio is the first deliverable); draft by default, public only on an explicit publishStatus with a fresh works receipt, requested-only 声明原创 declaration",
8
8
  "browserSession": {
9
9
  "profileName": "shipinhao",
10
- "homeUrl": "https://channels.weixin.qq.com/platform/post/video"
10
+ "homeUrl": "https://channels.weixin.qq.com/platform"
11
11
  }
12
12
  }