@gobing-ai/knowledge-kit 0.1.23 → 0.1.24
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 +117 -56
- package/package.json +5 -5
- package/plugins/generations/content-gen/dist/index.js +9 -9
- package/plugins/generations/core-facts-gen/dist/index.js +12 -12
- package/plugins/generations/daily-article-gen/dist/index.js +12 -12
- package/plugins/generations/dailynews-gen/dist/index.js +11 -11
- package/plugins/generations/dailynews-gen/src/script-plan.ts +2 -2
- package/plugins/generations/episode-plan-gen/dist/index.js +12 -12
- package/plugins/generations/gemini-tts/dist/index.js +9 -9
- package/plugins/generations/image-gen/dist/index.js +9 -9
- package/plugins/generations/music-gen/dist/index.js +16 -16
- package/plugins/generations/news-report-gen/dist/index.js +12 -12
- package/plugins/generations/vibe-voice-tts/dist/index.js +9 -9
- package/plugins/generations/voice-gen/dist/index.js +9 -9
- package/plugins/generations/voxcpm-tts/dist/index.js +9 -9
- package/plugins/ingestions/aihot-ingest/dist/index.js +12 -12
- package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
- package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
- package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
- package/plugins/ingestions/web-search/dist/index.js +10 -10
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +16 -16
- package/plugins/kk/scripts/cover-compositor.ts +104 -26
- package/plugins/kk/scripts/daily-stages.ts +217 -33
- package/plugins/kk/scripts/kk-workflow-stages.ts +144 -6
- package/plugins/kk/scripts/series-names.ts +16 -3
- package/plugins/kk/skills/news-editorial/SKILL.md +1 -1
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
- package/plugins/kk/workflows/kk-news-generate.yaml +3 -0
- package/plugins/publishings/bilibili-pub/dist/index.js +22 -22
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/cnblogs-pub/dist/index.js +22 -22
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/csdn-pub/dist/index.js +22 -22
- package/plugins/publishings/csdn-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/emdash-pub/dist/index.js +9 -9
- package/plugins/publishings/infoq-pub/dist/index.js +22 -22
- package/plugins/publishings/infoq-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/jike-pub/dist/index.js +22 -22
- package/plugins/publishings/jike-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/juejin-pub/dist/index.js +22 -22
- package/plugins/publishings/juejin-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/linkedin-pub/dist/index.js +82 -24
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/linkedin-pub/src/index.ts +93 -6
- package/plugins/publishings/medium-pub/dist/index.js +9 -9
- package/plugins/publishings/podcast-pub/dist/index.js +240 -37
- package/plugins/publishings/podcast-pub/src/index.ts +154 -3
- package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
- package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
- package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
- package/plugins/publishings/qiita-pub/dist/index.js +9 -9
- package/plugins/publishings/shipinhao-pub/dist/index.js +23 -23
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +23 -23
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +2 -1
- package/plugins/publishings/sspai-pub/dist/index.js +22 -22
- package/plugins/publishings/sspai-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/substack-pub/dist/index.js +22 -22
- package/plugins/publishings/substack-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/surfdash-pub/dist/index.js +200 -92
- package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
- package/plugins/publishings/surfdash-pub/src/index.ts +94 -75
- package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
- package/plugins/publishings/surfdash-pub/src/patch.ts +28 -23
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
- package/plugins/publishings/threads-pub/dist/index.js +36 -22
- package/plugins/publishings/threads-pub/dist/profile-check.js +27 -22
- package/plugins/publishings/threads-pub/src/post-rail.ts +20 -0
- package/plugins/publishings/wechatmp-pub/dist/index.js +180 -64
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +27 -23
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +56 -10
- package/plugins/publishings/wechatmp-pub/src/flow.ts +155 -43
- package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
- package/plugins/publishings/weibo-pub/dist/index.js +22 -22
- package/plugins/publishings/weibo-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/x-pub/dist/index.js +51 -45
- package/plugins/publishings/x-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/x-pub/src/post-rail.ts +40 -47
- package/plugins/publishings/xhs-pub/dist/index.js +22 -22
- package/plugins/publishings/xhs-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +22 -22
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/zenn-pub/dist/index.js +9 -9
|
@@ -4813,7 +4813,7 @@ var init_zod = __esm(() => {
|
|
|
4813
4813
|
init_external();
|
|
4814
4814
|
});
|
|
4815
4815
|
|
|
4816
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4816
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
|
|
4817
4817
|
var ErrorCode;
|
|
4818
4818
|
var init_errors3 = __esm(() => {
|
|
4819
4819
|
ErrorCode = {
|
|
@@ -4824,7 +4824,7 @@ var init_errors3 = __esm(() => {
|
|
|
4824
4824
|
};
|
|
4825
4825
|
});
|
|
4826
4826
|
|
|
4827
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4827
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
|
|
4828
4828
|
var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
|
|
4829
4829
|
var init_api_response = __esm(() => {
|
|
4830
4830
|
init_errors3();
|
|
@@ -4847,13 +4847,13 @@ var init_api_response = __esm(() => {
|
|
|
4847
4847
|
CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
|
|
4848
4848
|
});
|
|
4849
4849
|
|
|
4850
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4850
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
|
|
4851
4851
|
var init_cursor = () => {};
|
|
4852
4852
|
|
|
4853
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4853
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
|
|
4854
4854
|
var init_event_severity = () => {};
|
|
4855
4855
|
|
|
4856
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4856
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
|
|
4857
4857
|
function processStream(name) {
|
|
4858
4858
|
const proc = globalThis.process;
|
|
4859
4859
|
const stream = proc?.[name];
|
|
@@ -4871,7 +4871,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
|
|
|
4871
4871
|
}
|
|
4872
4872
|
var defaultStderrTarget;
|
|
4873
4873
|
|
|
4874
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4874
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
|
|
4875
4875
|
var init_dist = __esm(() => {
|
|
4876
4876
|
init_api_response();
|
|
4877
4877
|
init_cursor();
|
|
@@ -11869,7 +11869,7 @@ var init_dist2 = __esm(() => {
|
|
|
11869
11869
|
$visitAsync = visit.visitAsync;
|
|
11870
11870
|
});
|
|
11871
11871
|
|
|
11872
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11872
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
|
|
11873
11873
|
var configSchema;
|
|
11874
11874
|
var init_config = __esm(() => {
|
|
11875
11875
|
init_dist2();
|
|
@@ -11893,7 +11893,7 @@ var init_config = __esm(() => {
|
|
|
11893
11893
|
});
|
|
11894
11894
|
});
|
|
11895
11895
|
|
|
11896
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11896
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
|
|
11897
11897
|
import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
11898
11898
|
import { dirname, resolve as resolvePath } from "path";
|
|
11899
11899
|
function createNodeFileSystem(root, paths) {
|
|
@@ -12250,14 +12250,14 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
|
|
|
12250
12250
|
});
|
|
12251
12251
|
}
|
|
12252
12252
|
});
|
|
12253
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12253
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
|
|
12254
12254
|
init_file_system_node();
|
|
12255
12255
|
init_config();
|
|
12256
12256
|
|
|
12257
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12257
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/fs.js
|
|
12258
12258
|
init_file_system_node();
|
|
12259
12259
|
|
|
12260
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12260
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
|
|
12261
12261
|
function normalizeSeparators(path) {
|
|
12262
12262
|
return path.replaceAll("\\", "/");
|
|
12263
12263
|
}
|
|
@@ -12291,7 +12291,7 @@ function dirnamePath(path) {
|
|
|
12291
12291
|
return normalized.slice(0, index);
|
|
12292
12292
|
}
|
|
12293
12293
|
|
|
12294
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12294
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/fs.js
|
|
12295
12295
|
async function ensureDirForFile(path, fs = createNodeFileSystem()) {
|
|
12296
12296
|
await fs.ensureDir(dirnamePath(path));
|
|
12297
12297
|
}
|
|
@@ -4827,7 +4827,7 @@ var init_zod = __esm(() => {
|
|
|
4827
4827
|
init_external();
|
|
4828
4828
|
});
|
|
4829
4829
|
|
|
4830
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4830
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
|
|
4831
4831
|
var ErrorCode;
|
|
4832
4832
|
var init_errors3 = __esm(() => {
|
|
4833
4833
|
ErrorCode = {
|
|
@@ -4838,7 +4838,7 @@ var init_errors3 = __esm(() => {
|
|
|
4838
4838
|
};
|
|
4839
4839
|
});
|
|
4840
4840
|
|
|
4841
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4841
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
|
|
4842
4842
|
var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
|
|
4843
4843
|
var init_api_response = __esm(() => {
|
|
4844
4844
|
init_errors3();
|
|
@@ -4861,13 +4861,13 @@ var init_api_response = __esm(() => {
|
|
|
4861
4861
|
CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
|
|
4862
4862
|
});
|
|
4863
4863
|
|
|
4864
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4864
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
|
|
4865
4865
|
var init_cursor = () => {};
|
|
4866
4866
|
|
|
4867
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4867
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
|
|
4868
4868
|
var init_event_severity = () => {};
|
|
4869
4869
|
|
|
4870
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4870
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
|
|
4871
4871
|
function processStream(name) {
|
|
4872
4872
|
const proc = globalThis.process;
|
|
4873
4873
|
const stream = proc?.[name];
|
|
@@ -4885,7 +4885,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
|
|
|
4885
4885
|
}
|
|
4886
4886
|
var defaultStderrTarget;
|
|
4887
4887
|
|
|
4888
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4888
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
|
|
4889
4889
|
var init_dist = __esm(() => {
|
|
4890
4890
|
init_api_response();
|
|
4891
4891
|
init_cursor();
|
|
@@ -11883,7 +11883,7 @@ var init_dist2 = __esm(() => {
|
|
|
11883
11883
|
$visitAsync = visit.visitAsync;
|
|
11884
11884
|
});
|
|
11885
11885
|
|
|
11886
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11886
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
|
|
11887
11887
|
var configSchema;
|
|
11888
11888
|
var init_config = __esm(() => {
|
|
11889
11889
|
init_dist2();
|
|
@@ -11907,7 +11907,7 @@ var init_config = __esm(() => {
|
|
|
11907
11907
|
});
|
|
11908
11908
|
});
|
|
11909
11909
|
|
|
11910
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11910
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
|
|
11911
11911
|
import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
11912
11912
|
import { dirname, resolve as resolvePath } from "path";
|
|
11913
11913
|
function createNodeFileSystem(root, paths) {
|
|
@@ -12269,7 +12269,7 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
|
|
|
12269
12269
|
});
|
|
12270
12270
|
}
|
|
12271
12271
|
});
|
|
12272
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12272
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
|
|
12273
12273
|
init_file_system_node();
|
|
12274
12274
|
init_config();
|
|
12275
12275
|
|
|
@@ -14404,7 +14404,7 @@ var ConfigError = class extends Error {
|
|
|
14404
14404
|
}
|
|
14405
14405
|
};
|
|
14406
14406
|
|
|
14407
|
-
// ../../node_modules/.bun/@gobing-ai+ts-infra@0.
|
|
14407
|
+
// ../../node_modules/.bun/@gobing-ai+ts-infra@0.8.4+5042690a1c1c0ae5/node_modules/@gobing-ai/ts-infra/dist/logger.js
|
|
14408
14408
|
var ROOT_CATEGORY = "app";
|
|
14409
14409
|
function toLogTapeLevel(level) {
|
|
14410
14410
|
return level === "warn" ? "warning" : level;
|
package/plugins/kk/plugin.json
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
"name": "daily-ai-voice",
|
|
4
4
|
"targets": [
|
|
5
5
|
{
|
|
6
|
-
"plugin": "
|
|
7
|
-
"operation": "
|
|
8
|
-
"variant": "
|
|
6
|
+
"plugin": "podcast-pub",
|
|
7
|
+
"operation": "episode",
|
|
8
|
+
"variant": "episode",
|
|
9
9
|
"tier": 0,
|
|
10
10
|
"window": "after-generate",
|
|
11
11
|
"mode": "live",
|
|
12
12
|
"required": true
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
"plugin": "
|
|
16
|
-
"operation": "
|
|
17
|
-
"variant": "
|
|
15
|
+
"plugin": "surfdash-pub",
|
|
16
|
+
"operation": "post",
|
|
17
|
+
"variant": "article",
|
|
18
18
|
"tier": 0,
|
|
19
19
|
"window": "after-generate",
|
|
20
20
|
"mode": "live",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"variant": "article",
|
|
73
73
|
"tier": 2,
|
|
74
74
|
"window": "cn-peak",
|
|
75
|
-
"mode": "
|
|
75
|
+
"mode": "off"
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
"plugin": "xhs-pub",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"operation": "post",
|
|
104
104
|
"variant": "social:weibo",
|
|
105
105
|
"tier": 3,
|
|
106
|
-
"window": "
|
|
106
|
+
"window": "cn-peak",
|
|
107
107
|
"mode": "live"
|
|
108
108
|
},
|
|
109
109
|
{
|
|
@@ -152,29 +152,29 @@
|
|
|
152
152
|
"plugin": "x-pub",
|
|
153
153
|
"operation": "post",
|
|
154
154
|
"mode": "live",
|
|
155
|
-
"reason": "operator instruction 2026-11-
|
|
156
|
-
"until": "
|
|
155
|
+
"reason": "operator instruction 2026-11-21: publish illustrated promo post linking unified {{podcast_url}} (temporary until RSS sync lag resolved); no draftable rail exists, so this is a recorded exception to ADR-022",
|
|
156
|
+
"until": "until Xiaoyuzhou/Apple Podcasts RSS sync lag resolved"
|
|
157
157
|
},
|
|
158
158
|
{
|
|
159
159
|
"plugin": "weibo-pub",
|
|
160
160
|
"operation": "post",
|
|
161
161
|
"mode": "live",
|
|
162
|
-
"reason": "operator instruction 2026-11-
|
|
163
|
-
"until": "
|
|
162
|
+
"reason": "operator instruction 2026-11-21: replace long article with illustrated promo post linking unified {{podcast_url}} in cn-peak (temporary until RSS sync lag resolved); no draftable rail exists, so this is a recorded exception to ADR-022",
|
|
163
|
+
"until": "until Xiaoyuzhou/Apple Podcasts RSS sync lag resolved"
|
|
164
164
|
},
|
|
165
165
|
{
|
|
166
166
|
"plugin": "threads-pub",
|
|
167
167
|
"operation": "post",
|
|
168
168
|
"mode": "live",
|
|
169
|
-
"reason": "operator instruction 2026-11-
|
|
170
|
-
"until": "
|
|
169
|
+
"reason": "operator instruction 2026-11-21: publish illustrated promo post linking unified {{podcast_url}} (temporary until RSS sync lag resolved); no draftable rail exists, so this is a recorded exception to ADR-022",
|
|
170
|
+
"until": "until Xiaoyuzhou/Apple Podcasts RSS sync lag resolved"
|
|
171
171
|
},
|
|
172
172
|
{
|
|
173
173
|
"plugin": "linkedin-pub",
|
|
174
174
|
"operation": "post",
|
|
175
175
|
"mode": "live",
|
|
176
|
-
"reason": "operator instruction 2026-11-
|
|
177
|
-
"until": "
|
|
176
|
+
"reason": "operator instruction 2026-11-21: publish illustrated promo post linking unified {{podcast_url}} (temporary until RSS sync lag resolved); no draftable rail exists, so this is a recorded exception to ADR-022",
|
|
177
|
+
"until": "until Xiaoyuzhou/Apple Podcasts RSS sync lag resolved"
|
|
178
178
|
}
|
|
179
179
|
]
|
|
180
180
|
}
|
|
@@ -26,10 +26,14 @@ export interface CoverCompositorOptions {
|
|
|
26
26
|
outputPath: string;
|
|
27
27
|
width?: number; // default 1344
|
|
28
28
|
height?: number; // default 576
|
|
29
|
+
/** Raster output format passed to macOS `sips` (default `'png'`). */
|
|
30
|
+
format?: 'png' | 'jpeg';
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
export const COVER_WIDTH = 1344;
|
|
32
34
|
export const COVER_HEIGHT = 576;
|
|
35
|
+
export const SOCIAL_COVER_WIDTH = 1200;
|
|
36
|
+
export const SOCIAL_COVER_HEIGHT = 630;
|
|
33
37
|
/** Max Chinese characters per headline line (news-editorial style contract, 0347). */
|
|
34
38
|
export const HEADLINE_LINE_CAP = 25;
|
|
35
39
|
const FONT_STACK = `PingFang SC, Hiragino Sans GB, 'Noto Sans CJK SC', sans-serif`;
|
|
@@ -381,6 +385,33 @@ function backgroundDataUri(path: string): string {
|
|
|
381
385
|
return `data:${mime};base64,${readFileSync(path).toString('base64')}`;
|
|
382
386
|
}
|
|
383
387
|
|
|
388
|
+
function runSips(
|
|
389
|
+
args: string[],
|
|
390
|
+
outputPath: string,
|
|
391
|
+
messages: { notFound: string; failed: (status: number) => string; missingOutput: string },
|
|
392
|
+
): void {
|
|
393
|
+
const sips = spawnSync('sips', args, { stdio: 'ignore' });
|
|
394
|
+
// Bun reports a missing binary as `status: undefined` (older versions: `null`) plus an `error` object.
|
|
395
|
+
if (sips.error !== undefined || typeof sips.status !== 'number') {
|
|
396
|
+
throw new Error(messages.notFound);
|
|
397
|
+
}
|
|
398
|
+
if (sips.status !== 0) {
|
|
399
|
+
throw new Error(messages.failed(sips.status));
|
|
400
|
+
}
|
|
401
|
+
// sips exits 0 even when it silently fails to place the output (missing parent dir).
|
|
402
|
+
if (!existsSync(outputPath)) {
|
|
403
|
+
throw new Error(messages.missingOutput);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function sipsErrorMessages(noun: string, verb: string, outputPath: string) {
|
|
408
|
+
return {
|
|
409
|
+
notFound: `cover compositor: sips not found; cannot ${noun} (macOS required)`,
|
|
410
|
+
failed: (status: number) => `cover compositor: sips ${verb} failed (status ${status}); ${outputPath} missing`,
|
|
411
|
+
missingOutput: `cover compositor: sips reported success but ${outputPath} is missing`,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
384
415
|
export function compositeCover(options: CoverCompositorOptions): string {
|
|
385
416
|
const svgPath = join(tmpdir(), `cover-composite-${Date.now()}.svg`);
|
|
386
417
|
writeFileSync(
|
|
@@ -388,28 +419,80 @@ export function compositeCover(options: CoverCompositorOptions): string {
|
|
|
388
419
|
buildCoverSvg({ ...options, backgroundUri: backgroundDataUri(options.backgroundImagePath) }),
|
|
389
420
|
'utf-8',
|
|
390
421
|
);
|
|
422
|
+
const sipsArgs =
|
|
423
|
+
options.format === 'jpeg'
|
|
424
|
+
? ['-s', 'format', 'jpeg', '-s', 'formatOptions', '88', svgPath, '--out', options.outputPath]
|
|
425
|
+
: ['-s', 'format', 'png', svgPath, '--out', options.outputPath];
|
|
391
426
|
try {
|
|
392
|
-
|
|
393
|
-
|
|
427
|
+
runSips(sipsArgs, options.outputPath, {
|
|
428
|
+
notFound: 'cover compositor: sips not found; cannot render the cover overlay (macOS required)',
|
|
429
|
+
failed: (status) => `cover compositor: sips failed (status ${status}); overlay did not render`,
|
|
430
|
+
missingOutput: `cover compositor: sips reported success but ${options.outputPath} is missing`,
|
|
394
431
|
});
|
|
395
|
-
// Bun reports a missing binary as `status: undefined` plus an `error` object.
|
|
396
|
-
if (sips.error !== undefined || typeof sips.status !== 'number') {
|
|
397
|
-
throw new Error('cover compositor: sips not found; cannot render the cover overlay (macOS required)');
|
|
398
|
-
}
|
|
399
|
-
if (sips.status !== 0) {
|
|
400
|
-
throw new Error(`cover compositor: sips failed (status ${sips.status}); overlay did not render`);
|
|
401
|
-
}
|
|
402
|
-
// sips exits 0 even when it silently fails to place the output (missing parent dir) —
|
|
403
|
-
// a render that claims success without a file would leave a stale cover downstream.
|
|
404
|
-
if (!existsSync(options.outputPath)) {
|
|
405
|
-
throw new Error(`cover compositor: sips reported success but ${options.outputPath} is missing`);
|
|
406
|
-
}
|
|
407
432
|
} finally {
|
|
408
433
|
rmSync(svgPath, { force: true });
|
|
409
434
|
}
|
|
410
435
|
return options.outputPath;
|
|
411
436
|
}
|
|
412
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Render the 1200×630 JPEG Open Graph / Twitter social card derivative from the same raw background
|
|
440
|
+
* and frozen Chinese headline so `podcast-pub` populates `_microfeed.seo.social_image`.
|
|
441
|
+
*/
|
|
442
|
+
export function compositeSocialCover(options: Omit<CoverCompositorOptions, 'width' | 'height' | 'format'>): string {
|
|
443
|
+
return compositeCover({
|
|
444
|
+
...options,
|
|
445
|
+
width: SOCIAL_COVER_WIDTH,
|
|
446
|
+
height: SOCIAL_COVER_HEIGHT,
|
|
447
|
+
format: 'jpeg',
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Derive a 1200×630 JPEG social card from an already-rendered raster cover via centered aspect crop
|
|
453
|
+
* + resize (used for backfilling historical episodes without regenerating raw diffusion backgrounds).
|
|
454
|
+
*/
|
|
455
|
+
export function deriveSocialCoverFromImage(sourcePath: string, outputPath: string): string {
|
|
456
|
+
const probe = spawnSync('sips', ['-g', 'pixelWidth', '-g', 'pixelHeight', sourcePath], { encoding: 'utf-8' });
|
|
457
|
+
const width = Number(/pixelWidth:\s*(\d+)/.exec(probe.stdout ?? '')?.[1] ?? '0');
|
|
458
|
+
const height = Number(/pixelHeight:\s*(\d+)/.exec(probe.stdout ?? '')?.[1] ?? '0');
|
|
459
|
+
if (
|
|
460
|
+
probe.error !== undefined ||
|
|
461
|
+
typeof probe.status !== 'number' ||
|
|
462
|
+
probe.status !== 0 ||
|
|
463
|
+
width < 1 ||
|
|
464
|
+
height < 1
|
|
465
|
+
) {
|
|
466
|
+
throw new Error(`cover compositor: cannot probe dimensions of ${sourcePath}`);
|
|
467
|
+
}
|
|
468
|
+
const rect = centerCropRect(width, height, SOCIAL_COVER_WIDTH / SOCIAL_COVER_HEIGHT);
|
|
469
|
+
const croppedPng = join(tmpdir(), `cover-social-crop-${Date.now()}.png`);
|
|
470
|
+
try {
|
|
471
|
+
cropPng(sourcePath, rect, croppedPng);
|
|
472
|
+
runSips(
|
|
473
|
+
[
|
|
474
|
+
'-z',
|
|
475
|
+
String(SOCIAL_COVER_HEIGHT),
|
|
476
|
+
String(SOCIAL_COVER_WIDTH),
|
|
477
|
+
'-s',
|
|
478
|
+
'format',
|
|
479
|
+
'jpeg',
|
|
480
|
+
'-s',
|
|
481
|
+
'formatOptions',
|
|
482
|
+
'88',
|
|
483
|
+
croppedPng,
|
|
484
|
+
'--out',
|
|
485
|
+
outputPath,
|
|
486
|
+
],
|
|
487
|
+
outputPath,
|
|
488
|
+
sipsErrorMessages('transcode social cover', 'transcode', outputPath),
|
|
489
|
+
);
|
|
490
|
+
} finally {
|
|
491
|
+
rmSync(croppedPng, { force: true });
|
|
492
|
+
}
|
|
493
|
+
return outputPath;
|
|
494
|
+
}
|
|
495
|
+
|
|
413
496
|
/** One platform crop preview written next to the full cover. */
|
|
414
497
|
export interface CoverCropPreview {
|
|
415
498
|
platform: PlatformCrop['platform'];
|
|
@@ -451,8 +534,7 @@ export interface CoverPreviewOptions extends CoverCompositorOptions {
|
|
|
451
534
|
|
|
452
535
|
/** Center-crop a rendered PNG to `rect` via `sips` (macOS-only, same tool as the render itself). */
|
|
453
536
|
function cropPng(source: string, rect: Rect, outputPath: string): void {
|
|
454
|
-
|
|
455
|
-
'sips',
|
|
537
|
+
runSips(
|
|
456
538
|
[
|
|
457
539
|
'-c',
|
|
458
540
|
String(rect.height),
|
|
@@ -464,17 +546,13 @@ function cropPng(source: string, rect: Rect, outputPath: string): void {
|
|
|
464
546
|
'--out',
|
|
465
547
|
outputPath,
|
|
466
548
|
],
|
|
467
|
-
|
|
549
|
+
outputPath,
|
|
550
|
+
{
|
|
551
|
+
notFound: 'cover compositor: sips not found; cannot write the crop previews (macOS required)',
|
|
552
|
+
failed: (status) => `cover compositor: sips crop failed (status ${status}); preview ${outputPath} missing`,
|
|
553
|
+
missingOutput: `cover compositor: sips reported success but crop preview ${outputPath} is missing`,
|
|
554
|
+
},
|
|
468
555
|
);
|
|
469
|
-
if (sips.error !== undefined || typeof sips.status !== 'number') {
|
|
470
|
-
throw new Error('cover compositor: sips not found; cannot write the crop previews (macOS required)');
|
|
471
|
-
}
|
|
472
|
-
if (sips.status !== 0) {
|
|
473
|
-
throw new Error(`cover compositor: sips crop failed (status ${sips.status}); preview ${outputPath} missing`);
|
|
474
|
-
}
|
|
475
|
-
if (!existsSync(outputPath)) {
|
|
476
|
-
throw new Error(`cover compositor: sips reported success but crop preview ${outputPath} is missing`);
|
|
477
|
-
}
|
|
478
556
|
}
|
|
479
557
|
|
|
480
558
|
/** The top-right corner window the reference-blend preview zooms into (emblem + its surroundings). */
|