@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
@@ -1,13 +1,19 @@
1
1
  /**
2
- * shipinhao-pub — shipinhao (channels.weixin.qq.com) short-video publisher plugin surface (task 0296).
2
+ * shipinhao-pub — shipinhao (channels.weixin.qq.com) publisher plugin surface (task 0296; four
3
+ * post kinds since 2026-11-10).
3
4
  *
4
5
  * This module is the manifest-facing plugin surface: the declared operation list, the pre-browser
5
- * refusal ladder (operation → driver → publishStatus → format → title → body → video file → cover
6
+ * refusal ladder (operation → driver → publishStatus → format → title → body → media file → cover
6
7
  * → tags → original → unsupported fields — all refused before any browser opens),
7
8
  * `getPublishTransport`, the `--in/--out` IO contract and the CLI `main`. The selectors and the
8
9
  * vendor-grounded site predicates live in `src/selectors.ts`, the browser transport and flow in
9
10
  * `src/flow.ts`, and the operator session CLI in `src/profile-check.ts`.
10
11
  *
12
+ * Operations map one-to-one onto the 发布 page's post kinds (视频, 图文, 音乐, 音频):
13
+ * `shortVideo` (Grounded, vendor-port), `audio` (the first deliverable — the daily AI news
14
+ * episode mp3), `image` (图文) and `music`. The audio/image/music selectors are Provisional until
15
+ * the first logged-in live recon; everything fails closed.
16
+ *
11
17
  * Evidence: the recovered extension adapter
12
18
  * `.spur/run/yijianfa-source/platforms/shipinhao.js` (2817 lines) pins the field semantics cited
13
19
  * throughout `src/selectors.ts` and `src/flow.ts` (root policy 514-545, upload 549-631, fields
@@ -26,14 +32,16 @@ import { type BrowserDriver, FakeBrowserTransport, type PublishTransport } from
26
32
  import { createNodeFileSystem } from '@gobing-ai/ts-runtime';
27
33
  import { echoError } from '@gobing-ai/ts-utils';
28
34
  import { bounded, boundedDetail, errorMessage, fail, ShipinhaoBrowserTransport } from './flow';
29
- import { SHP_TARGET } from './selectors';
35
+ import { SHP_OPERATION_NAMES, SHP_TARGET, type ShipinhaoOperationName } from './selectors';
30
36
 
31
37
  /**
32
- * Declared operations (ADR-029 dispatch): the source registers a single short-video flow
33
- * (`shortVideo`; the vendor's type dispatch, shipinhao.js:10,2802, declares this one kind).
38
+ * Declared operations (ADR-029 dispatch): one per 发布-page post kind — `shortVideo` (视频, the
39
+ * vendor-port), `audio` (音频), `image` (图文), `music` (音乐). The vendor adapter declares only
40
+ * the short-video kind (shipinhao.js:10,2802); the other three are Provisional fail-closed flows
41
+ * over the same stage rails, pending the first logged-in live recon.
34
42
  */
35
- export const SHP_OPERATIONS = ['shortVideo'] as const;
36
- export type ShipinhaoOperation = (typeof SHP_OPERATIONS)[number];
43
+ export const SHP_OPERATIONS = SHP_OPERATION_NAMES;
44
+ export type ShipinhaoOperation = ShipinhaoOperationName;
37
45
 
38
46
  /**
39
47
  * Resolves the requested operation (`options.operation ?? content.metadata.operation ?? default`)
@@ -80,7 +88,7 @@ function resolveDriver(
80
88
  * `KNOWLEDGE_KIT_PUBLISH_TRANSPORT=fake` (offline, no profile, no browser), otherwise the real
81
89
  * shipinhao browser transport (`src/flow.ts`). API-only paths never load Playwright eagerly:
82
90
  * the harness launcher imports Playwright dynamically at launch time only.
83
- * @param operation - Resolved operation (`shortVideo`).
91
+ * @param operation - Resolved operation (one of `SHP_OPERATIONS`).
84
92
  * @param driver - Resolved driver; only `script` is declared.
85
93
  * @returns The publish transport for this channel.
86
94
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * shipinhao profile-session capability (task 0296, Chunk A).
3
3
  *
4
- * `login` opens the Channels publishing home (https://channels.weixin.qq.com/platform/post/video,
4
+ * `login` opens the Channels dashboard (https://channels.weixin.qq.com/platform,
5
5
  * see `src/selectors.ts`) in a headed browser and resolves only once the site readiness predicate
6
6
  * passes; `check` reopens the profile (headlessly, unless the operator passes `--headed` or the
7
7
  * config sets `checkHeadedOnly`) and reports `verified` or `refused`; `open` just brings the
@@ -24,11 +24,62 @@ import type { IsAuthenticatedPredicate } from '@gobing-ai/ts-browser-automation'
24
24
  export const SHP_TARGET = 'shipinhao';
25
25
 
26
26
  /**
27
- * Fixed home entry (task 0296 Design freeze): the Channels short-video publishing page. Grounded
28
- * as the display entry only — shipinhao.js never navigates (it fills in place inside an
29
- * already-open assistant tab).
27
+ * Fixed home entry (recon-Grounded 2026-11-11): the Channels dashboard. Every direct
28
+ * `/platform/post/<kind>` URL redirects here for a logged-in session — the per-op direct-create
29
+ * URLs in the earlier Provisional table do not exist. The unified create surface lives at
30
+ * `/platform/post/create`, reached by clicking the dashboard entry button (see
31
+ * `SHP_CREATE_ENTRY_SELECTORS`); the publish flow performs that click-through after navigation.
30
32
  */
