@gobing-ai/knowledge-kit 0.1.20 → 0.1.22
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/board/collect/index.js +1 -0
- package/dist/board/daily-voice/index.js +1279 -261
- package/dist/board/itc/index.js +1 -0
- package/dist/index.js +13893 -8995
- package/package.json +1 -1
- package/plugins/generations/dailynews-gen/dist/index.js +285 -16
- package/plugins/generations/dailynews-gen/src/editorial-claims.ts +215 -0
- package/plugins/generations/dailynews-gen/src/index.ts +23 -4
- package/plugins/generations/dailynews-gen/src/script-builder.ts +10 -3
- package/plugins/generations/dailynews-gen/src/script-plan.ts +74 -14
- package/plugins/generations/music-gen/README.md +277 -0
- package/plugins/generations/music-gen/dist/index.js +23544 -0
- package/plugins/generations/music-gen/package.json +24 -0
- package/plugins/generations/music-gen/plugin.json +23 -0
- package/plugins/generations/music-gen/presets/SOURCE.md +39 -0
- package/plugins/generations/music-gen/presets/formats/clip.yaml +21 -0
- package/plugins/generations/music-gen/presets/formats/jingle.yaml +22 -0
- package/plugins/generations/music-gen/presets/formats/loop.yaml +21 -0
- package/plugins/generations/music-gen/presets/formats/song.yaml +31 -0
- package/plugins/generations/music-gen/presets/formats/underscore.yaml +22 -0
- package/plugins/generations/music-gen/presets/themes/ambient-tech.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/cinematic.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/lofi.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/synthwave.yaml +30 -0
- package/plugins/generations/music-gen/scripts/gen-preset-index.ts +181 -0
- package/plugins/generations/music-gen/scripts/resolve-preset.ts +64 -0
- package/plugins/generations/music-gen/src/adapter/index.ts +35 -0
- package/plugins/generations/music-gen/src/adapter/instance.ts +904 -0
- package/plugins/generations/music-gen/src/adapter/offline.ts +124 -0
- package/plugins/generations/music-gen/src/artifact.ts +223 -0
- package/plugins/generations/music-gen/src/audio/checks.ts +618 -0
- package/plugins/generations/music-gen/src/audio/master.ts +267 -0
- package/plugins/generations/music-gen/src/audio/measure.ts +507 -0
- package/plugins/generations/music-gen/src/audio/profile.ts +131 -0
- package/plugins/generations/music-gen/src/audio.ts +122 -0
- package/plugins/generations/music-gen/src/brief.ts +191 -0
- package/plugins/generations/music-gen/src/config.ts +451 -0
- package/plugins/generations/music-gen/src/content.ts +199 -0
- package/plugins/generations/music-gen/src/digest.ts +100 -0
- package/plugins/generations/music-gen/src/index.ts +147 -0
- package/plugins/generations/music-gen/src/job.ts +131 -0
- package/plugins/generations/music-gen/src/plugin.ts +371 -0
- package/plugins/generations/music-gen/src/presets.ts +918 -0
- package/plugins/generations/music-gen/src/render.ts +87 -0
- package/plugins/generations/music-gen/src/request.ts +102 -0
- package/plugins/generations/music-gen/src/spend.ts +495 -0
- package/plugins/generations/music-gen/tsconfig.json +8 -0
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +2 -1
- package/plugins/kk/scripts/cover-compositor.ts +380 -32
- package/plugins/kk/scripts/daily-cover-mock.ts +40 -3
- package/plugins/kk/scripts/daily-stages.ts +659 -20
- package/plugins/kk/scripts/episode-identity.ts +180 -0
- package/plugins/kk/scripts/kk-workflow-stages.ts +37 -1
- package/plugins/kk/scripts/music-stages.ts +624 -0
- package/plugins/kk/scripts/news-editorial-ledger.ts +906 -0
- package/plugins/kk/scripts/source-citation.ts +187 -0
- package/plugins/kk/scripts/topic-selection-attempts.ts +446 -0
- package/plugins/kk/scripts/topic-selection-calibration.ts +161 -0
- package/plugins/kk/skills/content-judge/SKILL.md +11 -6
- package/plugins/kk/skills/content-judge/references/music-quality-rubric.md +147 -0
- package/plugins/kk/skills/content-judge/references/rubrics.md +15 -0
- package/plugins/kk/skills/content-safety/SKILL.md +12 -0
- package/plugins/kk/skills/music-authoring/SKILL.md +276 -0
- package/plugins/kk/skills/music-authoring/references/judge-input.md +117 -0
- package/plugins/kk/skills/news-editorial/SKILL.md +102 -15
- package/plugins/kk/skills/news-editorial/references/selection.md +4 -0
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +58 -11
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +8 -8
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +7 -7
- package/plugins/kk/workflows/kk-music.yaml +328 -0
- package/plugins/kk/workflows/kk-news-generate.yaml +58 -3
- package/plugins/publishings/bilibili-pub/dist/index.js +11 -1
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/cnblogs-pub/dist/index.js +11 -1
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/csdn-pub/dist/index.js +11 -1
- package/plugins/publishings/csdn-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/infoq-pub/dist/index.js +11 -1
- package/plugins/publishings/infoq-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/jike-pub/dist/index.js +11 -1
- package/plugins/publishings/jike-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/juejin-pub/dist/index.js +11 -1
- package/plugins/publishings/juejin-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/linkedin-pub/dist/index.js +11 -1
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/podcast-pub/dist/index.js +586 -20
- package/plugins/publishings/podcast-pub/src/corrections.ts +509 -0
- package/plugins/publishings/podcast-pub/src/index.ts +257 -5
- package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +240 -0
- package/plugins/publishings/podcast-pub/src/show-notes.ts +69 -13
- package/plugins/publishings/shipinhao-pub/dist/index.js +59 -8
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +105 -6
- package/plugins/publishings/sspai-pub/dist/index.js +11 -1
- package/plugins/publishings/sspai-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/substack-pub/dist/index.js +11 -1
- package/plugins/publishings/substack-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/surfdash-pub/dist/index.js +72 -20
- package/plugins/publishings/surfdash-pub/src/digest-check.ts +7 -3
- package/plugins/publishings/surfdash-pub/src/index.ts +100 -17
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +3 -1
- package/plugins/publishings/threads-pub/dist/index.js +11 -1
- package/plugins/publishings/threads-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/wechatmp-pub/dist/index.js +11 -1
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/weibo-pub/dist/index.js +11 -1
- package/plugins/publishings/weibo-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/x-pub/dist/index.js +11 -1
- package/plugins/publishings/x-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/xhs-pub/dist/index.js +11 -1
- package/plugins/publishings/xhs-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +11 -1
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +11 -1
|
@@ -67,6 +67,12 @@ import {
|
|
|
67
67
|
writeFileSync,
|
|
68
68
|
} from 'node:fs';
|
|
69
69
|
import { basename, isAbsolute, join, resolve } from 'node:path';
|
|
70
|
+
import {
|
|
71
|
+
EPISODE_IDENTITY_KEY,
|
|
72
|
+
type EpisodeIdentity,
|
|
73
|
+
freezeEpisodeIdentity,
|
|
74
|
+
identityFromMetadata,
|
|
75
|
+
} from './episode-identity.ts';
|
|
70
76
|
import {
|
|
71
77
|
ADMISSION_CRITERIA,
|
|
72
78
|
applyTopicBoundary,
|
|
@@ -114,8 +120,21 @@ import {
|
|
|
114
120
|
type XhsCard,
|
|
115
121
|
xhsPlan,
|
|
116
122
|
} from './kk-workflow-stages.ts';
|
|
123
|
+
import {
|
|
124
|
+
type AlignmentProposal,
|
|
125
|
+
commitAlignment,
|
|
126
|
+
dropReselectedJudgments,
|
|
127
|
+
type LockPort,
|
|
128
|
+
} from './news-editorial-ledger.ts';
|
|
117
129
|
import { splitSentences } from './sentences.ts';
|
|
118
130
|
import { normalizeSeriesNames } from './series-names.ts';
|
|
131
|
+
import { resolveSourceCitation } from './source-citation.ts';
|
|
132
|
+
import {
|
|
133
|
+
readSelectionAttempts,
|
|
134
|
+
recordSelectionAttempt,
|
|
135
|
+
recordSelectionStage,
|
|
136
|
+
selectionAttemptsPath,
|
|
137
|
+
} from './topic-selection-attempts.ts';
|
|
119
138
|
|
|
120
139
|
export function dailyQcContent(args: string[]): void {
|
|
121
140
|
const [
|
|
@@ -242,6 +261,40 @@ export function dailyQcContent(args: string[]): void {
|
|
|
242
261
|
sted('write', candidates, () => writeJsonText(candidates, dedupedContent));
|
|
243
262
|
console.error(`qc: dropped ${dropped.length} near-duplicate candidate(s): ${dropped.join(', ')}`);
|
|
244
263
|
}
|
|
264
|
+
// Task 0392 R2: the raw pool entering QC, captured OUTSIDE the timed block so a cached rerun
|
|
265
|
+
// still records it (`10-collect/pool.json` is a different artifact — this is the plan snapshot
|
|
266
|
+
// the QC filter actually reads). The QC drops are named by ID difference, so the stage's own
|
|
267
|
+
// arithmetic holds instead of being inferred.
|
|
268
|
+
const poolDocs = metadataOf(readJson(planContent)).docs;
|
|
269
|
+
const poolIds = (Array.isArray(poolDocs) ? poolDocs : []).map((doc) => String((doc as { id?: unknown }).id ?? ''));
|
|
270
|
+
const boundaryIds = new Set(boundaryDocs.map((doc) => String((doc as { id?: unknown }).id ?? '')));
|
|
271
|
+
const qcDropped = poolIds.filter((id) => !boundaryIds.has(id));
|
|
272
|
+
// Task 0392 R2: one record per stage that ran, so each stage is provable on its own
|
|
273
|
+
// (`input === kept + dropped`) instead of being inferred from one cross-stage sum.
|
|
274
|
+
const selectionPath = selectionAttemptsPath(workDir);
|
|
275
|
+
sted('write', selectionPath, () => {
|
|
276
|
+
const attemptOrdinal = (readSelectionAttempts(workDir)?.attempts.length ?? 0) + 1;
|
|
277
|
+
const keptDocs = dropped.length > 0 ? deduped : currentDocs;
|
|
278
|
+
recordSelectionAttempt(workDir, {
|
|
279
|
+
runDate,
|
|
280
|
+
attemptId: `${runDate}#${attemptOrdinal}`,
|
|
281
|
+
spec: readTopicBoundary(),
|
|
282
|
+
stages: [
|
|
283
|
+
{ stage: 'qc', input: poolIds.length, kept: boundaryDocs.length, dropped: qcDropped },
|
|
284
|
+
// The boundary's drops are rule-tagged, not just counted: the exclusions carry them.
|
|
285
|
+
{
|
|
286
|
+
stage: 'topicBoundary',
|
|
287
|
+
input: boundaryDocs.length,
|
|
288
|
+
kept: currentDocs.length,
|
|
289
|
+
dropped: excluded.map((entry) => entry.id),
|
|
290
|
+
},
|
|
291
|
+
{ stage: 'dedup', input: currentDocs.length, kept: keptDocs.length, dropped },
|
|
292
|
+
],
|
|
293
|
+
// Post-dedup survivors, so the recorded kept set is what later stages actually receive.
|
|
294
|
+
keptIds: keptDocs.map((doc) => String((doc as { id?: unknown }).id ?? '')),
|
|
295
|
+
excluded,
|
|
296
|
+
});
|
|
297
|
+
});
|
|
245
298
|
// Last, not inside the timed block above: the estimate must see the pool every shrink pass has
|
|
246
299
|
// already produced. 2026-10-22 cleared the floor on a 4-item pool (21.0 min estimated) that the
|
|
247
300
|
// topic boundary then cut to 3 (14.4 min), so the run paid for a full synthesis the measured
|
|
@@ -540,10 +593,20 @@ function applyFloorGate(
|
|
|
540
593
|
} = estimateSpokenMinutes(docs, vdriver, keptRatio.ratio);
|
|
541
594
|
if (estimatedSeconds >= floor * 60) {
|
|
542
595
|
if (clearStaleRefusal && isFile(refusal)) unlinkSync(refusal);
|
|
596
|
+
// Task 0392 R2: the floor gate observed this pool and admitted it — a stage that ran and
|
|
597
|
+
// dropped nothing is evidence, not silence.
|
|
598
|
+
recordSelectionStage(workDir, runDate, {
|
|
599
|
+
stages: [{ stage: 'floor', input: docs.length, kept: docs.length, dropped: [] }],
|
|
600
|
+
});
|
|
543
601
|
console.log(`floor gate: estimated ${estimatedMinutes} min from ${chars} chars — above the ${floor} min floor`);
|
|
544
602
|
return;
|
|
545
603
|
}
|
|
546
604
|
const ids = docs.map((doc) => String((doc as Record<string, unknown> | null)?.id ?? ''));
|
|
605
|
+
// A refusal drops the whole pool: recording it as `kept 0` keeps the stage identity true and
|
|
606
|
+
// tells the report the day ended here rather than leaving the stage unknown.
|
|
607
|
+
recordSelectionStage(workDir, runDate, {
|
|
608
|
+
stages: [{ stage: 'floor', input: docs.length, kept: 0, dropped: ids }],
|
|
609
|
+
});
|
|
547
610
|
sted('write', refusal, () =>
|
|
548
611
|
writeJqText(refusal, {
|
|
549
612
|
estimatedMinutes,
|
|
@@ -675,6 +738,64 @@ export function dailyExtract(args: string[]): void {
|
|
|
675
738
|
});
|
|
676
739
|
}
|
|
677
740
|
|
|
741
|
+
/**
|
|
742
|
+
* 0385 R4: the one frozen episode identity a bundle ships, read from the Content provenance first
|
|
743
|
+
* (a retry or a replay republishes what the episode already carried) and from the slot
|
|
744
|
+
* `daily-editorial-render` freezes second. `null` means "no identity recorded" — the caller leaves
|
|
745
|
+
* whatever title the artifact already has.
|
|
746
|
+
*/
|
|
747
|
+
function episodeIdentityFor(workDir: string, runDate: string, content: unknown): EpisodeIdentity | null {
|
|
748
|
+
return (
|
|
749
|
+
identityFromMetadata(metadataOf(content)) ??
|
|
750
|
+
identityFromMetadata({
|
|
751
|
+
[EPISODE_IDENTITY_KEY]: readJson(join(workDir, '21-plan', `${runDate}_05_script_identity.json`)),
|
|
752
|
+
})
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* 0385 R4: stamp the frozen title into one article Content — `title`, the H1 of the body, and the
|
|
758
|
+
* `metadata.episodeIdentity` record every later target reads. A withheld identity (`title: null`)
|
|
759
|
+
* leaves the Content untouched: there is no title to share, and inventing one is the bug.
|
|
760
|
+
*
|
|
761
|
+
* Both articles seams call this — `daily-article` after it derives (first run) and
|
|
762
|
+
* `daily-editorial-render` after the body is rewritten (retry) — so the stamp cannot be a no-op on
|
|
763
|
+
* one order and be wiped on the other.
|
|
764
|
+
*/
|
|
765
|
+
function stampEpisodeIdentity(articleContentPath: string, identity: EpisodeIdentity): boolean {
|
|
766
|
+
if (identity.title === null) return false;
|
|
767
|
+
const articleContent = readJson(articleContentPath);
|
|
768
|
+
if (articleContent === null) return false;
|
|
769
|
+
const priorBody = typeof articleContent.body === 'string' ? articleContent.body : '';
|
|
770
|
+
const body = priorBody.replace(/^#(?!#)[^\n]*/u, `# ${identity.title}`);
|
|
771
|
+
sted('write', articleContentPath, () =>
|
|
772
|
+
writeJsonText(articleContentPath, {
|
|
773
|
+
...articleContent,
|
|
774
|
+
title: identity.title,
|
|
775
|
+
body,
|
|
776
|
+
metadata: { ...metadataOf(articleContent), [EPISODE_IDENTITY_KEY]: identity },
|
|
777
|
+
}),
|
|
778
|
+
);
|
|
779
|
+
return true;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* 0385 R4: the article seam's one entry point — read the bundle's frozen identity for this run and
|
|
784
|
+
* stamp it into the article Content. `daily-article` calls it right after it derives the Content
|
|
785
|
+
* (first run) and after a `proseStale` re-derivation (retry), which is the only thing that keeps the
|
|
786
|
+
* stamp `daily-editorial-render` wrote from being wiped. Returns the identity it applied (or null).
|
|
787
|
+
*/
|
|
788
|
+
export function applyEpisodeIdentityToArticle(
|
|
789
|
+
workDir: string,
|
|
790
|
+
runDate: string,
|
|
791
|
+
articleContentPath: string,
|
|
792
|
+
): EpisodeIdentity | null {
|
|
793
|
+
const identity = episodeIdentityFor(workDir, runDate, readJson(articleContentPath));
|
|
794
|
+
if (identity === null) return null;
|
|
795
|
+
stampEpisodeIdentity(articleContentPath, identity);
|
|
796
|
+
return identity;
|
|
797
|
+
}
|
|
798
|
+
|
|
678
799
|
export function dailyArticle(args: string[]): void {
|
|
679
800
|
const [workDir = '', runDate = '', pluginsPath = ''] = args;
|
|
680
801
|
const articleMd = join(workDir, '22-article', `${runDate}_06_article_article.md`);
|
|
@@ -771,6 +892,11 @@ export function dailyArticle(args: string[]): void {
|
|
|
771
892
|
},
|
|
772
893
|
},
|
|
773
894
|
);
|
|
895
|
+
// 0385 R4: `generate-render` order is script → editorial-render → article → cover, so this
|
|
896
|
+
// is the FIRST seam where the Content exists; `daily-editorial-render`'s own stamp would be a
|
|
897
|
+
// no-op here. Stamping now — and re-stamping here after a `proseStale` re-derivation — is what
|
|
898
|
+
// keeps the article (surfdash) and the show notes on the same frozen title as podcast/ID3.
|
|
899
|
+
applyEpisodeIdentityToArticle(workDir, runDate, articleContent);
|
|
774
900
|
const body = readJson(articleContent)?.body;
|
|
775
901
|
if (typeof body !== 'string') failWith(1, `article: ${articleContent} has no string body`);
|
|
776
902
|
sted('write', articleMd, () => writeRaw(articleMd, body));
|
|
@@ -1914,7 +2040,12 @@ const WECHAT_OUTRO = '\n\n欲听往期节目,可至小宇宙、Apple Podcast
|
|
|
1914
2040
|
/** The brand strings this daily show pins on every 公众号 draft. */
|
|
1915
2041
|
const WECHAT_BRAND = {
|
|
1916
2042
|
author: '冰原奔狼',
|
|
1917
|
-
|
|
2043
|
+
// WX-03 (verified 2026-11-11): 《标识办法》第十条 + 微信 2025-08-31 公告 make the AI-generation
|
|
2044
|
+
// declaration a publish-time metadata duty, and 创作来源 is that declaration entry. The stance
|
|
2045
|
+
// label (`个人观点,仅供参考`, the 2026-10-10 choice) declares nothing about AI generation, so the
|
|
2046
|
+
// variants safety gate blocked every daily run (2026-11-19). The article is AI-drafted and the
|
|
2047
|
+
// audio is AI-synthesized; declare it. The field is single-select — one label per draft.
|
|
2048
|
+
claimSource: '内容由AI生成',
|
|
1918
2049
|
coverSource: 'library',
|
|
1919
2050
|
} as const;
|
|
1920
2051
|
|
|
@@ -1948,7 +2079,7 @@ export function buildWechatArticleContent(
|
|
|
1948
2079
|
reward: true,
|
|
1949
2080
|
author: WECHAT_BRAND.author,
|
|
1950
2081
|
collection: options.collection,
|
|
1951
|
-
// 创作来源 is the
|
|
2082
|
+
// 创作来源 is the platform's AI-declaration entry (WX-03); the label declares AI generation.
|
|
1952
2083
|
claimSource: WECHAT_BRAND.claimSource,
|
|
1953
2084
|
// 封面 comes from 图片库: the episode cover is uploaded there as the audio material's cover.
|
|
1954
2085
|
coverSource: WECHAT_BRAND.coverSource,
|
|
@@ -2053,21 +2184,46 @@ export function buildPodcastContent(
|
|
|
2053
2184
|
* (surfdash-pub/src/index.ts), so the run's cover rides along exactly as the episode/wechat
|
|
2054
2185
|
* builders stamp it. voice2's prepare mode never exercised this gate; the frozen-bundle matrix
|
|
2055
2186
|
* send surfaced it on 2026-11-05 (empty run → 'digest post has no cover image').
|
|
2187
|
+
*
|
|
2188
|
+
* 0409: `metadata.surfdash.locales` carries the en/ja translations the localize step wrote, so the
|
|
2189
|
+
* frozen variant — and therefore the safety review and the freeze digest — covers them. They are
|
|
2190
|
+
* read from the files at variant-build time so the variant is the single source the publisher reads.
|
|
2056
2191
|
*/
|
|
2057
2192
|
export function buildSurfdashContent(
|
|
2058
2193
|
article: Record<string, unknown>,
|
|
2059
2194
|
_links: PublishLinks,
|
|
2060
|
-
options: { coverPath?: string } = {},
|
|
2195
|
+
options: { coverPath?: string; locales?: Partial<Record<'en' | 'ja', { title: string; body: string }>> } = {},
|
|
2061
2196
|
): Record<string, unknown> {
|
|
2062
2197
|
return {
|
|
2063
2198
|
...article,
|
|
2064
2199
|
metadata: {
|
|
2065
2200
|
...metadataOf(article),
|
|
2066
2201
|
...(options.coverPath === undefined ? {} : { coverImage: options.coverPath }),
|
|
2202
|
+
...(options.locales === undefined ? {} : { surfdash: { locales: options.locales } }),
|
|
2067
2203
|
},
|
|
2068
2204
|
};
|
|
2069
2205
|
}
|
|
2070
2206
|
|
|
2207
|
+
/**
|
|
2208
|
+
* Reads `${workDir}/22-article/locales/{en,ja}.md` (first line `# <title>`, rest the body) into the
|
|
2209
|
+
* payload shape `surfdash-pub` consumes. A locale whose file is missing or untitled is simply
|
|
2210
|
+
* absent — `news-localize-validate` is the gate that refuses it, and the publisher refuses a digest
|
|
2211
|
+
* payload that lacks one, so silent partial data never reaches a live publish.
|
|
2212
|
+
*/
|
|
2213
|
+
function readArticleLocales(workDir: string): Partial<Record<'en' | 'ja', { title: string; body: string }>> {
|
|
2214
|
+
const locales: Partial<Record<'en' | 'ja', { title: string; body: string }>> = {};
|
|
2215
|
+
for (const locale of ['en', 'ja'] as const) {
|
|
2216
|
+
const file = join(workDir, '22-article', 'locales', `${locale}.md`);
|
|
2217
|
+
if (!isFile(file)) continue;
|
|
2218
|
+
const [firstLine = '', ...rest] = readFileSync(file, 'utf-8').split('\n');
|
|
2219
|
+
const title = firstLine.startsWith('# ') ? firstLine.slice(2).trim() : '';
|
|
2220
|
+
const body = rest.join('\n').trim();
|
|
2221
|
+
if (title === '' || body === '') continue;
|
|
2222
|
+
locales[locale] = { title, body };
|
|
2223
|
+
}
|
|
2224
|
+
return locales;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2071
2227
|
/**
|
|
2072
2228
|
* One channel's short copy as a Content (task 0327 R3): the body is the authored post text and the
|
|
2073
2229
|
* episode cover rides along as `metadata.coverImage`.
|
|
@@ -2225,8 +2381,15 @@ export function dailyBundleVariants(args: string[]): void {
|
|
|
2225
2381
|
: '';
|
|
2226
2382
|
if (article === null) skipped.push('article (no 22-article content)');
|
|
2227
2383
|
else {
|
|
2228
|
-
|
|
2229
|
-
|
|
2384
|
+
// 0409: the frozen variant carries the en/ja translations, so the safety review and the
|
|
2385
|
+
// freeze digest cover them and the publisher writes what was reviewed.
|
|
2386
|
+
const articleLocales = readArticleLocales(workDir);
|
|
2387
|
+
const articleOptions = {
|
|
2388
|
+
coverPath: cover,
|
|
2389
|
+
...(Object.keys(articleLocales).length > 0 ? { locales: articleLocales } : {}),
|
|
2390
|
+
};
|
|
2391
|
+
write('article', buildSurfdashContent(article, links, articleOptions));
|
|
2392
|
+
write('article@surfdash-pub', buildSurfdashContent(article, links, articleOptions));
|
|
2230
2393
|
write('article@xhs-pub', buildXhsArticleContent(article, { publishStatus: 'draft' }));
|
|
2231
2394
|
// The article carries the episode audio at the top (operator request 2026-11-15): the
|
|
2232
2395
|
// 公众号 播客 row is off, so without this the MP draft had no player at all. Same source
|
|
@@ -2428,6 +2591,45 @@ function planItemsForPodcast(workDir: string, runDate: string): Array<{ title: s
|
|
|
2428
2591
|
return items;
|
|
2429
2592
|
}
|
|
2430
2593
|
|
|
2594
|
+
/**
|
|
2595
|
+
* 0396 R2 — the other channels' dispatch rows, shaped for podcast-pub's delivery classifier.
|
|
2596
|
+
*
|
|
2597
|
+
* Read from the 0388 ledger (the authority on what was dispatched for this frozen date). Capability
|
|
2598
|
+
* is deliberately NOT asserted: an unknown content surface must surface as `unsupported` with its
|
|
2599
|
+
* documented reason rather than a delivery nobody verified.
|
|
2600
|
+
*/
|
|
2601
|
+
export function correctionTargetRows(ledgerPath: string): Array<Record<string, unknown>> {
|
|
2602
|
+
const ledger = readJson(ledgerPath);
|
|
2603
|
+
const entries =
|
|
2604
|
+
ledger !== null && Array.isArray((ledger as { entries?: unknown }).entries)
|
|
2605
|
+
? ((ledger as { entries: unknown[] }).entries as Array<Record<string, unknown>>)
|
|
2606
|
+
: [];
|
|
2607
|
+
const rows: Array<Record<string, unknown>> = [];
|
|
2608
|
+
for (const entry of entries) {
|
|
2609
|
+
// The 0388 ledger keys a row by `id` (`plugin[@operation]`) with `plugin` beside it — NOT by a
|
|
2610
|
+
// `target` field. Reading a non-existent field silently produced zero rows and made this whole
|
|
2611
|
+
// seam inert (0396 review), so the id is the identity here and `plugin` is the fallback.
|
|
2612
|
+
// The self row is identified by PLUGIN, not by id: the writer keys an entry as
|
|
2613
|
+
// `plugin.operation` (`podcast-pub.episode`), so comparing the id let the podcast's own row
|
|
2614
|
+
// through and the operator saw a "not delivered to podcast-pub.episode" warning for the target
|
|
2615
|
+
// that actually received it (0396 review).
|
|
2616
|
+
const plugin = typeof entry?.plugin === 'string' ? entry.plugin.trim() : '';
|
|
2617
|
+
const id = typeof entry?.id === 'string' ? entry.id.trim() : '';
|
|
2618
|
+
const target = id !== '' ? id : plugin;
|
|
2619
|
+
if (plugin === 'podcast-pub' || target === '' || target === 'podcast-pub') continue;
|
|
2620
|
+
const blockedBy = Array.isArray(entry.blockedBy) ? entry.blockedBy.filter((id) => typeof id === 'string') : [];
|
|
2621
|
+
rows.push({
|
|
2622
|
+
target,
|
|
2623
|
+
...(typeof entry.state === 'string' ? { state: entry.state } : {}),
|
|
2624
|
+
...(typeof entry.mode === 'string' ? { mode: entry.mode } : {}),
|
|
2625
|
+
...(typeof entry.manualStep === 'string' ? { manualStep: entry.manualStep } : {}),
|
|
2626
|
+
...(typeof entry.lastError === 'string' ? { lastError: entry.lastError } : {}),
|
|
2627
|
+
...(blockedBy.length > 0 ? { blockedBy } : {}),
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
return rows;
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2431
2633
|
export function dailyPublishPodcast(args: string[]): void {
|
|
2432
2634
|
const [workDir = '', runDate = '', pluginsPath = ''] = args;
|
|
2433
2635
|
const prep = join(workDir, '31-publish', `${runDate}_13_publish-prep_content.json`);
|
|
@@ -2458,6 +2660,18 @@ export function dailyPublishPodcast(args: string[]): void {
|
|
|
2458
2660
|
showNotes,
|
|
2459
2661
|
...(Object.keys(podcast).length > 0 ? { podcast } : {}),
|
|
2460
2662
|
});
|
|
2663
|
+
// 0396 R2: the plugin records a delivery per TARGET, so the dispatch state of the other
|
|
2664
|
+
// channels has to reach it. The prep file's top-level `options` IS the channel the plugin
|
|
2665
|
+
// documents, and the 0388 ledger is the authority on those rows — no capability is
|
|
2666
|
+
// asserted here, so an unknown surface comes back as `unsupported` with its exact reason
|
|
2667
|
+
// instead of a claimed delivery.
|
|
2668
|
+
const siblingTargets = correctionTargetRows(join(workDir, '4-publish', 'dispatch-ledger.json'));
|
|
2669
|
+
if (siblingTargets.length > 0) {
|
|
2670
|
+
merged.options = {
|
|
2671
|
+
...((merged.options as Record<string, unknown>) ?? {}),
|
|
2672
|
+
correctionTargets: siblingTargets,
|
|
2673
|
+
};
|
|
2674
|
+
}
|
|
2461
2675
|
sted('write', prep, () => writeJsonText(prep, merged));
|
|
2462
2676
|
kk(
|
|
2463
2677
|
[
|
|
@@ -2474,6 +2688,22 @@ export function dailyPublishPodcast(args: string[]): void {
|
|
|
2474
2688
|
{
|
|
2475
2689
|
unset: ['SPUR_WORKFLOW_RUN_ACTIVE'],
|
|
2476
2690
|
soft: true,
|
|
2691
|
+
// 0396 R1: the publish dispatch is where a correction's delivery is REAL, so the
|
|
2692
|
+
// frozen snapshot rides with it too. Without this the per-target delivery record
|
|
2693
|
+
// could never be written by a production run (only the show-notes render saw the
|
|
2694
|
+
// snapshot). `kk executor fan-out` exposes no options channel, so the env is the
|
|
2695
|
+
// seam the plugin already documents.
|
|
2696
|
+
env: {
|
|
2697
|
+
...(isFile(join(workDir, '21-plan', `${runDate}_judgment-snapshot.json`))
|
|
2698
|
+
? {
|
|
2699
|
+
PODCAST_PUB_CORRECTIONS: join(
|
|
2700
|
+
workDir,
|
|
2701
|
+
'21-plan',
|
|
2702
|
+
`${runDate}_judgment-snapshot.json`,
|
|
2703
|
+
),
|
|
2704
|
+
}
|
|
2705
|
+
: {}),
|
|
2706
|
+
},
|
|
2477
2707
|
},
|
|
2478
2708
|
);
|
|
2479
2709
|
} catch (error) {
|
|
@@ -2494,6 +2724,24 @@ export function dailyPublishPrep(args: string[]): void {
|
|
|
2494
2724
|
const coverPath = join(workDir, '23-cover', `${runDate}_07_cover_cover.png`);
|
|
2495
2725
|
timed(workDir, 'publish-prep', () => {
|
|
2496
2726
|
const article = requireJson(articlePath, 'publish-prep');
|
|
2727
|
+
// 0385 R4: the last seam before anything is dispatched is also the seam that proves the whole
|
|
2728
|
+
// run shares ONE episode identity. It is read from the bundle's metadata first (a retry or a
|
|
2729
|
+
// historical replay republishes the identity the episode already shipped), then from the slot
|
|
2730
|
+
// `editorial-render` froze; a bundle that carries neither keeps the title it already has.
|
|
2731
|
+
const identity =
|
|
2732
|
+
identityFromMetadata(metadataOf(article)) ??
|
|
2733
|
+
identityFromMetadata({
|
|
2734
|
+
[EPISODE_IDENTITY_KEY]: readJson(join(workDir, '21-plan', `${runDate}_05_script_identity.json`)),
|
|
2735
|
+
});
|
|
2736
|
+
if (identity !== null && identity.status === 'support-removed') {
|
|
2737
|
+
// The withhold path of R4: never publish a headline admission no longer backs, and never
|
|
2738
|
+
// silently publish the legacy title in its place — a human has to regenerate the point.
|
|
2739
|
+
failWith(
|
|
2740
|
+
1,
|
|
2741
|
+
`publish-prep: episode title withheld — admission dropped the headline's supporting source(s) (${identity.supportingSourceIds.join(', ')}); regenerate the headline from an admitted story before publishing`,
|
|
2742
|
+
);
|
|
2743
|
+
}
|
|
2744
|
+
const episodeTitle = identity?.title ?? (typeof article.title === 'string' ? article.title : '');
|
|
2497
2745
|
const audioMeta = metadataOf(readJson(audioPath));
|
|
2498
2746
|
const rawFile = audioMeta.mp3Path ?? audioMeta.audioPath;
|
|
2499
2747
|
if (typeof rawFile !== 'string' || rawFile === '') {
|
|
@@ -2505,7 +2753,7 @@ export function dailyPublishPrep(args: string[]): void {
|
|
|
2505
2753
|
if (!audioFile.endsWith('.mp3')) {
|
|
2506
2754
|
failWith(1, `publish-prep: resolved audio is not an MP3 (transcode_mp3 must be "true"): ${audioFile}`);
|
|
2507
2755
|
}
|
|
2508
|
-
stampId3Tags(audioFile,
|
|
2756
|
+
stampId3Tags(audioFile, episodeTitle, runDate, artist, album);
|
|
2509
2757
|
const resolvedCover = resolve(coverPath);
|
|
2510
2758
|
const hasCover = existsSync(resolvedCover);
|
|
2511
2759
|
// Daily-show itunes convention: season = year, episode = day-of-year. run_date arrives
|
|
@@ -2523,10 +2771,18 @@ export function dailyPublishPrep(args: string[]): void {
|
|
|
2523
2771
|
// alone was silently dropped by the mapper — episodes published without a cover.
|
|
2524
2772
|
const merged = {
|
|
2525
2773
|
...article,
|
|
2774
|
+
// Every publish target (podcast, ID3, show notes, surfdash) reads this one title.
|
|
2775
|
+
title: episodeTitle,
|
|
2526
2776
|
metadata: {
|
|
2527
2777
|
...metadataOf(article),
|
|
2528
2778
|
audioFile,
|
|
2529
2779
|
runDate,
|
|
2780
|
+
...(identity !== null
|
|
2781
|
+
? {
|
|
2782
|
+
[EPISODE_IDENTITY_KEY]: identity,
|
|
2783
|
+
...(identity.coverHeadline !== null ? { coverHeadline: identity.coverHeadline } : {}),
|
|
2784
|
+
}
|
|
2785
|
+
: {}),
|
|
2530
2786
|
...(hasCover ? { coverImage: resolvedCover } : {}),
|
|
2531
2787
|
...(episode > 0 ? { itunes: { season, episode } } : {}),
|
|
2532
2788
|
},
|
|
@@ -3639,6 +3895,23 @@ export function dailySafetyGate(args: string[]): void {
|
|
|
3639
3895
|
unlinkSync(infraMarker);
|
|
3640
3896
|
}
|
|
3641
3897
|
sted('write', statusFile, () => writeRaw(statusFile, status));
|
|
3898
|
+
// Task 0392 R2: the channel-admission decisions this run actually reached, keyed by target
|
|
3899
|
+
// and scope. A channel outcome is not a candidate drop — it never touches the totals.
|
|
3900
|
+
// Unobserved (no platforms array) leaves the stage unknown instead of claiming zero blocks.
|
|
3901
|
+
if (platforms.length > 0) {
|
|
3902
|
+
recordSelectionStage(workDir, runDate, {
|
|
3903
|
+
channelAdmission: [
|
|
3904
|
+
{
|
|
3905
|
+
scope: scopeDir === '' ? 'drafts' : scopeDir,
|
|
3906
|
+
targets: platforms.map((platform) => ({
|
|
3907
|
+
target: String(platform?.platform ?? ''),
|
|
3908
|
+
decision: String(platform?.decision ?? ''),
|
|
3909
|
+
})),
|
|
3910
|
+
status,
|
|
3911
|
+
},
|
|
3912
|
+
],
|
|
3913
|
+
});
|
|
3914
|
+
}
|
|
3642
3915
|
console.log(`safety: status=${status} (${reason}); routing is transition-owned`);
|
|
3643
3916
|
});
|
|
3644
3917
|
}
|
|
@@ -4377,6 +4650,11 @@ export function dailyScriptStyle(args: string[]): void {
|
|
|
4377
4650
|
* `24-script/<date>_08_script-write_errors.json` ([{itemId, rule}]) when the plan is absent or
|
|
4378
4651
|
* rejected, and removes it when the plan is accepted. The trial build goes to a scratch path so the
|
|
4379
4652
|
* `script` stage's isFile cache is never primed by a check.
|
|
4653
|
+
*
|
|
4654
|
+
* 0385 AC R2/R3: an ACCEPTED plan can still carry advisory editorial findings
|
|
4655
|
+
* (`metadata.scriptPlanAdvisories` from the generator's `analyzeEditorialClaims`). Those are written
|
|
4656
|
+
* to `24-script/<date>_08_script-write_advisories.json` and logged — a separate file, because the
|
|
4657
|
+
* acceptance verdict they describe is not a rejection and must not trigger the fix pass.
|
|
4380
4658
|
*/
|
|
4381
4659
|
export function dailyScriptCheck(args: string[]): void {
|
|
4382
4660
|
const [workDir = '', runDate = '', pluginsPath = ''] = args;
|
|
@@ -4409,7 +4687,19 @@ export function dailyScriptCheck(args: string[]): void {
|
|
|
4409
4687
|
}
|
|
4410
4688
|
if (source === 'plan') {
|
|
4411
4689
|
if (isFile(errorsOut)) unlinkSync(errorsOut);
|
|
4412
|
-
|
|
4690
|
+
// 0385 AC R2/R3: the editorial findings are advisory — an accepted plan stays accepted,
|
|
4691
|
+
// so they land in their own file and never re-open the fix loop that `errorsOut` drives.
|
|
4692
|
+
const advisoriesOut = join(workDir, '24-script', `${runDate}_08_script-write_advisories.json`);
|
|
4693
|
+
const advisories = Array.isArray(metadata.scriptPlanAdvisories) ? metadata.scriptPlanAdvisories : [];
|
|
4694
|
+
if (advisories.length > 0) {
|
|
4695
|
+
sted('write', advisoriesOut, () => writeJsonText(advisoriesOut, advisories));
|
|
4696
|
+
console.log(
|
|
4697
|
+
`script plan accepted by the validator (${advisories.length} advisory finding(s)): ${advisoriesOut}`,
|
|
4698
|
+
);
|
|
4699
|
+
} else {
|
|
4700
|
+
if (isFile(advisoriesOut)) unlinkSync(advisoriesOut);
|
|
4701
|
+
console.log('script plan accepted by the validator');
|
|
4702
|
+
}
|
|
4413
4703
|
return;
|
|
4414
4704
|
}
|
|
4415
4705
|
writeErrors(Array.isArray(metadata.scriptPlanErrors) ? metadata.scriptPlanErrors : []);
|
|
@@ -4454,6 +4744,14 @@ export function dailyCurateCheck(args: string[]): void {
|
|
|
4454
4744
|
sted('write', planFile, () => writeJsonText(planFile, candidateDocs));
|
|
4455
4745
|
sted('write', excludedFile, () => writeJsonText(excludedFile, []));
|
|
4456
4746
|
if (isFile(errFile)) unlinkSync(errFile);
|
|
4747
|
+
// Task 0392 R2: the recorded fallback IS the curation evidence for this attempt — the
|
|
4748
|
+
// agent's split was rejected, so the plan is every candidate and nothing was excluded.
|
|
4749
|
+
recordSelectionStage(workDir, runDate, {
|
|
4750
|
+
stages: [
|
|
4751
|
+
{ stage: 'curation', input: candidateIds.length, kept: candidateDocs.length, dropped: [] },
|
|
4752
|
+
{ stage: 'plan', input: candidateDocs.length, kept: candidateDocs.length, dropped: [] },
|
|
4753
|
+
],
|
|
4754
|
+
});
|
|
4457
4755
|
return;
|
|
4458
4756
|
}
|
|
4459
4757
|
sted('write', errFile, () => writeJsonText(errFile, errors));
|
|
@@ -4564,6 +4862,9 @@ export function dailyCurateCheck(args: string[]): void {
|
|
|
4564
4862
|
return;
|
|
4565
4863
|
}
|
|
4566
4864
|
|
|
4865
|
+
// Captured before the check's own dedup pass: `curation` records what the AGENT handed over,
|
|
4866
|
+
// `plan` records what the validation then kept, so the two stages never double-count a drop.
|
|
4867
|
+
const agentExcluded = excludedItems.map((entry) => entry.id);
|
|
4567
4868
|
const { kept, dropped } = dedupPlanByTitle(planDocs);
|
|
4568
4869
|
if (dropped.length > 0) {
|
|
4569
4870
|
sted('write', planFile, () => writeJsonText(planFile, kept));
|
|
@@ -4580,18 +4881,201 @@ export function dailyCurateCheck(args: string[]): void {
|
|
|
4580
4881
|
}
|
|
4581
4882
|
|
|
4582
4883
|
if (isFile(errFile)) unlinkSync(errFile);
|
|
4884
|
+
// Task 0392 R2: curation is authoritative only after this validation passed — that is why the
|
|
4885
|
+
// evidence is written here and not by the agent. `curation` is the agent's split as handed over;
|
|
4886
|
+
// `plan` is the validated plan after the check's own near-duplicate pass, so the two stages
|
|
4887
|
+
// chain (`curation.kept` → `plan.input`) and each one's arithmetic holds.
|
|
4888
|
+
recordSelectionStage(workDir, runDate, {
|
|
4889
|
+
stages: [
|
|
4890
|
+
{
|
|
4891
|
+
stage: 'curation',
|
|
4892
|
+
input: candidateIds.length,
|
|
4893
|
+
kept: planDocs.length,
|
|
4894
|
+
dropped: agentExcluded,
|
|
4895
|
+
},
|
|
4896
|
+
{ stage: 'plan', input: planDocs.length, kept: kept.length, dropped },
|
|
4897
|
+
],
|
|
4898
|
+
curationExcluded: excludedItems.map((entry) => ({ id: entry.id, reason: entry.reason })),
|
|
4899
|
+
});
|
|
4583
4900
|
console.log(`curate-check: accepted (${kept.length} kept, ${excludedItems.length} excluded)`);
|
|
4584
4901
|
}
|
|
4585
4902
|
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4903
|
+
/**
|
|
4904
|
+
* 0394 R1/R16 — the citation line for one curated item, or `''` when the doc carries no verifiable
|
|
4905
|
+
* link. Resolution (corroborated original → retrieval URL → explicit aggregator fallback) is owned
|
|
4906
|
+
* by `./source-citation.ts` so the same rule can serve the notes paths without a second convention.
|
|
4907
|
+
*/
|
|
4908
|
+
function sourceLineForDoc(doc: Record<string, unknown>, sourceUri: string): string {
|
|
4909
|
+
const citation = resolveSourceCitation(doc, sourceUri);
|
|
4910
|
+
return citation === null ? '' : `[来源:${citation.label}](${citation.url})`;
|
|
4911
|
+
}
|
|
4912
|
+
|
|
4913
|
+
/**
|
|
4914
|
+
* What the `editorial-commit` stage reports instead of the ledger module's raw status: the two
|
|
4915
|
+
* "nothing to fix" outcomes collapse to `committed` / `reused`, the two refusals stay verbatim.
|
|
4916
|
+
*/
|
|
4917
|
+
export type EditorialCommitSummary = 'committed' | 'reused' | 'conflict' | 'stop';
|
|
4918
|
+
|
|
4919
|
+
/**
|
|
4920
|
+
* The existing kk store single-flight claim as the ledger's `LockPort` (ADR-054/0384 R10): the
|
|
4921
|
+
* same `kk lock acquire/release` the collect workflow shells, scoped to the ledger's own name. A
|
|
4922
|
+
* second locking mechanism is deliberately not invented — the store's `LocksDao` owns the claim,
|
|
4923
|
+
* its TTL and its re-entrancy.
|
|
4924
|
+
*/
|
|
4925
|
+
function kkLedgerLockPort(): LockPort {
|
|
4926
|
+
const kkLock = (argv: string[]): { status: number; stdout: string; stderr: string } => {
|
|
4927
|
+
const result = spawnSync('kk', argv, { encoding: 'utf-8' });
|
|
4928
|
+
if (result.error !== undefined) failWith(127, `kk: ${result.error.message}`);
|
|
4929
|
+
return { status: result.status ?? 1, stdout: result.stdout ?? '', stderr: result.stderr ?? '' };
|
|
4930
|
+
};
|
|
4931
|
+
return {
|
|
4932
|
+
acquire: async (name: string, run: string) => {
|
|
4933
|
+
// stdout IS the lock contract: `{"acquired":true}` or `{"skipped":"locked",…}` (exit 0).
|
|
4934
|
+
const claimed = kkLock(['lock', 'acquire', '--name', name, '--run', run]);
|
|
4935
|
+
if (claimed.status !== 0) failWith(claimed.status, `lock acquire failed: ${claimed.stderr.trim()}`);
|
|
4936
|
+
return claimed.stdout.includes('"acquired":true');
|
|
4937
|
+
},
|
|
4938
|
+
release: async (name: string, run: string) => {
|
|
4939
|
+
const released = kkLock(['lock', 'release', '--name', name, '--run', run]);
|
|
4940
|
+
if (released.status !== 0) {
|
|
4941
|
+
console.error(`editorial-commit: lock release failed: ${released.stderr.trim()}`);
|
|
4942
|
+
}
|
|
4943
|
+
},
|
|
4944
|
+
};
|
|
4945
|
+
}
|
|
4946
|
+
|
|
4947
|
+
/** Selected ids from the plan `curate-final` settled — the only ids a judgment may cite (0393). */
|
|
4948
|
+
function selectedIdsOf(planRaw: unknown): Set<string> {
|
|
4949
|
+
const docs: Record<string, unknown>[] = Array.isArray(planRaw)
|
|
4950
|
+
? (planRaw as Record<string, unknown>[])
|
|
4951
|
+
: Array.isArray(metadataOf(planRaw).docs)
|
|
4952
|
+
? (metadataOf(planRaw).docs as Record<string, unknown>[])
|
|
4953
|
+
: [];
|
|
4954
|
+
const ids = new Set<string>();
|
|
4955
|
+
for (const doc of docs) {
|
|
4956
|
+
if (doc !== null && typeof doc === 'object' && typeof doc.id === 'string' && doc.id.trim() !== '') {
|
|
4957
|
+
ids.add(doc.id.trim());
|
|
4958
|
+
}
|
|
4590
4959
|
}
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4960
|
+
return ids;
|
|
4961
|
+
}
|
|
4962
|
+
|
|
4963
|
+
/**
|
|
4964
|
+
* 0384 R4/R10 — the deterministic judgment commit between final selection and drafting: the
|
|
4965
|
+
* `align` agent's proposal in, a validated ledger commit and an immutable run snapshot out.
|
|
4966
|
+
*
|
|
4967
|
+
* news-editorial-commit <work_dir> <run_date> <run_id> [proposal_file] [ledger_file]
|
|
4968
|
+
*
|
|
4969
|
+
* `<proposal_file>` defaults to `21-plan/<date>_judgment-proposal.json` (absent file = the documented
|
|
4970
|
+
* "nothing new" case, an empty proposal); `<ledger_file>` defaults to the run directory's parent
|
|
4971
|
+
* `<works_dir>/kk-news-generate/conclusion.md` (ADR-054). Outputs — both beside the plan:
|
|
4972
|
+
* `judgment-snapshot.json` (what 0385 drafts from and 0396 corrects from) and
|
|
4973
|
+
* `judgment-commit-receipt.json` (written on every exit path, including the refusals).
|
|
4974
|
+
*
|
|
4975
|
+
* Reselect tolerance: the proposal is authored in `curate`, but `curate-check`/`curate-fix`/`--final`
|
|
4976
|
+
* settle the plan afterwards, so a judgment may cite a selected id the settled plan no longer holds.
|
|
4977
|
+
* Such judgments are dropped *here* (never inside the ledger API, whose unknown-id refusal stays) and
|
|
4978
|
+
* the ids go into the receipt's `droppedByReselection` plus a printed line — the surviving judgments
|
|
4979
|
+
* still commit, and a proposal with nothing committable left behaves exactly like the documented
|
|
4980
|
+
* empty proposal (this run's legal snapshot is reused). Never silent, never a hard stop for reselection alone.
|
|
4981
|
+
*
|
|
4982
|
+
* Exit: `committed` / `reused` exit 0; `conflict` and `stop` print the recovery path and exit 1, so
|
|
4983
|
+
* a refused ledger commit can never be drafted against. `KK_EDITORIAL_COMMIT_OFFLINE=1` runs the
|
|
4984
|
+
* commit without the store claim (the documented `NULL_LOCK` seam; tests and offline replay).
|
|
4985
|
+
*/
|
|
4986
|
+
export async function newsEditorialCommit(args: string[]): Promise<void> {
|
|
4987
|
+
const [workDir = '', runDate = '', runId = '', proposalArg = '', ledgerArg = ''] = args;
|
|
4988
|
+
if (!workDir) fail('missing work_dir');
|
|
4989
|
+
if (!runDate) fail('missing run_date');
|
|
4990
|
+
if (!runId) fail('missing run_id');
|
|
4991
|
+
// 0384: judged artifacts live beside the plan, NOT under `20-editorial/` — that directory is the
|
|
4992
|
+
// per-run writer-skill snapshot (design §2.2 keeps the skill read in place, and the DAG contract
|
|
4993
|
+
// forbids agent prompts naming a copy there).
|
|
4994
|
+
const planDir = join(workDir, '21-plan');
|
|
4995
|
+
const proposalPath = proposalArg || join(planDir, `${runDate}_judgment-proposal.json`);
|
|
4996
|
+
const ledgerPath = ledgerArg || resolve(join(workDir, '..', 'conclusion.md'));
|
|
4997
|
+
const snapshotPath = join(planDir, `${runDate}_judgment-snapshot.json`);
|
|
4998
|
+
const receiptPath = join(planDir, `${runDate}_judgment-commit-receipt.json`);
|
|
4999
|
+
const planFile = join(workDir, '21-plan', `${runDate}_03_plan_plan.json`);
|
|
5000
|
+
|
|
5001
|
+
const planRaw = readJson(planFile);
|
|
5002
|
+
if (planRaw === null) {
|
|
5003
|
+
failWith(1, `editorial-commit: no selected plan at ${planFile} — refusing to commit judgments`);
|
|
5004
|
+
}
|
|
5005
|
+
const selectedIds = selectedIdsOf(planRaw);
|
|
5006
|
+
|
|
5007
|
+
let proposal: AlignmentProposal;
|
|
5008
|
+
if (isFile(proposalPath)) {
|
|
5009
|
+
try {
|
|
5010
|
+
const parsed = JSON.parse(readFileSync(proposalPath, 'utf-8')) as AlignmentProposal;
|
|
5011
|
+
if (parsed === null || typeof parsed !== 'object' || !Array.isArray(parsed.judgments)) {
|
|
5012
|
+
failWith(1, `editorial-commit: ${proposalPath} has no judgments array — re-run the align pass`);
|
|
5013
|
+
}
|
|
5014
|
+
proposal = parsed;
|
|
5015
|
+
} catch (error) {
|
|
5016
|
+
failWith(1, `editorial-commit: ${proposalPath} is not valid JSON: ${(error as Error).message}`);
|
|
5017
|
+
}
|
|
5018
|
+
} else {
|
|
5019
|
+
// An empty proposal is the normal case (skill `align` rule 4), not a failure.
|
|
5020
|
+
proposal = { version: 1, judgments: [] };
|
|
5021
|
+
console.log(`editorial-commit: no proposal at ${proposalPath} — committing this run's ledger as-is`);
|
|
5022
|
+
}
|
|
5023
|
+
|
|
5024
|
+
// The plan is settled by now (`curate-check`/`curate-fix`/`--final`), so an id the proposal cited
|
|
5025
|
+
// from the pre-settlement plan may be gone: drop those judgments and record them (never silent).
|
|
5026
|
+
const reselected = dropReselectedJudgments(proposal, selectedIds);
|
|
5027
|
+
if (reselected.dropped.length > 0) {
|
|
5028
|
+
// Same stream as the sibling drop reports (`curate-check`, `qc`): a drop is loud, not fatal.
|
|
5029
|
+
console.error(
|
|
5030
|
+
`editorial-commit: dropped ${reselected.dropped.length} judgment(s) the settled plan no longer carries: ${reselected.dropped.join(', ')}`,
|
|
5031
|
+
);
|
|
5032
|
+
}
|
|
5033
|
+
|
|
5034
|
+
sted('mkdir', planDir, () => mkdirSync(planDir, { recursive: true }));
|
|
5035
|
+
// Offline means NO lock port at all (the ledger's documented `NULL_LOCK` default), so the
|
|
5036
|
+
// receipt says `lock: none` — passing NULL_LOCK explicitly would report a claim it never took.
|
|
5037
|
+
const receipt = await commitAlignment({
|
|
5038
|
+
ledgerPath,
|
|
5039
|
+
snapshotPath,
|
|
5040
|
+
receiptPath,
|
|
5041
|
+
proposal: reselected.proposal,
|
|
5042
|
+
selectedIds,
|
|
5043
|
+
runDate,
|
|
5044
|
+
runId,
|
|
5045
|
+
now: new Date().toISOString(),
|
|
5046
|
+
droppedByReselection: reselected.dropped,
|
|
5047
|
+
...(process.env.KK_EDITORIAL_COMMIT_OFFLINE === '1' ? {} : { lock: kkLedgerLockPort() }),
|
|
5048
|
+
});
|
|
5049
|
+
|
|
5050
|
+
const summary: EditorialCommitSummary =
|
|
5051
|
+
receipt.status === 'applied'
|
|
5052
|
+
? 'committed'
|
|
5053
|
+
: receipt.status === 'no-op'
|
|
5054
|
+
? 'reused'
|
|
5055
|
+
: receipt.status === 'conflict'
|
|
5056
|
+
? 'conflict'
|
|
5057
|
+
: 'stop';
|
|
5058
|
+
const counts = [
|
|
5059
|
+
`appended=${receipt.appended.length}`,
|
|
5060
|
+
`superseded=${receipt.superseded.length}`,
|
|
5061
|
+
`corrections=${receipt.correctionIds.length}`,
|
|
5062
|
+
`dropped=${receipt.droppedByReselection.length}`,
|
|
5063
|
+
`lock=${receipt.lock}`,
|
|
5064
|
+
`snapshot=${receipt.snapshotReused ? 'reused' : 'frozen'}`,
|
|
5065
|
+
].join(' ');
|
|
5066
|
+
console.log(
|
|
5067
|
+
`editorial-commit: ${summary} — ${receipt.reason} (${counts}; ledger=${receipt.ledgerPath}; receipt=${receiptPath})`,
|
|
5068
|
+
);
|
|
5069
|
+
if (receipt.correctionIds.length > 0) {
|
|
5070
|
+
console.log(`editorial-commit: corrections owed by the draft: ${receipt.correctionIds.join(', ')}`);
|
|
5071
|
+
}
|
|
5072
|
+
if (summary === 'conflict' || summary === 'stop') {
|
|
5073
|
+
const recovery = receipt.recovery;
|
|
5074
|
+
const where = recovery?.backupPath ? ` backup=${recovery.backupPath}` : '';
|
|
5075
|
+
failWith(
|
|
5076
|
+
1,
|
|
5077
|
+
`editorial-commit: ${summary} — ${receipt.reason}${where} (${recovery?.action ?? 'see the receipt'})`,
|
|
5078
|
+
);
|
|
4595
5079
|
}
|
|
4596
5080
|
}
|
|
4597
5081
|
|
|
@@ -4659,11 +5143,19 @@ export function dailyEditorialRender(args: string[]): void {
|
|
|
4659
5143
|
const title = typeof doc?.title === 'string' ? doc.title.trim() : '';
|
|
4660
5144
|
const body = typeof doc?.body === 'string' ? doc.body.trim() : '';
|
|
4661
5145
|
const lead = typeof item?.lead === 'string' ? item.lead.trim() : '';
|
|
5146
|
+
// 0385 R3: a comment-free item is legal, so a blank insight drops the comment sentence
|
|
5147
|
+
// only — dropping the whole item would publish an episode the plan says to speak.
|
|
4662
5148
|
const insight = typeof item?.insight === 'string' ? item.insight.trim() : '';
|
|
4663
|
-
if (!title || !body || !lead
|
|
5149
|
+
if (!title || !body || !lead) continue;
|
|
4664
5150
|
const sourceUri = typeof doc?.sourceUri === 'string' ? doc.sourceUri.trim() : '';
|
|
4665
|
-
const sourceLine = sourceUri ?
|
|
4666
|
-
const parts = [
|
|
5151
|
+
const sourceLine = sourceUri ? sourceLineForDoc(doc ?? {}, sourceUri) : '';
|
|
5152
|
+
const parts = [
|
|
5153
|
+
`## ${title}`,
|
|
5154
|
+
lead,
|
|
5155
|
+
body,
|
|
5156
|
+
...(insight !== '' ? [insight] : []),
|
|
5157
|
+
...(sourceLine ? [sourceLine] : []),
|
|
5158
|
+
];
|
|
4667
5159
|
articleSections.push(parts.join('\n\n'));
|
|
4668
5160
|
}
|
|
4669
5161
|
if (articleSections.length > 0 && outro !== '') {
|
|
@@ -4693,8 +5185,73 @@ export function dailyEditorialRender(args: string[]): void {
|
|
|
4693
5185
|
const leadId = orderedIds[0];
|
|
4694
5186
|
const leadDoc = leadId !== undefined ? docById.get(leadId) : undefined;
|
|
4695
5187
|
const leadStoryTitle = typeof leadDoc?.title === 'string' ? leadDoc.title.trim() : '';
|
|
5188
|
+
// 0385 R4: freeze ONE episode identity (run date + one point + the source ids the point rests
|
|
5189
|
+
// on) for every publishing surface. The point is the script plan's cover headline and the cover
|
|
5190
|
+
// reuses it verbatim, never a second wording. Two non-frozen outcomes are explicit: an existing
|
|
5191
|
+
// frozen record wins (a retry or a historical replay keeps the identity the bundle shipped), and
|
|
5192
|
+
// a point whose supporting sources admission dropped is WITHHELD — no title, no cover point, so
|
|
5193
|
+
// nothing downstream can publish a headline the settled plan no longer backs.
|
|
5194
|
+
const rawCoverSupport =
|
|
5195
|
+
rawCover !== null && typeof rawCover === 'object' ? (rawCover as Record<string, unknown>).sourceIds : undefined;
|
|
5196
|
+
// 0385 R4/P3: "admitted" means the episode actually covers the id — the plan docs MINUS the drop
|
|
5197
|
+
// signals downstream already honours (the article boundary drop `metadata.excludedIds` and the
|
|
5198
|
+
// script plan's own `excluded` list). Comparing against the raw plan set made the withhold
|
|
5199
|
+
// guarantee structurally unreachable: the lead is always in the plan it came from.
|
|
5200
|
+
const droppedIds = new Set<string>();
|
|
5201
|
+
const articleMetaExcluded = metadataOf(
|
|
5202
|
+
readJson(join(workDir, '22-article', `${runDate}_06_article_content.json`)),
|
|
5203
|
+
)?.excludedIds;
|
|
5204
|
+
if (Array.isArray(articleMetaExcluded)) {
|
|
5205
|
+
for (const id of articleMetaExcluded) if (typeof id === 'string' && id !== '') droppedIds.add(id);
|
|
5206
|
+
}
|
|
5207
|
+
if (Array.isArray(master.excluded)) {
|
|
5208
|
+
for (const entry of master.excluded as unknown[]) {
|
|
5209
|
+
const id = entry !== null && typeof entry === 'object' ? (entry as { id?: unknown }).id : undefined;
|
|
5210
|
+
if (typeof id === 'string' && id !== '') droppedIds.add(id);
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
const admittedSourceIds = [...docById.keys()].filter((id) => !droppedIds.has(id));
|
|
5214
|
+
// The point's support is the cover's own `sourceIds` when the writer named them (the documented
|
|
5215
|
+
// producer, 0385 R4), otherwise the admitted lead — the story the point is about.
|
|
5216
|
+
const supportIds = Array.isArray(rawCoverSupport)
|
|
5217
|
+
? rawCoverSupport.filter((id): id is string => typeof id === 'string' && id.trim() !== '')
|
|
5218
|
+
: leadId !== undefined
|
|
5219
|
+
? [leadId]
|
|
5220
|
+
: [];
|
|
5221
|
+
const identityPath = join(workDir, '21-plan', `${runDate}_05_script_identity.json`);
|
|
5222
|
+
const priorIdentity = identityFromMetadata({ [EPISODE_IDENTITY_KEY]: readJson(identityPath) });
|
|
5223
|
+
const identity =
|
|
5224
|
+
priorIdentity !== null && priorIdentity.status === 'frozen'
|
|
5225
|
+
? priorIdentity
|
|
5226
|
+
: freezeEpisodeIdentity({
|
|
5227
|
+
date: runDate,
|
|
5228
|
+
headline: coverHeadline,
|
|
5229
|
+
supportingSourceIds: supportIds,
|
|
5230
|
+
admittedSourceIds,
|
|
5231
|
+
legacyTitle: leadStoryTitle,
|
|
5232
|
+
});
|
|
5233
|
+
if (priorIdentity === null || priorIdentity.status !== 'frozen') {
|
|
5234
|
+
sted('mkdir', join(workDir, '21-plan'), () => mkdirSync(join(workDir, '21-plan'), { recursive: true }));
|
|
5235
|
+
sted('write', identityPath, () => writeJsonText(identityPath, identity));
|
|
5236
|
+
}
|
|
5237
|
+
if (identity.status === 'frozen') {
|
|
5238
|
+
console.log(`editorial-render: episode identity frozen: ${identity.title} (${identityPath})`);
|
|
5239
|
+
} else if (identity.status === 'support-removed') {
|
|
5240
|
+
// The point lost its support in admission: withhold it and its cover copy (never a fallback
|
|
5241
|
+
// title here — the fallback below would smuggle back a point the plan no longer admits).
|
|
5242
|
+
console.error(
|
|
5243
|
+
`editorial-render: WITHHELD episode identity — admission dropped the headline's support (${identity.supportingSourceIds.join(', ')}); the title and the cover point are withheld (see ${identityPath})`,
|
|
5244
|
+
);
|
|
5245
|
+
coverHeadline = '';
|
|
5246
|
+
}
|
|
5247
|
+
// Every target reads the frozen title from the bundle, so the article Content (surfdash, ID3,
|
|
5248
|
+
// show notes) carries the same one the podcast and the cover do. A withheld identity leaves the
|
|
5249
|
+
// article title untouched: there is no title to share. On a first run the Content does not exist
|
|
5250
|
+
// yet (this stage precedes `daily-article`) and the stamp is a no-op — `daily-article` re-applies
|
|
5251
|
+
// it after it derives, so both orders converge on one title.
|
|
5252
|
+
stampEpisodeIdentity(join(workDir, '22-article', `${runDate}_06_article_content.json`), identity);
|
|
4696
5253
|
if (coverSubject !== '') {
|
|
4697
|
-
if (coverHeadline === '' && leadStoryTitle !== '') {
|
|
5254
|
+
if (coverHeadline === '' && leadStoryTitle !== '' && identity.status !== 'support-removed') {
|
|
4698
5255
|
coverHeadline = leadStoryTitle;
|
|
4699
5256
|
}
|
|
4700
5257
|
const coverDir = join(workDir, '23-cover');
|
|
@@ -4703,8 +5260,11 @@ export function dailyEditorialRender(args: string[]): void {
|
|
|
4703
5260
|
sted('write', coverOut, () =>
|
|
4704
5261
|
writeJsonText(coverOut, {
|
|
4705
5262
|
subject: coverSubject,
|
|
4706
|
-
|
|
5263
|
+
// The cover reuses the frozen point verbatim (0385 R4); `episodeIdentity` carries the
|
|
5264
|
+
// title so a retry or a replay re-renders the same episode identity.
|
|
5265
|
+
headline: identity.coverHeadline ?? coverHeadline,
|
|
4707
5266
|
leadStoryTitle,
|
|
5267
|
+
episodeIdentity: identity,
|
|
4708
5268
|
}),
|
|
4709
5269
|
);
|
|
4710
5270
|
console.log(`editorial-render: wrote cover brief: ${coverOut}`);
|
|
@@ -4916,12 +5476,29 @@ export function dailyShowNotes(args: string[]): void {
|
|
|
4916
5476
|
}
|
|
4917
5477
|
}
|
|
4918
5478
|
}
|
|
5479
|
+
// 0386 R1 — the card manifest (already in published order) rides along as a file path, and
|
|
5480
|
+
// its problems are recorded beside the notes, never inside them. When no receipt exists yet
|
|
5481
|
+
// the render is explicitly allowed to run link-free: the notes are reviewable before the
|
|
5482
|
+
// article URL is known, and the article link is added only from a real receipt `postPath`.
|
|
5483
|
+
const cardsManifest = join(workDir, '25-xhs', 'cards.json');
|
|
5484
|
+
const cardsDiagnostics = join(workDir, '31-publish', `${runDate}_15_show-notes_cards-diagnostics.json`);
|
|
4919
5485
|
kk(['executor', 'run', 'podcast-pub', '--in', planIn, '--out', out, ...pluginsArgs(pluginsPath)], {
|
|
4920
5486
|
env: {
|
|
4921
5487
|
PODCAST_PUB_TITLE: titleArg,
|
|
4922
5488
|
PODCAST_PUB_RUN_DATE: runDate,
|
|
4923
5489
|
PODCAST_PUB_BRIEF_MODE: 'true',
|
|
5490
|
+
...(isFile(cardsManifest) ? { PODCAST_PUB_CARDS: cardsManifest } : {}),
|
|
5491
|
+
PODCAST_PUB_CARDS_DIAGNOSTICS: cardsDiagnostics,
|
|
5492
|
+
...(postPath === '' ? { PODCAST_PUB_BRIEF_WITHOUT_RECEIPT: 'true' } : {}),
|
|
4924
5493
|
PODCAST_PUB_ARTICLE_POST_PATH: postPath,
|
|
5494
|
+
// 0396 R1: the frozen 0384 judgment snapshot is what the correction block is read
|
|
5495
|
+
// from (stable correction id, prior-episode reference, evidence). Passing the path
|
|
5496
|
+
// only when the snapshot exists keeps a run without corrections byte-identical, and
|
|
5497
|
+
// a snapshot that cannot be read fails the render instead of dropping an owed
|
|
5498
|
+
// correction silently.
|
|
5499
|
+
...(isFile(join(workDir, '21-plan', `${runDate}_judgment-snapshot.json`))
|
|
5500
|
+
? { PODCAST_PUB_CORRECTIONS: join(workDir, '21-plan', `${runDate}_judgment-snapshot.json`) }
|
|
5501
|
+
: {}),
|
|
4925
5502
|
// 2026-10-08: the column settings carry the AI-production note. Do not append the
|
|
4926
5503
|
// stock closer to show notes (or the article, or the spoken sign-off).
|
|
4927
5504
|
...(isFile(audioContent) ? { PODCAST_PUB_AUDIO_CONTENT: audioContent } : {}),
|
|
@@ -5258,6 +5835,68 @@ export function dailyTranslateValidate(args: string[]): void {
|
|
|
5258
5835
|
});
|
|
5259
5836
|
}
|
|
5260
5837
|
|
|
5838
|
+
/** CJK ideographs and kana: present in a zh draft, absent from a real en translation. */
|
|
5839
|
+
const CJK_TEXT = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uff66-\uff9f]/u;
|
|
5840
|
+
/** Kana only: a ja translation always carries hiragana/katakana; a zh copy of the draft never does. */
|
|
5841
|
+
const KANA_TEXT = /[\u3040-\u309f\u30a0-\u30ff]/u;
|
|
5842
|
+
|
|
5843
|
+
/**
|
|
5844
|
+
* `news-localize-validate <workDir>` — the pre-freeze gate on the news pipeline's en/ja translations
|
|
5845
|
+
* (task 0409 R1).
|
|
5846
|
+
*
|
|
5847
|
+
* The `localize` agent node writes `${workDir}/22-article/locales/{en,ja}.md` (first line
|
|
5848
|
+
* `# <title>`, rest the body) between `review` and `variants`. This stage refuses a locale that is
|
|
5849
|
+
* missing, empty, untitled, or still Chinese — an untranslated locale is not a locale — so no bundle
|
|
5850
|
+
* can freeze half-localized. Translating after the freeze would break ADR-053's "publish exactly what
|
|
5851
|
+
* was safety-reviewed and frozen", and translating inside the plugin would put a model call in a
|
|
5852
|
+
* deterministic step, so the gate lives here.
|
|
5853
|
+
*/
|
|
5854
|
+
export function newsLocalizeValidate(args: string[]): void {
|
|
5855
|
+
const [workDir = ''] = args;
|
|
5856
|
+
timed(workDir, 'localize-validate', () => {
|
|
5857
|
+
const localesDir = join(workDir, '22-article', 'locales');
|
|
5858
|
+
const accepted: string[] = [];
|
|
5859
|
+
const problems: string[] = [];
|
|
5860
|
+
for (const locale of ['en', 'ja'] as const) {
|
|
5861
|
+
const file = join(localesDir, `${locale}.md`);
|
|
5862
|
+
if (!isFile(file)) {
|
|
5863
|
+
problems.push(`${locale}: file missing (${file})`);
|
|
5864
|
+
continue;
|
|
5865
|
+
}
|
|
5866
|
+
const raw = readFileSync(file, 'utf-8');
|
|
5867
|
+
if (raw.trim() === '') {
|
|
5868
|
+
problems.push(`${locale}: file is empty`);
|
|
5869
|
+
continue;
|
|
5870
|
+
}
|
|
5871
|
+
const [firstLine = '', ...rest] = raw.split('\n');
|
|
5872
|
+
const title = firstLine.startsWith('# ') ? firstLine.slice(2).trim() : '';
|
|
5873
|
+
if (title === '') {
|
|
5874
|
+
problems.push(`${locale}: first line must be "# <title>", got "${firstLine.trim().slice(0, 60)}"`);
|
|
5875
|
+
continue;
|
|
5876
|
+
}
|
|
5877
|
+
if (rest.join('\n').trim() === '') {
|
|
5878
|
+
problems.push(`${locale}: body is empty after the title line`);
|
|
5879
|
+
continue;
|
|
5880
|
+
}
|
|
5881
|
+
const untranslated = locale === 'en' ? CJK_TEXT.test(raw) : !KANA_TEXT.test(raw);
|
|
5882
|
+
if (untranslated) {
|
|
5883
|
+
problems.push(
|
|
5884
|
+
`${locale}: untranslated — ${locale === 'en' ? 'the document still carries CJK text' : 'the document has no kana, so it is not Japanese'}`,
|
|
5885
|
+
);
|
|
5886
|
+
continue;
|
|
5887
|
+
}
|
|
5888
|
+
accepted.push(locale);
|
|
5889
|
+
}
|
|
5890
|
+
if (problems.length > 0) {
|
|
5891
|
+
failWith(1, `localize-validate: ${problems.join('; ')} — repair the translation before freezing`);
|
|
5892
|
+
}
|
|
5893
|
+
sted('write', join(localesDir, 'localize-validate.json'), () =>
|
|
5894
|
+
writeJsonText(join(localesDir, 'localize-validate.json'), { ok: true, locales: accepted }),
|
|
5895
|
+
);
|
|
5896
|
+
console.log(`localize-validate: ${accepted.join('/')} translations ready for the freeze`);
|
|
5897
|
+
});
|
|
5898
|
+
}
|
|
5899
|
+
|
|
5261
5900
|
export function dailyTranslateSync(args: string[]): void {
|
|
5262
5901
|
const [workDir = '', runDate = '', pluginsPath = '', zhPathFile = ''] = args;
|
|
5263
5902
|
const sync = join(workDir, '31-publish', `${runDate}_24_translate-sync_sync.json`);
|