@gobing-ai/knowledge-kit 0.1.24 → 0.1.27
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 +416 -79
- package/package.json +1 -1
- package/plugins/generations/episode-plan-gen/dist/index.js +47 -6
- package/plugins/generations/episode-plan-gen/src/index.ts +71 -7
- package/plugins/generations/music-gen/dist/index.js +17 -13
- package/plugins/generations/music-gen/src/audio/measure.ts +25 -20
- package/plugins/kk/decisions/extract/ai-news.yaml +8 -1
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +4 -4
- package/plugins/kk/publish-presets/itc-main.json +39 -23
- package/plugins/kk/scripts/cn-lead-gate.ts +494 -0
- package/plugins/kk/scripts/daily-stages.ts +880 -131
- package/plugins/kk/scripts/kk-workflow-stages.ts +58 -3
- package/plugins/kk/skills/content-safety/references/platforms/apple-podcasts.md +12 -5
- package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +8 -0
- package/plugins/kk/skills/content-safety/references/platforms/xiaoyuzhou.md +5 -0
- package/plugins/kk/skills/daily-news-cover/SKILL.md +96 -0
- package/plugins/kk/skills/daily-news-illustrations/SKILL.md +123 -0
- package/plugins/kk/skills/news-editorial/SKILL.md +25 -6
- package/plugins/kk/skills/news-editorial/references/daily-visual-composition.md +150 -0
- package/plugins/kk/skills/news-editorial/references/selection.md +42 -0
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +1 -1
- package/plugins/kk/workflows/kk-article-generate.yaml +13 -1
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +6 -3
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -4
- package/plugins/kk/workflows/kk-news-generate.yaml +71 -1
- package/plugins/publishings/bilibili-pub/dist/index.js +35 -3
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/cnblogs-pub/dist/index.js +35 -3
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/csdn-pub/dist/index.js +35 -3
- package/plugins/publishings/csdn-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/infoq-pub/dist/index.js +35 -3
- package/plugins/publishings/infoq-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/jike-pub/dist/index.js +35 -3
- package/plugins/publishings/jike-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/juejin-pub/dist/index.js +35 -3
- package/plugins/publishings/juejin-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/linkedin-pub/dist/index.js +86 -14
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +52 -6
- package/plugins/publishings/linkedin-pub/src/index.ts +126 -9
- package/plugins/publishings/medium-pub/dist/index.js +9229 -279
- package/plugins/publishings/medium-pub/dist/profile-check.js +21205 -0
- package/plugins/publishings/medium-pub/package.json +3 -1
- package/plugins/publishings/medium-pub/plugin.json +6 -1
- package/plugins/publishings/medium-pub/src/browser-rail.ts +280 -0
- package/plugins/publishings/medium-pub/src/index.ts +17 -1
- package/plugins/publishings/medium-pub/src/profile-check.ts +27 -0
- package/plugins/publishings/shipinhao-pub/dist/index.js +38 -4
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +37 -4
- package/plugins/publishings/shipinhao-pub/src/flow.ts +5 -0
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +11 -4
- package/plugins/publishings/sspai-pub/dist/index.js +35 -3
- package/plugins/publishings/sspai-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/substack-pub/dist/index.js +35 -3
- package/plugins/publishings/substack-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/surfdash-pub/dist/index.js +53 -15
- package/plugins/publishings/surfdash-pub/src/index.ts +31 -4
- package/plugins/publishings/surfdash-pub/src/patch.ts +81 -12
- package/plugins/publishings/threads-pub/dist/index.js +35 -3
- package/plugins/publishings/threads-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/wechatmp-pub/dist/index.js +326 -44
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +69 -4
- package/plugins/publishings/wechatmp-pub/src/flow.ts +447 -53
- package/plugins/publishings/wechatmp-pub/src/index.ts +68 -2
- package/plugins/publishings/wechatmp-pub/src/page.ts +8 -0
- package/plugins/publishings/weibo-pub/dist/index.js +58 -9
- package/plugins/publishings/weibo-pub/dist/profile-check.js +57 -9
- package/plugins/publishings/weibo-pub/plugin.json +1 -1
- package/plugins/publishings/weibo-pub/src/index.ts +76 -8
- package/plugins/publishings/x-pub/dist/index.js +35 -3
- package/plugins/publishings/x-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/xhs-pub/dist/index.js +35 -3
- package/plugins/publishings/xhs-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +35 -3
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +35 -3
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Daily visual composition — one text-free scene per episode
|
|
2
|
+
|
|
3
|
+
Shared by `kk:daily-news-cover` (the cover) and the card series. It owns *how to pick and describe*
|
|
4
|
+
the scene; the renderers own pixels, typography and pins. Nothing here is vendor artwork or vendor
|
|
5
|
+
prose: every pattern and example is written for this product, so the reference ships inside the
|
|
6
|
+
package and reads the same on any machine.
|
|
7
|
+
|
|
8
|
+
## The canvas the scene has to survive
|
|
9
|
+
|
|
10
|
+
| Fact | Value | Owner |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| Cover canvas | 1344 × 576 (21:9) | `plugins/generations/image-gen/presets/formats/daily-news-podcast-cover.yaml` |
|
|
13
|
+
| Social crop | 1200 × 630 JPG | `plugins/kk/scripts/cover-compositor.ts` |
|
|
14
|
+
| Headline zone | lower third, ≤25 chars/row, ≤3 rows | `cover-compositor.ts` |
|
|
15
|
+
| Safe region | the intersection of every target crop, inset 32 px — the only area the headline may occupy | `cover-compositor.ts` (`SAFE_MARGIN`) |
|
|
16
|
+
| Tightest crop | the 1:1 feed crop keeps only x 384..960 of the 1344-wide frame | `cover-compositor.ts` |
|
|
17
|
+
|
|
18
|
+
The model authors a **scene**, never a layout: the format template already asks for "focal subject in
|
|
19
|
+
upper-center or right-third, generous dark negative space in the lower third". Your job is to choose a
|
|
20
|
+
focal subject that belongs in that band and to keep the middle column (`x 384..960`) meaningful,
|
|
21
|
+
because that column is all the 1:1 feed crop will ever show.
|
|
22
|
+
|
|
23
|
+
## Choosing a pattern
|
|
24
|
+
|
|
25
|
+
Pick the first rule that applies, and say which one you picked in one clause of the scene:
|
|
26
|
+
|
|
27
|
+
1. **Product-led** — the story names a product, device, model card, dataset, robot or facility you can
|
|
28
|
+
point at. Show that object doing its thing. This is the default for release, benchmark, hardware and
|
|
29
|
+
deployment news.
|
|
30
|
+
2. **Comparison** — the story's fact is an A/B (before/after, ours/theirs, price/performance, two
|
|
31
|
+
vendors, an old limit and a new one). Only when the source states both sides; show the pair in one
|
|
32
|
+
frame, never two collages.
|
|
33
|
+
3. **Metaphor** — the story is a policy, market, litigation or safety event with no photographable
|
|
34
|
+
object. Use one concrete physical object that carries the same relation (a locked gate, a
|
|
35
|
+
weighbridge, a sealed archive box, a printed contract on a desk). Concrete noun, not an abstract
|
|
36
|
+
symbol.
|
|
37
|
+
|
|
38
|
+
Never mix two patterns in one scene, never illustrate the headline's wording literally, and never
|
|
39
|
+
invent a product, benchmark or person the sources do not name.
|
|
40
|
+
|
|
41
|
+
## The ten patterns
|
|
42
|
+
|
|
43
|
+
Each row is a layout you may describe. "Focal band" is where the subject sits on the 1344 × 576 frame;
|
|
44
|
+
"Crop-safe" is what must stay inside `x 384..960`.
|
|
45
|
+
|
|
46
|
+
| # | Pattern | Use when | Focal band | Crop-safe requirement |
|
|
47
|
+
| --- | --- | --- | --- | --- |
|
|
48
|
+
| 1 | Product hero, right third | A released product or device is the news | right third, mid-height | the product's silhouette reaches into the middle column |
|
|
49
|
+
| 2 | Product hero, upper centre | A model, chip or dataset is shown as an object | upper centre | the object's core detail sits inside the middle column |
|
|
50
|
+
| 3 | Cleanroom / lab bench | Manufacturing, yield, process or hardware claims | upper centre, bench line low | the bench edge and the handled object both survive |
|
|
51
|
+
| 4 | Screen-in-room | Software, API, agent or UI release | right third screen, room left | the screen's frame is inside the middle column |
|
|
52
|
+
| 5 | Two-object comparison | A sourced A/B fact (price, speed, size) | left and right thirds, equal weight | both objects enter the middle column by at least a third |
|
|
53
|
+
| 6 | Before/after seam | A limit lifted, a cost dropped, a migration done | vertical seam just right of centre | the seam itself is inside the middle column |
|
|
54
|
+
| 7 | Supply-chain chain | Chips, export controls, procurement, logistics | diagonal chain from lower-left to upper-right | the chain's middle link sits in the middle column |
|
|
55
|
+
| 8 | Institutional facade | Regulation, litigation, standards, enforcement | upper centre facade, steps low | the doorway and the steps both survive |
|
|
56
|
+
| 9 | Sealed object on a desk | Market, funding, contracts, a withheld claim | upper centre object on a low desk plane | the object and its seal stay in the middle column |
|
|
57
|
+
| 10 | Single concrete metaphor | Safety, alignment, opacity, a broken promise | upper centre object, generous dark space | the metaphor's single readable detail sits in the middle column |
|
|
58
|
+
|
|
59
|
+
Two patterns may not be stacked: pick one, and let the negative space in the lower third stay empty
|
|
60
|
+
for the composited headline.
|
|
61
|
+
|
|
62
|
+
## Eight worked examples
|
|
63
|
+
|
|
64
|
+
Every example names a **sourced focal subject** (the plan item it comes from), its **spatial placement**
|
|
65
|
+
and the **crop-safe region** it protects. The quoted string is what you hand the renderer: English,
|
|
66
|
+
≤240 characters, no text.
|
|
67
|
+
|
|
68
|
+
### E1 — product-led, released accelerator (pattern 1)
|
|
69
|
+
|
|
70
|
+
- Source: the lead plan item's `title`/`metadata.brief` naming a specific accelerator or chip.
|
|
71
|
+
- Focal subject: that chip on a handler, pins catching the light.
|
|
72
|
+
- Placement: right third, mid-height; handler arm enters from the upper right.
|
|
73
|
+
- Crop-safe: the chip body and its socket must reach `x 384..960`.
|
|
74
|
+
- Scene: `a single server accelerator card held by a robotic handler arm, copper heatsink fins catching cold light, dark datacenter racks behind, empty dark lower third`
|
|
75
|
+
|
|
76
|
+
### E2 — product-led, model release (pattern 2)
|
|
77
|
+
|
|
78
|
+
- Source: the item naming the model and what it does, not its benchmark numbers.
|
|
79
|
+
- Focal subject: a glowing compute module as the model's stand-in object.
|
|
80
|
+
- Placement: upper centre, small and dense.
|
|
81
|
+
- Crop-safe: the module's core stays inside the middle column at every crop.
|
|
82
|
+
- Scene: `a compact illuminated compute module floating above a dark plinth, thin light filaments rising from its surface, deep shadows, empty dark lower third`
|
|
83
|
+
|
|
84
|
+
### E3 — product-led, robot or embodied release (pattern 1)
|
|
85
|
+
|
|
86
|
+
- Source: the item naming the robot, the task and the venue.
|
|
87
|
+
- Focal subject: the robot's end effector in mid-task.
|
|
88
|
+
- Placement: right third, reaching left into the middle column.
|
|
89
|
+
- Crop-safe: the gripper and the object it holds both survive the 1:1 crop.
|
|
90
|
+
- Scene: `a robotic gripper closing on a small metal component at a bright assembly bench, shallow depth of field, industrial hall behind, empty dark lower third`
|
|
91
|
+
|
|
92
|
+
### E4 — comparison, two vendors (pattern 5)
|
|
93
|
+
|
|
94
|
+
- Source: a sourced A/B fact — two named vendors, two measured numbers, two prices.
|
|
95
|
+
- Focal subject: two identical objects, one visibly larger or brighter, no logos.
|
|
96
|
+
- Placement: left and right thirds, equal visual weight.
|
|
97
|
+
- Crop-safe: both objects enter the middle column; neither is cropped out at 1:1.
|
|
98
|
+
- Scene: `two identical unmarked metal server chassis side by side on a dark floor, the right one taller with brighter status lights, cold rim light, empty dark lower third`
|
|
99
|
+
|
|
100
|
+
### E5 — comparison, limit lifted (pattern 6)
|
|
101
|
+
|
|
102
|
+
- Source: the item stating the old limit and the new one.
|
|
103
|
+
- Focal subject: one wall of stacked panels ending mid-frame, the far half clean.
|
|
104
|
+
- Placement: vertical seam just right of centre.
|
|
105
|
+
- Crop-safe: the seam sits inside the middle column so both halves read at 1:1.
|
|
106
|
+
- Scene: `a wall of stacked dark glass panels, the left half frosted and the right half clear, a clean vertical seam just right of centre, empty dark lower third`
|
|
107
|
+
|
|
108
|
+
### E6 — supply chain, export controls (pattern 7)
|
|
109
|
+
|
|
110
|
+
- Source: the item naming the component, the restriction and the two countries or firms.
|
|
111
|
+
- Focal subject: a chain of identical sealed crates on a loading line.
|
|
112
|
+
- Placement: diagonal from lower-left to upper-right.
|
|
113
|
+
- Crop-safe: the middle crate sits inside the middle column.
|
|
114
|
+
- Scene: `a diagonal line of sealed cargo crates on an industrial loading dock, cold overhead light, the middle crate in sharp focus, empty dark lower third`
|
|
115
|
+
|
|
116
|
+
### E7 — institutional, regulation or litigation (pattern 8)
|
|
117
|
+
|
|
118
|
+
- Source: the item naming the regulator, court or standard, and the actor it acts on.
|
|
119
|
+
- Focal subject: the institution's steps and doorway, no crest, no flag, no readable sign.
|
|
120
|
+
- Placement: upper centre facade, steps low in frame.
|
|
121
|
+
- Crop-safe: doorway and steps both stay inside the middle column.
|
|
122
|
+
- Scene: `the stone steps and open doorway of a neoclassical institutional building at dusk, unmarked facade, cold blue light, empty dark lower third`
|
|
123
|
+
|
|
124
|
+
### E8 — metaphor, a withheld or broken claim (pattern 10)
|
|
125
|
+
|
|
126
|
+
- Source: an item whose fact is an unverifiable claim, a retraction or a sealed filing.
|
|
127
|
+
- Focal subject: one sealed document box on a bare desk, tape intact.
|
|
128
|
+
- Placement: upper centre on a low desk plane.
|
|
129
|
+
- Crop-safe: the box and its seal remain inside the middle column.
|
|
130
|
+
- Scene: `a single sealed cardboard document box taped shut on a bare metal desk, one bare bulb above, deep shadow around it, empty dark lower third`
|
|
131
|
+
|
|
132
|
+
## Refusals
|
|
133
|
+
|
|
134
|
+
A scene is rejected before any spend when it contains any of:
|
|
135
|
+
|
|
136
|
+
- lettering of any kind — words, captions, labels, UI text, code, numbers, signage;
|
|
137
|
+
- a logo, brand mark, crest, flag or uniform insignia;
|
|
138
|
+
- a recognizable real person, or a person's face as the focal subject;
|
|
139
|
+
- a style, colour, lighting or lens instruction (the pinned style owns those);
|
|
140
|
+
- two patterns at once, or a focal subject in the lower third where the headline is composited;
|
|
141
|
+
- a product, benchmark or actor the sources do not name;
|
|
142
|
+
- more than 240 characters, or a non-English scene.
|
|
143
|
+
|
|
144
|
+
## Pointers
|
|
145
|
+
|
|
146
|
+
- Composition and typography pixels: `plugins/kk/scripts/cover-compositor.ts`.
|
|
147
|
+
- The pinned look: `daily-news-podcast-cover` × `quasi-news-podcast` (format preset above).
|
|
148
|
+
- Card series: `kk:xhs-images` reuses this reference for its card artwork direction.
|
|
149
|
+
- Editorial ownership of `cover.headline`, `sourceIds` and the plan shape:
|
|
150
|
+
`plugins/kk/skills/news-editorial/SKILL.md` (mode `write`).
|
|
@@ -32,6 +32,44 @@ Every candidate `id` from `21-plan/<date>_04_quality-control-content_candidates.
|
|
|
32
32
|
gives the per-driver character rates. If kept items cannot reach the floor, keep more in-scope items rather
|
|
33
33
|
than padding.
|
|
34
34
|
|
|
35
|
+
## CN lead constraint (0433)
|
|
36
|
+
|
|
37
|
+
The plan feeds a **CN-distributed cut** (小宇宙 / 微信公众号 / 视频号 / 即刻) and the overseas surfaces from the
|
|
38
|
+
same script. Platform review items `XY-02` (`../content-safety/references/platforms/xiaoyuzhou.md`) and `WX-01`
|
|
39
|
+
(`.../wechatmp.md`) block a 单集 whose mainline is **时政 / 贸易管制 / 公共安全审查** — political affairs, export
|
|
40
|
+
or trade controls (出口管制/实体清单/关税/制裁), state- or public-security review (国家安全审查/情报/审查委员会),
|
|
41
|
+
foreign-intelligence framing. So:
|
|
42
|
+
|
|
43
|
+
- **Never lead a CN cut with that mainline.** It may not be the lead title, the cover headline or the episode
|
|
44
|
+
summary. It normally stays in scope as an **item** (SKILL.md shared rule 2 keeps regulation and export
|
|
45
|
+
controls that decide AI capacity reportable, and the 2026-11-24 operator ruling grades an overseas vendor
|
|
46
|
+
under its own regulator as `note`); only the lead position is constrained.
|
|
47
|
+
- **Chosen behaviour when it is also the day's biggest story: demote.** Move it to the best body position and
|
|
48
|
+
lead with the first clean in-scope story, and rewrite the demoted title/`metadata.brief` as a neutral
|
|
49
|
+
headline that names the AI-industry fact (融资、产能、客户、定价、产品) instead of the state-security or
|
|
50
|
+
trade-control framing. Keep every fact, number and name — this is a framing change, never a fact change.
|
|
51
|
+
- **Tradeoff, recorded.** The alternative was **two cuts** (a CN lead and an overseas lead). The pipeline
|
|
52
|
+
ships one zh script, one TTS pass and one bundle, so two leads would mean a second render path, a second
|
|
53
|
+
headline slot and two audio variants — far more than the day's loss. Demote keeps one cut and one
|
|
54
|
+
synthesis bill, at the cost of the CN surface not leading with the day's biggest story. If the losing
|
|
55
|
+
story is genuinely the only consequential one, the run refuses before synthesis instead
|
|
56
|
+
(`daily-curate-check --final` writes `21-plan/<date>_03_cn-lead-refusal.json` and exits non-zero rather
|
|
57
|
+
than pay for an episode the CN rows would drop afterwards).
|
|
58
|
+
- **Enforced in code, not by this prose.** `daily-curate-check` runs `plugins/kk/scripts/cn-lead-gate.ts` on
|
|
59
|
+
the lead (plan index 0). The scanned surface is the `title` plus the first of `metadata.brief` / `summary` /
|
|
60
|
+
the body's first sentence — the same fallback the CN show notes use. A trip rejects the plan with rule
|
|
61
|
+
`cn-lead:XY-02`, naming the matched terms in the error's `detail`. The vocabulary lives in that module,
|
|
62
|
+
which cites `XY-02`/`WX-01` as its source of truth — re-verify against the platform files when a platform
|
|
63
|
+
ruling changes.
|
|
64
|
+
- **Weak-lead fallback (0438).** On `--final`, when no candidate is clean, the first candidate whose hits all
|
|
65
|
+
come from the two-signal heuristic (AI object × policy signal — it also fires on some product copy) leads,
|
|
66
|
+
and the run logs `weak lead <id> (<terms>)` instead of refusing. The refusal is kept for a pool where every
|
|
67
|
+
candidate carries an enumerated vocabulary term.
|
|
68
|
+
- **Re-measure before changing the gate.** `plugins/kk/tests/fixtures/cn-lead-calibration.json` holds 30
|
|
69
|
+
class leads (≥28 must trip), 86 product leads (≤3 may trip) and the accepted misses; run
|
|
70
|
+
`bun test plugins/kk/tests/cn-lead-gate-0438.test.ts`. Add rows for a new shape; never edit a row after
|
|
71
|
+
seeing the gate's output, and pin each new term or actor with a class row that goes clean without it.
|
|
72
|
+
|
|
35
73
|
## Spoken Chinese adaptation
|
|
36
74
|
|
|
37
75
|
For kept items (especially those marked `needsTranslation`), adapt `title`, `body` and `metadata.brief` into spoken simplified Chinese:
|
|
@@ -49,3 +87,7 @@ When `daily-curate-check` writes `21-plan/<date>_03_curate_errors.json` (`[{ "it
|
|
|
49
87
|
- `missing-item`: add the missing candidate id either to `--out-plan` (translated) or to `--out-excluded` (with a Chinese reason).
|
|
50
88
|
- `conflict-id`: remove the id from one of the two files so it appears in only one.
|
|
51
89
|
- `unknown-id`: remove any id that does not exist in `candidates.json`'s `metadata.docs`.
|
|
90
|
+
- `cn-lead:XY-02`: the lead (plan index 0) carries a 时政/贸易管制/公共安全审查 mainline in its `title` or
|
|
91
|
+
`metadata.brief`; the error's `detail` names the matched terms. Demote that item to a body position, lead
|
|
92
|
+
with the first clean in-scope story, and rewrite the demoted `title`/`metadata.brief` into a neutral headline
|
|
93
|
+
(see § CN lead). Do **not** drop the item: it is still reportable, just not as the lead.
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
- `outro`:简短收束语,接在固定致谢之前,不超过 150 字。跨条目的综评也在这里:当天有真实可归纳的共性才写,价值不够或时长紧张时省略,只留一句收束;不为了「串起来」生造主题,不把综评写成第二个开场。
|
|
83
83
|
- `cover`:头版具象视觉内容。字符串形态是英文画面场景(不超过 240 字符,不含文字、数字、商标、旗帜或可辨识真人);0385 R4 起要冻结节目标题就必须写对象形态 `{ "scene": "…", "headline": "…", "sourceIds": ["<计划条目 id>"] }`:`headline`(必填,不超过 25 字)是本期冻结的**当日要点**,单行白话,不带日期、期号、栏目名;`scene` 可选,沿用同一英文画面契约(缺省时封面图回落默认画面主题);`sourceIds` 可选,写明这条要点依据的计划条目 id(通常是头条),一旦准入把这些条目全部丢弃,这条要点就被撤下而不是带着无依据的标题发布;不写 `sourceIds` 时默认取准入后的头条条目。只写字符串形态不会冻结要点,标题只能回落旧标题。
|
|
84
84
|
- `cards`:小红书图文笔记总标题 `title`(不超过 20 字)与导语 `body`,单条卡片标题 `card.copy`(不超过 12 字)、2–4 条短要点 `card.points`、英文画面 `card.subject`。
|
|
85
|
-
- `social`:面向 X / Threads / 微博 的推广短帖钩子 `short`(不超过 100 字)与面向 LinkedIn 的精选要点推广 `long`(不超过 300 字;禁止写成多段长文摘要),`bundle-variants` 会统一前置冻结节目标题、末尾注入 `{{podcast_url}}`
|
|
85
|
+
- `social`:面向 X / Threads / 微博 的推广短帖钩子 `short`(不超过 100 字)与面向 LinkedIn 的精选要点推广 `long`(不超过 300 字;禁止写成多段长文摘要),`bundle-variants` 会统一前置冻结节目标题、末尾注入 `{{podcast_url}}` 播客页链接;微博 / X / Threads / LinkedIn 均不附上传图片,以链接触发 `1200×630` Open Graph 预览卡,Jike 保留首张卡片图。
|
|
86
86
|
|
|
87
87
|
## 节目标题与节目身份(0385 R4)
|
|
88
88
|
|
|
@@ -36,6 +36,7 @@ vars:
|
|
|
36
36
|
agent: inline
|
|
37
37
|
skill_dir: ""
|
|
38
38
|
auto: "false"
|
|
39
|
+
adapt_only: "false"
|
|
39
40
|
preset: ""
|
|
40
41
|
__hitlAnswer: ""
|
|
41
42
|
|
|
@@ -292,10 +293,21 @@ states:
|
|
|
292
293
|
description: "Terminal — the run was rejected, the judge failed, or a revision budget ran out"
|
|
293
294
|
|
|
294
295
|
transitions:
|
|
296
|
+
- from: executor-probe
|
|
297
|
+
to: adapt
|
|
298
|
+
description: "Adapt-only mode (--adapt-only): skip outline/draft/judge and adapt + freeze the seeded draft"
|
|
299
|
+
guard:
|
|
300
|
+
kind: shell
|
|
301
|
+
options:
|
|
302
|
+
command: 'test "${vars.adapt_only}" = "true"'
|
|
303
|
+
|
|
295
304
|
- from: executor-probe
|
|
296
305
|
to: outline-write
|
|
306
|
+
description: "Full authoring mode: proceed to outline options"
|
|
297
307
|
guard:
|
|
298
|
-
kind:
|
|
308
|
+
kind: shell
|
|
309
|
+
options:
|
|
310
|
+
command: 'test "${vars.adapt_only}" != "true"'
|
|
299
311
|
|
|
300
312
|
- from: outline-write
|
|
301
313
|
to: draft-write
|
|
@@ -48,6 +48,10 @@ vars:
|
|
|
48
48
|
podcast_artist: "Robin Min"
|
|
49
49
|
podcast_album: "咸话咸说"
|
|
50
50
|
cover_enabled: "true"
|
|
51
|
+
# 0424 R2: the package's skill root, read in place by the cover brief (the daily-news-cover skill
|
|
52
|
+
# and the shared composition reference). A direct `spur workflow run` gets the checkout-relative
|
|
53
|
+
# default; `kk news generate` passes the resolved absolute root.
|
|
54
|
+
visual_skill_root: "plugins/kk/skills"
|
|
51
55
|
# F614: the daily cover pins provider+model in vars — each provider has its own look, so the
|
|
52
56
|
# pin is part of the style contract; it stays a var because the right value depends on which
|
|
53
57
|
# credentials the machine has (2026-09-24 run: minimax/image-01).
|
|
@@ -261,10 +265,9 @@ states:
|
|
|
261
265
|
agent: ${vars.agent}
|
|
262
266
|
# ADR-115 error tier: keep this prompt <= 1000 chars.
|
|
263
267
|
input: |
|
|
268
|
+
Follow mode `brief` in ${vars.visual_skill_root}/daily-news-cover/SKILL.md (read it first; composition: ${vars.visual_skill_root}/news-editorial/references/daily-visual-composition.md).
|
|
264
269
|
Read ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json — a JSON array of plan docs; don't edit it.
|
|
265
270
|
Take item 1 only (its "title" and "metadata.brief") — the episode's lead story. If item 1's mainline IS a political figure, an armed conflict or a non-AI event, take the first in-scope item instead; an AI-subject public-policy story (AI regulation, model liability/litigation, export controls, procurement, standards and safety enforcement) is in scope — keep it.
|
|
266
|
-
Write one concrete visual scene in English, ≤240 characters, that a viewer would connect to that story: objects, settings, symbols, metaphor.
|
|
267
|
-
No text, letters, numbers, logos, brand marks, flags, or recognizable real people. No style, color, lighting, or composition words — the preset owns those.
|
|
268
271
|
Output strictly valid JSON {"subject": "..."} to ${vars.work_dir}/23-cover/${vars.run_date}_07_cover-brief.json.
|
|
269
272
|
expectFile: ${vars.work_dir}/23-cover/${vars.run_date}_07_cover-brief.json
|
|
270
273
|
allowAppend: false
|
|
@@ -485,7 +488,7 @@ states:
|
|
|
485
488
|
Take item 1 only (its "title" and "metadata.brief") — the lead story.
|
|
486
489
|
Write an XHS note: "title" (≤20 chars) and "body" (≤1000 Chinese chars, 3-5 hashtags at the end). 选题边界:只写 AI 主题;主线是政治人物本人、武装冲突或非 AI 事件就跳过;AI 监管、模型责任与诉讼、出口管制、采购、标准与安全执法属 AI 主题公共政策,照常写入。
|
|
487
490
|
Write ${vars.xhs_cards} cards: card 1 "cover", the rest "content", a final "closing". Each card: "role", "copy" (≤12 chars), "points" (2-4 bullets), "layout", "subject" (English visual scene), "sourcePoint" (the story fact that card uses).
|
|
488
|
-
|
|
491
|
+
Card art: mode `card` in ${vars.visual_skill_root}/daily-news-illustrations/SKILL.md owns each "subject"; ground every other field in that story — no invented facts.
|
|
489
492
|
Output strictly valid JSON {"title": "...", "body": "...", "cards": [...]} to ${vars.work_dir}/25-xhs/${vars.run_date}_18_xhs_plan.json.
|
|
490
493
|
expectFile: ${vars.work_dir}/25-xhs/${vars.run_date}_18_xhs_plan.json
|
|
491
494
|
allowAppend: false
|
|
@@ -46,6 +46,10 @@ vars:
|
|
|
46
46
|
podcast_artist: "Robin Min"
|
|
47
47
|
podcast_album: "咸话咸说"
|
|
48
48
|
cover_enabled: "true"
|
|
49
|
+
# 0424 R2: the package's skill root, read in place by the cover brief (the daily-news-cover skill
|
|
50
|
+
# and the shared composition reference). A direct `spur workflow run` gets the checkout-relative
|
|
51
|
+
# default; `kk news generate` passes the resolved absolute root.
|
|
52
|
+
visual_skill_root: "plugins/kk/skills"
|
|
49
53
|
cover_provider: "minimax"
|
|
50
54
|
cover_model: "image-01"
|
|
51
55
|
cover_fallback: ""
|
|
@@ -465,10 +469,9 @@ nodes:
|
|
|
465
469
|
timeoutMs: 600000
|
|
466
470
|
# ADR-115 error tier: keep this prompt <= 1000 chars.
|
|
467
471
|
input: |
|
|
472
|
+
Follow mode `brief` in ${vars.visual_skill_root}/daily-news-cover/SKILL.md (read it first; composition: ${vars.visual_skill_root}/news-editorial/references/daily-visual-composition.md).
|
|
468
473
|
Read ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json — a JSON array of plan docs; don't edit it.
|
|
469
474
|
Take item 1 only (its "title" and "metadata.brief") — the episode's lead story. If item 1's mainline IS a political figure, an armed conflict or a non-AI event, take the first in-scope item instead; an AI-subject public-policy story (AI regulation, model liability/litigation, export controls, procurement, standards and safety enforcement) is in scope — keep it.
|
|
470
|
-
Write one concrete visual scene in English, ≤240 characters, that a viewer would connect to that story: objects, settings, symbols, metaphor.
|
|
471
|
-
No text, letters, numbers, logos, brand marks, flags, or recognizable real people. No style, color, lighting, or composition words — the preset owns those.
|
|
472
475
|
Output strictly valid JSON {"subject": "..."} to ${vars.work_dir}/23-cover/${vars.run_date}_07_cover-brief.json.
|
|
473
476
|
expectFile: ${vars.work_dir}/23-cover/${vars.run_date}_07_cover-brief.json
|
|
474
477
|
allowAppend: false
|
|
@@ -770,10 +773,9 @@ nodes:
|
|
|
770
773
|
# ADR-115 error tier: keep this prompt <= 1000 chars.
|
|
771
774
|
input: |
|
|
772
775
|
Read ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json — a JSON array of news docs; don't edit it.
|
|
773
|
-
Plan the whole episode; card 1 is the hook.
|
|
774
776
|
Write an XHS note: "title" (≤20 chars) and "body" (Chinese lead paragraph + 3-5 hashtags) — the stage appends one numbered line per image below it. 选题边界:只写 AI 主题;主线是政治人物本人、武装冲突或非 AI 事件就跳过;AI 监管、模型责任与诉讼、出口管制、采购、标准与安全执法属 AI 主题公共政策,照常写入。
|
|
775
777
|
Write ${vars.xhs_cards} cards in plan order: card 1 "cover"; one "content" per plan item (max ${vars.xhs_cards} - 2); last "closing". Each card: "role", "copy" (≤12 chars), "points" (2-4 bullets), "layout", "subject" (English visual scene), "sourcePoint" (that item's fact), "itemId" (its "id").
|
|
776
|
-
|
|
778
|
+
Card art: mode `card` in ${vars.visual_skill_root}/daily-news-illustrations/SKILL.md owns each "subject"; ground every other field in that item — no invented facts.
|
|
777
779
|
Output strictly valid JSON {"title": "...", "body": "...", "cards": [...]} to ${vars.work_dir}/25-xhs/${vars.run_date}_18_xhs_plan.json.
|
|
778
780
|
expectFile: ${vars.work_dir}/25-xhs/${vars.run_date}_18_xhs_plan.json
|
|
779
781
|
allowAppend: false
|
|
@@ -32,6 +32,21 @@ vars:
|
|
|
32
32
|
# The writer skill, read in place (design §2.2): `<package>/plugins/kk/skills/news-editorial`. No
|
|
33
33
|
# `20-editorial/` copy and no style-contract copy exist in a new run — the prompts cite this path.
|
|
34
34
|
skill_dir: ""
|
|
35
|
+
# 0424 R2: the package's skill root, read in place for the daily visual direction (cover scene +
|
|
36
|
+
# shared composition reference). `kk news generate` passes the resolved absolute root; the
|
|
37
|
+
# checkout-relative default keeps a direct `spur workflow run` call working.
|
|
38
|
+
visual_skill_root: "plugins/kk/skills"
|
|
39
|
+
# 0426 R1: opt-in inline figures in the WeChat article variant. Off by default; `kk news generate
|
|
40
|
+
# --inline-illustrations` forwards "true" after admitting the target, and a direct
|
|
41
|
+
# `spur workflow run` gets the gated-off default.
|
|
42
|
+
inline_illustrations: "false"
|
|
43
|
+
# 0426 R2: the figure requests reuse the daily cover's pinned provider/model (no implicit
|
|
44
|
+
# fallback) — the same pair the daily voice workflows ship.
|
|
45
|
+
cover_provider: "minimax"
|
|
46
|
+
cover_model: "image-01"
|
|
47
|
+
# The extra product-plugin root the figure requests may resolve presets from; "" keeps the
|
|
48
|
+
# executor's own resolution (the voice workflows' default).
|
|
49
|
+
plugins_path: ""
|
|
35
50
|
skip_review: "false"
|
|
36
51
|
preset: ""
|
|
37
52
|
|
|
@@ -167,6 +182,8 @@ nodes:
|
|
|
167
182
|
# ADR-115 error tier: keep this prompt <= 1000 chars.
|
|
168
183
|
input: |
|
|
169
184
|
Follow mode `write` in ${vars.skill_dir}/SKILL.md (read its references first: the skill owns selection, balance, style contract and the master output shape).
|
|
185
|
+
Visuals: `scene` mode in ${vars.visual_skill_root}/daily-news-cover/SKILL.md owns `cover` (keep the frozen headline and sourceIds);
|
|
186
|
+
`card` mode in ${vars.visual_skill_root}/daily-news-illustrations/SKILL.md owns each items[].card.subject. Compose per ${vars.visual_skill_root}/news-editorial/references/daily-visual-composition.md.
|
|
170
187
|
--in ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json (don't edit it)
|
|
171
188
|
--excluded ${vars.work_dir}/21-plan/${vars.run_date}_03_curate_excluded.json
|
|
172
189
|
--out ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json
|
|
@@ -208,6 +225,8 @@ nodes:
|
|
|
208
225
|
# ADR-115 error tier: keep this prompt <= 1000 chars.
|
|
209
226
|
input: |
|
|
210
227
|
Follow mode `write --fix` in ${vars.skill_dir}/SKILL.md (read its references first).
|
|
228
|
+
Visuals: `scene` mode in ${vars.visual_skill_root}/daily-news-cover/SKILL.md owns `cover` (keep the frozen headline and sourceIds);
|
|
229
|
+
`card` mode in ${vars.visual_skill_root}/daily-news-illustrations/SKILL.md owns each items[].card.subject. Compose per ${vars.visual_skill_root}/news-editorial/references/daily-visual-composition.md.
|
|
211
230
|
--in ${vars.work_dir}/21-plan/${vars.run_date}_03_plan_plan.json (don't edit it)
|
|
212
231
|
--excluded ${vars.work_dir}/21-plan/${vars.run_date}_03_curate_excluded.json
|
|
213
232
|
Previous plan (may be absent): ${vars.work_dir}/24-script/${vars.run_date}_08_script-write_plan.json
|
|
@@ -298,6 +317,57 @@ nodes:
|
|
|
298
317
|
&& grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null
|
|
299
318
|
|
|
300
319
|
# ── 13a. localize: en/ja translations of the reviewed zh article, before the freeze ────────
|
|
320
|
+
# ── 0426: inline figures for the reviewed article (opt-in, default off) ─────────────────────
|
|
321
|
+
# After the drafts verdict AND the operator review, as 0426 R1 requires: figures anchor to the body
|
|
322
|
+
# the operator approved, so an edit made at the pause never leaves a figure rendered against a
|
|
323
|
+
# superseded paragraph. Both edges are declared on purpose — `--skip-review` SKIPS `review`, and a
|
|
324
|
+
# node whose dependencies are ALL skipped is skipped, so `[safety]` alone would also work while
|
|
325
|
+
# `[review]` alone would silently drop opted-in figures; done+skipped is a mix, so this node runs.
|
|
326
|
+
# The render stage re-validates every anchor against the article as it stands when it renders, and
|
|
327
|
+
# the receipt binds the body hash, so a later edit is refused at materialization, never published.
|
|
328
|
+
- id: illustrations-plan
|
|
329
|
+
description: "Author 22-article/illustrations/plan.json (1-2 sourced whole-paragraph anchors, concept, caption, alt text) — 0426 R1; opt-in only"
|
|
330
|
+
dependsOn: [safety, review]
|
|
331
|
+
condition:
|
|
332
|
+
kind: shell
|
|
333
|
+
options:
|
|
334
|
+
command: >-
|
|
335
|
+
test "${vars.inline_illustrations}" = "true"
|
|
336
|
+
&& grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null
|
|
337
|
+
action:
|
|
338
|
+
kind: agent.run
|
|
339
|
+
options:
|
|
340
|
+
role: scribe
|
|
341
|
+
agent: ${vars.agent}
|
|
342
|
+
timeoutMs: 300000
|
|
343
|
+
# ADR-115 error tier: keep this prompt <= 1000 chars.
|
|
344
|
+
input: |
|
|
345
|
+
Follow mode `inline` in ${vars.visual_skill_root}/daily-news-illustrations/SKILL.md (read it first; composition: ${vars.visual_skill_root}/news-editorial/references/daily-visual-composition.md).
|
|
346
|
+
Read the reviewed article ${vars.work_dir}/22-article/${vars.run_date}_06_article_content.json — don't edit it.
|
|
347
|
+
Pick ONE or TWO prose paragraphs that each carry a distinct visual idea, in body order. Copy each paragraph VERBATIM as "anchor" — a whole paragraph, never a heading, quotation, list item, code line or a sentence inside one.
|
|
348
|
+
Per figure: "anchor", "sourceId" (the plan item it is about), "concept" (one text-free English scene), "caption" (<=30 Chinese chars), "altText" (<=40 Chinese chars).
|
|
349
|
+
Output strictly valid JSON {"version":1,"figures":[...]} to ${vars.work_dir}/22-article/illustrations/plan.json.
|
|
350
|
+
expectFile: ${vars.work_dir}/22-article/illustrations/plan.json
|
|
351
|
+
allowAppend: false
|
|
352
|
+
|
|
353
|
+
- id: illustrations-render
|
|
354
|
+
description: "`kk stage news-inline-illustrations` — validate the whole figure plan, then render or resume one pinned illustration per figure (0426 R1/R2); opt-in only"
|
|
355
|
+
dependsOn: [illustrations-plan]
|
|
356
|
+
condition:
|
|
357
|
+
kind: shell
|
|
358
|
+
options:
|
|
359
|
+
command: >-
|
|
360
|
+
test "${vars.inline_illustrations}" = "true"
|
|
361
|
+
&& grep -q "status.*PASS" "${vars.work_dir}/pool-gate.json" 2>/dev/null
|
|
362
|
+
action:
|
|
363
|
+
kind: shell
|
|
364
|
+
options:
|
|
365
|
+
command: >-
|
|
366
|
+
kk stage run news-inline-illustrations
|
|
367
|
+
"${vars.work_dir}" "${vars.run_date}" "${vars.plugins_path}"
|
|
368
|
+
"${vars.cover_provider}" "${vars.cover_model}"
|
|
369
|
+
"${vars.visual_skill_root}/../publish-presets/${vars.preset}.json"
|
|
370
|
+
|
|
301
371
|
- id: localize
|
|
302
372
|
description: >-
|
|
303
373
|
Translate the reviewed zh article into en/ja (0409 R1) and write
|
|
@@ -437,7 +507,7 @@ nodes:
|
|
|
437
507
|
`daily-safety-manifest` in one process: `31-publish/` prep, `30-variants/*` payloads and the
|
|
438
508
|
manifest the nested variants review registers. Two stages, because the review of those
|
|
439
509
|
variants has to run between them and a nested workflow call cannot live inside a verb.
|
|
440
|
-
dependsOn: [voice, voice-fallback, voice-fallback2, cards, localize-check]
|
|
510
|
+
dependsOn: [voice, voice-fallback, voice-fallback2, cards, localize-check, illustrations-render]
|
|
441
511
|
condition:
|
|
442
512
|
kind: shell
|
|
443
513
|
options:
|
|
@@ -20540,7 +20540,12 @@ async function acquireProfileLease(profileDir, options = {}) {
|
|
|
20540
20540
|
const leaseDir = join3(leaseRoot, id);
|
|
20541
20541
|
await fileSystem.ensureDir(leaseRoot);
|
|
20542
20542
|
if (!mkdirExclusive(leaseDir, 448)) {
|
|
20543
|
-
|
|
20543
|
+
if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
|
|
20544
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
20545
|
+
}
|
|
20546
|
+
if (!mkdirExclusive(leaseDir, 448)) {
|
|
20547
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
20548
|
+
}
|
|
20544
20549
|
}
|
|
20545
20550
|
const token = randomBytes(16).toString("hex");
|
|
20546
20551
|
const owner = {
|
|
@@ -20656,7 +20661,34 @@ async function busyGuidance(fileSystem, leaseDir) {
|
|
|
20656
20661
|
}
|
|
20657
20662
|
return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
|
|
20658
20663
|
}
|
|
20659
|
-
|
|
20664
|
+
const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
|
|
20665
|
+
const suffix = live.length > 0 ? `pid ${owner.pid} is gone but child holders ${live.join(", ")} are still running \u2014 stop those processes before retrying` : isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running and the lease could not be reclassified \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
|
|
20666
|
+
return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
|
|
20667
|
+
}
|
|
20668
|
+
async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
|
|
20669
|
+
const owner = await readOwner(fileSystem, leaseDir);
|
|
20670
|
+
if (owner === null || isProcessAlive(owner.pid))
|
|
20671
|
+
return false;
|
|
20672
|
+
if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
|
|
20673
|
+
return false;
|
|
20674
|
+
const target = staleLeaseDir(leaseDir);
|
|
20675
|
+
try {
|
|
20676
|
+
rename(leaseDir, target);
|
|
20677
|
+
} catch {
|
|
20678
|
+
return false;
|
|
20679
|
+
}
|
|
20680
|
+
const moved = await readOwner(fileSystem, target);
|
|
20681
|
+
if (moved !== null && moved.token !== owner.token) {
|
|
20682
|
+
try {
|
|
20683
|
+
rename(target, leaseDir);
|
|
20684
|
+
} catch {}
|
|
20685
|
+
return false;
|
|
20686
|
+
}
|
|
20687
|
+
return true;
|
|
20688
|
+
}
|
|
20689
|
+
function staleLeaseDir(leaseDir) {
|
|
20690
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
|
|
20691
|
+
return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
|
|
20660
20692
|
}
|
|
20661
20693
|
async function holderResidue(fileSystem, leaseDir) {
|
|
20662
20694
|
try {
|
|
@@ -20880,7 +20912,7 @@ function resolveChannelProfileDir(channel, override) {
|
|
|
20880
20912
|
return resolveBrowserProfileDir(channel, chosen);
|
|
20881
20913
|
}
|
|
20882
20914
|
async function checkChannelSession(config, opts) {
|
|
20883
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20915
|
+
const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20884
20916
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20885
20917
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20886
20918
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -19947,7 +19947,12 @@ async function acquireProfileLease(profileDir, options = {}) {
|
|
|
19947
19947
|
const leaseDir = join2(leaseRoot, id);
|
|
19948
19948
|
await fileSystem.ensureDir(leaseRoot);
|
|
19949
19949
|
if (!mkdirExclusive(leaseDir, 448)) {
|
|
19950
|
-
|
|
19950
|
+
if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
|
|
19951
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
19952
|
+
}
|
|
19953
|
+
if (!mkdirExclusive(leaseDir, 448)) {
|
|
19954
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
19955
|
+
}
|
|
19951
19956
|
}
|
|
19952
19957
|
const token = randomBytes(16).toString("hex");
|
|
19953
19958
|
const owner = {
|
|
@@ -20063,7 +20068,34 @@ async function busyGuidance(fileSystem, leaseDir) {
|
|
|
20063
20068
|
}
|
|
20064
20069
|
return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
|
|
20065
20070
|
}
|
|
20066
|
-
|
|
20071
|
+
const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
|
|
20072
|
+
const suffix = live.length > 0 ? `pid ${owner.pid} is gone but child holders ${live.join(", ")} are still running \u2014 stop those processes before retrying` : isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running and the lease could not be reclassified \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
|
|
20073
|
+
return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
|
|
20074
|
+
}
|
|
20075
|
+
async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
|
|
20076
|
+
const owner = await readOwner(fileSystem, leaseDir);
|
|
20077
|
+
if (owner === null || isProcessAlive(owner.pid))
|
|
20078
|
+
return false;
|
|
20079
|
+
if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
|
|
20080
|
+
return false;
|
|
20081
|
+
const target = staleLeaseDir(leaseDir);
|
|
20082
|
+
try {
|
|
20083
|
+
rename(leaseDir, target);
|
|
20084
|
+
} catch {
|
|
20085
|
+
return false;
|
|
20086
|
+
}
|
|
20087
|
+
const moved = await readOwner(fileSystem, target);
|
|
20088
|
+
if (moved !== null && moved.token !== owner.token) {
|
|
20089
|
+
try {
|
|
20090
|
+
rename(target, leaseDir);
|
|
20091
|
+
} catch {}
|
|
20092
|
+
return false;
|
|
20093
|
+
}
|
|
20094
|
+
return true;
|
|
20095
|
+
}
|
|
20096
|
+
function staleLeaseDir(leaseDir) {
|
|
20097
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
|
|
20098
|
+
return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
|
|
20067
20099
|
}
|
|
20068
20100
|
async function holderResidue(fileSystem, leaseDir) {
|
|
20069
20101
|
try {
|
|
@@ -20311,7 +20343,7 @@ function resolveChannelProfileDir(channel, override) {
|
|
|
20311
20343
|
return resolveBrowserProfileDir(channel, chosen);
|
|
20312
20344
|
}
|
|
20313
20345
|
async function checkChannelSession(config, opts) {
|
|
20314
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20346
|
+
const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20315
20347
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20316
20348
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20317
20349
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -20561,7 +20561,12 @@ async function acquireProfileLease(profileDir, options = {}) {
|
|
|
20561
20561
|
const leaseDir = join3(leaseRoot, id);
|
|
20562
20562
|
await fileSystem.ensureDir(leaseRoot);
|
|
20563
20563
|
if (!mkdirExclusive(leaseDir, 448)) {
|
|
20564
|
-
|
|
20564
|
+
if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
|
|
20565
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
20566
|
+
}
|
|
20567
|
+
if (!mkdirExclusive(leaseDir, 448)) {
|
|
20568
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
20569
|
+
}
|
|
20565
20570
|
}
|
|
20566
20571
|
const token = randomBytes(16).toString("hex");
|
|
20567
20572
|
const owner = {
|
|
@@ -20677,7 +20682,34 @@ async function busyGuidance(fileSystem, leaseDir) {
|
|
|
20677
20682
|
}
|
|
20678
20683
|
return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
|
|
20679
20684
|
}
|
|
20680
|
-
|
|
20685
|
+
const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
|
|
20686
|
+
const suffix = live.length > 0 ? `pid ${owner.pid} is gone but child holders ${live.join(", ")} are still running \u2014 stop those processes before retrying` : isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running and the lease could not be reclassified \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
|
|
20687
|
+
return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
|
|
20688
|
+
}
|
|
20689
|
+
async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
|
|
20690
|
+
const owner = await readOwner(fileSystem, leaseDir);
|
|
20691
|
+
if (owner === null || isProcessAlive(owner.pid))
|
|
20692
|
+
return false;
|
|
20693
|
+
if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
|
|
20694
|
+
return false;
|
|
20695
|
+
const target = staleLeaseDir(leaseDir);
|
|
20696
|
+
try {
|
|
20697
|
+
rename(leaseDir, target);
|
|
20698
|
+
} catch {
|
|
20699
|
+
return false;
|
|
20700
|
+
}
|
|
20701
|
+
const moved = await readOwner(fileSystem, target);
|
|
20702
|
+
if (moved !== null && moved.token !== owner.token) {
|
|
20703
|
+
try {
|
|
20704
|
+
rename(target, leaseDir);
|
|
20705
|
+
} catch {}
|
|
20706
|
+
return false;
|
|
20707
|
+
}
|
|
20708
|
+
return true;
|
|
20709
|
+
}
|
|
20710
|
+
function staleLeaseDir(leaseDir) {
|
|
20711
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
|
|
20712
|
+
return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
|
|
20681
20713
|
}
|
|
20682
20714
|
async function holderResidue(fileSystem, leaseDir) {
|
|
20683
20715
|
try {
|
|
@@ -20903,7 +20935,7 @@ function resolveChannelProfileDir(channel, override) {
|
|
|
20903
20935
|
return resolveBrowserProfileDir(channel, chosen);
|
|
20904
20936
|
}
|
|
20905
20937
|
async function checkChannelSession(config, opts) {
|
|
20906
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20938
|
+
const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20907
20939
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20908
20940
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20909
20941
|
const deadline = Date.now() + timeoutMs;
|