31
- export const SHP_HOME_URL = 'https://channels.weixin.qq.com/platform/post/video';
33
+ export const SHP_HOME_URL = 'https://channels.weixin.qq.com/platform';
34
+
35
+ /**
36
+ * The post kinds the 发布 page offers (视频, 图文, 音乐, 音频). Declared operation names are
37
+ * ASCII (`shortVideo` is the task 0296 freeze), one per platform post kind.
38
+ */
39
+ export const SHP_OPERATION_NAMES = ['shortVideo', 'audio', 'image', 'music'] as const;
40
+ export type ShipinhaoOperationName = (typeof SHP_OPERATION_NAMES)[number];
41
+
42
+ /**
43
+ * Dashboard create-entry button (recon-Grounded 2026-11-11): the dashboard offers exactly the
44
+ * visible `发表视频` button; clicking it opens the unified `/platform/post/create` surface for
45
+ * every post kind — the kind is determined by the media file fed to the single intake input.
46
+ */
47
+ export const SHP_CREATE_ENTRY_SELECTORS = ['button:text-is("发表视频")'] as const;
48
+
49
+ /**
50
+ * 添加描述 hard cap: the editor truncates any paste to exactly 100 plain-text characters
51
+ * (Grounded live probe 2026-11-11 — a 6054-char paste retained exactly 100). Topic tags count
52
+ * toward the same budget, so the body plain text is clipped to leave room for them.
53
+ */
54
+ export const SHP_DESCRIPTION_MAX_CHARS = 100;
55
+
56
+ /**
57
+ * Draft-save confirm dialog (Grounded live probe 2026-11-11): with 定时发表 active, clicking
58
+ * 保存草稿 renders a dialog — "使用定时发表将无法保存草稿。若要保存草稿,需先取消定时发表。"
59
+ * with visible buttons 不保存 (abort) / 保存 (proceed); the save only proceeds after clicking the
60
+ * visible dialog's 保存. The vendor also ships this dialog as a permanently hidden 0×0 template,
61
+ * so the rail anchors from the button side and requires a rendered box; absence = normal no-op.
62
+ */
63
+ export const SHP_DRAFT_CONFIRM_DIALOG_TEXT = '使用定时发表将无法保存草稿';
64
+ export const SHP_DRAFT_CONFIRM_PROCEED_LABEL = '保存';
65
+
66
+ /**
67
+ * Per-operation creation entries: ALL operations share the dashboard entry and the unified
68
+ * `/platform/post/create` surface (recon-Grounded 2026-11-11 — the former per-kind
69
+ * `/platform/post/<kind>` URLs redirect to the dashboard; the kept map keeps the flow's
70
+ * per-operation seam while every entry is the same page).
71
+ */
72
+ export const SHP_AUDIO_HOME_URL = SHP_HOME_URL;
73
+ export const SHP_IMAGE_HOME_URL = SHP_HOME_URL;
74
+ export const SHP_MUSIC_HOME_URL = SHP_HOME_URL;
75
+
76
+ /** Creation-page entry per declared operation (see {@link SHP_AUDIO_HOME_URL} for the caveat). */
77
+ export const SHP_HOME_URL_BY_OPERATION: Record<ShipinhaoOperationName, string> = {
78
+ shortVideo: SHP_HOME_URL,
79
+ audio: SHP_AUDIO_HOME_URL,
80
+ image: SHP_IMAGE_HOME_URL,
81
+ music: SHP_MUSIC_HOME_URL,
82
+ };
32
83
 
