@gobing-ai/knowledge-kit 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/index.js +2399 -177
- package/package.json +1 -1
- package/plugins/generations/content-gen/dist/index.js +60 -54
- package/plugins/generations/content-gen/src/storm.ts +94 -61
- package/plugins/generations/core-facts-gen/dist/index.js +3 -3
- package/plugins/generations/daily-article-gen/dist/index.js +3 -3
- package/plugins/generations/dailynews-gen/dist/index.js +73 -10
- package/plugins/generations/dailynews-gen/src/index.ts +23 -1
- package/plugins/generations/dailynews-gen/src/script-plan.ts +103 -5
- package/plugins/generations/episode-plan-gen/dist/index.js +3 -3
- package/plugins/generations/gemini-tts/dist/index.js +3 -3
- package/plugins/generations/image-gen/README.md +31 -10
- package/plugins/generations/image-gen/assets/sample/cover__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-cover__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__clean-webapp-ui.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__cute.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__daily-news.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__editorial.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__fresh.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__minimalist.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__photorealistic.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__sketch.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__technical-diagram.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__vibrant.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__warm.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__xhs-knowledge.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/free__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/illustration__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/assets/sample/xhs-card__quasi-news-podcast.jpg +0 -0
- package/plugins/generations/image-gen/dist/index.js +3 -3
- package/plugins/generations/image-gen/presets/formats/daily-news-podcast-cover.yaml +18 -0
- package/plugins/generations/image-gen/presets/styles/quasi-news-podcast.yaml +9 -0
- package/plugins/generations/news-report-gen/dist/index.js +3 -3
- package/plugins/generations/voice-gen/dist/index.js +3 -3
- package/plugins/generations/voxcpm-tts/dist/index.js +3 -3
- package/plugins/ingestions/aihot-ingest/dist/index.js +3 -3
- package/plugins/ingestions/horizon-ingest/dist/index.js +3 -3
- package/plugins/ingestions/last30days-ingest/dist/index.js +3 -3
- package/plugins/ingestions/web-search/dist/index.js +3 -3
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice-migration.json +12 -3
- package/plugins/kk/publish-presets/daily-ai-voice.json +11 -3
- package/plugins/kk/scripts/cover-compositor.ts +152 -0
- package/plugins/kk/scripts/daily-cover-mock.ts +164 -0
- package/plugins/kk/scripts/daily-scheduled-run.ts +192 -3
- package/plugins/kk/scripts/daily-stages.ts +599 -27
- package/plugins/kk/scripts/daily-triage-core.ts +451 -0
- package/plugins/kk/scripts/daily-triage.ts +74 -0
- package/plugins/kk/scripts/kk-workflow-stages.ts +51 -6
- package/plugins/kk/skills/content-judge/SKILL.md +5 -4
- package/plugins/kk/skills/content-judge/references/rubrics.md +14 -0
- package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +16 -10
- package/plugins/kk/skills/news-editorial/SKILL.md +122 -0
- package/plugins/kk/skills/news-editorial/references/selection.md +47 -0
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +100 -0
- package/plugins/kk/skills/publish/SKILL.md +4 -4
- package/plugins/kk/skills/web-automation/SKILL.md +229 -77
- package/plugins/kk/skills/web-automation/references/browser-launch.md +127 -36
- package/plugins/kk/skills/wiki-authoring/SKILL.md +53 -0
- package/plugins/kk/skills/wiki-authoring/references/page-shapes.md +44 -0
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +4 -6
- package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +185 -224
- package/plugins/kk/workflows/kk-daily-publish3.yaml +16 -8
- package/plugins/kk/workflows/kk-daily-safety.yaml +32 -7
- package/plugins/publishings/bilibili-pub/dist/index.js +6 -4
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +3 -1
- package/plugins/publishings/cnblogs-pub/dist/index.js +6 -4
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +3 -1
- package/plugins/publishings/csdn-pub/dist/index.js +6 -4
- package/plugins/publishings/csdn-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/emdash-pub/dist/index.js +3 -3
- package/plugins/publishings/infoq-pub/dist/index.js +6 -4
- package/plugins/publishings/infoq-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/jike-pub/dist/index.js +6 -4
- package/plugins/publishings/jike-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/juejin-pub/dist/index.js +6 -4
- package/plugins/publishings/juejin-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/linkedin-pub/dist/index.js +6 -4
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/medium-pub/dist/index.js +3 -3
- package/plugins/publishings/podcast-pub/dist/index.js +148 -5
- package/plugins/publishings/podcast-pub/src/index.ts +71 -2
- package/plugins/publishings/podcast-pub/src/map.ts +3 -0
- package/plugins/publishings/podcast-pub/src/transcript.ts +195 -0
- package/plugins/publishings/qiita-pub/dist/index.js +3 -3
- package/plugins/publishings/shipinhao-pub/dist/index.js +227 -53
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +51 -2
- package/plugins/publishings/shipinhao-pub/plugin.json +2 -2
- package/plugins/publishings/shipinhao-pub/src/flow.ts +335 -79
- package/plugins/publishings/shipinhao-pub/src/index.ts +16 -8
- package/plugins/publishings/shipinhao-pub/src/profile-check.ts +1 -1
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +103 -5
- package/plugins/publishings/sspai-pub/dist/index.js +6 -4
- package/plugins/publishings/sspai-pub/dist/profile-check.js +3 -1
- package/plugins/publishings/substack-pub/dist/index.js +6 -4
- package/plugins/publishings/substack-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/surfdash-pub/dist/index.js +237 -14
- package/plugins/publishings/surfdash-pub/src/index.ts +127 -6
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +189 -0
- package/plugins/publishings/threads-pub/dist/index.js +3 -3
- package/plugins/publishings/wechatmp-pub/dist/index.js +62 -40
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +10 -3
- package/plugins/publishings/wechatmp-pub/src/flow.ts +73 -37
- package/plugins/publishings/wechatmp-pub/src/page.ts +14 -0
- package/plugins/publishings/weibo-pub/dist/index.js +6 -4
- package/plugins/publishings/weibo-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/x-pub/dist/index.js +6 -4
- package/plugins/publishings/x-pub/dist/profile-check.js +6 -4
- package/plugins/publishings/xhs-pub/dist/index.js +562 -34
- package/plugins/publishings/xhs-pub/dist/profile-check.js +25 -4
- package/plugins/publishings/xhs-pub/src/errors.ts +45 -0
- package/plugins/publishings/xhs-pub/src/flow.ts +773 -45
- package/plugins/publishings/xhs-pub/src/page.ts +33 -0
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +6 -4
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +3 -1
- package/plugins/publishings/zenn-pub/dist/index.js +3 -3
- package/plugins/kk/scripts/daily-voice-style.zh.md +0 -70
|
@@ -12078,7 +12078,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
|
|
|
12078
12078
|
shortVideo: Object.freeze({
|
|
12079
12079
|
douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12080
12080
|
kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
|
|
12081
|
-
shipinhao: Object.freeze({ max:
|
|
12081
|
+
shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
|
|
12082
12082
|
})
|
|
12083
12083
|
})
|
|
12084
12084
|
});
|
|
@@ -12246,11 +12246,11 @@ var PluginManifestSchemaBase = looseObject({
|
|
|
12246
12246
|
});
|
|
12247
12247
|
var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx) => {
|
|
12248
12248
|
if (manifest.browserSession !== undefined) {
|
|
12249
|
-
if (manifest.kind !== "publish") {
|
|
12249
|
+
if (manifest.kind !== "publish" && manifest.kind !== "ingestion") {
|
|
12250
12250
|
ctx.addIssue({
|
|
12251
12251
|
code: "custom",
|
|
12252
12252
|
path: ["browserSession"],
|
|
12253
|
-
message: `browserSession requires kind "publish", not "${manifest.kind}"`
|
|
12253
|
+
message: `browserSession requires kind "publish" or "ingestion", not "${manifest.kind}"`
|
|
12254
12254
|
});
|
|
12255
12255
|
}
|
|
12256
12256
|
if (manifest.check === undefined) {
|
package/plugins/kk/plugin.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"variant": "episode",
|
|
30
30
|
"tier": 1,
|
|
31
31
|
"window": "after-generate",
|
|
32
|
-
"mode": "
|
|
32
|
+
"mode": "draft"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"id": "xhs.podcast",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"variant": "article",
|
|
60
60
|
"tier": 2,
|
|
61
61
|
"window": "after-generate",
|
|
62
|
-
"mode": "
|
|
62
|
+
"mode": "off"
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"id": "xhs.cards",
|
|
@@ -124,10 +124,19 @@
|
|
|
124
124
|
"window": "overseas-rss",
|
|
125
125
|
"mode": "dummy"
|
|
126
126
|
},
|
|
127
|
+
{
|
|
128
|
+
"id": "shipinhao.audio",
|
|
129
|
+
"plugin": "shipinhao-pub",
|
|
130
|
+
"operation": "audio",
|
|
131
|
+
"variant": "episode",
|
|
132
|
+
"tier": 1,
|
|
133
|
+
"window": "after-generate",
|
|
134
|
+
"mode": "draft"
|
|
135
|
+
},
|
|
127
136
|
{
|
|
128
137
|
"id": "shipinhao.cards",
|
|
129
138
|
"plugin": "shipinhao-pub",
|
|
130
|
-
"operation": "
|
|
139
|
+
"operation": "image",
|
|
131
140
|
"variant": "cards",
|
|
132
141
|
"tier": 3,
|
|
133
142
|
"window": "overseas-rss",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"variant": "episode",
|
|
27
27
|
"tier": 1,
|
|
28
28
|
"window": "after-generate",
|
|
29
|
-
"mode": "
|
|
29
|
+
"mode": "draft"
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"plugin": "xhs-pub",
|
|
@@ -36,6 +36,14 @@
|
|
|
36
36
|
"window": "after-generate",
|
|
37
37
|
"mode": "draft"
|
|
38
38
|
},
|
|
39
|
+
{
|
|
40
|
+
"plugin": "shipinhao-pub",
|
|
41
|
+
"operation": "audio",
|
|
42
|
+
"variant": "episode",
|
|
43
|
+
"tier": 1,
|
|
44
|
+
"window": "after-generate",
|
|
45
|
+
"mode": "draft"
|
|
46
|
+
},
|
|
39
47
|
{
|
|
40
48
|
"plugin": "wechatmp-pub",
|
|
41
49
|
"operation": "文章",
|
|
@@ -53,7 +61,7 @@
|
|
|
53
61
|
"variant": "article",
|
|
54
62
|
"tier": 2,
|
|
55
63
|
"window": "after-generate",
|
|
56
|
-
"mode": "
|
|
64
|
+
"mode": "off"
|
|
57
65
|
},
|
|
58
66
|
{
|
|
59
67
|
"plugin": "xhs-pub",
|
|
@@ -113,7 +121,7 @@
|
|
|
113
121
|
},
|
|
114
122
|
{
|
|
115
123
|
"plugin": "shipinhao-pub",
|
|
116
|
-
"operation": "
|
|
124
|
+
"operation": "image",
|
|
117
125
|
"variant": "cards",
|
|
118
126
|
"tier": 3,
|
|
119
127
|
"window": "overseas-rss",
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 0348 / ADR-046 layer 2 — deterministic typography and branding compositor for the quasi-news
|
|
8
|
+
* podcast cover. AI diffusion renders the background only (strict negative text prompt, 0347);
|
|
9
|
+
* this module renders the Chinese headline and the podcast emblem as real vector layers, so no
|
|
10
|
+
* glyph ever passes through the model. Output is a 1344x576 PNG composited via macOS `sips`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export interface CoverCompositorOptions {
|
|
14
|
+
backgroundImagePath: string;
|
|
15
|
+
headline: string;
|
|
16
|
+
leadStoryTitle?: string;
|
|
17
|
+
/** Defaults to the repo `assets/general/xhxs.svg`; a missing asset omits the badge. */
|
|
18
|
+
logoPath?: string;
|
|
19
|
+
outputPath: string;
|
|
20
|
+
width?: number; // default 1344
|
|
21
|
+
height?: number; // default 576
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const COVER_WIDTH = 1344;
|
|
25
|
+
export const COVER_HEIGHT = 576;
|
|
26
|
+
/** Max Chinese characters per headline line (news-editorial style contract, 0347). */
|
|
27
|
+
export const HEADLINE_LINE_CAP = 25;
|
|
28
|
+
const FONT_STACK = `PingFang SC, Hiragino Sans GB, 'Noto Sans CJK SC', sans-serif`;
|
|
29
|
+
|
|
30
|
+
/** XML-escape a text node or attribute value (headlines are model-authored, so assume the worst). */
|
|
31
|
+
function esc(text: string): string {
|
|
32
|
+
return text.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Split a headline into at most two lines: explicit `\n` wins, otherwise chunk at
|
|
37
|
+
* HEADLINE_LINE_CAP characters. Anything past two lines truncates with an ellipsis —
|
|
38
|
+
* the style contract caps headlines at 2 x 25 chars, so this is a last-resort guard.
|
|
39
|
+
*/
|
|
40
|
+
export function wrapHeadline(headline: string): string[] {
|
|
41
|
+
const hasBreaks = headline.includes('\n');
|
|
42
|
+
const source = hasBreaks
|
|
43
|
+
? headline
|
|
44
|
+
.split('\n')
|
|
45
|
+
.map((line) => line.trim())
|
|
46
|
+
.filter((line) => line.length > 0)
|
|
47
|
+
: chunk(headline.replaceAll('\n', ' ').trim());
|
|
48
|
+
if (source.length <= 2) return source;
|
|
49
|
+
// >2 lines: keep line 1 whole, squeeze the rest into one ellipsized line.
|
|
50
|
+
const rest = source.slice(1).join(' ');
|
|
51
|
+
const second = chunk(rest)[0] ?? '';
|
|
52
|
+
if (rest.length <= second.length) return [source[0], second];
|
|
53
|
+
return [source[0], `${second.slice(0, HEADLINE_LINE_CAP - 1)}…`];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Fixed-width chunker for CJK headlines — code points, not UTF-16 units. */
|
|
57
|
+
function chunk(text: string): string[] {
|
|
58
|
+
const chars = Array.from(text);
|
|
59
|
+
const lines: string[] = [];
|
|
60
|
+
for (let i = 0; i < chars.length; i += HEADLINE_LINE_CAP)
|
|
61
|
+
lines.push(chars.slice(i, i + HEADLINE_LINE_CAP).join(''));
|
|
62
|
+
return lines;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Inline the logo SVG with its lower text band (`SALTY CLUB`, y >= 780 of the 1095-tall
|
|
67
|
+
* viewBox) cropped away by re-clipping to `0 0 1095 760`. Returns '' when the asset is
|
|
68
|
+
* absent — the badge is branding, not content, so a missing file degrades instead of failing.
|
|
69
|
+
*/
|
|
70
|
+
export function logoBadgeSvg(logoPath: string, x: number, y: number, width: number, height: number): string {
|
|
71
|
+
if (!existsSync(logoPath)) {
|
|
72
|
+
console.error(`cover compositor: logo asset missing, badge omitted (${logoPath})`);
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
const raw = readFileSync(logoPath, 'utf-8');
|
|
76
|
+
const open = raw.indexOf('>', raw.indexOf('<svg'));
|
|
77
|
+
const close = raw.lastIndexOf('</svg>');
|
|
78
|
+
if (open === -1 || close === -1) {
|
|
79
|
+
console.error('cover compositor: logo asset is not a parseable svg, badge omitted');
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
const inner = raw.slice(open + 1, close);
|
|
83
|
+
return `<svg x="${x}" y="${y}" width="${width}" height="${height}" viewBox="0 0 1095 760" preserveAspectRatio="xMidYMid meet">${inner}</svg>`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Deterministic SVG overlay: background image, bottom scrim, logo badge, headline, podcast tag. */
|
|
87
|
+
export function buildCoverSvg(options: CoverCompositorOptions): string {
|
|
88
|
+
const width = options.width ?? COVER_WIDTH;
|
|
89
|
+
const height = options.height ?? COVER_HEIGHT;
|
|
90
|
+
const lines = wrapHeadline(options.headline);
|
|
91
|
+
const logo = logoBadgeSvg(options.logoPath ?? 'assets/general/xhxs.svg', 48, 40, 72, 50);
|
|
92
|
+
|
|
93
|
+
const typography =
|
|
94
|
+
lines.length === 1
|
|
95
|
+
? `<text x="48" y="500" font-family="${FONT_STACK}" font-size="46" font-weight="800" fill="#FFFFFF" filter="url(#textShadow)">${esc(lines[0])}</text>`
|
|
96
|
+
: `<text x="48" y="472" font-family="${FONT_STACK}" font-size="46" font-weight="800" fill="#FFFFFF" filter="url(#textShadow)">${esc(lines[0])}</text>
|
|
97
|
+
<text x="48" y="532" font-family="${FONT_STACK}" font-size="32" font-weight="700" fill="#FFB800" filter="url(#textShadow)">${esc(lines[1])}</text>`;
|
|
98
|
+
|
|
99
|
+
const badge =
|
|
100
|
+
logo !== ''
|
|
101
|
+
? `<rect x="36" y="30" width="96" height="70" rx="12" fill="#0a1424" fill-opacity="0.7" />
|
|
102
|
+
${logo}`
|
|
103
|
+
: '';
|
|
104
|
+
|
|
105
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
|
106
|
+
<image href="${encodeURI(`file://${resolve(options.backgroundImagePath)}`)}" x="0" y="0" width="${width}" height="${height}" preserveAspectRatio="xMidYMid slice" />
|
|
107
|
+
<defs>
|
|
108
|
+
<linearGradient id="bottomScrim" x1="0" y1="0" x2="0" y2="1">
|
|
109
|
+
<stop offset="0" stop-color="#0a1424" stop-opacity="0" />
|
|
110
|
+
<stop offset="1" stop-color="#0a1424" stop-opacity="0.92" />
|
|
111
|
+
</linearGradient>
|
|
112
|
+
<filter id="textShadow" x="-20%" y="-20%" width="140%" height="140%">
|
|
113
|
+
<feDropShadow dx="0" dy="3" stdDeviation="6" flood-color="#000000" flood-opacity="0.85" />
|
|
114
|
+
</filter>
|
|
115
|
+
</defs>
|
|
116
|
+
<rect x="0" y="${Math.round(height * 0.45)}" width="${width}" height="${height - Math.round(height * 0.45)}" fill="url(#bottomScrim)" />
|
|
117
|
+
${badge}
|
|
118
|
+
${typography}
|
|
119
|
+
<text x="${width - 48}" y="${height - 40}" text-anchor="end" font-family="${FONT_STACK}" font-size="18" font-weight="600" letter-spacing="2" fill="#FFFFFF" fill-opacity="0.85">DAILY AI PODCAST</text>
|
|
120
|
+
</svg>
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Render `buildCoverSvg` to a PNG at `outputPath` via macOS `sips` (ships with the OS; no
|
|
126
|
+
* native image dependency). Fail-fast: a missing `sips` or nonzero transcode throws with an
|
|
127
|
+
* actionable message — the daily run must not publish a half-composited cover.
|
|
128
|
+
*/
|
|
129
|
+
export function compositeCover(options: CoverCompositorOptions): string {
|
|
130
|
+
const svgPath = join(tmpdir(), `cover-composite-${Date.now()}.svg`);
|
|
131
|
+
writeFileSync(svgPath, buildCoverSvg(options), 'utf-8');
|
|
132
|
+
try {
|
|
133
|
+
const sips = spawnSync('sips', ['-s', 'format', 'png', svgPath, '--out', options.outputPath], {
|
|
134
|
+
stdio: 'ignore',
|
|
135
|
+
});
|
|
136
|
+
// Bun reports a missing binary as `status: undefined` plus an `error` object.
|
|
137
|
+
if (sips.error !== undefined || typeof sips.status !== 'number') {
|
|
138
|
+
throw new Error('cover compositor: sips not found; cannot render the cover overlay (macOS required)');
|
|
139
|
+
}
|
|
140
|
+
if (sips.status !== 0) {
|
|
141
|
+
throw new Error(`cover compositor: sips failed (status ${sips.status}); overlay did not render`);
|
|
142
|
+
}
|
|
143
|
+
// sips exits 0 even when it silently fails to place the output (missing parent dir) —
|
|
144
|
+
// a render that claims success without a file would leave a stale cover downstream.
|
|
145
|
+
if (!existsSync(options.outputPath)) {
|
|
146
|
+
throw new Error(`cover compositor: sips reported success but ${options.outputPath} is missing`);
|
|
147
|
+
}
|
|
148
|
+
} finally {
|
|
149
|
+
rmSync(svgPath, { force: true });
|
|
150
|
+
}
|
|
151
|
+
return options.outputPath;
|
|
152
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* 0349 R2: standalone mock cover runner — end-to-end cover verification without a daily cron
|
|
4
|
+
* run. `--mock-bg` renders a local 1344×576 gradient background via SVG→sips (zero tokens,
|
|
5
|
+
* fully offline); otherwise the background is generated through `kk executor run image-gen`
|
|
6
|
+
* with the pinned daily-news-podcast presets. Either way the headline is composited through
|
|
7
|
+
* the same `compositeCover` the daily pipeline uses, then the output is dimension-verified.
|
|
8
|
+
*/
|
|
9
|
+
import { spawnSync } from 'node:child_process';
|
|
10
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { tmpdir } from 'node:os';
|
|
12
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
13
|
+
import { parseArgs } from 'node:util';
|
|
14
|
+
import { COVER_HEIGHT, COVER_WIDTH, compositeCover } from './cover-compositor';
|
|
15
|
+
|
|
16
|
+
interface MockOptions {
|
|
17
|
+
headline: string;
|
|
18
|
+
scene: string;
|
|
19
|
+
out: string;
|
|
20
|
+
provider: string;
|
|
21
|
+
mockBg: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const MOCK_BG_SVG = `<?xml version="1.0" encoding="UTF-8"?>
|
|
25
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="${COVER_WIDTH}" height="${COVER_HEIGHT}" viewBox="0 0 ${COVER_WIDTH} ${COVER_HEIGHT}">
|
|
26
|
+
<defs>
|
|
27
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
28
|
+
<stop offset="0" stop-color="#0d1e33"/>
|
|
29
|
+
<stop offset="0.55" stop-color="#123252"/>
|
|
30
|
+
<stop offset="1" stop-color="#0a1424"/>
|
|
31
|
+
</linearGradient>
|
|
32
|
+
<radialGradient id="glow" cx="0.72" cy="0.35" r="0.5">
|
|
33
|
+
<stop offset="0" stop-color="#2f6da8" stop-opacity="0.55"/>
|
|
34
|
+
<stop offset="1" stop-color="#2f6da8" stop-opacity="0"/>
|
|
35
|
+
</radialGradient>
|
|
36
|
+
</defs>
|
|
37
|
+
<rect width="100%" height="100%" fill="url(#bg)"/>
|
|
38
|
+
<rect width="100%" height="100%" fill="url(#glow)"/>
|
|
39
|
+
<!-- scene placeholder: the live path puts diffusion imagery here -->
|
|
40
|
+
<text x="24" y="${COVER_HEIGHT - 24}" font-family="Helvetica, Arial, sans-serif" font-size="15" fill="#5a7ea6">MOCK BACKGROUND — ${COVER_WIDTH}x${COVER_HEIGHT}</text>
|
|
41
|
+
</svg>`;
|
|
42
|
+
|
|
43
|
+
function parseMockArgs(args: string[]): MockOptions {
|
|
44
|
+
const { values } = parseArgs({
|
|
45
|
+
args,
|
|
46
|
+
options: {
|
|
47
|
+
headline: { type: 'string', default: '重大突破:下一代AI深度推理时代正式开启' },
|
|
48
|
+
scene: { type: 'string', default: 'an illuminated advanced semiconductor wafer glowing in dark cleanroom' },
|
|
49
|
+
out: { type: 'string', default: '/tmp/kk-cover-mock.png' },
|
|
50
|
+
provider: { type: 'string', default: '' },
|
|
51
|
+
'mock-bg': { type: 'boolean', default: false },
|
|
52
|
+
},
|
|
53
|
+
strict: true,
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
headline: values.headline ?? '',
|
|
57
|
+
scene: values.scene ?? '',
|
|
58
|
+
out: resolve(values.out ?? ''),
|
|
59
|
+
provider: values.provider ?? '',
|
|
60
|
+
mockBg: values['mock-bg'] ?? false,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Render the mock background SVG to PNG via sips (mac-only, ADR-046). */
|
|
65
|
+
function renderMockBg(svgPath: string, pngPath: string): void {
|
|
66
|
+
const sips = spawnSync('sips', ['-s', 'format', 'png', svgPath, '--out', pngPath], { encoding: 'utf-8' });
|
|
67
|
+
if (sips.error || sips.status !== 0 || !existsSync(pngPath)) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
`daily-cover-mock: mock background render failed (sips status ${sips.status ?? 'n/a'}); stderr: ${(sips.stderr || '').trim()}`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Live path: same envelope shape dailyCover writes, through the pinned presets. */
|
|
75
|
+
function generateLiveBg(options: MockOptions, envPath: string, contentOut: string): string {
|
|
76
|
+
const kkBin = process.env.KK_BIN || 'kk';
|
|
77
|
+
const envelope = [
|
|
78
|
+
{
|
|
79
|
+
id: 'daily-cover-mock',
|
|
80
|
+
title: basename(options.out),
|
|
81
|
+
body: '',
|
|
82
|
+
metadata: {
|
|
83
|
+
imageGen: {
|
|
84
|
+
job: 'cover',
|
|
85
|
+
format: 'daily-news-podcast-cover',
|
|
86
|
+
style: 'quasi-news-podcast',
|
|
87
|
+
vars: { subject: options.scene },
|
|
88
|
+
maxImages: 1,
|
|
89
|
+
...(options.provider !== '' ? { provider: options.provider } : {}),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
writeFileSync(envPath, JSON.stringify(envelope, null, 4));
|
|
95
|
+
const run = spawnSync(kkBin, ['executor', 'run', 'image-gen', '--in', envPath, '--out', contentOut], {
|
|
96
|
+
encoding: 'utf-8',
|
|
97
|
+
});
|
|
98
|
+
if (run.error || run.status !== 0) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`daily-cover-mock: image-gen failed (status ${run.status ?? 'n/a'}); stderr: ${(run.stderr || '').trim().slice(-400)}`,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const content = JSON.parse(readFileSync(contentOut, 'utf-8')) as Array<{ metadata?: { image_path?: string } }>;
|
|
104
|
+
const imagePath = content[0]?.metadata?.image_path;
|
|
105
|
+
if (imagePath === undefined || !existsSync(imagePath)) {
|
|
106
|
+
throw new Error('daily-cover-mock: image-gen produced no usable image_path');
|
|
107
|
+
}
|
|
108
|
+
return imagePath;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Verify the composited output is a real COVER_WIDTH×COVER_HEIGHT PNG. */
|
|
112
|
+
function verifyOutput(outPath: string): { width: number; height: number } {
|
|
113
|
+
const probe = spawnSync('sips', ['-g', 'pixelWidth', '-g', 'pixelHeight', outPath], { encoding: 'utf-8' });
|
|
114
|
+
const text = probe.stdout || '';
|
|
115
|
+
const width = Number(/pixelWidth:\s*(\d+)/.exec(text)?.[1]);
|
|
116
|
+
const height = Number(/pixelHeight:\s*(\d+)/.exec(text)?.[1]);
|
|
117
|
+
if (!Number.isFinite(width) || !Number.isFinite(height)) {
|
|
118
|
+
throw new Error(`daily-cover-mock: output verification failed — sips cannot read dimensions from ${outPath}`);
|
|
119
|
+
}
|
|
120
|
+
if (width !== COVER_WIDTH || height !== COVER_HEIGHT) {
|
|
121
|
+
throw new Error(`daily-cover-mock: output is ${width}x${height}, expected ${COVER_WIDTH}x${COVER_HEIGHT}`);
|
|
122
|
+
}
|
|
123
|
+
return { width, height };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function runMock(args: string[]): { out: string; width: number; height: number; background: string } {
|
|
127
|
+
const options = parseMockArgs(args);
|
|
128
|
+
const parent = dirname(options.out);
|
|
129
|
+
if (!existsSync(parent)) {
|
|
130
|
+
// sips would silently no-op on a missing parent (0348 finding) — fail before compositing.
|
|
131
|
+
throw new Error(`daily-cover-mock: output directory does not exist: ${parent}`);
|
|
132
|
+
}
|
|
133
|
+
const tmp = mkdtempSync(join(tmpdir(), 'kk-cover-mock-'));
|
|
134
|
+
try {
|
|
135
|
+
const envPath = join(tmp, 'mock-image-gen-in.json');
|
|
136
|
+
const contentOut = join(tmp, 'content.json');
|
|
137
|
+
const background = options.mockBg
|
|
138
|
+
? (() => {
|
|
139
|
+
const svgPath = join(tmp, 'mock-bg.svg');
|
|
140
|
+
const pngPath = join(tmp, 'mock-bg.png');
|
|
141
|
+
writeFileSync(svgPath, MOCK_BG_SVG);
|
|
142
|
+
renderMockBg(svgPath, pngPath);
|
|
143
|
+
return pngPath;
|
|
144
|
+
})()
|
|
145
|
+
: generateLiveBg(options, envPath, contentOut);
|
|
146
|
+
compositeCover({
|
|
147
|
+
backgroundImagePath: background,
|
|
148
|
+
headline: options.headline,
|
|
149
|
+
outputPath: options.out,
|
|
150
|
+
});
|
|
151
|
+
const { width, height } = verifyOutput(options.out);
|
|
152
|
+
console.error(
|
|
153
|
+
`daily-cover-mock: composited ${options.out} (${width}x${height}, background=${options.mockBg ? 'mock' : options.provider || 'default'})`,
|
|
154
|
+
);
|
|
155
|
+
return { out: options.out, width, height, background: options.mockBg ? 'mock' : 'live' };
|
|
156
|
+
} finally {
|
|
157
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const invokedDirectly = process.argv[1] !== undefined && basename(process.argv[1]) === 'daily-cover-mock.ts';
|
|
162
|
+
if (invokedDirectly) {
|
|
163
|
+
runMock(process.argv.slice(2));
|
|
164
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
/** Supervise one scheduled daily run and persist its terminal outcome even after a deadline. */
|
|
3
3
|
import { spawn, spawnSync } from 'node:child_process';
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
5
6
|
import { dirname, join, resolve } from 'node:path';
|
|
6
7
|
import { parseArgs } from 'node:util';
|
|
8
|
+
import type { TriageReceipt, TriageReport } from './daily-triage-core';
|
|
9
|
+
import { collectTriage, summarizeTriage } from './daily-triage-core';
|
|
7
10
|
|
|
8
11
|
const { values } = parseArgs({
|
|
9
12
|
options: {
|
|
@@ -20,6 +23,9 @@ const { values } = parseArgs({
|
|
|
20
23
|
'generate-only': { type: 'boolean', default: false },
|
|
21
24
|
window: { type: 'string' },
|
|
22
25
|
'publish-preset': { type: 'string' },
|
|
26
|
+
'publish-live-channels': { type: 'string' },
|
|
27
|
+
'allow-dirty': { type: 'boolean', default: false },
|
|
28
|
+
'skip-probe': { type: 'boolean', default: false },
|
|
23
29
|
},
|
|
24
30
|
});
|
|
25
31
|
const timeoutMs = Number(values['timeout-ms']);
|
|
@@ -47,6 +53,9 @@ const vars = isVoice3
|
|
|
47
53
|
? {
|
|
48
54
|
auto_publish: generateOnly ? 'false' : 'true',
|
|
49
55
|
...(values['publish-preset'] !== undefined ? { publish_preset: values['publish-preset'] } : {}),
|
|
56
|
+
...(values['publish-live-channels'] !== undefined
|
|
57
|
+
? { publish_live_channels: values['publish-live-channels'] }
|
|
58
|
+
: {}),
|
|
50
59
|
...(values.window ? { window: values.window } : {}),
|
|
51
60
|
skip_review: 'true',
|
|
52
61
|
agent: values.agent,
|
|
@@ -63,7 +72,159 @@ const vars = isVoice3
|
|
|
63
72
|
work_dir: workDir,
|
|
64
73
|
run_date: stamp,
|
|
65
74
|
};
|
|
66
|
-
|
|
75
|
+
// ------------------------------------------------------------------
|
|
76
|
+
// Preflight (0347 F1, 2026-11-10). Fail fast at minute one with named
|
|
77
|
+
// reasons instead of burning the window on a doomed run (2026-11-09: 80
|
|
78
|
+
// minutes died on a quota-dead executor chain a probe would have refused,
|
|
79
|
+
// on workflow bytes that had already diverged from the installed kk).
|
|
80
|
+
// ------------------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
interface Preflight {
|
|
83
|
+
ok: boolean;
|
|
84
|
+
reasons: string[];
|
|
85
|
+
warnings: string[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const ANSI_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*[A-Za-z]`, 'g');
|
|
89
|
+
|
|
90
|
+
function harnessDirtyPaths(): string[] {
|
|
91
|
+
const git = spawnSync('git', ['status', '--porcelain', '--', 'plugins/kk', '.spur/workflows'], {
|
|
92
|
+
cwd: repo,
|
|
93
|
+
encoding: 'utf-8',
|
|
94
|
+
timeout: 10_000,
|
|
95
|
+
});
|
|
96
|
+
if (git.status !== 0) return [];
|
|
97
|
+
// Keep the full porcelain line (XY + path): the refusal must show whether a byte is staged,
|
|
98
|
+
// unstaged or untracked — 20261111 a16 spent a fix loop guessing that from bare paths.
|
|
99
|
+
return git.stdout
|
|
100
|
+
.split('\n')
|
|
101
|
+
.map((line) => line.trimEnd())
|
|
102
|
+
.filter(Boolean);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Package root of the kk binary this machine resolves `kk` to, or null. */
|
|
106
|
+
function kkPackageRoot(): string | null {
|
|
107
|
+
const which = spawnSync('sh', ['-c', 'command -v kk'], { encoding: 'utf-8', timeout: 5_000 });
|
|
108
|
+
const bin = which.stdout.trim();
|
|
109
|
+
if (which.status !== 0 || bin === '') return null;
|
|
110
|
+
try {
|
|
111
|
+
const real = realpathSync(bin);
|
|
112
|
+
// <pkg>/dist/index.js -> <pkg>
|
|
113
|
+
return dirname(dirname(real));
|
|
114
|
+
} catch {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function diffDirs(a: string, b: string): string[] {
|
|
120
|
+
if (!existsSync(a) || !existsSync(b)) return [];
|
|
121
|
+
const diff = spawnSync('diff', ['-rq', a, b], { encoding: 'utf-8', timeout: 20_000 });
|
|
122
|
+
if (diff.status === 0) return [];
|
|
123
|
+
if (diff.error || (diff.status !== 1 && diff.status !== null)) return []; // unavailable: warn elsewhere, never false-refuse
|
|
124
|
+
return diff.stdout
|
|
125
|
+
.split('\n')
|
|
126
|
+
.filter((line) => line.trim() !== '')
|
|
127
|
+
.map((line) => line.replace(a, 'checkout').replace(b, 'install'))
|
|
128
|
+
.slice(0, 5);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* One minimal real agent round-trip. `spur agent doctor` reports usable:true for accounts whose
|
|
133
|
+
* quota is exhausted (2026-11-09 R3), so executor health must be proven with traffic, not probes.
|
|
134
|
+
*/
|
|
135
|
+
function executorProbe(agentName: string): { ok: boolean; detail: string } {
|
|
136
|
+
const probeCwd = mkdtempSync(join(tmpdir(), 'kk-preflight-'));
|
|
137
|
+
try {
|
|
138
|
+
const probe = spawnSync(
|
|
139
|
+
'spur',
|
|
140
|
+
['agent', 'run', '--agent', agentName, '--mode', 'text', '--json', 'Reply with exactly: OK'],
|
|
141
|
+
{ cwd: probeCwd, encoding: 'utf-8', timeout: 120_000 },
|
|
142
|
+
);
|
|
143
|
+
if (probe.status === 0) return { ok: true, detail: 'ok' };
|
|
144
|
+
const text = `${probe.stderr ?? ''}${probe.stdout ?? ''}`.replace(ANSI_RE, '').trim();
|
|
145
|
+
const named = text
|
|
146
|
+
.split('\n')
|
|
147
|
+
.filter((line) => line.trim() !== '')
|
|
148
|
+
.slice(-2)
|
|
149
|
+
.join(' | ')
|
|
150
|
+
.slice(-240);
|
|
151
|
+
return { ok: false, detail: named !== '' ? named : `exit ${probe.status ?? '?'}` };
|
|
152
|
+
} finally {
|
|
153
|
+
rmSync(probeCwd, { recursive: true, force: true });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function runPreflight(): Preflight {
|
|
158
|
+
const reasons: string[] = [];
|
|
159
|
+
const warnings: string[] = [];
|
|
160
|
+
const dirty = harnessDirtyPaths();
|
|
161
|
+
if (dirty.length > 0 && values['allow-dirty'] !== true) {
|
|
162
|
+
reasons.push(
|
|
163
|
+
`working tree dirty on harness paths (git status --porcelain):\n ${dirty.slice(0, 10).join('\n ')}`,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
const install = kkPackageRoot();
|
|
167
|
+
if (install === null) {
|
|
168
|
+
warnings.push('kk binary not found on PATH; executed-vs-installed sync not checked');
|
|
169
|
+
} else {
|
|
170
|
+
const diffs = [
|
|
171
|
+
...diffDirs(join(repo, 'plugins', 'kk', 'workflows'), join(install, 'plugins', 'kk', 'workflows')),
|
|
172
|
+
...diffDirs(join(repo, 'plugins', 'kk', 'scripts'), join(install, 'plugins', 'kk', 'scripts')),
|
|
173
|
+
];
|
|
174
|
+
if (diffs.length > 0) {
|
|
175
|
+
reasons.push(`checkout diverges from installed kk (${install}): ${diffs.join('; ')}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (values['skip-probe'] !== true) {
|
|
179
|
+
if (values.agent !== 'inline') {
|
|
180
|
+
const probe = executorProbe(values.agent);
|
|
181
|
+
if (!probe.ok) reasons.push(`executor probe failed for primary '${values.agent}': ${probe.detail}`);
|
|
182
|
+
}
|
|
183
|
+
const retry = values['retry-agent'];
|
|
184
|
+
if (retry !== undefined && retry !== 'inline') {
|
|
185
|
+
const retryProbe = executorProbe(retry);
|
|
186
|
+
if (!retryProbe.ok) {
|
|
187
|
+
warnings.push(`executor probe failed for retry '${retry}': ${retryProbe.detail}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return { ok: reasons.length === 0, reasons, warnings };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const preflight = runPreflight();
|
|
195
|
+
if (!preflight.ok) {
|
|
196
|
+
const refused = {
|
|
197
|
+
runId,
|
|
198
|
+
startedAt,
|
|
199
|
+
completedAt: new Date().toISOString(),
|
|
200
|
+
status: 'preflight-refused',
|
|
201
|
+
exitCode: 5,
|
|
202
|
+
agent: values.agent,
|
|
203
|
+
retryAgent: values['retry-agent'],
|
|
204
|
+
workDir,
|
|
205
|
+
preflight: { reasons: preflight.reasons, warnings: preflight.warnings },
|
|
206
|
+
error: preflight.reasons[0] ?? 'preflight refused',
|
|
207
|
+
};
|
|
208
|
+
writeFileSync(receiptPath, `${JSON.stringify(refused, null, 2)}\n`);
|
|
209
|
+
console.error(`daily-scheduled-run: preflight refused run ${runId}`);
|
|
210
|
+
for (const reason of preflight.reasons) console.error(` ! ${reason}`);
|
|
211
|
+
for (const warning of preflight.warnings) console.error(` ~ ${warning}`);
|
|
212
|
+
process.exit(5);
|
|
213
|
+
}
|
|
214
|
+
writeFileSync(
|
|
215
|
+
receiptPath,
|
|
216
|
+
JSON.stringify(
|
|
217
|
+
{
|
|
218
|
+
runId,
|
|
219
|
+
startedAt,
|
|
220
|
+
status: 'running',
|
|
221
|
+
workDir,
|
|
222
|
+
preflight: { warnings: preflight.warnings, probes: values['skip-probe'] === true ? 'skipped' : 'passed' },
|
|
223
|
+
},
|
|
224
|
+
null,
|
|
225
|
+
2,
|
|
226
|
+
),
|
|
227
|
+
);
|
|
67
228
|
let interrupted = false;
|
|
68
229
|
let timedOut = false;
|
|
69
230
|
let spawnError = '';
|
|
@@ -365,6 +526,33 @@ const status =
|
|
|
365
526
|
: primaryPublishStatus === 'full' && !(!isVoice3 && missingRequiredChannels.length > 0)
|
|
366
527
|
? 'done'
|
|
367
528
|
: 'incomplete';
|
|
529
|
+
function buildTriage(finalStatus: string, exitCode: number): TriageReport | null {
|
|
530
|
+
try {
|
|
531
|
+
const inlineReceipt: TriageReceipt = {
|
|
532
|
+
status: finalStatus,
|
|
533
|
+
startedAt,
|
|
534
|
+
completedAt: new Date().toISOString(),
|
|
535
|
+
workDir,
|
|
536
|
+
agent: values.agent,
|
|
537
|
+
retryAgent: values['retry-agent'],
|
|
538
|
+
exitCode,
|
|
539
|
+
error: spawnError || null,
|
|
540
|
+
};
|
|
541
|
+
const report = collectTriage(repo, runId, { receipt: inlineReceipt, workflow: values.workflow });
|
|
542
|
+
console.error('daily-scheduled-run: triage summary');
|
|
543
|
+
for (const line of summarizeTriage(report)) console.error(` ${line}`);
|
|
544
|
+
return report;
|
|
545
|
+
} catch (error) {
|
|
546
|
+
console.error(`daily-scheduled-run: triage collection failed: ${String(error)}`);
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const terminalExitCode = timedOut ? 124 : interrupted ? 143 : exitCode !== 0 ? exitCode : status === 'done' ? 0 : 4;
|
|
552
|
+
const triage =
|
|
553
|
+
status === 'failed' || status === 'timed-out' || status === 'interrupted' || status === 'incomplete'
|
|
554
|
+
? buildTriage(status, terminalExitCode)
|
|
555
|
+
: null;
|
|
368
556
|
const receipt = {
|
|
369
557
|
runId,
|
|
370
558
|
startedAt,
|
|
@@ -372,7 +560,7 @@ const receipt = {
|
|
|
372
560
|
status,
|
|
373
561
|
generateOnly,
|
|
374
562
|
generationInspection,
|
|
375
|
-
exitCode:
|
|
563
|
+
exitCode: terminalExitCode,
|
|
376
564
|
workDir,
|
|
377
565
|
timeoutMs,
|
|
378
566
|
agent: values.agent,
|
|
@@ -384,6 +572,7 @@ const receipt = {
|
|
|
384
572
|
runSummary,
|
|
385
573
|
reservationRecovery,
|
|
386
574
|
cleanup,
|
|
575
|
+
triage,
|
|
387
576
|
};
|
|
388
577
|
writeFileSync(receiptPath, `${JSON.stringify(receipt, null, 2)}\n`);
|
|
389
578
|
console.log(JSON.stringify(receipt));
|