@gobing-ai/knowledge-kit 0.1.22 → 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 +282 -147
- 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 +56 -16
- package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
- package/plugins/generations/image-gen/dist/index.js +9 -9
- package/plugins/generations/music-gen/README.md +2 -2
- package/plugins/generations/music-gen/dist/index.js +62 -26
- package/plugins/generations/music-gen/presets/formats/song.yaml +6 -1
- package/plugins/generations/music-gen/presets/themes/synthwave.yaml +6 -1
- package/plugins/generations/music-gen/src/adapter/instance.ts +34 -11
- package/plugins/generations/music-gen/src/presets.ts +36 -3
- package/plugins/generations/news-report-gen/dist/index.js +12 -12
- package/plugins/generations/omni-voice-gen/uv.toml +5 -0
- package/plugins/generations/vibe-voice-tts/README.md +64 -0
- package/plugins/generations/vibe-voice-tts/dist/index.js +14259 -0
- package/plugins/generations/vibe-voice-tts/package.json +16 -0
- package/plugins/generations/vibe-voice-tts/plugin.json +6 -0
- package/plugins/generations/vibe-voice-tts/profiles.json +10 -0
- package/plugins/generations/vibe-voice-tts/pyproject.toml +9 -0
- package/plugins/generations/vibe-voice-tts/python/worker.py +566 -0
- package/plugins/generations/vibe-voice-tts/src/index.ts +88 -0
- package/plugins/generations/vibe-voice-tts/src/vibevoice-client.ts +828 -0
- package/plugins/generations/vibe-voice-tts/tsconfig.json +8 -0
- package/plugins/generations/vibe-voice-tts/uv.lock +1767 -0
- package/plugins/generations/vibe-voice-tts/uv.toml +4 -0
- package/plugins/generations/voice-gen/dist/index.js +40 -10
- package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
- package/plugins/generations/voxcpm-tts/dist/index.js +90 -18
- package/plugins/generations/voxcpm-tts/python/worker.py +9 -0
- package/plugins/generations/voxcpm-tts/src/index.ts +41 -0
- package/plugins/generations/voxcpm-tts/src/voxcpm-client.ts +32 -11
- package/plugins/generations/voxcpm-tts/uv.toml +5 -0
- 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/README.md +21 -0
- package/plugins/kk/decisions/kk-safety.yaml +5 -2
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +16 -16
- package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +12 -1
- package/plugins/kk/scripts/cover-compositor.ts +104 -26
- package/plugins/kk/scripts/daily-stages.ts +481 -63
- package/plugins/kk/scripts/kk-workflow-stages.ts +218 -17
- package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
- 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-daily-ai-voice.yaml +4 -3
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -5
- package/plugins/kk/workflows/kk-daily-safety.yaml +12 -10
- package/plugins/kk/workflows/kk-music.yaml +20 -16
- package/plugins/kk/workflows/kk-news-generate.yaml +26 -3
- package/plugins/kk/workflows/kk-publish.yaml +4 -1
- 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 +133 -33
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +27 -22
- package/plugins/publishings/linkedin-pub/src/index.ts +192 -18
- 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 +207 -95
- package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
- package/plugins/publishings/surfdash-pub/src/index.ts +101 -76
- package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
- package/plugins/publishings/surfdash-pub/src/patch.ts +49 -26
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
- package/plugins/publishings/threads-pub/dist/index.js +83 -27
- package/plugins/publishings/threads-pub/dist/profile-check.js +34 -23
- package/plugins/publishings/threads-pub/src/post-rail.ts +121 -4
- package/plugins/publishings/wechatmp-pub/dist/index.js +274 -98
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +27 -23
- package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +117 -13
- package/plugins/publishings/wechatmp-pub/src/flow.ts +183 -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 +113 -32
- package/plugins/publishings/x-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/x-pub/src/post-rail.ts +155 -20
- 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
|
@@ -4850,7 +4850,7 @@ var init_zod = __esm(() => {
|
|
|
4850
4850
|
init_external();
|
|
4851
4851
|
});
|
|
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/errors.js
|
|
4854
4854
|
var ErrorCode;
|
|
4855
4855
|
var init_errors3 = __esm(() => {
|
|
4856
4856
|
ErrorCode = {
|
|
@@ -4861,7 +4861,7 @@ var init_errors3 = __esm(() => {
|
|
|
4861
4861
|
};
|
|
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/api-response.js
|
|
4865
4865
|
var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
|
|
4866
4866
|
var init_api_response = __esm(() => {
|
|
4867
4867
|
init_errors3();
|
|
@@ -4884,13 +4884,13 @@ var init_api_response = __esm(() => {
|
|
|
4884
4884
|
CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
|
|
4885
4885
|
});
|
|
4886
4886
|
|
|
4887
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4887
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
|
|
4888
4888
|
var init_cursor = () => {};
|
|
4889
4889
|
|
|
4890
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4890
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
|
|
4891
4891
|
var init_event_severity = () => {};
|
|
4892
4892
|
|
|
4893
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4893
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
|
|
4894
4894
|
function processStream(name) {
|
|
4895
4895
|
const proc = globalThis.process;
|
|
4896
4896
|
const stream = proc?.[name];
|
|
@@ -4908,7 +4908,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
|
|
|
4908
4908
|
}
|
|
4909
4909
|
var defaultStderrTarget;
|
|
4910
4910
|
|
|
4911
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4911
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
|
|
4912
4912
|
var init_dist = __esm(() => {
|
|
4913
4913
|
init_api_response();
|
|
4914
4914
|
init_cursor();
|
|
@@ -11906,7 +11906,7 @@ var init_dist2 = __esm(() => {
|
|
|
11906
11906
|
$visitAsync = visit.visitAsync;
|
|
11907
11907
|
});
|
|
11908
11908
|
|
|
11909
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11909
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
|
|
11910
11910
|
var configSchema;
|
|
11911
11911
|
var init_config = __esm(() => {
|
|
11912
11912
|
init_dist2();
|
|
@@ -11930,7 +11930,7 @@ var init_config = __esm(() => {
|
|
|
11930
11930
|
});
|
|
11931
11931
|
});
|
|
11932
11932
|
|
|
11933
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11933
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
|
|
11934
11934
|
import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
11935
11935
|
import { dirname, resolve as resolvePath } from "path";
|
|
11936
11936
|
function createNodeFileSystem(root, paths) {
|
|
@@ -12072,8 +12072,8 @@ var init_src = () => {};
|
|
|
12072
12072
|
// ../../plugins/publishings/surfdash-pub/src/index.ts
|
|
12073
12073
|
import { createHash } from "crypto";
|
|
12074
12074
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
12075
|
-
import {
|
|
12076
|
-
import { dirname as dirname4, extname, isAbsolute, join
|
|
12075
|
+
import { writeFile } from "fs/promises";
|
|
12076
|
+
import { basename as basename3, dirname as dirname4, extname as extname2, isAbsolute, join, relative, resolve, sep as sep2 } from "path";
|
|
12077
12077
|
import { parseArgs } from "util";
|
|
12078
12078
|
|
|
12079
12079
|
// ../../packages/kk-core/src/content-limits.ts
|
|
@@ -12340,7 +12340,7 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
|
|
|
12340
12340
|
});
|
|
12341
12341
|
}
|
|
12342
12342
|
});
|
|
12343
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12343
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
|
|
12344
12344
|
init_file_system_node();
|
|
12345
12345
|
init_config();
|
|
12346
12346
|
|
|
@@ -12354,7 +12354,7 @@ var ATTACHED_CLOSERS = new Set(["\u201D", "\u2019", "\u300D", "\u300F", "\uFF09"
|
|
|
12354
12354
|
init_dist();
|
|
12355
12355
|
|
|
12356
12356
|
// ../../plugins/publishings/surfdash-pub/src/patch.ts
|
|
12357
|
-
import { basename, dirname as dirname2,
|
|
12357
|
+
import { basename, dirname as dirname2, sep } from "path";
|
|
12358
12358
|
var PATCH_LOCALES = ["zh", "en", "ja"];
|
|
12359
12359
|
function localeIndexPath(postPath, locale) {
|
|
12360
12360
|
if (locale === "zh")
|
|
@@ -12370,10 +12370,10 @@ var SERIES_NAMES = {
|
|
|
12370
12370
|
en: "Daily AI Stew",
|
|
12371
12371
|
ja: "\u30C7\u30A4\u30EA\u30FCAI\u30B7\u30C1\u30E5\u30FC"
|
|
12372
12372
|
};
|
|
12373
|
-
function crossLinkFor(locale, dateIso, showNotesUrl) {
|
|
12373
|
+
function crossLinkFor(locale, dateIso, showNotesUrl, episodeTitle = "") {
|
|
12374
12374
|
const series = SERIES_NAMES[locale];
|
|
12375
12375
|
const links = {
|
|
12376
|
-
zh: `\uD83C\uDFA7 \u672C\u671F\u5DF2\u540C\u6B65\u5236\u4F5C\u4E3A\u64AD\u5BA2\u8282\u76EE\uFF0C[\u70B9\u51FB\u6536\u542C\u300A${series} \xB7 ${dateIso}\u300B](${showNotesUrl})\u3002`,
|
|
12376
|
+
zh: episodeTitle !== "" ? `\uD83C\uDFA7 \u672C\u671F\u5DF2\u540C\u6B65\u5236\u4F5C\u4E3A\u64AD\u5BA2\u8282\u76EE\uFF0C[\u70B9\u51FB\u6536\u542C\u300A${series} \xB7 ${dateIso}\u300B](${showNotesUrl})\uFF1A${episodeTitle}\u3002` : `\uD83C\uDFA7 \u672C\u671F\u5DF2\u540C\u6B65\u5236\u4F5C\u4E3A\u64AD\u5BA2\u8282\u76EE\uFF0C[\u70B9\u51FB\u6536\u542C\u300A${series} \xB7 ${dateIso}\u300B](${showNotesUrl})\u3002`,
|
|
12377
12377
|
en: `\uD83C\uDFA7 This episode is also available as a podcast: [listen to ${series} \xB7 ${dateIso}](${showNotesUrl}).`,
|
|
12378
12378
|
ja: `\uD83C\uDFA7 \u672C\u30A8\u30D4\u30BD\u30FC\u30C9\u306F\u30DD\u30C3\u30C9\u30AD\u30E3\u30B9\u30C8\u3067\u3082\u914D\u4FE1\u4E2D\uFF1A[${series} \xB7 ${dateIso} \u3092\u8074\u304F](${showNotesUrl})\u3002`
|
|
12379
12379
|
};
|
|
@@ -12401,17 +12401,18 @@ async function patchPostFiles(request) {
|
|
|
12401
12401
|
const absent = [];
|
|
12402
12402
|
const images = {};
|
|
12403
12403
|
let changed = 0;
|
|
12404
|
+
let uploadedFallbackCover;
|
|
12404
12405
|
for (const locale of PATCH_LOCALES) {
|
|
12405
12406
|
const indexMd = localeIndexPath(request.postPath, locale);
|
|
12406
12407
|
if (indexMd === undefined || !await fs.exists(indexMd)) {
|
|
12407
12408
|
absent.push(locale);
|
|
12408
12409
|
continue;
|
|
12409
12410
|
}
|
|
12410
|
-
const dir = dirname2(indexMd);
|
|
12411
12411
|
const before = await fs.readFile(indexMd);
|
|
12412
12412
|
let md = before;
|
|
12413
12413
|
const end = frontmatterEnd(md);
|
|
12414
12414
|
const fm = end < 0 ? md : md.slice(0, end);
|
|
12415
|
+
const existingImage = /^image:\s*['"]?([^'"\n]+)['"]?/m.exec(fm)?.[1]?.trim() ?? "";
|
|
12415
12416
|
if (request.coverUrl !== "") {
|
|
12416
12417
|
if (!/^https:\/\//.test(request.coverUrl)) {
|
|
12417
12418
|
throw new Error(`coverUrl must be an absolute https:// URL, got: ${request.coverUrl}`);
|
|
@@ -12419,20 +12420,28 @@ async function patchPostFiles(request) {
|
|
|
12419
12420
|
md = upsertFrontmatterKey(md, "image", request.coverUrl);
|
|
12420
12421
|
md = upsertFrontmatterKey(md, "og_image", request.coverUrl);
|
|
12421
12422
|
images[locale] = request.coverUrl;
|
|
12422
|
-
} else if (
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
|
-
|
|
12423
|
+
} else if (/^https:\/\//.test(existingImage)) {
|
|
12424
|
+
md = upsertFrontmatterKey(md, "og_image", existingImage);
|
|
12425
|
+
images[locale] = existingImage;
|
|
12426
|
+
} else if (request.uploadLocalCover !== undefined && request.localCover !== "" && await fs.exists(request.localCover)) {
|
|
12427
|
+
if (uploadedFallbackCover === undefined) {
|
|
12428
|
+
const uploaded = await request.uploadLocalCover(request.localCover);
|
|
12429
|
+
if (!/^https:\/\//.test(uploaded)) {
|
|
12430
|
+
throw new Error(`uploaded cover must be an absolute https:// URL, got: ${uploaded}`);
|
|
12431
|
+
}
|
|
12432
|
+
uploadedFallbackCover = uploaded;
|
|
12433
|
+
}
|
|
12434
|
+
md = upsertFrontmatterKey(md, "image", uploadedFallbackCover);
|
|
12435
|
+
md = upsertFrontmatterKey(md, "og_image", uploadedFallbackCover);
|
|
12436
|
+
images[locale] = uploadedFallbackCover;
|
|
12437
|
+
} else {
|
|
12438
|
+
throw new Error(`${locale} post has no remote https:// cover: coverUrl is empty and frontmatter has no https:// image key`);
|
|
12439
|
+
}
|
|
12440
|
+
if (locale === "zh" && (request.episodeTitle ?? "") !== "") {
|
|
12441
|
+
md = upsertFrontmatterKey(md, "episode_title", request.episodeTitle);
|
|
12433
12442
|
}
|
|
12434
12443
|
if (request.showNotesUrl !== "") {
|
|
12435
|
-
const link = crossLinkFor(locale, request.dateIso, request.showNotesUrl);
|
|
12444
|
+
const link = crossLinkFor(locale, request.dateIso, request.showNotesUrl, request.episodeTitle ?? "");
|
|
12436
12445
|
const lines = md.split(`
|
|
12437
12446
|
`);
|
|
12438
12447
|
const carriesUrl = lines.some((line) => line.includes(request.showNotesUrl));
|
|
@@ -12449,10 +12458,6 @@ ${link}
|
|
|
12449
12458
|
if (md !== before) {
|
|
12450
12459
|
await fs.writeFile(indexMd, md);
|
|
12451
12460
|
written.push(indexMd);
|
|
12452
|
-
const assetsDir = join(dir, "assets");
|
|
12453
|
-
if (await fs.exists(assetsDir) && !written.includes(join(assetsDir, "cover.png"))) {
|
|
12454
|
-
written.push(assetsDir);
|
|
12455
|
-
}
|
|
12456
12461
|
changed += 1;
|
|
12457
12462
|
}
|
|
12458
12463
|
}
|
|
@@ -12463,6 +12468,20 @@ ${link}
|
|
|
12463
12468
|
var DIGEST_TAG = "sub-category:ai-daily";
|
|
12464
12469
|
var PODCAST_INTROS = ["\u8FD9\u91CC\u662F\u7531Robin", "\u54B8\u8BDD\u54B8\u8BF4", "This is Robin", "Robin \u304C\u304A\u5C4A\u3051"];
|
|
12465
12470
|
var SEO_TITLE_LIMIT = 60;
|
|
12471
|
+
var EPISODE_TITLE_MAX = 80;
|
|
12472
|
+
var EPISODE_IDENTITY_TITLE_RE = {
|
|
12473
|
+
zh: /^\u7B2C\d{6}\u671F\s*\u00B7\s*\S/u,
|
|
12474
|
+
en: /^Issue\s+\d{6}\s*\u00B7\s*\S/iu,
|
|
12475
|
+
ja: /^\u7B2C\d{6}\u56DE\s*\u00B7\s*\S/u
|
|
12476
|
+
};
|
|
12477
|
+
function isEpisodeIdentityTitle(title, locale) {
|
|
12478
|
+
const clean = title.trim();
|
|
12479
|
+
if (clean === "")
|
|
12480
|
+
return false;
|
|
12481
|
+
if (locale !== undefined)
|
|
12482
|
+
return EPISODE_IDENTITY_TITLE_RE[locale].test(clean);
|
|
12483
|
+
return Object.values(EPISODE_IDENTITY_TITLE_RE).some((re) => re.test(clean));
|
|
12484
|
+
}
|
|
12466
12485
|
var KEY_LINE = /^([A-Za-z_][A-Za-z0-9_-]*):(.*)$/;
|
|
12467
12486
|
var BLOCK_SCALAR = /^[>|][+-]?$/;
|
|
12468
12487
|
var escapeRe = (token) => token.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -12602,6 +12621,21 @@ function checkDigestFrontmatter(markdown, locale) {
|
|
|
12602
12621
|
const title = scalar(frontmatter, "title");
|
|
12603
12622
|
if (title === undefined || title === "") {
|
|
12604
12623
|
problems.push("title: missing");
|
|
12624
|
+
} else if (isEpisodeIdentityTitle(title, locale)) {
|
|
12625
|
+
const titleLength = Array.from(title).length;
|
|
12626
|
+
if (titleLength > EPISODE_TITLE_MAX) {
|
|
12627
|
+
problems.push(`title: ${titleLength} code points (max ${EPISODE_TITLE_MAX})`);
|
|
12628
|
+
}
|
|
12629
|
+
const explicitSeoTitle = scalar(frontmatter, "seo_title");
|
|
12630
|
+
const seoTitle = explicitSeoTitle !== undefined && explicitSeoTitle !== "" ? explicitSeoTitle : `${title} | Surfing`;
|
|
12631
|
+
const seoLength = Array.from(seoTitle).length;
|
|
12632
|
+
if (seoLength > SEO_TITLE_LIMIT) {
|
|
12633
|
+
problems.push(`seo_title: "${seoTitle}" is ${seoLength} code points (max ${SEO_TITLE_LIMIT})`);
|
|
12634
|
+
}
|
|
12635
|
+
if (title.includes("\u2026") || title.includes("..."))
|
|
12636
|
+
problems.push('title: contains "\u2026" or "..."');
|
|
12637
|
+
if (seoTitle.includes("\u2026") || seoTitle.includes("..."))
|
|
12638
|
+
problems.push('seo_title: contains "\u2026" or "..."');
|
|
12605
12639
|
} else {
|
|
12606
12640
|
const match = title.match(new RegExp(`^${escapeRe(series)} \xB7 (\\d{4}-\\d{2}-\\d{2})${escapeRe(titleSep)}(.+)$`));
|
|
12607
12641
|
if (!match) {
|
|
@@ -12669,6 +12703,69 @@ function checkDigestFrontmatter(markdown, locale) {
|
|
|
12669
12703
|
return problems;
|
|
12670
12704
|
}
|
|
12671
12705
|
|
|
12706
|
+
// ../../plugins/publishings/surfdash-pub/src/media-upload.ts
|
|
12707
|
+
import { basename as basename2, extname } from "path";
|
|
12708
|
+
function contentTypeForImage(filePath) {
|
|
12709
|
+
const ext = extname(filePath).toLowerCase();
|
|
12710
|
+
if (ext === ".jpg" || ext === ".jpeg")
|
|
12711
|
+
return "image/jpeg";
|
|
12712
|
+
if (ext === ".webp")
|
|
12713
|
+
return "image/webp";
|
|
12714
|
+
return "image/png";
|
|
12715
|
+
}
|
|
12716
|
+
async function readErrorBody(res) {
|
|
12717
|
+
try {
|
|
12718
|
+
return (await res.text()).slice(0, 200);
|
|
12719
|
+
} catch {
|
|
12720
|
+
return "";
|
|
12721
|
+
}
|
|
12722
|
+
}
|
|
12723
|
+
async function uploadCoverToMicrofeed(filePath, options = {}) {
|
|
12724
|
+
const baseUrl = (options.baseUrl ?? process.env.MICROFEED_BASE_URL ?? "").trim().replace(/\/$/, "");
|
|
12725
|
+
const apiKey = (options.apiKey ?? process.env.MICROFEED_API_KEY ?? "").trim();
|
|
12726
|
+
if (!baseUrl) {
|
|
12727
|
+
throw new Error("MICROFEED_BASE_URL is required to upload a local cover image to podcast-media");
|
|
12728
|
+
}
|
|
12729
|
+
if (!apiKey) {
|
|
12730
|
+
throw new Error("MICROFEED_API_KEY is required to upload a local cover image to podcast-media");
|
|
12731
|
+
}
|
|
12732
|
+
const mime = contentTypeForImage(filePath);
|
|
12733
|
+
const bytes = await Bun.file(filePath).arrayBuffer();
|
|
12734
|
+
const doFetch = options.fetchImpl ?? fetch;
|
|
12735
|
+
const presignRes = await doFetch(`${baseUrl}/api/v1/media_files/presigned_urls`, {
|
|
12736
|
+
method: "POST",
|
|
12737
|
+
headers: {
|
|
12738
|
+
Authorization: `Bearer ${apiKey}`,
|
|
12739
|
+
Origin: baseUrl,
|
|
12740
|
+
"Content-Type": "application/json"
|
|
12741
|
+
},
|
|
12742
|
+
body: JSON.stringify({
|
|
12743
|
+
category: "image",
|
|
12744
|
+
full_local_file_path: basename2(filePath),
|
|
12745
|
+
size: bytes.byteLength,
|
|
12746
|
+
type: mime
|
|
12747
|
+
})
|
|
12748
|
+
});
|
|
12749
|
+
if (!presignRes.ok) {
|
|
12750
|
+
const body = await readErrorBody(presignRes);
|
|
12751
|
+
throw new Error(`Microfeed cover presign failed (${presignRes.status}): ${body}`);
|
|
12752
|
+
}
|
|
12753
|
+
const { presigned_url, media_url } = await presignRes.json();
|
|
12754
|
+
if (!presigned_url || !media_url || !/^https:\/\//.test(media_url)) {
|
|
12755
|
+
throw new Error(`Microfeed cover presign returned incomplete media_url: ${String(media_url)}`);
|
|
12756
|
+
}
|
|
12757
|
+
const putRes = await doFetch(presigned_url, {
|
|
12758
|
+
method: "PUT",
|
|
12759
|
+
headers: { "Content-Type": mime },
|
|
12760
|
+
body: bytes
|
|
12761
|
+
});
|
|
12762
|
+
if (!putRes.ok) {
|
|
12763
|
+
const body = await readErrorBody(putRes);
|
|
12764
|
+
throw new Error(`Microfeed cover PUT upload failed (${putRes.status}): ${body}`);
|
|
12765
|
+
}
|
|
12766
|
+
return media_url;
|
|
12767
|
+
}
|
|
12768
|
+
|
|
12672
12769
|
// ../../plugins/publishings/surfdash-pub/src/topic-claims.ts
|
|
12673
12770
|
import { dirname as dirname3 } from "path";
|
|
12674
12771
|
var escapeRe2 = (token) => token.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -12738,8 +12835,9 @@ function buildLocaleEntry(markdown, locale) {
|
|
|
12738
12835
|
}
|
|
12739
12836
|
const frontmatter = parseFrontmatterScalars(markdown);
|
|
12740
12837
|
const title = scalar2(frontmatter, "title") ?? "";
|
|
12741
|
-
const
|
|
12742
|
-
|
|
12838
|
+
const episodeIdentity = isEpisodeIdentityTitle(title, locale);
|
|
12839
|
+
const parsedHeadlines = episodeIdentity ? undefined : parseTitleHeadlines(title, locale);
|
|
12840
|
+
if (!episodeIdentity && !parsedHeadlines) {
|
|
12743
12841
|
return `${locale}: title is not "<series> \xB7 YYYY-MM-DD${titleSepFor(locale)}h1${listSepFor(locale)}h2"`;
|
|
12744
12842
|
}
|
|
12745
12843
|
const description = (scalar2(frontmatter, "description") ?? scalar2(frontmatter, "seo_description") ?? "").trim();
|
|
@@ -12754,7 +12852,11 @@ function buildLocaleEntry(markdown, locale) {
|
|
|
12754
12852
|
if (!parts) {
|
|
12755
12853
|
return `${locale}: key_points must be "label \u2014 sentence"`;
|
|
12756
12854
|
}
|
|
12757
|
-
|
|
12855
|
+
const headlines = episodeIdentity ? parts.labels.slice(0, 2) : parsedHeadlines ?? [];
|
|
12856
|
+
if (headlines.length === 0) {
|
|
12857
|
+
return `${locale}: key_points has no labels to derive headlines`;
|
|
12858
|
+
}
|
|
12859
|
+
if (!episodeIdentity && (headlines.length > parts.labels.length || headlines.some((headline, i) => headline !== parts.labels[i]))) {
|
|
12758
12860
|
return `${locale}: title headlines do not match the leading key_points labels`;
|
|
12759
12861
|
}
|
|
12760
12862
|
const claims = parts.sentences;
|
|
@@ -12864,19 +12966,30 @@ function mapContentToSurfingMarkdown(content, options = {}) {
|
|
|
12864
12966
|
const tags = contentTags(content);
|
|
12865
12967
|
const isoDate = options.publishDate ?? new Date().toISOString().slice(0, 10);
|
|
12866
12968
|
const draft = typeof content.metadata?.published === "boolean" ? !content.metadata.published : false;
|
|
12969
|
+
const postLocale = options.locale ?? "zh";
|
|
12970
|
+
const rawEpisodeTitle = typeof content.metadata?.episodeTitle === "string" && content.metadata.episodeTitle.trim() !== "" ? content.metadata.episodeTitle.trim() : typeof content.metadata?.episode_title === "string" && content.metadata.episode_title.trim() !== "" ? content.metadata.episode_title.trim() : "";
|
|
12971
|
+
const podcastUrl = typeof content.metadata?.podcastUrl === "string" && /^https:\/\//.test(content.metadata.podcastUrl) ? content.metadata.podcastUrl : "";
|
|
12972
|
+
const episodeTitleForLocale = postLocale === "zh" ? rawEpisodeTitle || (isEpisodeIdentityTitle(title, "zh") ? title : "") : isEpisodeIdentityTitle(title, postLocale) ? title : "";
|
|
12867
12973
|
const frontmatterObj = {
|
|
12868
12974
|
title,
|
|
12869
12975
|
description,
|
|
12870
12976
|
tags,
|
|
12871
12977
|
publishDate: isoDate,
|
|
12872
12978
|
draft,
|
|
12873
|
-
...options.image ? { image: options.image, og_image: options.image } : {}
|
|
12979
|
+
...options.image ? { image: options.image, og_image: options.image } : {},
|
|
12980
|
+
...episodeTitleForLocale !== "" ? { episode_title: episodeTitleForLocale } : {}
|
|
12874
12981
|
};
|
|
12875
12982
|
const yamlLines = ["---", ...Object.entries(frontmatterObj).map(([k, v]) => `${k}: ${JSON.stringify(v)}`), "---"];
|
|
12983
|
+
let bodyText = content.body.trim();
|
|
12984
|
+
if (podcastUrl !== "" && !bodyText.includes(podcastUrl)) {
|
|
12985
|
+
bodyText = `${bodyText}
|
|
12986
|
+
|
|
12987
|
+
${crossLinkFor(postLocale, isoDate, podcastUrl, rawEpisodeTitle)}`;
|
|
12988
|
+
}
|
|
12876
12989
|
return `${yamlLines.join(`
|
|
12877
12990
|
`)}
|
|
12878
12991
|
|
|
12879
|
-
${
|
|
12992
|
+
${bodyText}
|
|
12880
12993
|
`;
|
|
12881
12994
|
}
|
|
12882
12995
|
function isDigestContent(content) {
|
|
@@ -13106,7 +13219,7 @@ async function runDailyTopicsSync(surfdashRoot, zhPostPath) {
|
|
|
13106
13219
|
if (!built.ok) {
|
|
13107
13220
|
return { ok: false, error: `daily-topics sync failed: ${built.error}` };
|
|
13108
13221
|
}
|
|
13109
|
-
const mapPath =
|
|
13222
|
+
const mapPath = join(surfdashRoot, "scripts", "seo", "daily-topics.json");
|
|
13110
13223
|
const before = await spawnCli(["git", "status", "--porcelain", "--", ...DAILY_TOPICS_GIT_PATHS], surfdashRoot);
|
|
13111
13224
|
const beforePaths = new Set(parsePorcelainPaths(before.stdout));
|
|
13112
13225
|
try {
|
|
@@ -13342,10 +13455,6 @@ async function scaffoldLocale(options) {
|
|
|
13342
13455
|
if (!existsSync2(draftPath)) {
|
|
13343
13456
|
return fail(`sd translate reported success but the draft is missing: ${draftPath}`);
|
|
13344
13457
|
}
|
|
13345
|
-
const assetsDir = join2(dirname4(postPath.postPath), "assets");
|
|
13346
|
-
if (existsSync2(assetsDir)) {
|
|
13347
|
-
await cp(assetsDir, join2(dirname4(draftPath), "assets"), { recursive: true });
|
|
13348
|
-
}
|
|
13349
13458
|
return ResultSchema.parse({
|
|
13350
13459
|
ok: true,
|
|
13351
13460
|
target: TARGET,
|
|
@@ -13434,29 +13543,17 @@ async function patchPost(options) {
|
|
|
13434
13543
|
coverUrl: strOption(options, "coverUrl"),
|
|
13435
13544
|
showNotesUrl: strOption(options, "showNotesUrl"),
|
|
13436
13545
|
localCover: strOption(options, "localCover"),
|
|
13437
|
-
dateIso: strOption(options, "dateIso")
|
|
13546
|
+
dateIso: strOption(options, "dateIso"),
|
|
13547
|
+
episodeTitle: strOption(options, "episodeTitle"),
|
|
13548
|
+
uploadLocalCover: uploadCoverToMicrofeed
|
|
13438
13549
|
});
|
|
13439
13550
|
} catch (error) {
|
|
13440
13551
|
return fail(`patch error: ${error instanceof Error ? error.message : String(error)}`);
|
|
13441
13552
|
}
|
|
13442
13553
|
if (outcome.changed === 0)
|
|
13443
13554
|
echoError(`patch: no post bytes changed for ${outcome.slug}`);
|
|
13444
|
-
const topics = await runDailyTopicsSync(surfdashRoot, postPath.postPath);
|
|
13445
|
-
if (!topics.ok)
|
|
13446
|
-
return fail(topics.error);
|
|
13447
13555
|
const synced = await syncPost({ postPath: postPath.postPath });
|
|
13448
13556
|
const commitPaths = new Set(outcome.written.map((path) => relative(surfdashRoot, path)));
|
|
13449
|
-
for (const p of topics.paths)
|
|
13450
|
-
commitPaths.add(p);
|
|
13451
|
-
for (const locale of PATCH_LOCALES) {
|
|
13452
|
-
const indexMd = localeIndexPath(postPath.postPath, locale);
|
|
13453
|
-
if (!indexMd)
|
|
13454
|
-
continue;
|
|
13455
|
-
const assetsDir = join2(dirname4(indexMd), "assets");
|
|
13456
|
-
if (existsSync2(assetsDir)) {
|
|
13457
|
-
commitPaths.add(relative(surfdashRoot, assetsDir));
|
|
13458
|
-
}
|
|
13459
|
-
}
|
|
13460
13557
|
if (process.env.SURFDASH_AUTO_PUSH !== "0") {
|
|
13461
13558
|
const backfilled = await runListenLinkBackfill(surfdashRoot);
|
|
13462
13559
|
for (const p of backfilled)
|
|
@@ -13607,8 +13704,8 @@ function resolvePreparedPost(options) {
|
|
|
13607
13704
|
dateStamp: runDate,
|
|
13608
13705
|
slug,
|
|
13609
13706
|
filePath: preparedPath,
|
|
13610
|
-
relPostDir:
|
|
13611
|
-
relPostDirs: ["zh", "en", "ja"].map((locale) =>
|
|
13707
|
+
relPostDir: join("content", "posts", "articles", "zh", slug),
|
|
13708
|
+
relPostDirs: ["zh", "en", "ja"].map((locale) => join("content", "posts", "articles", locale, slug)),
|
|
13612
13709
|
articleUrl: `${baseUrl}/zh/posts/${slug}`
|
|
13613
13710
|
},
|
|
13614
13711
|
identity: identity.value
|
|
@@ -13637,22 +13734,15 @@ function readLocaleDrafts(content) {
|
|
|
13637
13734
|
return drafts;
|
|
13638
13735
|
}
|
|
13639
13736
|
async function mintLocalePost(options) {
|
|
13640
|
-
const filePath =
|
|
13737
|
+
const filePath = join(options.postDir, "index.md");
|
|
13641
13738
|
if (readRefinedSnapshot(filePath) !== undefined) {
|
|
13642
13739
|
echoError(`surfdash-pub: keeping existing refined post at ${filePath} (not re-minting)`);
|
|
13643
13740
|
return;
|
|
13644
13741
|
}
|
|
13645
13742
|
await createNodeFileSystem().ensureDir(options.postDir);
|
|
13646
|
-
let imageFrontmatter;
|
|
13647
|
-
if (options.coverPath !== undefined) {
|
|
13648
|
-
const assetsDir = join2(options.postDir, "assets");
|
|
13649
|
-
await createNodeFileSystem().ensureDir(assetsDir);
|
|
13650
|
-
const coverName = `cover${extname(options.coverPath).toLowerCase()}`;
|
|
13651
|
-
await copyFile(options.coverPath, join2(assetsDir, coverName));
|
|
13652
|
-
imageFrontmatter = `./assets/${coverName}`;
|
|
13653
|
-
}
|
|
13654
13743
|
const markdown = mapContentToSurfingMarkdown(options.content, {
|
|
13655
|
-
image:
|
|
13744
|
+
image: options.coverUrl,
|
|
13745
|
+
locale: options.locale,
|
|
13656
13746
|
publishDate: options.publishDate
|
|
13657
13747
|
});
|
|
13658
13748
|
await createNodeFileSystem().writeFile(filePath, markdown);
|
|
@@ -13683,17 +13773,39 @@ async function preparePost(payload) {
|
|
|
13683
13773
|
if (dirname4(localeRoot) !== articlesRoot || dirname4(postDir) !== localeRoot) {
|
|
13684
13774
|
return { ok: false, result: failNotSent(`post path escapes ${articlesRoot}`) };
|
|
13685
13775
|
}
|
|
13686
|
-
const
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
13776
|
+
const rawCover = payload.content.metadata?.coverImage;
|
|
13777
|
+
let coverUrl;
|
|
13778
|
+
if (typeof rawCover === "string" && rawCover.trim() !== "") {
|
|
13779
|
+
const trimmedCover = rawCover.trim();
|
|
13780
|
+
if (/^https:\/\//.test(trimmedCover)) {
|
|
13781
|
+
coverUrl = trimmedCover;
|
|
13782
|
+
} else {
|
|
13783
|
+
if (!existsSync2(trimmedCover)) {
|
|
13784
|
+
return { ok: false, result: failNotSent(`metadata.coverImage not found: ${trimmedCover}`) };
|
|
13785
|
+
}
|
|
13786
|
+
if (!COVER_EXTS.has(extname2(trimmedCover).toLowerCase())) {
|
|
13787
|
+
return {
|
|
13788
|
+
ok: false,
|
|
13789
|
+
result: failNotSent(`metadata.coverImage must be one of ${[...COVER_EXTS].join(", ")}`)
|
|
13790
|
+
};
|
|
13791
|
+
}
|
|
13792
|
+
const optsObj = payload.options !== undefined && typeof payload.options === "object" && payload.options !== null ? payload.options : {};
|
|
13793
|
+
const isDryRun = optsObj.dryRun === true || process.env.KNOWLEDGE_KIT_PUBLISH_TRANSPORT === "fake";
|
|
13794
|
+
if (isDryRun) {
|
|
13795
|
+
const safeName = basename3(trimmedCover).replace(/[^a-zA-Z0-9._-]/g, "_") || "cover.png";
|
|
13796
|
+
coverUrl = `https://podcast-media.salty.vip/production/images/dry-run-${safeName}`;
|
|
13797
|
+
} else {
|
|
13798
|
+
try {
|
|
13799
|
+
coverUrl = await uploadCoverToMicrofeed(trimmedCover);
|
|
13800
|
+
} catch (err) {
|
|
13801
|
+
return {
|
|
13802
|
+
ok: false,
|
|
13803
|
+
result: failNotSent(`Failed to upload cover image to podcast-media: ${err instanceof Error ? err.message : String(err)}`)
|
|
13804
|
+
};
|
|
13805
|
+
}
|
|
13806
|
+
}
|
|
13807
|
+
}
|
|
13808
|
+
} else if (isDigestContent(payload.content)) {
|
|
13697
13809
|
return { ok: false, result: failNotSent("digest post has no cover image (metadata.coverImage)") };
|
|
13698
13810
|
}
|
|
13699
13811
|
const drafts = readLocaleDrafts(payload.content);
|
|
@@ -13706,25 +13818,27 @@ async function preparePost(payload) {
|
|
|
13706
13818
|
};
|
|
13707
13819
|
}
|
|
13708
13820
|
}
|
|
13709
|
-
const filePath =
|
|
13821
|
+
const filePath = join(postDir, "index.md");
|
|
13710
13822
|
const publishDate = runDate ? `${runDate.slice(0, 4)}-${runDate.slice(4, 6)}-${runDate.slice(6, 8)}` : undefined;
|
|
13711
|
-
const
|
|
13823
|
+
const mintedDirs = [join("content", "posts", "articles", locale, slug)];
|
|
13712
13824
|
try {
|
|
13713
|
-
await mintLocalePost({ postDir, content: payload.content,
|
|
13714
|
-
for (const
|
|
13715
|
-
const draft = drafts[
|
|
13825
|
+
await mintLocalePost({ postDir, content: payload.content, coverUrl, locale, publishDate });
|
|
13826
|
+
for (const draftLocale of LOCAL_DRAFTS) {
|
|
13827
|
+
const draft = drafts[draftLocale];
|
|
13716
13828
|
if (draft === undefined)
|
|
13717
13829
|
continue;
|
|
13718
|
-
const siblingDir = resolve(articlesRoot,
|
|
13719
|
-
if (dirname4(resolve(siblingDir)) !== resolve(articlesRoot,
|
|
13830
|
+
const siblingDir = resolve(articlesRoot, draftLocale, slug);
|
|
13831
|
+
if (dirname4(resolve(siblingDir)) !== resolve(articlesRoot, draftLocale)) {
|
|
13720
13832
|
return { ok: false, result: failNotSent(`post path escapes ${articlesRoot}`) };
|
|
13721
13833
|
}
|
|
13722
13834
|
await mintLocalePost({
|
|
13723
13835
|
postDir: siblingDir,
|
|
13724
13836
|
content: { ...payload.content, title: draft.title, body: draft.body },
|
|
13725
|
-
|
|
13837
|
+
coverUrl,
|
|
13838
|
+
locale: draftLocale,
|
|
13726
13839
|
publishDate
|
|
13727
13840
|
});
|
|
13841
|
+
mintedDirs.push(join("content", "posts", "articles", draftLocale, slug));
|
|
13728
13842
|
}
|
|
13729
13843
|
} catch (err) {
|
|
13730
13844
|
return {
|
|
@@ -13742,7 +13856,8 @@ async function preparePost(payload) {
|
|
|
13742
13856
|
dateStamp,
|
|
13743
13857
|
slug,
|
|
13744
13858
|
filePath,
|
|
13745
|
-
relPostDir:
|
|
13859
|
+
relPostDir: join("content", "posts", "articles", locale, slug),
|
|
13860
|
+
relPostDirs: mintedDirs,
|
|
13746
13861
|
articleUrl
|
|
13747
13862
|
}
|
|
13748
13863
|
};
|
|
@@ -13805,16 +13920,13 @@ async function publishPreparedFile(prepared, identity) {
|
|
|
13805
13920
|
}
|
|
13806
13921
|
});
|
|
13807
13922
|
}
|
|
13808
|
-
const topics = await runDailyTopicsSync(surfdashRoot, filePath);
|
|
13809
|
-
if (!topics.ok)
|
|
13810
|
-
return failUncertain(topics.error);
|
|
13811
13923
|
const backfilled = await runListenLinkBackfill(surfdashRoot);
|
|
13812
13924
|
const commitPaths = relPostDirs ?? [relPostDir];
|
|
13813
|
-
const gate = await runSiteGate(surfdashRoot, [...commitPaths, ...backfilled
|
|
13925
|
+
const gate = await runSiteGate(surfdashRoot, [...commitPaths, ...backfilled]);
|
|
13814
13926
|
if (!gate.ok)
|
|
13815
13927
|
return failUncertain(gate.error);
|
|
13816
|
-
const commitLocales = relPostDirs
|
|
13817
|
-
const pushed = await pushPostGit(surfdashRoot, commitPaths, `content: daily AI news ${dateStamp} (${commitLocales.join(", ")})`,
|
|
13928
|
+
const commitLocales = relPostDirs !== undefined && relPostDirs.length > 1 ? ["zh", "en", "ja"] : [locale];
|
|
13929
|
+
const pushed = await pushPostGit(surfdashRoot, commitPaths, `content: daily AI news ${dateStamp} (${commitLocales.join(", ")})`, backfilled);
|
|
13818
13930
|
if (!pushed.ok)
|
|
13819
13931
|
return failUncertain(pushed.error);
|
|
13820
13932
|
const live = await awaitArticleLive(articleUrl);
|
|
@@ -13845,7 +13957,7 @@ async function refinePreparedPost(options) {
|
|
|
13845
13957
|
const resolved = resolvePreparedLocaleSet(options);
|
|
13846
13958
|
if (!resolved.ok)
|
|
13847
13959
|
return resolved.result;
|
|
13848
|
-
const orchestrator =
|
|
13960
|
+
const orchestrator = join(resolved.value.surfdashRoot, "scripts", "publish-orchestrator.ts");
|
|
13849
13961
|
if (!existsSync2(orchestrator))
|
|
13850
13962
|
return failNotSent(`Surfdash refine orchestrator is missing: ${orchestrator}`);
|
|
13851
13963
|
try {
|
|
@@ -28,8 +28,23 @@ export const DIGEST_TAG = 'sub-category:ai-daily';
|
|
|
28
28
|
/** Podcast-intro openings a digest description must not start with (case-insensitive). */
|
|
29
29
|
const PODCAST_INTROS = ['这里是由Robin', '咸话咸说', 'This is Robin', 'Robin がお届け'] as const;
|
|
30
30
|
|
|
31
|
-
/** Rendered `<title>` budget: title + " | Surfing" must fit (site SEO_TITLE_LIMIT). */
|
|
31
|
+
/** Rendered `<title>` budget: title + " | Surfing" (or bare episode title) must fit (site SEO_TITLE_LIMIT). */
|
|
32
32
|
const SEO_TITLE_LIMIT = 60;
|
|
33
|
+
const EPISODE_TITLE_MAX = 80;
|
|
34
|
+
|
|
35
|
+
const EPISODE_IDENTITY_TITLE_RE: Record<DigestLocale, RegExp> = {
|
|
36
|
+
zh: /^第\d{6}期\s*·\s*\S/u,
|
|
37
|
+
en: /^Issue\s+\d{6}\s*·\s*\S/iu,
|
|
38
|
+
ja: /^第\d{6}回\s*·\s*\S/u,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** True when `title` matches the 0385+ episode-identity format for `locale` (or any locale if omitted). */
|
|
42
|
+
export function isEpisodeIdentityTitle(title: string, locale?: DigestLocale): boolean {
|
|
43
|
+
const clean = title.trim();
|
|
44
|
+
if (clean === '') return false;
|
|
45
|
+
if (locale !== undefined) return EPISODE_IDENTITY_TITLE_RE[locale].test(clean);
|
|
46
|
+
return Object.values(EPISODE_IDENTITY_TITLE_RE).some((re) => re.test(clean));
|
|
47
|
+
}
|
|
33
48
|
|
|
34
49
|
/** One parsed frontmatter entry: a scalar string or a block/flow list of strings. */
|
|
35
50
|
type FrontmatterValue = string | string[];
|
|
@@ -211,6 +226,20 @@ export function checkDigestFrontmatter(markdown: string, locale: DigestLocale):
|
|
|
211
226
|
const title = scalar(frontmatter, 'title');
|
|
212
227
|
if (title === undefined || title === '') {
|
|
213
228
|
problems.push('title: missing');
|
|
229
|
+
} else if (isEpisodeIdentityTitle(title, locale)) {
|
|
230
|
+
const titleLength = Array.from(title).length;
|
|
231
|
+
if (titleLength > EPISODE_TITLE_MAX) {
|
|
232
|
+
problems.push(`title: ${titleLength} code points (max ${EPISODE_TITLE_MAX})`);
|
|
233
|
+
}
|
|
234
|
+
const explicitSeoTitle = scalar(frontmatter, 'seo_title');
|
|
235
|
+
const seoTitle =
|
|
236
|
+
explicitSeoTitle !== undefined && explicitSeoTitle !== '' ? explicitSeoTitle : `${title} | Surfing`;
|
|
237
|
+
const seoLength = Array.from(seoTitle).length;
|
|
238
|
+
if (seoLength > SEO_TITLE_LIMIT) {
|
|
239
|
+
problems.push(`seo_title: "${seoTitle}" is ${seoLength} code points (max ${SEO_TITLE_LIMIT})`);
|
|
240
|
+
}
|
|
241
|
+
if (title.includes('…') || title.includes('...')) problems.push('title: contains "…" or "..."');
|
|
242
|
+
if (seoTitle.includes('…') || seoTitle.includes('...')) problems.push('seo_title: contains "…" or "..."');
|
|
214
243
|
} else {
|
|
215
244
|
const match = title.match(
|
|
216
245
|
new RegExp(`^${escapeRe(series)} · (\\d{4}-\\d{2}-\\d{2})${escapeRe(titleSep)}(.+)$`),
|