33
84
  /**
34
85
  * Login/passport redirect marker. **Provisional**: shipinhao.js never observes a redirect URL; it
@@ -116,6 +167,11 @@ export const SHP_COVER_SAVE_WAIT_MS = 60_000;
116
167
  * shipinhao.js:2326). All fail closed when absent or ambiguous.
117
168
  */
118
169
  export const SHP_VIDEO_SELECTORS = {
170
+ /**
171
+ * Dashboard entry button into the unified create surface (see
172
+ * {@link SHP_CREATE_ENTRY_SELECTORS}). Clicked once after navigation, before the form rails.
173
+ */
174
+ createEntry: SHP_CREATE_ENTRY_SELECTORS,
119
175
  /**
120
176
  * Video file input candidates, vendor priority: accept-kind (shipinhao.js:549-555) → semantic
121
177
  * upload region 上传视频/视频文件/选择视频 (shipinhao.js:565-568) → the single untyped
@@ -145,7 +201,11 @@ export const SHP_VIDEO_SELECTORS = {
145
201
  coverEditEntry: ['div.cover-preview-wrap > div'],
146
202
  /**
147
203
  * Cover dialog container candidates (vendor `findCoverControl`, shipinhao.js:2144-2149): the
148
- * flow requires the resolved dialog to hold an `input[type="file"]` before use.
204
+ * flow requires the resolved dialog to hold an `input[type="file"]` before use. **Grounded
205
+ * audio known-gap (live probe 2026-11-11)**: for AUDIO the container stays `visible:false` and
206
+ * the slot stays `primary-loading` (auto-cover processing), so the vendor's visible-dialog
207
+ * contract never materializes — a requested audio cover is a typed cover-attach failure, never
208
+ * a silent skip. Daily presets request no cover for shipinhao rows.
149
209
  */
150
210
  coverDialog: [
151
211
  'div.cover-control-wrap',
@@ -188,6 +248,41 @@ export const SHP_VIDEO_SELECTORS = {
188
248
  /** Keys of the selector map, for typed probes. */
189
249
  export type ShipinhaoVideoSelectorKey = keyof typeof SHP_VIDEO_SELECTORS;
190
250
 
251
+ /**
252
+ * The 音频 (audio-post) flow selectors: the video flow's rails (title, description editor,
253
+ * 声明原创 dialog, cover dialog, submit rail) reused verbatim plus the unified intake ladder.
254
+ * Recon-Grounded 2026-11-11: the create surface has ONE media intake (the video-accept input)
255
+ * and no audio-accept input exists — feeding the .mp3 to that input morphs the form into the
256
+ * audio post flow (title/description/cover/save rails all render post-upload). **Grounded.**
257
+ */
258
+ export const SHP_AUDIO_SELECTORS = {
259
+ ...SHP_VIDEO_SELECTORS,
260
+ audioInput: ['input[type="file"][accept*="video"]', 'input[type="file"]'] as readonly string[],
261
+ } as const;
262
+
263
+ /**
264
+ * The 音乐 (music-post) flow selectors: the audio flow's unified-intake ladder plus the cover
265
+ * rails (music posts carry their own cover). Same intake evidence as audio; the music-specific
266
+ * form rails stay **Provisional until live recon**, same fail-closed rule.
267
+ */
268
+ export const SHP_MUSIC_SELECTORS: typeof SHP_AUDIO_SELECTORS = { ...SHP_AUDIO_SELECTORS };
269
+
270
+ /**
271
+ * The 图文 (image-post) flow selectors: a multi-file image-input ladder plus the shared
272
+ * text/submit rails. No cover rails are read — the platform owns the 图文 cover from the images
273
+ * themselves, so the flow refuses an explicit cover for this operation instead of guessing a
274
+ * slot. **Provisional until live recon**, same fail-closed rule.
275
+ */
276
+ export const SHP_IMAGE_SELECTORS = {
277
+ ...SHP_VIDEO_SELECTORS,
278
+ imagesInput: [
279
+ 'input[type="file"][multiple]',
280
+ 'input[type="file"][accept*="image"]',
281
+ 'section:has(input[type="file"]):has-text("上传图片") input[type="file"]',
282
+ 'input[type="file"]',
283
+ ] as readonly string[],
284
+ } as const;
285
+
191
286
  /**
192
287
  * Receipt-shaped URLs. **Provisional**: the vendor never reads a receipt (a clicked 发表 without
193
288
  * a works record is `unknown`, shipinhao.js:2326), so these are the id-bearing works/record
@@ -198,6 +293,9 @@ export type ShipinhaoVideoSelectorKey = keyof typeof SHP_VIDEO_SELECTORS;
198
293
  export const SHP_RECEIPT_URL_RES = [
199
294
  /channels\.weixin\.qq\.com\/platform\/record\/detail\/[0-9a-zA-Z_-]+/,
200
295
  /channels\.weixin\.qq\.com\/platform\/post\/video\/[0-9a-zA-Z_-]+/,
296
+ /channels\.weixin\.qq\.com\/platform\/post\/audio\/[0-9a-zA-Z_-]+/,
297
+ /channels\.weixin\.qq\.com\/platform\/post\/image\/[0-9a-zA-Z_-]+/,
298
+ /channels\.weixin\.qq\.com\/platform\/post\/music\/[0-9a-zA-Z_-]+/,
201
299
  ] as const;
202
300
 
203
301
  /** Upload/processing ceiling for the video step (media ceiling — large local files, task 0296 freeze). */
@@ -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
  });
@@ -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
  });
