@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.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/index.js +1603 -1
- 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 +11 -3
- package/plugins/kk/scripts/cover-compositor.ts +152 -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/kk-workflow-stages.ts +31 -2
- 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-safety.yaml +32 -7
- package/plugins/publishings/bilibili-pub/dist/index.js +1 -1
- package/plugins/publishings/cnblogs-pub/dist/index.js +1 -1
- package/plugins/publishings/csdn-pub/dist/index.js +1 -1
- package/plugins/publishings/csdn-pub/dist/profile-check.js +1 -1
- package/plugins/publishings/emdash-pub/dist/index.js +1 -1
- package/plugins/publishings/infoq-pub/dist/index.js +1 -1
- package/plugins/publishings/infoq-pub/dist/profile-check.js +1 -1
- package/plugins/publishings/jike-pub/dist/index.js +1 -1
- package/plugins/publishings/jike-pub/dist/profile-check.js +1 -1
- package/plugins/publishings/juejin-pub/dist/index.js +1 -1
- package/plugins/publishings/juejin-pub/dist/profile-check.js +1 -1
- package/plugins/publishings/linkedin-pub/dist/index.js +1 -1
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +1 -1
- 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 +222 -50
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +48 -1
- 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 +1 -1
- package/plugins/publishings/substack-pub/dist/index.js +1 -1
- package/plugins/publishings/substack-pub/dist/profile-check.js +1 -1
- package/plugins/publishings/surfdash-pub/dist/index.js +235 -12
- package/plugins/publishings/surfdash-pub/src/index.ts +127 -6
- 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 +10 -7
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +1 -1
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +10 -3
- package/plugins/publishings/wechatmp-pub/src/flow.ts +3 -4
- package/plugins/publishings/wechatmp-pub/src/page.ts +14 -0
- package/plugins/publishings/weibo-pub/dist/index.js +1 -1
- package/plugins/publishings/weibo-pub/dist/profile-check.js +1 -1
- package/plugins/publishings/x-pub/dist/index.js +1 -1
- package/plugins/publishings/x-pub/dist/profile-check.js +1 -1
- package/plugins/publishings/xhs-pub/dist/index.js +557 -31
- package/plugins/publishings/xhs-pub/dist/profile-check.js +20 -1
- 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 +1 -1
- package/plugins/publishings/zenn-pub/dist/index.js +1 -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",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"variant": "episode",
|
|
27
27
|
"tier": 1,
|
|
28
28
|
"window": "after-generate",
|
|
29
|
-
"mode": "
|
|
29
|
+
"mode": "draft"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"plugin": "xhs-pub",
|
|
@@ -36,6 +36,14 @@
|
|
|
36
36
|
"window": "after-generate",
|
|
37
37
|
"mode": "draft"
|
|
38
38
|
},
|
|
39
|
+
{
|
|
40
|
+
"plugin": "shipinhao-pub",
|
|
41
|
+
"operation": "audio",
|
|
42
|
+
"variant": "episode",
|
|
43
|
+
"tier": 1,
|
|
44
|
+
"window": "after-generate",
|
|
45
|
+
"mode": "draft"
|
|
46
|
+
},
|
|
39
47
|
{
|
|
40
48
|
"plugin": "wechatmp-pub",
|
|
41
49
|
"operation": "文章",
|
|
@@ -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",
|
|
@@ -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,152 @@
|
|
|
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
|
+
headline: string;
|
|
16
|
+
leadStoryTitle?: string;
|
|
17
|
+
/** Defaults to the repo `assets/general/xhxs.svg`; a missing asset omits the badge. */
|
|
18
|
+
logoPath?: string;
|
|
19
|
+
outputPath: string;
|
|
20
|
+
width?: number; // default 1344
|
|
21
|
+
height?: number; // default 576
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const COVER_WIDTH = 1344;
|
|
25
|
+
export const COVER_HEIGHT = 576;
|
|
26
|
+
/** Max Chinese characters per headline line (news-editorial style contract, 0347). */
|
|
27
|
+
export const HEADLINE_LINE_CAP = 25;
|
|
28
|
+
const FONT_STACK = `PingFang SC, Hiragino Sans GB, 'Noto Sans CJK SC', sans-serif`;
|
|
29
|
+
|
|
30
|
+
/** XML-escape a text node or attribute value (headlines are model-authored, so assume the worst). */
|
|
31
|
+
function esc(text: string): string {
|
|
32
|
+
return text.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Split a headline into at most two lines: explicit `\n` wins, otherwise chunk at
|
|
37
|
+
* HEADLINE_LINE_CAP characters. Anything past two lines truncates with an ellipsis —
|
|
38
|
+
* the style contract caps headlines at 2 x 25 chars, so this is a last-resort guard.
|
|
39
|
+
*/
|
|
40
|
+
export function wrapHeadline(headline: string): string[] {
|
|
41
|
+
const hasBreaks = headline.includes('\n');
|
|
42
|
+
const source = hasBreaks
|
|
43
|
+
? headline
|
|
44
|
+
.split('\n')
|
|
45
|
+
.map((line) => line.trim())
|
|
46
|
+
.filter((line) => line.length > 0)
|
|
47
|
+
: chunk(headline.replaceAll('\n', ' ').trim());
|
|
48
|
+
if (source.length <= 2) return source;
|
|
49
|
+
// >2 lines: keep line 1 whole, squeeze the rest into one ellipsized line.
|
|
50
|
+
const rest = source.slice(1).join(' ');
|
|
51
|
+
const second = chunk(rest)[0] ?? '';
|
|
52
|
+
if (rest.length <= second.length) return [source[0], second];
|
|
53
|
+
return [source[0], `${second.slice(0, HEADLINE_LINE_CAP - 1)}…`];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Fixed-width chunker for CJK headlines — code points, not UTF-16 units. */
|
|
57
|
+
function chunk(text: string): string[] {
|
|
58
|
+
const chars = Array.from(text);
|
|
59
|
+
const lines: string[] = [];
|
|
60
|
+
for (let i = 0; i < chars.length; i += HEADLINE_LINE_CAP)
|
|
61
|
+
lines.push(chars.slice(i, i + HEADLINE_LINE_CAP).join(''));
|
|
62
|
+
return lines;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Inline the logo SVG with its lower text band (`SALTY CLUB`, y >= 780 of the 1095-tall
|
|
67
|
+
* viewBox) cropped away by re-clipping to `0 0 1095 760`. Returns '' when the asset is
|
|
68
|
+
* absent — the badge is branding, not content, so a missing file degrades instead of failing.
|
|
69
|
+
*/
|
|
70
|
+
export function logoBadgeSvg(logoPath: string, x: number, y: number, width: number, height: number): string {
|
|
71
|
+
if (!existsSync(logoPath)) {
|
|
72
|
+
console.error(`cover compositor: logo asset missing, badge omitted (${logoPath})`);
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
const raw = readFileSync(logoPath, 'utf-8');
|
|
76
|
+
const open = raw.indexOf('>', raw.indexOf('<svg'));
|
|
77
|
+
const close = raw.lastIndexOf('</svg>');
|
|
78
|
+
if (open === -1 || close === -1) {
|
|
79
|
+
console.error('cover compositor: logo asset is not a parseable svg, badge omitted');
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
const inner = raw.slice(open + 1, close);
|
|
83
|
+
return `<svg x="${x}" y="${y}" width="${width}" height="${height}" viewBox="0 0 1095 760" preserveAspectRatio="xMidYMid meet">${inner}</svg>`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Deterministic SVG overlay: background image, bottom scrim, logo badge, headline, podcast tag. */
|
|
87
|
+
export function buildCoverSvg(options: CoverCompositorOptions): string {
|
|
88
|
+
const width = options.width ?? COVER_WIDTH;
|
|
89
|
+
const height = options.height ?? COVER_HEIGHT;
|
|
90
|
+
const lines = wrapHeadline(options.headline);
|
|
91
|
+
const logo = logoBadgeSvg(options.logoPath ?? 'assets/general/xhxs.svg', 48, 40, 72, 50);
|
|
92
|
+
|
|
93
|
+
const typography =
|
|
94
|
+
lines.length === 1
|
|
95
|
+
? `<text x="48" y="500" font-family="${FONT_STACK}" font-size="46" font-weight="800" fill="#FFFFFF" filter="url(#textShadow)">${esc(lines[0])}</text>`
|
|
96
|
+
: `<text x="48" y="472" font-family="${FONT_STACK}" font-size="46" font-weight="800" fill="#FFFFFF" filter="url(#textShadow)">${esc(lines[0])}</text>
|
|
97
|
+
<text x="48" y="532" font-family="${FONT_STACK}" font-size="32" font-weight="700" fill="#FFB800" filter="url(#textShadow)">${esc(lines[1])}</text>`;
|
|
98
|
+
|
|
99
|
+
const badge =
|
|
100
|
+
logo !== ''
|
|
101
|
+
? `<rect x="36" y="30" width="96" height="70" rx="12" fill="#0a1424" fill-opacity="0.7" />
|
|
102
|
+
${logo}`
|
|
103
|
+
: '';
|
|
104
|
+
|
|
105
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
106
|
+
<image href="${encodeURI(`file://${resolve(options.backgroundImagePath)}`)}" x="0" y="0" width="${width}" height="${height}" preserveAspectRatio="xMidYMid slice" />
|
|
107
|
+
<defs>
|
|
108
|
+
<linearGradient id="bottomScrim" x1="0" y1="0" x2="0" y2="1">
|
|
109
|
+
<stop offset="0" stop-color="#0a1424" stop-opacity="0" />
|
|
110
|
+
<stop offset="1" stop-color="#0a1424" stop-opacity="0.92" />
|
|
111
|
+
</linearGradient>
|
|
112
|
+
<filter id="textShadow" x="-20%" y="-20%" width="140%" height="140%">
|
|
113
|
+
<feDropShadow dx="0" dy="3" stdDeviation="6" flood-color="#000000" flood-opacity="0.85" />
|
|
114
|
+
</filter>
|
|
115
|
+
</defs>
|
|
116
|
+
<rect x="0" y="${Math.round(height * 0.45)}" width="${width}" height="${height - Math.round(height * 0.45)}" fill="url(#bottomScrim)" />
|
|
117
|
+
${badge}
|
|
118
|
+
${typography}
|
|
119
|
+
<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>
|
|
120
|
+
</svg>
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Render `buildCoverSvg` to a PNG at `outputPath` via macOS `sips` (ships with the OS; no
|
|
126
|
+
* native image dependency). Fail-fast: a missing `sips` or nonzero transcode throws with an
|
|
127
|
+
* actionable message — the daily run must not publish a half-composited cover.
|
|
128
|
+
*/
|
|
129
|
+
export function compositeCover(options: CoverCompositorOptions): string {
|
|
130
|
+
const svgPath = join(tmpdir(), `cover-composite-${Date.now()}.svg`);
|
|
131
|
+
writeFileSync(svgPath, buildCoverSvg(options), 'utf-8');
|
|
132
|
+
try {
|
|
133
|
+
const sips = spawnSync('sips', ['-s', 'format', 'png', svgPath, '--out', options.outputPath], {
|
|
134
|
+
stdio: 'ignore',
|
|
135
|
+
});
|
|
136
|
+
// Bun reports a missing binary as `status: undefined` plus an `error` object.
|
|
137
|
+
if (sips.error !== undefined || typeof sips.status !== 'number') {
|
|
138
|
+
throw new Error('cover compositor: sips not found; cannot render the cover overlay (macOS required)');
|
|
139
|
+
}
|
|
140
|
+
if (sips.status !== 0) {
|
|
141
|
+
throw new Error(`cover compositor: sips failed (status ${sips.status}); overlay did not render`);
|
|
142
|
+
}
|
|
143
|
+
// sips exits 0 even when it silently fails to place the output (missing parent dir) —
|
|
144
|
+
// a render that claims success without a file would leave a stale cover downstream.
|
|
145
|
+
if (!existsSync(options.outputPath)) {
|
|
146
|
+
throw new Error(`cover compositor: sips reported success but ${options.outputPath} is missing`);
|
|
147
|
+
}
|
|
148
|
+
} finally {
|
|
149
|
+
rmSync(svgPath, { force: true });
|
|
150
|
+
}
|
|
151
|
+
return options.outputPath;
|
|
152
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* 0349 R2: standalone mock cover runner — end-to-end cover verification without a daily cron
|
|
4
|
+
* run. `--mock-bg` renders a local 1344×576 gradient background via SVG→sips (zero tokens,
|
|
5
|
+
* fully offline); otherwise the background is generated through `kk executor run image-gen`
|
|
6
|
+
* with the pinned daily-news-podcast presets. Either way the headline is composited through
|
|
7
|
+
* the same `compositeCover` the daily pipeline uses, then the output is dimension-verified.
|
|
8
|
+
*/
|
|
9
|
+
import { spawnSync } from 'node:child_process';
|
|
10
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { tmpdir } from 'node:os';
|
|
12
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
13
|
+
import { parseArgs } from 'node:util';
|
|
14
|
+
import { COVER_HEIGHT, COVER_WIDTH, compositeCover } from './cover-compositor';
|
|
15
|
+
|
|
16
|
+
interface MockOptions {
|
|
17
|
+
headline: string;
|
|
18
|
+
scene: string;
|
|
19
|
+
out: string;
|
|
20
|
+
provider: string;
|
|
21
|
+
mockBg: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const MOCK_BG_SVG = `<?xml version="1.0" encoding="UTF-8"?>
|
|
25
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="${COVER_WIDTH}" height="${COVER_HEIGHT}" viewBox="0 0 ${COVER_WIDTH} ${COVER_HEIGHT}">
|
|
26
|
+
<defs>
|
|
27
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
28
|
+
<stop offset="0" stop-color="#0d1e33"/>
|
|
29
|
+
<stop offset="0.55" stop-color="#123252"/>
|
|
30
|
+
<stop offset="1" stop-color="#0a1424"/>
|
|
31
|
+
</linearGradient>
|
|
32
|
+
<radialGradient id="glow" cx="0.72" cy="0.35" r="0.5">
|
|
33
|
+
<stop offset="0" stop-color="#2f6da8" stop-opacity="0.55"/>
|
|
34
|
+
<stop offset="1" stop-color="#2f6da8" stop-opacity="0"/>
|
|
35
|
+
</radialGradient>
|
|
36
|
+
</defs>
|
|
37
|
+
<rect width="100%" height="100%" fill="url(#bg)"/>
|
|
38
|
+
<rect width="100%" height="100%" fill="url(#glow)"/>
|
|
39
|
+
<!-- scene placeholder: the live path puts diffusion imagery here -->
|
|
40
|
+
<text x="24" y="${COVER_HEIGHT - 24}" font-family="Helvetica, Arial, sans-serif" font-size="15" fill="#5a7ea6">MOCK BACKGROUND — ${COVER_WIDTH}x${COVER_HEIGHT}</text>
|
|
41
|
+
</svg>`;
|
|
42
|
+
|
|
43
|
+
function parseMockArgs(args: string[]): MockOptions {
|
|
44
|
+
const { values } = parseArgs({
|
|
45
|
+
args,
|
|
46
|
+
options: {
|
|
47
|
+
headline: { type: 'string', default: '重大突破:下一代AI深度推理时代正式开启' },
|
|
48
|
+
scene: { type: 'string', default: 'an illuminated advanced semiconductor wafer glowing in dark cleanroom' },
|
|
49
|
+
out: { type: 'string', default: '/tmp/kk-cover-mock.png' },
|
|
50
|
+
provider: { type: 'string', default: '' },
|
|
51
|
+
'mock-bg': { type: 'boolean', default: false },
|
|
52
|
+
},
|
|
53
|
+
strict: true,
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
headline: values.headline ?? '',
|
|
57
|
+
scene: values.scene ?? '',
|
|
58
|
+
out: resolve(values.out ?? ''),
|
|
59
|
+
provider: values.provider ?? '',
|
|
60
|
+
mockBg: values['mock-bg'] ?? false,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Render the mock background SVG to PNG via sips (mac-only, ADR-046). */
|
|
65
|
+
function renderMockBg(svgPath: string, pngPath: string): void {
|
|
66
|
+
const sips = spawnSync('sips', ['-s', 'format', 'png', svgPath, '--out', pngPath], { encoding: 'utf-8' });
|
|
67
|
+
if (sips.error || sips.status !== 0 || !existsSync(pngPath)) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
`daily-cover-mock: mock background render failed (sips status ${sips.status ?? 'n/a'}); stderr: ${(sips.stderr || '').trim()}`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Live path: same envelope shape dailyCover writes, through the pinned presets. */
|
|
75
|
+
function generateLiveBg(options: MockOptions, envPath: string, contentOut: string): string {
|
|
76
|
+
const kkBin = process.env.KK_BIN || 'kk';
|
|
77
|
+
const envelope = [
|
|
78
|
+
{
|
|
79
|
+
id: 'daily-cover-mock',
|
|
80
|
+
title: basename(options.out),
|
|
81
|
+
body: '',
|
|
82
|
+
metadata: {
|
|
83
|
+
imageGen: {
|
|
84
|
+
job: 'cover',
|
|
85
|
+
format: 'daily-news-podcast-cover',
|
|
86
|
+
style: 'quasi-news-podcast',
|
|
87
|
+
vars: { subject: options.scene },
|
|
88
|
+
maxImages: 1,
|
|
89
|
+
...(options.provider !== '' ? { provider: options.provider } : {}),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
writeFileSync(envPath, JSON.stringify(envelope, null, 4));
|
|
95
|
+
const run = spawnSync(kkBin, ['executor', 'run', 'image-gen', '--in', envPath, '--out', contentOut], {
|
|
96
|
+
encoding: 'utf-8',
|
|
97
|
+
});
|
|
98
|
+
if (run.error || run.status !== 0) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`daily-cover-mock: image-gen failed (status ${run.status ?? 'n/a'}); stderr: ${(run.stderr || '').trim().slice(-400)}`,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const content = JSON.parse(readFileSync(contentOut, 'utf-8')) as Array<{ metadata?: { image_path?: string } }>;
|
|
104
|
+
const imagePath = content[0]?.metadata?.image_path;
|
|
105
|
+
if (imagePath === undefined || !existsSync(imagePath)) {
|
|
106
|
+
throw new Error('daily-cover-mock: image-gen produced no usable image_path');
|
|
107
|
+
}
|
|
108
|
+
return imagePath;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Verify the composited output is a real COVER_WIDTH×COVER_HEIGHT PNG. */
|
|
112
|
+
function verifyOutput(outPath: string): { width: number; height: number } {
|
|
113
|
+
const probe = spawnSync('sips', ['-g', 'pixelWidth', '-g', 'pixelHeight', outPath], { encoding: 'utf-8' });
|
|
114
|
+
const text = probe.stdout || '';
|
|
115
|
+
const width = Number(/pixelWidth:\s*(\d+)/.exec(text)?.[1]);
|
|
116
|
+
const height = Number(/pixelHeight:\s*(\d+)/.exec(text)?.[1]);
|
|
117
|
+
if (!Number.isFinite(width) || !Number.isFinite(height)) {
|
|
118
|
+
throw new Error(`daily-cover-mock: output verification failed — sips cannot read dimensions from ${outPath}`);
|
|
119
|
+
}
|
|
120
|
+
if (width !== COVER_WIDTH || height !== COVER_HEIGHT) {
|
|
121
|
+
throw new Error(`daily-cover-mock: output is ${width}x${height}, expected ${COVER_WIDTH}x${COVER_HEIGHT}`);
|
|
122
|
+
}
|
|
123
|
+
return { width, height };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function runMock(args: string[]): { out: string; width: number; height: number; background: string } {
|
|
127
|
+
const options = parseMockArgs(args);
|
|
128
|
+
const parent = dirname(options.out);
|
|
129
|
+
if (!existsSync(parent)) {
|
|
130
|
+
// sips would silently no-op on a missing parent (0348 finding) — fail before compositing.
|
|
131
|
+
throw new Error(`daily-cover-mock: output directory does not exist: ${parent}`);
|
|
132
|
+
}
|
|
133
|
+
const tmp = mkdtempSync(join(tmpdir(), 'kk-cover-mock-'));
|
|
134
|
+
try {
|
|
135
|
+
const envPath = join(tmp, 'mock-image-gen-in.json');
|
|
136
|
+
const contentOut = join(tmp, 'content.json');
|
|
137
|
+
const background = options.mockBg
|
|
138
|
+
? (() => {
|
|
139
|
+
const svgPath = join(tmp, 'mock-bg.svg');
|
|
140
|
+
const pngPath = join(tmp, 'mock-bg.png');
|
|
141
|
+
writeFileSync(svgPath, MOCK_BG_SVG);
|
|
142
|
+
renderMockBg(svgPath, pngPath);
|
|
143
|
+
return pngPath;
|
|
144
|
+
})()
|
|
145
|
+
: generateLiveBg(options, envPath, contentOut);
|
|
146
|
+
compositeCover({
|
|
147
|
+
backgroundImagePath: background,
|
|
148
|
+
headline: options.headline,
|
|
149
|
+
outputPath: options.out,
|
|
150
|
+
});
|
|
151
|
+
const { width, height } = verifyOutput(options.out);
|
|
152
|
+
console.error(
|
|
153
|
+
`daily-cover-mock: composited ${options.out} (${width}x${height}, background=${options.mockBg ? 'mock' : options.provider || 'default'})`,
|
|
154
|
+
);
|
|
155
|
+
return { out: options.out, width, height, background: options.mockBg ? 'mock' : 'live' };
|
|
156
|
+
} finally {
|
|
157
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const invokedDirectly = process.argv[1] !== undefined && basename(process.argv[1]) === 'daily-cover-mock.ts';
|
|
162
|
+
if (invokedDirectly) {
|
|
163
|
+
runMock(process.argv.slice(2));
|
|
164
|
+
}
|