@gobing-ai/knowledge-kit 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/index.js +1765 -40
- package/package.json +1 -1
- package/plugins/generations/content-gen/dist/index.js +58 -52
- package/plugins/generations/content-gen/src/storm.ts +94 -61
- package/plugins/generations/core-facts-gen/dist/index.js +1 -1
- package/plugins/generations/daily-article-gen/dist/index.js +1 -1
- package/plugins/generations/dailynews-gen/dist/index.js +1 -1
- package/plugins/generations/episode-plan-gen/dist/index.js +1 -1
- package/plugins/generations/gemini-tts/dist/index.js +1 -1
- package/plugins/generations/image-gen/README.md +31 -10
- package/plugins/generations/image-gen/assets/sample/cover__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-cover__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__clean-webapp-ui.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__cute.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__daily-news.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__editorial.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__fresh.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__minimalist.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__photorealistic.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__sketch.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__technical-diagram.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__vibrant.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__warm.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__xhs-knowledge.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/free__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/illustration__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/xhs-card__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/dist/index.js +1 -1
- package/plugins/generations/image-gen/presets/formats/daily-news-podcast-cover.yaml +18 -0
- package/plugins/generations/image-gen/presets/styles/quasi-news-podcast.yaml +9 -0
- package/plugins/generations/news-report-gen/dist/index.js +1 -1
- package/plugins/generations/voice-gen/dist/index.js +1 -1
- package/plugins/generations/voxcpm-tts/dist/index.js +1 -1
- package/plugins/ingestions/aihot-ingest/dist/index.js +1 -1
- package/plugins/ingestions/horizon-ingest/dist/index.js +1 -1
- package/plugins/ingestions/last30days-ingest/dist/index.js +1 -1
- package/plugins/ingestions/web-search/dist/index.js +1 -1
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice-migration.json +12 -3
- package/plugins/kk/publish-presets/daily-ai-voice.json +17 -9
- package/plugins/kk/publish-presets/itc-main.json +42 -0
- package/plugins/kk/scripts/cover-compositor.ts +198 -0
- package/plugins/kk/scripts/daily-cover-mock.ts +164 -0
- package/plugins/kk/scripts/daily-scheduled-run.ts +188 -3
- package/plugins/kk/scripts/daily-stages.ts +134 -26
- package/plugins/kk/scripts/daily-triage-core.ts +451 -0
- package/plugins/kk/scripts/daily-triage.ts +74 -0
- package/plugins/kk/scripts/itc-stages.ts +3 -2
- package/plugins/kk/scripts/kk-workflow-stages.ts +31 -2
- package/plugins/kk/scripts/voice3-publish-window.ts +5 -1
- package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +16 -10
- package/plugins/kk/skills/news-editorial/SKILL.md +3 -3
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +2 -1
- package/plugins/kk/skills/publish/SKILL.md +1 -1
- package/plugins/kk/skills/wiki-authoring/SKILL.md +53 -0
- package/plugins/kk/skills/wiki-authoring/references/page-shapes.md +44 -0
- package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +3 -3
- package/plugins/kk/workflows/kk-daily-publish3.yaml +10 -3
- package/plugins/kk/workflows/kk-daily-safety.yaml +32 -7
- package/plugins/publishings/bilibili-pub/dist/index.js +90 -17
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +90 -16
- package/plugins/publishings/cnblogs-pub/dist/index.js +90 -17
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +90 -16
- package/plugins/publishings/csdn-pub/dist/index.js +90 -17
- package/plugins/publishings/csdn-pub/dist/profile-check.js +91 -17
- package/plugins/publishings/emdash-pub/dist/index.js +1 -1
- package/plugins/publishings/infoq-pub/dist/index.js +120 -19
- package/plugins/publishings/infoq-pub/dist/profile-check.js +95 -18
- package/plugins/publishings/infoq-pub/src/index.ts +40 -1
- package/plugins/publishings/jike-pub/dist/index.js +90 -17
- package/plugins/publishings/jike-pub/dist/profile-check.js +91 -17
- package/plugins/publishings/juejin-pub/dist/index.js +117 -20
- package/plugins/publishings/juejin-pub/dist/profile-check.js +94 -18
- package/plugins/publishings/juejin-pub/src/index.ts +41 -2
- package/plugins/publishings/linkedin-pub/dist/index.js +90 -17
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +91 -17
- package/plugins/publishings/medium-pub/dist/index.js +1 -1
- package/plugins/publishings/podcast-pub/dist/index.js +1 -1
- package/plugins/publishings/qiita-pub/dist/index.js +1 -1
- package/plugins/publishings/shipinhao-pub/dist/index.js +311 -66
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +138 -17
- package/plugins/publishings/shipinhao-pub/plugin.json +2 -2
- package/plugins/publishings/shipinhao-pub/src/flow.ts +335 -79
- package/plugins/publishings/shipinhao-pub/src/index.ts +16 -8
- package/plugins/publishings/shipinhao-pub/src/profile-check.ts +1 -1
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +103 -5
- package/plugins/publishings/sspai-pub/dist/index.js +90 -17
- package/plugins/publishings/sspai-pub/dist/profile-check.js +90 -16
- package/plugins/publishings/substack-pub/dist/index.js +90 -17
- package/plugins/publishings/substack-pub/dist/profile-check.js +91 -17
- package/plugins/publishings/surfdash-pub/dist/index.js +244 -13
- package/plugins/publishings/surfdash-pub/src/index.ts +144 -8
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +189 -0
- package/plugins/publishings/threads-pub/dist/index.js +1 -1
- package/plugins/publishings/wechatmp-pub/dist/index.js +186 -39
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +96 -19
- package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +14 -2
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +10 -3
- package/plugins/publishings/wechatmp-pub/src/flow.ts +158 -25
- package/plugins/publishings/wechatmp-pub/src/page.ts +14 -0
- package/plugins/publishings/wechatmp-pub/src/profile-check.ts +8 -1
- package/plugins/publishings/weibo-pub/dist/index.js +90 -17
- package/plugins/publishings/weibo-pub/dist/profile-check.js +91 -17
- package/plugins/publishings/x-pub/dist/index.js +90 -17
- package/plugins/publishings/x-pub/dist/profile-check.js +91 -17
- package/plugins/publishings/xhs-pub/dist/index.js +646 -47
- package/plugins/publishings/xhs-pub/dist/profile-check.js +109 -17
- package/plugins/publishings/xhs-pub/src/errors.ts +45 -0
- package/plugins/publishings/xhs-pub/src/flow.ts +773 -45
- package/plugins/publishings/xhs-pub/src/page.ts +33 -0
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +90 -17
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +90 -16
- package/plugins/publishings/zenn-pub/dist/index.js +94 -2
- package/plugins/publishings/zenn-pub/src/index.ts +134 -1
|
Binary file
|
|
Binary file
|
package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__xhs-knowledge.jpg
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -12398,7 +12398,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
|
|
|
12398
12398
|
shortVideo: Object.freeze({
|
|
12399
12399
|
douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12400
12400
|
kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12401
|
-
shipinhao: Object.freeze({ max:
|
|
12401
|
+
shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
|
|
12402
12402
|
})
|
|
12403
12403
|
})
|
|
12404
12404
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: daily-news-podcast-cover
|
|
2
|
+
description: Daily AI quasi-news podcast episode cover — fixed ultrawide composition with lower-third negative space for headline text
|
|
3
|
+
job: cover
|
|
4
|
+
aspectRatio: '21:9'
|
|
5
|
+
width: 1344
|
|
6
|
+
height: 576
|
|
7
|
+
defaultStyle: quasi-news-podcast
|
|
8
|
+
keywords: [editorial documentary, dramatic contrast, news podcast, lead story scene]
|
|
9
|
+
outputFilename: 'daily-news-podcast-cover.png'
|
|
10
|
+
variables:
|
|
11
|
+
subject:
|
|
12
|
+
description: Concrete visual scene for the day's lead story (objects, settings, symbols, dramatic lighting; no text)
|
|
13
|
+
default: an illuminated advanced semiconductor wafer glowing under industrial microscope inspection in a dark cleanroom
|
|
14
|
+
template: |-
|
|
15
|
+
Ultrawide quasi-news podcast cover background scene for a daily technology news report.
|
|
16
|
+
Scene: {{subject | an illuminated advanced semiconductor wafer glowing under industrial microscope inspection in a dark cleanroom}}.
|
|
17
|
+
Composition: dramatic cinematic lighting, clear focal subject in upper-center or right-third, generous dark negative space in the lower third for headline text overlay, uncluttered background.
|
|
18
|
+
Atmosphere: urgent, authoritative, investigative, cutting-edge technology journalism.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
name: quasi-news-podcast
|
|
2
|
+
description: House style for quasi-news podcast cover — editorial documentary photography, dramatic contrast, deep navy/slate shadows
|
|
3
|
+
modifiers: editorial documentary photography, cinematic dramatic lighting, high contrast, deep navy and slate shadows, crisp focal subject, clean composition, uncluttered lower third
|
|
4
|
+
palette:
|
|
5
|
+
- { role: background, name: deep navy slate, hex: '#0A1424' }
|
|
6
|
+
- { role: primary, name: signal white, hex: '#FFFFFF' }
|
|
7
|
+
- { role: accent, name: urgent amber, hex: '#FFB800' }
|
|
8
|
+
negative: text, letters, words, numbers, captions, watermark, logo, brand marks, flags, real people, recognizable faces, blurry, clutter, distorted graphics
|
|
9
|
+
source: { kind: authored }
|
|
@@ -12057,7 +12057,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
|
|
|
12057
12057
|
shortVideo: Object.freeze({
|
|
12058
12058
|
douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12059
12059
|
kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12060
|
-
shipinhao: Object.freeze({ max:
|
|
12060
|
+
shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
|
|
12061
12061
|
})
|
|
12062
12062
|
})
|
|
12063
12063
|
});
|
|
@@ -12057,7 +12057,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
|
|
|
12057
12057
|
shortVideo: Object.freeze({
|
|
12058
12058
|
douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12059
12059
|
kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12060
|
-
shipinhao: Object.freeze({ max:
|
|
12060
|
+
shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
|
|
12061
12061
|
})
|
|
12062
12062
|
})
|
|
12063
12063
|
});
|
|
@@ -12060,7 +12060,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
|
|
|
12060
12060
|
shortVideo: Object.freeze({
|
|
12061
12061
|
douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12062
12062
|
kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12063
|
-
shipinhao: Object.freeze({ max:
|
|
12063
|
+
shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
|
|
12064
12064
|
})
|
|
12065
12065
|
})
|
|
12066
12066
|
});
|
|
@@ -12309,7 +12309,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
|
|
|
12309
12309
|
shortVideo: Object.freeze({
|
|
12310
12310
|
douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12311
12311
|
kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12312
|
-
shipinhao: Object.freeze({ max:
|
|
12312
|
+
shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
|
|
12313
12313
|
})
|
|
12314
12314
|
})
|
|
12315
12315
|
});
|
|
@@ -12058,7 +12058,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
|
|
|
12058
12058
|
shortVideo: Object.freeze({
|
|
12059
12059
|
douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12060
12060
|
kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12061
|
-
shipinhao: Object.freeze({ max:
|
|
12061
|
+
shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
|
|
12062
12062
|
})
|
|
12063
12063
|
})
|
|
12064
12064
|
});
|
|
@@ -12059,7 +12059,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
|
|
|
12059
12059
|
shortVideo: Object.freeze({
|
|
12060
12060
|
douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12061
12061
|
kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12062
|
-
shipinhao: Object.freeze({ max:
|
|
12062
|
+
shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
|
|
12063
12063
|
})
|
|
12064
12064
|
})
|
|
12065
12065
|
});
|
|
@@ -12078,7 +12078,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
|
|
|
12078
12078
|
shortVideo: Object.freeze({
|
|
12079
12079
|
douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12080
12080
|
kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12081
|
-
shipinhao: Object.freeze({ max:
|
|
12081
|
+
shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
|
|
12082
12082
|
})
|
|
12083
12083
|
})
|
|
12084
12084
|
});
|
package/plugins/kk/plugin.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"variant": "episode",
|
|
30
30
|
"tier": 1,
|
|
31
31
|
"window": "after-generate",
|
|
32
|
-
"mode": "
|
|
32
|
+
"mode": "draft"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"id": "xhs.podcast",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"variant": "article",
|
|
60
60
|
"tier": 2,
|
|
61
61
|
"window": "after-generate",
|
|
62
|
-
"mode": "
|
|
62
|
+
"mode": "off"
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"id": "xhs.cards",
|
|
@@ -124,10 +124,19 @@
|
|
|
124
124
|
"window": "overseas-rss",
|
|
125
125
|
"mode": "dummy"
|
|
126
126
|
},
|
|
127
|
+
{
|
|
128
|
+
"id": "shipinhao.audio",
|
|
129
|
+
"plugin": "shipinhao-pub",
|
|
130
|
+
"operation": "audio",
|
|
131
|
+
"variant": "episode",
|
|
132
|
+
"tier": 1,
|
|
133
|
+
"window": "after-generate",
|
|
134
|
+
"mode": "draft"
|
|
135
|
+
},
|
|
127
136
|
{
|
|
128
137
|
"id": "shipinhao.cards",
|
|
129
138
|
"plugin": "shipinhao-pub",
|
|
130
|
-
"operation": "
|
|
139
|
+
"operation": "image",
|
|
131
140
|
"variant": "cards",
|
|
132
141
|
"tier": 3,
|
|
133
142
|
"window": "overseas-rss",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"variant": "article",
|
|
9
9
|
"tier": 0,
|
|
10
10
|
"window": "after-generate",
|
|
11
|
-
"mode": "
|
|
11
|
+
"mode": "live",
|
|
12
12
|
"required": true
|
|
13
13
|
},
|
|
14
14
|
{
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"variant": "episode",
|
|
18
18
|
"tier": 0,
|
|
19
19
|
"window": "after-generate",
|
|
20
|
-
"mode": "
|
|
20
|
+
"mode": "live",
|
|
21
21
|
"required": true
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"variant": "episode",
|
|
27
27
|
"tier": 1,
|
|
28
28
|
"window": "after-generate",
|
|
29
|
-
"mode": "
|
|
29
|
+
"mode": "live"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"plugin": "xhs-pub",
|
|
@@ -34,7 +34,15 @@
|
|
|
34
34
|
"variant": "episode",
|
|
35
35
|
"tier": 1,
|
|
36
36
|
"window": "after-generate",
|
|
37
|
-
"mode": "
|
|
37
|
+
"mode": "live"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"plugin": "shipinhao-pub",
|
|
41
|
+
"operation": "audio",
|
|
42
|
+
"variant": "episode",
|
|
43
|
+
"tier": 1,
|
|
44
|
+
"window": "after-generate",
|
|
45
|
+
"mode": "live"
|
|
38
46
|
},
|
|
39
47
|
{
|
|
40
48
|
"plugin": "wechatmp-pub",
|
|
@@ -42,7 +50,7 @@
|
|
|
42
50
|
"variant": "article",
|
|
43
51
|
"tier": 2,
|
|
44
52
|
"window": "after-generate",
|
|
45
|
-
"mode": "
|
|
53
|
+
"mode": "live",
|
|
46
54
|
"options": {
|
|
47
55
|
"collection": "每日AI资讯"
|
|
48
56
|
}
|
|
@@ -53,7 +61,7 @@
|
|
|
53
61
|
"variant": "article",
|
|
54
62
|
"tier": 2,
|
|
55
63
|
"window": "after-generate",
|
|
56
|
-
"mode": "
|
|
64
|
+
"mode": "off"
|
|
57
65
|
},
|
|
58
66
|
{
|
|
59
67
|
"plugin": "xhs-pub",
|
|
@@ -61,7 +69,7 @@
|
|
|
61
69
|
"variant": "cards",
|
|
62
70
|
"tier": 3,
|
|
63
71
|
"window": "after-generate",
|
|
64
|
-
"mode": "
|
|
72
|
+
"mode": "live"
|
|
65
73
|
},
|
|
66
74
|
{
|
|
67
75
|
"plugin": "weibo-pub",
|
|
@@ -69,7 +77,7 @@
|
|
|
69
77
|
"variant": "article",
|
|
70
78
|
"tier": 2,
|
|
71
79
|
"window": "cn-peak",
|
|
72
|
-
"mode": "
|
|
80
|
+
"mode": "live"
|
|
73
81
|
},
|
|
74
82
|
{
|
|
75
83
|
"plugin": "x-pub",
|
|
@@ -113,7 +121,7 @@
|
|
|
113
121
|
},
|
|
114
122
|
{
|
|
115
123
|
"plugin": "shipinhao-pub",
|
|
116
|
-
"operation": "
|
|
124
|
+
"operation": "image",
|
|
117
125
|
"variant": "cards",
|
|
118
126
|
"tier": 3,
|
|
119
127
|
"window": "overseas-rss",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"name": "itc-main",
|
|
4
|
+
"targets": [
|
|
5
|
+
{
|
|
6
|
+
"plugin": "surfdash-pub",
|
|
7
|
+
"profile": "article"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"plugin": "infoq-pub",
|
|
11
|
+
"profile": "article"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"plugin": "juejin-pub",
|
|
15
|
+
"profile": "article"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"plugin": "wechatmp-pub",
|
|
19
|
+
"profile": "article"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"plugin": "x-pub",
|
|
23
|
+
"profile": "article-zh"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"plugin": "zenn-pub",
|
|
27
|
+
"profile": "article"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"plugin": "qiita-pub",
|
|
31
|
+
"profile": "article"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"plugin": "medium-pub",
|
|
35
|
+
"profile": "article"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"plugin": "substack-pub",
|
|
39
|
+
"profile": "article"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 0348 / ADR-046 layer 2 — deterministic typography and branding compositor for the quasi-news
|
|
8
|
+
* podcast cover. AI diffusion renders the background only (strict negative text prompt, 0347);
|
|
9
|
+
* this module renders the Chinese headline and the podcast emblem as real vector layers, so no
|
|
10
|
+
* glyph ever passes through the model. Output is a 1344x576 PNG composited via macOS `sips`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface CoverCompositorOptions {
|
|
14
|
+
backgroundImagePath: string;
|
|
15
|
+
/**
|
|
16
|
+
* Background as a `data:` URI. `compositeCover` always sets it: `sips` cannot rasterize an
|
|
17
|
+
* SVG `<image href="file://…">`, so the file-URL form silently rendered only the overlay
|
|
18
|
+
* chrome (the placeholder-looking cover that shipped on 2026-11-11) plus a lost headline.
|
|
19
|
+
* The field is optional only so the pure template probes can exercise the legacy form.
|
|
20
|
+
*/
|
|
21
|
+
backgroundUri?: string;
|
|
22
|
+
headline: string;
|
|
23
|
+
leadStoryTitle?: string;
|
|
24
|
+
/** Defaults to the repo `assets/general/xhxs.svg`; a missing asset omits the badge. */
|
|
25
|
+
logoPath?: string;
|
|
26
|
+
outputPath: string;
|
|
27
|
+
width?: number; // default 1344
|
|
28
|
+
height?: number; // default 576
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const COVER_WIDTH = 1344;
|
|
32
|
+
export const COVER_HEIGHT = 576;
|
|
33
|
+
/** Max Chinese characters per headline line (news-editorial style contract, 0347). */
|
|
34
|
+
export const HEADLINE_LINE_CAP = 25;
|
|
35
|
+
const FONT_STACK = `PingFang SC, Hiragino Sans GB, 'Noto Sans CJK SC', sans-serif`;
|
|
36
|
+
|
|
37
|
+
/** XML-escape a text node or attribute value (headlines are model-authored, so assume the worst). */
|
|
38
|
+
function esc(text: string): string {
|
|
39
|
+
return text.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Split a headline into at most two lines: explicit `\n` wins, otherwise chunk at
|
|
44
|
+
* HEADLINE_LINE_CAP characters. Anything past two lines truncates with an ellipsis —
|
|
45
|
+
* the style contract caps headlines at 2 x 25 chars, so this is a last-resort guard.
|
|
46
|
+
*/
|
|
47
|
+
export function wrapHeadline(headline: string): string[] {
|
|
48
|
+
const hasBreaks = headline.includes('\n');
|
|
49
|
+
const source = hasBreaks
|
|
50
|
+
? headline
|
|
51
|
+
.split('\n')
|
|
52
|
+
.map((line) => line.trim())
|
|
53
|
+
.filter((line) => line.length > 0)
|
|
54
|
+
: chunk(headline.replaceAll('\n', ' ').trim());
|
|
55
|
+
if (source.length <= 2) return source;
|
|
56
|
+
// >2 lines: keep line 1 whole, squeeze the rest into one ellipsized line.
|
|
57
|
+
const rest = source.slice(1).join(' ');
|
|
58
|
+
const second = chunk(rest)[0] ?? '';
|
|
59
|
+
if (rest.length <= second.length) return [source[0], second];
|
|
60
|
+
return [source[0], `${second.slice(0, HEADLINE_LINE_CAP - 1)}…`];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Estimated rendered width in px for the mixed CJK/Latin headline: `sips` has no text metrics we
|
|
65
|
+
* can read back, so each code point is charged its rough advance (CJK ≈ 1em, Latin ≈ 0.55em,
|
|
66
|
+
* space ≈ 0.28em). Used only to shrink a line until it fits — a clipped headline is worse than a
|
|
67
|
+
* smaller one (the 2026-11-12 regeneration clipped "Anthropic" at the canvas edge).
|
|
68
|
+
*/
|
|
69
|
+
function estimateWidth(text: string, fontSize: number): number {
|
|
70
|
+
let em = 0;
|
|
71
|
+
for (const ch of text) {
|
|
72
|
+
if (/\s/.test(ch)) em += 0.28;
|
|
73
|
+
else if (/[\u2E80-\u9FFF\uF900-\uFAFF\uFF00-\uFF60\u3000-\u303F]/.test(ch)) em += 1;
|
|
74
|
+
else em += 0.55;
|
|
75
|
+
}
|
|
76
|
+
return em * fontSize;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Largest size <= `baseSize` at which `text` fits `maxWidth`, floored so it stays legible. */
|
|
80
|
+
export function fitFontSize(text: string, baseSize: number, maxWidth: number, floorSize = 24): number {
|
|
81
|
+
let size = baseSize;
|
|
82
|
+
while (size > floorSize && estimateWidth(text, size) > maxWidth) size -= 1;
|
|
83
|
+
return size;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Fixed-width chunker for CJK headlines — code points, not UTF-16 units. */
|
|
87
|
+
function chunk(text: string): string[] {
|
|
88
|
+
const chars = Array.from(text);
|
|
89
|
+
const lines: string[] = [];
|
|
90
|
+
for (let i = 0; i < chars.length; i += HEADLINE_LINE_CAP)
|
|
91
|
+
lines.push(chars.slice(i, i + HEADLINE_LINE_CAP).join(''));
|
|
92
|
+
return lines;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Inline the logo SVG with its lower text band (`SALTY CLUB`, y >= 780 of the 1095-tall
|
|
97
|
+
* viewBox) cropped away by re-clipping to `0 0 1095 760`. Returns '' when the asset is
|
|
98
|
+
* absent — the badge is branding, not content, so a missing file degrades instead of failing.
|
|
99
|
+
*/
|
|
100
|
+
export function logoBadgeSvg(logoPath: string, x: number, y: number, width: number, height: number): string {
|
|
101
|
+
if (!existsSync(logoPath)) {
|
|
102
|
+
console.error(`cover compositor: logo asset missing, badge omitted (${logoPath})`);
|
|
103
|
+
return '';
|
|
104
|
+
}
|
|
105
|
+
const raw = readFileSync(logoPath, 'utf-8');
|
|
106
|
+
const open = raw.indexOf('>', raw.indexOf('<svg'));
|
|
107
|
+
const close = raw.lastIndexOf('</svg>');
|
|
108
|
+
if (open === -1 || close === -1) {
|
|
109
|
+
console.error('cover compositor: logo asset is not a parseable svg, badge omitted');
|
|
110
|
+
return '';
|
|
111
|
+
}
|
|
112
|
+
const inner = raw.slice(open + 1, close);
|
|
113
|
+
return `<svg x="${x}" y="${y}" width="${width}" height="${height}" viewBox="0 0 1095 760" preserveAspectRatio="xMidYMid meet">${inner}</svg>`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Deterministic SVG overlay: background image, bottom scrim, logo badge, headline, podcast tag. */
|
|
117
|
+
export function buildCoverSvg(options: CoverCompositorOptions): string {
|
|
118
|
+
const width = options.width ?? COVER_WIDTH;
|
|
119
|
+
const height = options.height ?? COVER_HEIGHT;
|
|
120
|
+
const lines = wrapHeadline(options.headline);
|
|
121
|
+
const logo = logoBadgeSvg(options.logoPath ?? 'assets/general/xhxs.svg', 48, 40, 72, 50);
|
|
122
|
+
|
|
123
|
+
// 2026-11-12 regression: `sips` drops EVERY `<text>` that carries an SVG filter, so the
|
|
124
|
+
// headline never rasterized (both the 11-11 and 11-12 covers shipped chrome with no headline).
|
|
125
|
+
// Contrast comes from the bottom scrim plus a geometric shadow — the same text drawn once in
|
|
126
|
+
// dark behind the visible line — because that is plain geometry, not a filter.
|
|
127
|
+
const line = (text: string, y: number, size: number, weight: number, fill: string): string =>
|
|
128
|
+
`<text x="48" y="${y + 3}" font-family="${FONT_STACK}" font-size="${size}" font-weight="${weight}" fill="#000000" fill-opacity="0.72">${esc(text)}</text>
|
|
129
|
+
<text x="48" y="${y}" font-family="${FONT_STACK}" font-size="${size}" font-weight="${weight}" fill="${fill}">${esc(text)}</text>`;
|
|
130
|
+
const textWidth = width - 96;
|
|
131
|
+
const typography =
|
|
132
|
+
lines.length === 1
|
|
133
|
+
? line(lines[0], 500, fitFontSize(lines[0], 46, textWidth), 800, '#FFFFFF')
|
|
134
|
+
: `${line(lines[0], 472, fitFontSize(lines[0], 46, textWidth), 800, '#FFFFFF')}
|
|
135
|
+
${line(lines[1], 532, fitFontSize(lines[1], 32, textWidth), 700, '#FFB800')}`;
|
|
136
|
+
|
|
137
|
+
const badge =
|
|
138
|
+
logo !== ''
|
|
139
|
+
? `<rect x="36" y="30" width="96" height="70" rx="12" fill="#0a1424" fill-opacity="0.7" />
|
|
140
|
+
${logo}`
|
|
141
|
+
: '';
|
|
142
|
+
|
|
143
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
144
|
+
<image href="${options.backgroundUri ?? encodeURI(`file://${resolve(options.backgroundImagePath)}`)}" x="0" y="0" width="${width}" height="${height}" preserveAspectRatio="xMidYMid slice" />
|
|
145
|
+
<defs>
|
|
146
|
+
<linearGradient id="bottomScrim" x1="0" y1="0" x2="0" y2="1">
|
|
147
|
+
<stop offset="0" stop-color="#0a1424" stop-opacity="0" />
|
|
148
|
+
<stop offset="1" stop-color="#0a1424" stop-opacity="0.92" />
|
|
149
|
+
</linearGradient>
|
|
150
|
+
</defs>
|
|
151
|
+
<rect x="0" y="${Math.round(height * 0.45)}" width="${width}" height="${height - Math.round(height * 0.45)}" fill="url(#bottomScrim)" />
|
|
152
|
+
${badge}
|
|
153
|
+
${typography}
|
|
154
|
+
<text x="${width - 48}" y="${height - 40}" text-anchor="end" font-family="${FONT_STACK}" font-size="18" font-weight="600" letter-spacing="2" fill="#FFFFFF" fill-opacity="0.85">DAILY AI PODCAST</text>
|
|
155
|
+
</svg>
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Render `buildCoverSvg` to a PNG at `outputPath` via macOS `sips` (ships with the OS; no
|
|
161
|
+
* native image dependency). Fail-fast: a missing `sips` or nonzero transcode throws with an
|
|
162
|
+
* actionable message — the daily run must not publish a half-composited cover.
|
|
163
|
+
*/
|
|
164
|
+
/** Inline the background as a data URI so `sips` actually rasterizes it (see the option doc). */
|
|
165
|
+
function backgroundDataUri(path: string): string {
|
|
166
|
+
const lower = path.toLowerCase();
|
|
167
|
+
const mime = lower.endsWith('.jpg') || lower.endsWith('.jpeg') ? 'image/jpeg' : 'image/png';
|
|
168
|
+
return `data:${mime};base64,${readFileSync(path).toString('base64')}`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function compositeCover(options: CoverCompositorOptions): string {
|
|
172
|
+
const svgPath = join(tmpdir(), `cover-composite-${Date.now()}.svg`);
|
|
173
|
+
writeFileSync(
|
|
174
|
+
svgPath,
|
|
175
|
+
buildCoverSvg({ ...options, backgroundUri: backgroundDataUri(options.backgroundImagePath) }),
|
|
176
|
+
'utf-8',
|
|
177
|
+
);
|
|
178
|
+
try {
|
|
179
|
+
const sips = spawnSync('sips', ['-s', 'format', 'png', svgPath, '--out', options.outputPath], {
|
|
180
|
+
stdio: 'ignore',
|
|
181
|
+
});
|
|
182
|
+
// Bun reports a missing binary as `status: undefined` plus an `error` object.
|
|
183
|
+
if (sips.error !== undefined || typeof sips.status !== 'number') {
|
|
184
|
+
throw new Error('cover compositor: sips not found; cannot render the cover overlay (macOS required)');
|
|
185
|
+
}
|
|
186
|
+
if (sips.status !== 0) {
|
|
187
|
+
throw new Error(`cover compositor: sips failed (status ${sips.status}); overlay did not render`);
|
|
188
|
+
}
|
|
189
|
+
// sips exits 0 even when it silently fails to place the output (missing parent dir) —
|
|
190
|
+
// a render that claims success without a file would leave a stale cover downstream.
|
|
191
|
+
if (!existsSync(options.outputPath)) {
|
|
192
|
+
throw new Error(`cover compositor: sips reported success but ${options.outputPath} is missing`);
|
|
193
|
+
}
|
|
194
|
+
} finally {
|
|
195
|
+
rmSync(svgPath, { force: true });
|
|
196
|
+
}
|
|
197
|
+
return options.outputPath;
|
|
198
|
+
}
|