@@ -20782,7 +20782,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
20782
20782
  shortVideo: Object.freeze({
20783
20783
  douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
20784
20784
  kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
20785
- shipinhao: Object.freeze({ max: 1000, unit: "unicode_code_points" })
20785
+ shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
20786
20786
  })
20787
20787
  })
20788
20788
  });
@@ -12073,7 +12073,7 @@ var init_src = () => {};
12073
12073
  import { createHash } from "crypto";
12074
12074
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
12075
12075
  import { copyFile, cp, writeFile } from "fs/promises";
12076
- import { dirname as dirname3, extname, isAbsolute, join as join2, relative, resolve, sep as sep2 } from "path";
12076
+ import { dirname as dirname4, extname, isAbsolute, join as join2, relative, resolve, sep as sep2 } from "path";
12077
12077
  import { parseArgs } from "util";
12078
12078
 
12079
12079
  // ../../packages/kk-core/src/content-limits.ts
@@ -12149,7 +12149,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
12149
12149
  shortVideo: Object.freeze({
12150
12150
  douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
12151
12151
  kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
12152
- shipinhao: Object.freeze({ max: 1000, unit: "unicode_code_points" })
12152
+ shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
12153
12153
  })
12154
12154
  })
12155
12155
  });
@@ -12670,6 +12670,143 @@ function checkDigestFrontmatter(markdown, locale) {
12670
12670
  return problems;
12671
12671
  }
12672
12672
 
12673
+ // ../../plugins/publishings/surfdash-pub/src/topic-claims.ts
12674
+ import { dirname as dirname3 } from "path";
12675
+ var escapeRe2 = (token) => token.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
12676
+ var titleSepFor = (locale) => locale === "en" ? ": " : "\uFF1A";
12677
+ var listSepFor = (locale) => locale === "en" ? ", " : "\u3001";
12678
+ function slugFromPostPath(postPath) {
12679
+ const normalized = postPath.replaceAll("\\", "/");
12680
+ const match = normalized.match(/(?:^|\/)posts\/articles\/(?:zh|en|ja)\/([^/]+)/);
12681
+ return match?.[1];
12682
+ }
12683
+ function tagList(frontmatter) {
12684
+ const tags = frontmatter.get("tags");
12685
+ if (Array.isArray(tags))
12686
+ return tags;
12687
+ if (typeof tags === "string" && tags !== "")
12688
+ return [tags];
12689
+ return [];
12690
+ }
12691
+ function isDigestMarkdown(markdown) {
12692
+ return tagList(parseFrontmatterScalars(markdown)).some((tag) => tag.includes(DIGEST_TAG));
12693
+ }
12694
+ function scalar2(frontmatter, key) {
12695
+ const value = frontmatter.get(key);
12696
+ if (value === undefined)
12697
+ return;
12698
+ return Array.isArray(value) ? value.join(" ") : value;
12699
+ }
12700
+ function parseTitleHeadlines(title, locale) {
12701
+ const series = SERIES_NAMES[locale];
12702
+ const titleSep = titleSepFor(locale);
12703
+ const listSep = listSepFor(locale);
12704
+ const match = title.match(new RegExp(`^${escapeRe2(series)} \xB7 (\\d{4}-\\d{2}-\\d{2})${escapeRe2(titleSep)}(.+)$`));
12705
+ if (!match?.[2])
12706
+ return;
12707
+ const heads = match[2].split(listSep).map((head) => head.trim());
12708
+ if (heads.length < 2 || heads.some((head) => head === ""))
12709
+ return;
12710
+ return heads;
12711
+ }
12712
+ function parseKeyPointParts(points) {
12713
+ const labels = [];
12714
+ const sentences = [];
12715
+ for (const point of points) {
12716
+ const sep = point.indexOf(" \u2014 ");
12717
+ if (sep < 0)
12718
+ return;
12719
+ const label = point.slice(0, sep).trim();
12720
+ const sentence = point.slice(sep + 3).trim();
12721
+ if (label === "" || sentence === "")
12722
+ return;
12723
+ labels.push(label);
12724
+ sentences.push(sentence);
12725
+ }
12726
+ return { labels, sentences };
12727
+ }
12728
+ function splitDescriptionParts(description, count) {
12729
+ for (const pattern of [/\uFF1B|; /, /\uFF1B|;/]) {
12730
+ const parts = description.split(pattern).map((part) => part.trim()).filter((part) => part !== "");
12731
+ if (parts.length === count)
12732
+ return parts;
12733
+ }
12734
+ return;
12735
+ }
12736
+ function buildLocaleEntry(markdown, locale) {
12737
+ if (!isDigestMarkdown(markdown)) {
12738
+ return `${locale}: missing ${DIGEST_TAG} tag`;
12739
+ }
12740
+ const frontmatter = parseFrontmatterScalars(markdown);
12741
+ const title = scalar2(frontmatter, "title") ?? "";
12742
+ const headlines = parseTitleHeadlines(title, locale);
12743
+ if (!headlines) {
12744
+ return `${locale}: title is not "<series> \xB7 YYYY-MM-DD${titleSepFor(locale)}h1${listSepFor(locale)}h2"`;
12745
+ }
12746
+ const description = (scalar2(frontmatter, "description") ?? scalar2(frontmatter, "seo_description") ?? "").trim();
12747
+ if (description === "") {
12748
+ return `${locale}: description is empty`;
12749
+ }
12750
+ const rawPoints = frontmatter.get("key_points");
12751
+ if (!Array.isArray(rawPoints) || rawPoints.length === 0) {
12752
+ return `${locale}: key_points is missing`;
12753
+ }
12754
+ const parts = parseKeyPointParts(rawPoints);
12755
+ if (!parts) {
12756
+ return `${locale}: key_points must be "label \u2014 sentence"`;
12757
+ }
12758
+ if (parts.labels.length !== headlines.length || parts.labels.some((label, i) => label !== headlines[i])) {
12759
+ return `${locale}: title headlines do not match key_points labels`;
12760
+ }
12761
+ const claims = parts.sentences;
12762
+ const shortClaims = splitDescriptionParts(description, headlines.length) ?? claims;
12763
+ return {
12764
+ headlines,
12765
+ description,
12766
+ key_points: headlines,
12767
+ claims,
12768
+ short_claims: shortClaims
12769
+ };
12770
+ }
12771
+ function buildDailyTopicsEntry(posts) {
12772
+ const entry = {};
12773
+ for (const locale of PATCH_LOCALES) {
12774
+ const markdown = posts[locale];
12775
+ if (typeof markdown !== "string" || markdown.trim() === "") {
12776
+ return { ok: false, error: `${locale}: post markdown is empty` };
12777
+ }
12778
+ const built = buildLocaleEntry(markdown, locale);
12779
+ if (typeof built === "string")
12780
+ return { ok: false, error: built };
12781
+ entry[locale] = built;
12782
+ }
12783
+ return { ok: true, entry };
12784
+ }
12785
+ async function upsertDailyTopicsEntry(mapPath, slug, entry, fileSystem = createNodeFileSystem()) {
12786
+ if (slug.trim() === "")
12787
+ throw new Error("daily-topics upsert: empty slug");
12788
+ let existing = {};
12789
+ if (await fileSystem.exists(mapPath)) {
12790
+ const raw = (await fileSystem.readFile(mapPath)).trim();
12791
+ if (raw !== "") {
12792
+ let parsed;
12793
+ try {
12794
+ parsed = JSON.parse(raw);
12795
+ } catch (error) {
12796
+ throw new Error(`daily-topics upsert: invalid JSON in ${mapPath}: ${error instanceof Error ? error.message : String(error)}`);
12797
+ }
12798
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
12799
+ throw new Error(`daily-topics upsert: ${mapPath} is not a JSON object`);
12800
+ }
12801
+ existing = parsed;
12802
+ }
12803
+ }
12804
+ existing[slug] = entry;
12805
+ await fileSystem.ensureDir(dirname3(mapPath));
12806
+ await fileSystem.writeFile(mapPath, `${JSON.stringify(existing, null, "\t")}
12807
+ `);
12808
+ }
12809
+
12673
12810
  // ../../plugins/publishings/surfdash-pub/src/index.ts
12674
12811
  var TARGET = "surfdash";
12675
12812
  var OPERATIONS = [
@@ -12745,7 +12882,7 @@ function failUncertain(error) {
12745
12882
  return failWithDeliveryState(error, "uncertain");
12746
12883
  }
12747
12884
  async function writePublishResult(outputPath, result) {
12748
- const outDir = dirname3(outputPath);
12885
+ const outDir = dirname4(outputPath);
12749
12886
  if (outDir && outDir !== ".") {
12750
12887
  await createNodeFileSystem().ensureDir(outDir);
12751
12888
  }
@@ -12795,7 +12932,7 @@ function deriveLocaleDraftPath(postPath, locale) {
12795
12932
  }
12796
12933
  function resolveSurfdashRoot() {
12797
12934
  const postsurfingBin = process.env.POSTSURFING_BIN ?? "postsurfing";
12798
- return process.env.SURFDASH_ROOT ?? (postsurfingBin.includes("/") ? resolve(dirname3(dirname3(postsurfingBin))) : undefined);
12935
+ return process.env.SURFDASH_ROOT ?? (postsurfingBin.includes("/") ? resolve(dirname4(dirname4(postsurfingBin))) : undefined);
12799
12936
  }
12800
12937
  async function spawnCli(cmd, cwd) {
12801
12938
  const env = { ...process.env };
@@ -12889,6 +13026,61 @@ async function runListenLinkBackfill(surfdashRoot) {
12889
13026
  const afterPaths = parsePorcelainPaths(after.stdout);
12890
13027
  return [...new Set(afterPaths.filter((p) => !beforePaths.has(p)))];
12891
13028
  }
13029
+ var DAILY_TOPICS_GIT_PATHS = ["scripts/seo/daily-topics.json", "content/posts"];
13030
+ async function runDailyTopicsSync(surfdashRoot, zhPostPath) {
13031
+ const enPath = localeIndexPath(zhPostPath, "en");
13032
+ const jaPath = localeIndexPath(zhPostPath, "ja");
13033
+ if (enPath === undefined || jaPath === undefined) {
13034
+ echoError(`daily-topics sync: skipped \u2014 ${zhPostPath} is not a zh locale post path`);
13035
+ return { ok: true, paths: [] };
13036
+ }
13037
+ if (!existsSync2(zhPostPath)) {
13038
+ echoError(`daily-topics sync: skipped \u2014 zh post is missing: ${zhPostPath}`);
13039
+ return { ok: true, paths: [] };
13040
+ }
13041
+ const zhPost = readFileSync2(zhPostPath, "utf-8");
13042
+ if (!isDigestMarkdown(zhPost)) {
13043
+ echoError(`daily-topics sync: skipped \u2014 not a digest post (no ${DIGEST_TAG} tag): ${zhPostPath}`);
13044
+ return { ok: true, paths: [] };
13045
+ }
13046
+ if (!existsSync2(enPath) || !existsSync2(jaPath)) {
13047
+ echoError(`daily-topics sync: skipped \u2014 locale index.md missing (en=${existsSync2(enPath)} ja=${existsSync2(jaPath)}): ${zhPostPath}`);
13048
+ return { ok: true, paths: [] };
13049
+ }
13050
+ const slug = slugFromPostPath(zhPostPath);
13051
+ if (slug === undefined) {
13052
+ return { ok: false, error: `daily-topics sync failed: cannot derive slug from ${zhPostPath}` };
13053
+ }
13054
+ const built = buildDailyTopicsEntry({
13055
+ zh: zhPost,
13056
+ en: readFileSync2(enPath, "utf-8"),
13057
+ ja: readFileSync2(jaPath, "utf-8")
13058
+ });
13059
+ if (!built.ok) {
13060
+ return { ok: false, error: `daily-topics sync failed: ${built.error}` };
13061
+ }
13062
+ const mapPath = join2(surfdashRoot, "scripts", "seo", "daily-topics.json");
13063
+ const before = await spawnCli(["git", "status", "--porcelain", "--", ...DAILY_TOPICS_GIT_PATHS], surfdashRoot);
13064
+ const beforePaths = new Set(parsePorcelainPaths(before.stdout));
13065
+ try {
13066
+ await upsertDailyTopicsEntry(mapPath, slug, built.entry);
13067
+ } catch (error) {
13068
+ return {
13069
+ ok: false,
13070
+ error: `daily-topics sync failed: ${error instanceof Error ? error.message : String(error)}`
13071
+ };
13072
+ }
13073
+ const retitle = await spawnCli(["bun", "run", "sd", "seo", "retitle", "--write", "--stamp-claims"], surfdashRoot);
13074
+ if (retitle.exitCode !== 0) {
13075
+ return {
13076
+ ok: false,
13077
+ error: `daily-topics sync failed: bun run sd seo retitle --write --stamp-claims (exit ${retitle.exitCode}): ${cliErrorText(retitle)}`
13078
+ };
13079
+ }
13080
+ const after = await spawnCli(["git", "status", "--porcelain", "--", ...DAILY_TOPICS_GIT_PATHS], surfdashRoot);
13081
+ const changed = parsePorcelainPaths(after.stdout).filter((p) => !beforePaths.has(p));
13082
+ return { ok: true, paths: [...new Set([relative(surfdashRoot, mapPath), ...changed])] };
13083
+ }
12892
13084
  var SITE_GATE_COMMANDS = [
12893
13085
  ["bun", "run", "sd", "check", "digest"],
12894
13086
  ["bun", "run", "check:content"]
@@ -12922,9 +13114,18 @@ function isUnrelatedDatePostFailure(output, ownedPaths) {
12922
13114
  }
12923
13115
  return true;
12924
13116
  }
13117
+ async function checkoutBranch(surfdashRoot) {
13118
+ const branch = await spawnCli(["git", "rev-parse", "--abbrev-ref", "HEAD"], surfdashRoot);
13119
+ return branch.exitCode === 0 ? branch.stdout.trim() : "";
13120
+ }
12925
13121
  async function runSiteGate(surfdashRoot, ownedPaths = []) {
13122
+ const pushingToMain = process.env.SURFDASH_AUTO_PUSH !== "0" && await checkoutBranch(surfdashRoot) === "main";
12926
13123
  if (process.env.SURFDASH_DIGEST_CHECK === "off") {
12927
- return { ok: true };
13124
+ if (pushingToMain) {
13125
+ echoError("site gate: SURFDASH_DIGEST_CHECK=off ignored \u2014 this run pushes to surfdash main, so the gate runs fail-closed");
13126
+ } else {
13127
+ return { ok: true };
13128
+ }
12928
13129
  }
12929
13130
  for (const cmd of SITE_GATE_COMMANDS) {
12930
13131
  const spawned = await spawnCli([...cmd], surfdashRoot);
@@ -12933,7 +13134,16 @@ async function runSiteGate(surfdashRoot, ownedPaths = []) {
12933
13134
  const postHint = extractFailingPostHint(output);
12934
13135
  const hint = postHint ? ` [failing post: ${postHint}]` : "";
12935
13136
  const error = `site gate failed: ${cmd.join(" ")} (exit ${spawned.exitCode})${hint}: ${output}`;
12936
- if (process.env.SURFDASH_DIGEST_CHECK === "warn" || isUnrelatedDatePostFailure(output, ownedPaths)) {
13137
+ const escapable = process.env.SURFDASH_DIGEST_CHECK === "warn" || isUnrelatedDatePostFailure(output, ownedPaths);
13138
+ if (escapable && pushingToMain) {
13139
+ echoError("site gate: warn/unrelated-date escape hatch ignored because this run pushes to surfdash main \u2014 failing closed (set SURFDASH_AUTO_PUSH=0 to skip the push entirely)");
13140
+ for (const line of error.split(`
13141
+ `)) {
13142
+ echoError(`site gate (blocked): ${line}`);
13143
+ }
13144
+ return { ok: false, error };
13145
+ }
13146
+ if (escapable) {
12937
13147
  for (const line of error.split(`
12938
13148
  `)) {
12939
13149
  echoError(`site gate (warn): ${line}`);
@@ -13083,9 +13293,9 @@ async function scaffoldLocale(options) {
13083
13293
  if (!existsSync2(draftPath)) {
13084
13294
  return fail(`sd translate reported success but the draft is missing: ${draftPath}`);
13085
13295
  }
13086
- const assetsDir = join2(dirname3(postPath.postPath), "assets");
13296
+ const assetsDir = join2(dirname4(postPath.postPath), "assets");
13087
13297
  if (existsSync2(assetsDir)) {
13088
- await cp(assetsDir, join2(dirname3(draftPath), "assets"), { recursive: true });
13298
+ await cp(assetsDir, join2(dirname4(draftPath), "assets"), { recursive: true });
13089
13299
  }
13090
13300
  return ResultSchema.parse({
13091
13301
  ok: true,
@@ -13183,13 +13393,18 @@ async function patchPost(options) {
13183
13393
  }
13184
13394
  if (outcome.changed === 0)
13185
13395
  echoError(`patch: no post bytes changed for ${outcome.slug}`);
13396
+ const topics = await runDailyTopicsSync(surfdashRoot, postPath.postPath);
13397
+ if (!topics.ok)
13398
+ return fail(topics.error);
13186
13399
  const synced = await syncPost({ postPath: postPath.postPath });
13187
13400
  const commitPaths = new Set(outcome.written.map((path) => relative(surfdashRoot, path)));
13401
+ for (const p of topics.paths)
13402
+ commitPaths.add(p);
13188
13403
  for (const locale of PATCH_LOCALES) {
13189
13404
  const indexMd = localeIndexPath(postPath.postPath, locale);
13190
13405
  if (!indexMd)
13191
13406
  continue;
13192
- const assetsDir = join2(dirname3(indexMd), "assets");
13407
+ const assetsDir = join2(dirname4(indexMd), "assets");
13193
13408
  if (existsSync2(assetsDir)) {
13194
13409
  commitPaths.add(relative(surfdashRoot, assetsDir));
13195
13410
  }
@@ -13374,7 +13589,7 @@ async function preparePost(payload) {
13374
13589
  const articlesRoot = resolve(surfdashRoot, "content", "posts", "articles");
13375
13590
  const localeRoot = resolve(articlesRoot, locale);
13376
13591
  const postDir = resolve(localeRoot, slug);
13377
- if (dirname3(localeRoot) !== articlesRoot || dirname3(postDir) !== localeRoot) {
13592
+ if (dirname4(localeRoot) !== articlesRoot || dirname4(postDir) !== localeRoot) {
13378
13593
  return { ok: false, result: failNotSent(`post path escapes ${articlesRoot}`) };
13379
13594
  }
13380
13595
  const coverPath = payload.content.metadata?.coverImage;
@@ -13489,13 +13704,16 @@ async function publishPreparedFile(prepared, identity) {
13489
13704
  }
13490
13705
  });
13491
13706
  }
13707
+ const topics = await runDailyTopicsSync(surfdashRoot, filePath);
13708
+ if (!topics.ok)
13709
+ return failUncertain(topics.error);
13492
13710
  const backfilled = await runListenLinkBackfill(surfdashRoot);
13493
13711
  const commitPaths = relPostDirs ?? [relPostDir];
13494
- const gate = await runSiteGate(surfdashRoot, [...commitPaths, ...backfilled]);
13712
+ const gate = await runSiteGate(surfdashRoot, [...commitPaths, ...backfilled, ...topics.paths]);
13495
13713
  if (!gate.ok)
13496
13714
  return failUncertain(gate.error);
13497
13715
  const commitLocales = relPostDirs === undefined ? [locale] : ["zh", "en", "ja"];
13498
- const pushed = await pushPostGit(surfdashRoot, commitPaths, `content: daily AI news ${dateStamp} (${commitLocales.join(", ")})`, backfilled);
13716
+ const pushed = await pushPostGit(surfdashRoot, commitPaths, `content: daily AI news ${dateStamp} (${commitLocales.join(", ")})`, [...backfilled, ...topics.paths]);
13499
13717
  if (!pushed.ok)
13500
13718
  return failUncertain(pushed.error);
13501
13719
  const live = await awaitArticleLive(articleUrl);
@@ -13652,6 +13870,7 @@ export {
13652
13870
  DIGEST_TAG,
13653
13871
  PostsurfingFileCliTransport,
13654
13872
  awaitArticleLive,
13873
+ buildDailyTopicsEntry,
13655
13874
  checkDigestFrontmatter,
13656
13875
  commitPostPaths,
13657
13876
  contentTags,
@@ -13659,6 +13878,7 @@ export {
13659
13878
  extractFailingPostHint,
13660
13879
  fastForwardToOrigin,
13661
13880
  getPublishTransport,
13881
+ isDigestMarkdown,
13662
13882
  main2 as main,
13663
13883
  mapContentToSurfingMarkdown,
13664
13884
  normalizeLocaleFrontmatter,
@@ -13667,8 +13887,11 @@ export {
13667
13887
  pushPostGit,
13668
13888
  readRefinedSnapshot,
13669
13889
  requireRefined,
13890
+ runDailyTopicsSync,
13670
13891
  runListenLinkBackfill,
13671
13892
  runSiteGate,
13893
+ slugFromPostPath,
13672
13894
  slugify2 as slugify,
13895
+ upsertDailyTopicsEntry,
13673
13896
  withEmdashTokenHint
13674
13897
  };