mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-07-12 05:51:44 +08:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8042cef0d | |||
| 15508eae43 | |||
| 94eab2de63 | |||
| 126b72ed36 | |||
| 38f4f253df | |||
| 8bc01debac | |||
| c5c54e26da | |||
| 2a0bba6161 | |||
| c44a524fa6 | |||
| 826535abe4 | |||
| fc50f31694 | |||
| 204765a137 | |||
| 4874cd2dae | |||
| b791ee5dc7 | |||
| 450c76d955 | |||
| db33da26e7 | |||
| c7c98ba034 | |||
| 60ab574559 |
@@ -6,7 +6,7 @@
|
|||||||
},
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"description": "Skills shared by Baoyu for improving daily work efficiency",
|
"description": "Skills shared by Baoyu for improving daily work efficiency",
|
||||||
"version": "1.89.0"
|
"version": "1.92.0"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,26 @@
|
|||||||
|
|
||||||
English | [中文](./CHANGELOG.zh.md)
|
English | [中文](./CHANGELOG.zh.md)
|
||||||
|
|
||||||
|
## 1.92.0 - 2026-04-08
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- `baoyu-article-illustrator`: add `macaron` style — soft macaron pastel color blocks (blue, mint, lavender, peach) on warm cream background with optional hand-drawn mode; add `edu-visual` preset
|
||||||
|
|
||||||
|
## 1.90.1 - 2026-04-05
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- `baoyu-post-to-wechat`: detect actual image format from buffer magic bytes to fix CDN content-type mismatches (e.g. WebP served for .png URLs); treat WebP as PNG-preferred for transparency handling
|
||||||
|
|
||||||
|
## 1.89.1 - 2026-04-01
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- `baoyu-chrome-cdp`: add `gracefulKillChrome` that waits for Chrome to exit and release its port; fix `killChrome` to use `exitCode`/`signalCode` instead of `.killed` for reliable process state detection
|
||||||
|
- `baoyu-fetch`: auto-detect login state before extraction in interaction wait mode
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
- Sync vendor baoyu-chrome-cdp across CDP skills
|
||||||
|
- `baoyu-url-to-markdown`: sync vendor baoyu-fetch with login auto-detect
|
||||||
|
|
||||||
## 1.89.0 - 2026-03-31
|
## 1.89.0 - 2026-03-31
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -2,6 +2,26 @@
|
|||||||
|
|
||||||
[English](./CHANGELOG.md) | 中文
|
[English](./CHANGELOG.md) | 中文
|
||||||
|
|
||||||
|
## 1.92.0 - 2026-04-08
|
||||||
|
|
||||||
|
### 新功能
|
||||||
|
- `baoyu-article-illustrator`:新增 `macaron` 风格 — 马卡龙柔和色块(浅蓝、浅绿、浅紫、浅橙)配暖白底色,可选手绘模式;新增 `edu-visual` 预设
|
||||||
|
|
||||||
|
## 1.90.1 - 2026-04-05
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
- `baoyu-post-to-wechat`:通过 magic bytes 检测实际图片格式,修复 CDN 返回与 URL 扩展名不一致的 content-type 问题(如 .png URL 实际返回 WebP);WebP 格式按 PNG 策略处理以保留透明度
|
||||||
|
|
||||||
|
## 1.89.1 - 2026-04-01
|
||||||
|
|
||||||
|
### 新功能
|
||||||
|
- `baoyu-chrome-cdp`:新增 `gracefulKillChrome`,等待 Chrome 进程退出并释放端口;修复 `killChrome` 使用 `exitCode`/`signalCode` 替代 `.killed` 以更可靠地检测进程状态
|
||||||
|
- `baoyu-fetch`:在交互等待模式下自动检测登录状态,未登录时提示用户先登录再提取内容
|
||||||
|
|
||||||
|
### 维护
|
||||||
|
- 同步 vendor baoyu-chrome-cdp 至所有 CDP 技能
|
||||||
|
- `baoyu-url-to-markdown`:同步 vendor baoyu-fetch 的登录自动检测功能
|
||||||
|
|
||||||
## 1.89.0 - 2026-03-31
|
## 1.89.0 - 2026-03-31
|
||||||
|
|
||||||
### 新功能
|
### 新功能
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# CLAUDE.md
|
# CLAUDE.md
|
||||||
|
|
||||||
Claude Code marketplace plugin providing AI-powered content generation skills. Version: **1.89.0**.
|
Claude Code marketplace plugin providing AI-powered content generation skills. Version: **1.92.0**.
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,10 @@ Xiaohongshu (RedNote) infographic series generator. Breaks down content into 1-1
|
|||||||
|
|
||||||
# Direct content input
|
# Direct content input
|
||||||
/baoyu-xhs-images 今日星座运势
|
/baoyu-xhs-images 今日星座运势
|
||||||
|
|
||||||
|
# Non-interactive (skip all confirmations, for scheduled tasks)
|
||||||
|
/baoyu-xhs-images posts/ai-future/article.md --yes
|
||||||
|
/baoyu-xhs-images posts/ai-future/article.md --yes --preset knowledge-card
|
||||||
```
|
```
|
||||||
|
|
||||||
**Styles** (visual aesthetics): `cute` (default), `fresh`, `warm`, `bold`, `minimal`, `retro`, `pop`, `notion`, `chalkboard`
|
**Styles** (visual aesthetics): `cute` (default), `fresh`, `warm`, `bold`, `minimal`, `retro`, `pop`, `notion`, `chalkboard`
|
||||||
@@ -508,6 +512,7 @@ Smart article illustration skill with Type × Style two-dimension approach. Anal
|
|||||||
| `watercolor` | Soft artistic with natural warmth | Lifestyle, travel, creative |
|
| `watercolor` | Soft artistic with natural warmth | Lifestyle, travel, creative |
|
||||||
| `editorial` | Magazine-style infographic | Tech explainers, journalism |
|
| `editorial` | Magazine-style infographic | Tech explainers, journalism |
|
||||||
| `scientific` | Academic precise diagrams | Biology, chemistry, technical |
|
| `scientific` | Academic precise diagrams | Biology, chemistry, technical |
|
||||||
|
| `macaron` | Soft macaron pastel blocks on warm cream | Educational, knowledge, tutorials |
|
||||||
|
|
||||||
**Style Previews**:
|
**Style Previews**:
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,10 @@ clawhub install baoyu-markdown-to-html
|
|||||||
|
|
||||||
# 直接输入内容
|
# 直接输入内容
|
||||||
/baoyu-xhs-images 今日星座运势
|
/baoyu-xhs-images 今日星座运势
|
||||||
|
|
||||||
|
# 非交互模式(跳过所有确认,适用于定时任务)
|
||||||
|
/baoyu-xhs-images posts/ai-future/article.md --yes
|
||||||
|
/baoyu-xhs-images posts/ai-future/article.md --yes --preset knowledge-card
|
||||||
```
|
```
|
||||||
|
|
||||||
**风格**(视觉美学):`cute`(默认)、`fresh`、`warm`、`bold`、`minimal`、`retro`、`pop`、`notion`、`chalkboard`
|
**风格**(视觉美学):`cute`(默认)、`fresh`、`warm`、`bold`、`minimal`、`retro`、`pop`、`notion`、`chalkboard`
|
||||||
@@ -508,6 +512,7 @@ clawhub install baoyu-markdown-to-html
|
|||||||
| `watercolor` | 柔和艺术感、自然温暖 | 生活方式、旅行、创意 |
|
| `watercolor` | 柔和艺术感、自然温暖 | 生活方式、旅行、创意 |
|
||||||
| `editorial` | 杂志风格信息图 | 科技解说、新闻 |
|
| `editorial` | 杂志风格信息图 | 科技解说、新闻 |
|
||||||
| `scientific` | 学术精确图表 | 生物、化学、技术 |
|
| `scientific` | 学术精确图表 | 生物、化学、技术 |
|
||||||
|
| `macaron` | 马卡龙柔和色块、暖白底色 | 教育、知识分享、教程 |
|
||||||
|
|
||||||
**风格预览**:
|
**风格预览**:
|
||||||
|
|
||||||
|
|||||||
@@ -15,5 +15,8 @@
|
|||||||
"turndown": "^7.2.2",
|
"turndown": "^7.2.2",
|
||||||
"turndown-plugin-gfm": "^1.0.2",
|
"turndown-plugin-gfm": "^1.0.2",
|
||||||
"tsx": "^4.20.5"
|
"tsx": "^4.20.5"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"pdf-lib": "^1.17.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
discoverRunningChromeDebugPort,
|
discoverRunningChromeDebugPort,
|
||||||
findChromeExecutable,
|
findChromeExecutable,
|
||||||
findExistingChromeDebugPort,
|
findExistingChromeDebugPort,
|
||||||
|
gracefulKillChrome,
|
||||||
getFreePort,
|
getFreePort,
|
||||||
openPageSession,
|
openPageSession,
|
||||||
resolveSharedChromeProfileDir,
|
resolveSharedChromeProfileDir,
|
||||||
@@ -110,6 +111,44 @@ async function stopProcess(child: ChildProcess | null): Promise<void> {
|
|||||||
await new Promise((resolve) => child.once("exit", resolve));
|
await new Promise((resolve) => child.once("exit", resolve));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function startPortHoldingProcess(port: number): Promise<ChildProcess> {
|
||||||
|
const child = spawn(
|
||||||
|
process.execPath,
|
||||||
|
[
|
||||||
|
"-e",
|
||||||
|
`
|
||||||
|
const http = require("node:http");
|
||||||
|
const port = Number(process.argv[1]);
|
||||||
|
const server = http.createServer((_req, res) => res.end("ok"));
|
||||||
|
server.listen(port, "127.0.0.1", () => process.stdout.write("ready\\n"));
|
||||||
|
setInterval(() => {}, 1000);
|
||||||
|
`,
|
||||||
|
String(port),
|
||||||
|
],
|
||||||
|
{
|
||||||
|
stdio: ["ignore", "pipe", "ignore"],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
const timer = setTimeout(() => reject(new Error("Timed out waiting for child server to start.")), 3_000);
|
||||||
|
child.once("error", (error) => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
child.stdout?.once("data", () => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
child.once("exit", () => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
reject(new Error("Child server exited before becoming ready."));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
test("getFreePort honors a fixed environment override and otherwise allocates a TCP port", async (t) => {
|
test("getFreePort honors a fixed environment override and otherwise allocates a TCP port", async (t) => {
|
||||||
useEnv(t, { TEST_FIXED_PORT: "45678" });
|
useEnv(t, { TEST_FIXED_PORT: "45678" });
|
||||||
assert.equal(await getFreePort("TEST_FIXED_PORT"), 45678);
|
assert.equal(await getFreePort("TEST_FIXED_PORT"), 45678);
|
||||||
@@ -305,3 +344,19 @@ test("waitForChromeDebugPort retries until the debug endpoint becomes available"
|
|||||||
|
|
||||||
assert.equal(websocketUrl, `ws://127.0.0.1:${port}/devtools/browser/demo`);
|
assert.equal(websocketUrl, `ws://127.0.0.1:${port}/devtools/browser/demo`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("gracefulKillChrome waits for the Chrome process to exit and release its port", async (t) => {
|
||||||
|
const port = await getFreePort();
|
||||||
|
const child = await startPortHoldingProcess(port);
|
||||||
|
t.after(async () => { await stopProcess(child); });
|
||||||
|
|
||||||
|
assert.equal(await waitForChromeDebugPort(port, 1_000).catch(() => null), null);
|
||||||
|
|
||||||
|
await gracefulKillChrome(child, port, 4_000);
|
||||||
|
|
||||||
|
assert.ok(child.exitCode !== null || child.signalCode !== null);
|
||||||
|
assert.equal(
|
||||||
|
await fetch(`http://127.0.0.1:${port}`).then(() => true).catch(() => false),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
@@ -399,6 +399,22 @@ export async function runConvertCommand(options: ConvertCommandOptions): Promise
|
|||||||
if (restored) logger.info(`Restored ${adapter.name} session cookies from sidecar.`);
|
if (restored) logger.info(`Restored ${adapter.name} session cookies from sidecar.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.waitMode === "interaction" && adapter.checkLogin) {
|
||||||
|
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
||||||
|
const preLogin = await adapter.checkLogin(context);
|
||||||
|
if (preLogin.state !== "logged_in") {
|
||||||
|
didLogin = true;
|
||||||
|
await waitForInteraction(adapter, context, {
|
||||||
|
type: "wait_for_interaction",
|
||||||
|
kind: "login",
|
||||||
|
provider: preLogin.provider ?? adapter.name,
|
||||||
|
prompt: `Please sign in to ${adapter.name === "x" ? "X" : adapter.name} in the opened Chrome window. Extraction will continue automatically once login is detected.`,
|
||||||
|
reason: preLogin.reason ?? `Not logged in to ${adapter.name}`,
|
||||||
|
requiresVisibleBrowser: true,
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (options.waitMode === "force") {
|
if (options.waitMode === "force") {
|
||||||
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
||||||
await waitForForceResume(adapter, context, options);
|
await waitForForceResume(adapter, context, options);
|
||||||
|
|||||||
@@ -264,6 +264,37 @@ STYLE: [style characteristics]
|
|||||||
ASPECT: 16:9
|
ASPECT: 16:9
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Macaron Style Instructions
|
||||||
|
|
||||||
|
When `style: macaron`, add these style instructions:
|
||||||
|
|
||||||
|
```
|
||||||
|
Educational infographic with soft macaron pastel color blocks on warm cream paper.
|
||||||
|
COLORS: Warm Cream background (#F5F0E8), Macaron Blue (#A8D8EA), Macaron Mint (#B5E5CF),
|
||||||
|
Macaron Lavender (#D5C6E0), Macaron Peach (#FFD5C2), Coral Red (#E8655A) for emphasis,
|
||||||
|
Deep Charcoal (#2D2D2D) text, Warm Gray (#6B6B6B) annotations
|
||||||
|
CONTAINERS: Rounded cards, bubbles, dashed-box frames with pastel fills to separate info zones
|
||||||
|
TYPOGRAPHY: Bold large title, bold keywords, smaller muted annotations
|
||||||
|
STRUCTURE: Auto-select best layout for content (flow→arrows, compare→columns, cycle→ring, cards→grid)
|
||||||
|
BOTTOM: Bold summary quote at bottom capturing core insight
|
||||||
|
```
|
||||||
|
|
||||||
|
**Infographic + macaron**:
|
||||||
|
```
|
||||||
|
Educational infographic on warm cream paper (#F5F0E8). Soft macaron pastel blocks as info zones.
|
||||||
|
COLORS: Macaron Blue (#A8D8EA), Mint (#B5E5CF), Lavender (#D5C6E0), Peach (#FFD5C2),
|
||||||
|
Coral Red (#E8655A) for key data, Deep Charcoal (#2D2D2D) text
|
||||||
|
ELEMENTS: Rounded-corner cards with pastel fills, clear labels, bold title, summary quote at bottom
|
||||||
|
```
|
||||||
|
|
||||||
|
**Flowchart + macaron**:
|
||||||
|
```
|
||||||
|
Process flow on warm cream paper (#F5F0E8). Each step in a macaron pastel card.
|
||||||
|
COLORS: Steps alternate Macaron Blue (#A8D8EA), Mint (#B5E5CF), Lavender (#D5C6E0), Peach (#FFD5C2),
|
||||||
|
Coral Red (#E8655A) for decision points, Deep Charcoal (#2D2D2D) outlines
|
||||||
|
ELEMENTS: Rounded step containers, soft arrow connectors, bold step labels
|
||||||
|
```
|
||||||
|
|
||||||
### Screen-Print Style Override
|
### Screen-Print Style Override
|
||||||
|
|
||||||
When `style: screen-print`, replace standard style instructions with:
|
When `style: screen-print`, replace standard style instructions with:
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
| `tutorial` | `flowchart` | `vector-illustration` | Step-by-step tutorials, setup guides |
|
| `tutorial` | `flowchart` | `vector-illustration` | Step-by-step tutorials, setup guides |
|
||||||
| `process-flow` | `flowchart` | `notion` | Workflow documentation, onboarding flows |
|
| `process-flow` | `flowchart` | `notion` | Workflow documentation, onboarding flows |
|
||||||
| `warm-knowledge` | `infographic` | `vector-illustration` (warm palette) | Product showcases, team intros, feature cards, brand content |
|
| `warm-knowledge` | `infographic` | `vector-illustration` (warm palette) | Product showcases, team intros, feature cards, brand content |
|
||||||
|
| `edu-visual` | `infographic` | `macaron` | Knowledge summaries, concept explainers, educational articles |
|
||||||
|
|
||||||
### Data & Analysis
|
### Data & Analysis
|
||||||
|
|
||||||
@@ -55,14 +56,14 @@ Use this table during Step 3 to recommend presets based on Step 2 content analys
|
|||||||
| Content Type (Step 2) | Primary Preset | Alternatives |
|
| Content Type (Step 2) | Primary Preset | Alternatives |
|
||||||
|------------------------|----------------|--------------|
|
|------------------------|----------------|--------------|
|
||||||
| Technical | `tech-explainer` | `system-design`, `architecture` |
|
| Technical | `tech-explainer` | `system-design`, `architecture` |
|
||||||
| Tutorial | `tutorial` | `process-flow`, `knowledge-base` |
|
| Tutorial | `tutorial` | `process-flow`, `knowledge-base`, `edu-visual` |
|
||||||
| Methodology / Framework | `system-design` | `architecture`, `process-flow` |
|
| Methodology / Framework | `system-design` | `architecture`, `process-flow` |
|
||||||
| Data / Metrics | `data-report` | `versus`, `tech-explainer` |
|
| Data / Metrics | `data-report` | `versus`, `tech-explainer` |
|
||||||
| Comparison / Review | `versus` | `business-compare`, `editorial-poster` |
|
| Comparison / Review | `versus` | `business-compare`, `editorial-poster` |
|
||||||
| Narrative / Personal | `storytelling` | `lifestyle`, `evolution` |
|
| Narrative / Personal | `storytelling` | `lifestyle`, `evolution` |
|
||||||
| Opinion / Editorial | `opinion-piece` | `cinematic`, `editorial-poster` |
|
| Opinion / Editorial | `opinion-piece` | `cinematic`, `editorial-poster` |
|
||||||
| Historical / Timeline | `history` | `evolution` |
|
| Historical / Timeline | `history` | `evolution` |
|
||||||
| Academic / Research | `science-paper` | `tech-explainer`, `data-report` |
|
| Academic / Research | `science-paper` | `tech-explainer`, `data-report`, `edu-visual` |
|
||||||
| SaaS / Product | `saas-guide` | `knowledge-base`, `process-flow`, `warm-knowledge` |
|
| SaaS / Product | `saas-guide` | `knowledge-base`, `process-flow`, `warm-knowledge` |
|
||||||
|
|
||||||
## Override Examples
|
## Override Examples
|
||||||
|
|||||||
@@ -43,20 +43,21 @@ Use Core Styles for most cases. See full Style Gallery below for granular contro
|
|||||||
| `sketch` | Raw pencil notebook style | Brainstorming, creative exploration |
|
| `sketch` | Raw pencil notebook style | Brainstorming, creative exploration |
|
||||||
| `screen-print` | Bold poster art, halftone textures, limited colors | Opinion, editorial, cultural, cinematic |
|
| `screen-print` | Bold poster art, halftone textures, limited colors | Opinion, editorial, cultural, cinematic |
|
||||||
| `sketch-notes` | Soft hand-drawn warm notes | Educational, warm notes |
|
| `sketch-notes` | Soft hand-drawn warm notes | Educational, warm notes |
|
||||||
|
| `macaron` | Soft macaron pastel blocks on warm cream, clean educational layouts | Educational, knowledge, tutorials, concept explainers |
|
||||||
| `vintage` | Aged parchment historical | Historical, heritage |
|
| `vintage` | Aged parchment historical | Historical, heritage |
|
||||||
|
|
||||||
Full specifications: `references/styles/<style>.md`
|
Full specifications: `references/styles/<style>.md`
|
||||||
|
|
||||||
## Type × Style Compatibility Matrix
|
## Type × Style Compatibility Matrix
|
||||||
|
|
||||||
| | vector-illustration | notion | warm | minimal | blueprint | watercolor | elegant | editorial | scientific | screen-print |
|
| | vector-illustration | notion | warm | minimal | blueprint | watercolor | elegant | editorial | scientific | screen-print | macaron |
|
||||||
|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|
|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|
||||||
| infographic | ✓✓ | ✓✓ | ✓ | ✓✓ | ✓✓ | ✓ | ✓✓ | ✓✓ | ✓✓ | ✓ |
|
| infographic | ✓✓ | ✓✓ | ✓ | ✓✓ | ✓✓ | ✓ | ✓✓ | ✓✓ | ✓✓ | ✓ | ✓✓ |
|
||||||
| scene | ✓ | ✓ | ✓✓ | ✓ | ✗ | ✓✓ | ✓ | ✓ | ✗ | ✓✓ |
|
| scene | ✓ | ✓ | ✓✓ | ✓ | ✗ | ✓✓ | ✓ | ✓ | ✗ | ✓✓ | ✓ |
|
||||||
| flowchart | ✓✓ | ✓✓ | ✓ | ✓ | ✓✓ | ✗ | ✓ | ✓✓ | ✓ | ✗ |
|
| flowchart | ✓✓ | ✓✓ | ✓ | ✓ | ✓✓ | ✗ | ✓ | ✓✓ | ✓ | ✗ | ✓✓ |
|
||||||
| comparison | ✓✓ | ✓✓ | ✓ | ✓✓ | ✓ | ✓ | ✓✓ | ✓✓ | ✓ | ✓ |
|
| comparison | ✓✓ | ✓✓ | ✓ | ✓✓ | ✓ | ✓ | ✓✓ | ✓✓ | ✓ | ✓ | ✓✓ |
|
||||||
| framework | ✓✓ | ✓✓ | ✓ | ✓✓ | ✓✓ | ✗ | ✓✓ | ✓ | ✓✓ | ✓ |
|
| framework | ✓✓ | ✓✓ | ✓ | ✓✓ | ✓✓ | ✗ | ✓✓ | ✓ | ✓✓ | ✓ | ✓✓ |
|
||||||
| timeline | ✓ | ✓✓ | ✓ | ✓ | ✓ | ✓✓ | ✓✓ | ✓✓ | ✓ | ✓ |
|
| timeline | ✓ | ✓✓ | ✓ | ✓ | ✓ | ✓✓ | ✓✓ | ✓✓ | ✓ | ✓ | ✓ |
|
||||||
|
|
||||||
✓✓ = highly recommended | ✓ = compatible | ✗ = not recommended
|
✓✓ = highly recommended | ✓ = compatible | ✗ = not recommended
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ Full specifications: `references/styles/<style>.md`
|
|||||||
| Content Signals | Recommended Type | Recommended Style |
|
| Content Signals | Recommended Type | Recommended Style |
|
||||||
|-----------------|------------------|-------------------|
|
|-----------------|------------------|-------------------|
|
||||||
| API, metrics, data, comparison, numbers | infographic | blueprint, vector-illustration |
|
| API, metrics, data, comparison, numbers | infographic | blueprint, vector-illustration |
|
||||||
| Knowledge, concept, tutorial, learning, guide | infographic | vector-illustration, notion |
|
| Knowledge, concept, tutorial, learning, guide | infographic | vector-illustration, notion, macaron |
|
||||||
| Tech, AI, programming, development, code | infographic | vector-illustration, blueprint |
|
| Tech, AI, programming, development, code | infographic | vector-illustration, blueprint |
|
||||||
| How-to, steps, workflow, process, tutorial | flowchart | vector-illustration, notion |
|
| How-to, steps, workflow, process, tutorial | flowchart | vector-illustration, notion |
|
||||||
| Framework, model, architecture, principles | framework | blueprint, vector-illustration |
|
| Framework, model, architecture, principles | framework | blueprint, vector-illustration |
|
||||||
@@ -200,3 +201,28 @@ Full specifications: `references/styles/<style>.md`
|
|||||||
- Limited color coding (one color per concept level)
|
- Limited color coding (one color per concept level)
|
||||||
- Clean silhouette-based iconography
|
- Clean silhouette-based iconography
|
||||||
- Poster-style hierarchy with bold typography
|
- Poster-style hierarchy with bold typography
|
||||||
|
|
||||||
|
### infographic + macaron
|
||||||
|
- Soft pastel color blocks (blue, mint, lavender, peach) as info zone backgrounds
|
||||||
|
- Warm cream base with clear typography hierarchy
|
||||||
|
- Rounded-corner cards and bubble containers
|
||||||
|
- Coral Red accents for key data and emphasis
|
||||||
|
- Bold summary quote at bottom
|
||||||
|
|
||||||
|
### flowchart + macaron
|
||||||
|
- Each step in a distinct macaron pastel card
|
||||||
|
- Arrow chains connecting pastel containers
|
||||||
|
- Clear progression with color-coded stages
|
||||||
|
- Generous spacing between steps
|
||||||
|
|
||||||
|
### comparison + macaron
|
||||||
|
- Split columns with different pastel fills per side
|
||||||
|
- Soft visual separation, not harsh dividers
|
||||||
|
- Coral Red highlights for key differentiators
|
||||||
|
- Bottom summary capturing the comparison insight
|
||||||
|
|
||||||
|
### framework + macaron
|
||||||
|
- Nodes as rounded pastel-filled cards
|
||||||
|
- Hierarchical or network layout with soft connectors
|
||||||
|
- Each concept level in a different macaron color
|
||||||
|
- Clean labels with bold keywords
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
# macaron
|
||||||
|
|
||||||
|
Soft macaron pastel color blocks on warm cream, clean and readable educational layouts
|
||||||
|
|
||||||
|
## Design Aesthetic
|
||||||
|
|
||||||
|
Clean, approachable infographic style built around soft macaron pastel color blocks as information containers. Each content zone sits on a distinct pastel fill — blue, mint, lavender, or peach — against a warm cream paper background. Emphasis on clarity, information hierarchy, and moderate density. Pairs well with hand-drawn line treatment (optional) or clean flat vector rendering.
|
||||||
|
|
||||||
|
## Background
|
||||||
|
|
||||||
|
- Color: Warm Cream (#F5F0E8)
|
||||||
|
- Texture: Subtle warm paper grain
|
||||||
|
|
||||||
|
## Color Palette
|
||||||
|
|
||||||
|
| Role | Color | Hex | Usage |
|
||||||
|
|------|-------|-----|-------|
|
||||||
|
| Background | Warm Cream | #F5F0E8 | Primary background |
|
||||||
|
| Primary Text | Deep Charcoal | #2D2D2D | Headlines, main text, outlines |
|
||||||
|
| Macaron Blue | Sky Blue | #A8D8EA | Info block fill, cool-toned zones |
|
||||||
|
| Macaron Mint | Mint Green | #B5E5CF | Info block fill, growth/positive zones |
|
||||||
|
| Macaron Lavender | Lavender | #D5C6E0 | Info block fill, abstract/concept zones |
|
||||||
|
| Macaron Peach | Peach | #FFD5C2 | Info block fill, warm-toned zones |
|
||||||
|
| Accent | Coral Red | #E8655A | Key data, warnings, emphasis highlights |
|
||||||
|
| Muted Text | Warm Gray | #6B6B6B | Secondary annotations, small labels |
|
||||||
|
|
||||||
|
## Visual Elements
|
||||||
|
|
||||||
|
- Rounded-corner cards, speech bubbles, and dashed-box frames as content containers
|
||||||
|
- Each container filled with a distinct macaron pastel color
|
||||||
|
- Clear typography hierarchy: bold large title → bold keywords → smaller muted annotations
|
||||||
|
- Bold summary quote at the bottom of the image capturing the core insight
|
||||||
|
- Auto-selected visual structure based on content: flow → arrow chains, compare → split columns, cycle → ring layout, composition → parallel cards, hierarchy → nested containers
|
||||||
|
- Generous whitespace between zones, moderate information density
|
||||||
|
|
||||||
|
## Optional Hand-Drawn Mode
|
||||||
|
|
||||||
|
Can be combined with hand-drawn rendering for a warmer feel:
|
||||||
|
- Slight wobble on lines and shape edges (not perfectly straight)
|
||||||
|
- Simple stick-figure cartoon characters or hand-drawn icons
|
||||||
|
- Color fills that don't completely fill outlines (hand-painted feel)
|
||||||
|
- Doodle decorations: small stars, underlines, arrows
|
||||||
|
|
||||||
|
When not using hand-drawn mode, renders as clean flat shapes with smooth edges.
|
||||||
|
|
||||||
|
## Style Rules
|
||||||
|
|
||||||
|
### Do
|
||||||
|
|
||||||
|
- Use pastel color blocks to visually separate information zones
|
||||||
|
- Maintain clear information hierarchy through typography weight and size
|
||||||
|
- Include a bold summary quote at the bottom
|
||||||
|
- Choose the best visual structure for the content (don't force one layout)
|
||||||
|
- Keep generous whitespace and moderate density
|
||||||
|
- Use Coral Red sparingly for emphasis on key data or warnings
|
||||||
|
|
||||||
|
### Don't
|
||||||
|
|
||||||
|
- Use pure white backgrounds
|
||||||
|
- Overcrowd with too many elements or decorations
|
||||||
|
- Mix too many accent colors beyond the macaron palette
|
||||||
|
- Create dark or moody compositions
|
||||||
|
- Use tiny text that's hard to read
|
||||||
|
|
||||||
|
## Best For
|
||||||
|
|
||||||
|
Educational content, knowledge sharing, concept explainers, tutorials, tech summaries, onboarding materials, visual study notes
|
||||||
+47
-26
@@ -29,9 +29,9 @@ Create original knowledge comics with flexible art style × tone combinations.
|
|||||||
|
|
||||||
| Option | Values | Description |
|
| Option | Values | Description |
|
||||||
|--------|--------|-------------|
|
|--------|--------|-------------|
|
||||||
| `--art` | ligne-claire (default), manga, realistic, ink-brush, chalk | Art style / rendering technique |
|
| `--art` | ligne-claire (default), manga, realistic, ink-brush, chalk, minimalist | Art style / rendering technique |
|
||||||
| `--tone` | neutral (default), warm, dramatic, romantic, energetic, vintage, action | Mood / atmosphere |
|
| `--tone` | neutral (default), warm, dramatic, romantic, energetic, vintage, action | Mood / atmosphere |
|
||||||
| `--layout` | standard (default), cinematic, dense, splash, mixed, webtoon | Panel arrangement |
|
| `--layout` | standard (default), cinematic, dense, splash, mixed, webtoon, four-panel | Panel arrangement |
|
||||||
| `--aspect` | 3:4 (default, portrait), 4:3 (landscape), 16:9 (widescreen) | Page aspect ratio |
|
| `--aspect` | 3:4 (default, portrait), 4:3 (landscape), 16:9 (widescreen) | Page aspect ratio |
|
||||||
| `--lang` | auto (default), zh, en, ja, etc. | Output language |
|
| `--lang` | auto (default), zh, en, ja, etc. | Output language |
|
||||||
|
|
||||||
@@ -55,6 +55,7 @@ Details: [references/partial-workflows.md](references/partial-workflows.md)
|
|||||||
| `realistic` | 写实 | Digital painting, realistic proportions, sophisticated |
|
| `realistic` | 写实 | Digital painting, realistic proportions, sophisticated |
|
||||||
| `ink-brush` | 水墨 | Chinese brush strokes, ink wash effects |
|
| `ink-brush` | 水墨 | Chinese brush strokes, ink wash effects |
|
||||||
| `chalk` | 粉笔 | Chalkboard aesthetic, hand-drawn warmth |
|
| `chalk` | 粉笔 | Chalkboard aesthetic, hand-drawn warmth |
|
||||||
|
| `minimalist` | 极简 | Clean black line art, limited spot color, stick-figure characters |
|
||||||
|
|
||||||
### Tones (基调)
|
### Tones (基调)
|
||||||
|
|
||||||
@@ -77,6 +78,8 @@ Presets with special rules beyond art+tone:
|
|||||||
| `--style ohmsha` | `--art manga --tone neutral` | Visual metaphors, NO talking heads, gadget reveals |
|
| `--style ohmsha` | `--art manga --tone neutral` | Visual metaphors, NO talking heads, gadget reveals |
|
||||||
| `--style wuxia` | `--art ink-brush --tone action` | Qi effects, combat visuals, atmospheric elements |
|
| `--style wuxia` | `--art ink-brush --tone action` | Qi effects, combat visuals, atmospheric elements |
|
||||||
| `--style shoujo` | `--art manga --tone romantic` | Decorative elements, eye details, romantic beats |
|
| `--style shoujo` | `--art manga --tone romantic` | Decorative elements, eye details, romantic beats |
|
||||||
|
| `--style concept-story` | `--art manga --tone warm` | Visual symbol system, growth arc, dialogue+action balance |
|
||||||
|
| `--style four-panel` | `--art minimalist --tone neutral --layout four-panel` | 起承转合 4-panel structure, B&W + spot color, stick-figure characters |
|
||||||
|
|
||||||
### Compatibility Matrix
|
### Compatibility Matrix
|
||||||
|
|
||||||
@@ -87,6 +90,7 @@ Presets with special rules beyond art+tone:
|
|||||||
| realistic | neutral, warm, dramatic, vintage | action | romantic, energetic |
|
| realistic | neutral, warm, dramatic, vintage | action | romantic, energetic |
|
||||||
| ink-brush | neutral, dramatic, action, vintage | warm | romantic, energetic |
|
| ink-brush | neutral, dramatic, action, vintage | warm | romantic, energetic |
|
||||||
| chalk | neutral, warm, energetic | vintage | dramatic, action, romantic |
|
| chalk | neutral, warm, energetic | vintage | dramatic, action, romantic |
|
||||||
|
| minimalist | neutral | warm, energetic | dramatic, vintage, romantic, action |
|
||||||
|
|
||||||
Details: [references/auto-selection.md](references/auto-selection.md)
|
Details: [references/auto-selection.md](references/auto-selection.md)
|
||||||
|
|
||||||
@@ -101,6 +105,8 @@ Content signals determine default art + tone + layout (or preset):
|
|||||||
| Personal story, mentor | ligne-claire + warm |
|
| Personal story, mentor | ligne-claire + warm |
|
||||||
| Martial arts, wuxia | **wuxia** preset |
|
| Martial arts, wuxia | **wuxia** preset |
|
||||||
| Romance, school life | **shoujo** preset |
|
| Romance, school life | **shoujo** preset |
|
||||||
|
| Psychology, motivation, business narrative | **concept-story** preset |
|
||||||
|
| Business allegory, fable, parable, short insight, 四格 | **four-panel** preset |
|
||||||
| Biography, balanced | ligne-claire + neutral |
|
| Biography, balanced | ligne-claire + neutral |
|
||||||
|
|
||||||
**When preset is recommended**: Load `references/presets/{preset}.md` and apply all special rules.
|
**When preset is recommended**: Load `references/presets/{preset}.md` and apply all special rules.
|
||||||
@@ -172,9 +178,9 @@ Comic Progress:
|
|||||||
- [ ] Step 4: Review outline (conditional)
|
- [ ] Step 4: Review outline (conditional)
|
||||||
- [ ] Step 5: Generate prompts
|
- [ ] Step 5: Generate prompts
|
||||||
- [ ] Step 6: Review prompts (conditional)
|
- [ ] Step 6: Review prompts (conditional)
|
||||||
- [ ] Step 7: Generate images ⚠️ CHARACTER REF REQUIRED
|
- [ ] Step 7: Generate images
|
||||||
- [ ] 7.1 Generate character sheet FIRST → characters/characters.png
|
- [ ] 7.1 Generate character sheet (if needed) → characters/characters.png
|
||||||
- [ ] 7.2 Generate pages WITH --ref characters/characters.png
|
- [ ] 7.2 Generate pages (with --ref if character sheet exists)
|
||||||
- [ ] Step 8: Merge to PDF
|
- [ ] Step 8: Merge to PDF
|
||||||
- [ ] Step 9: Completion report
|
- [ ] Step 9: Completion report
|
||||||
```
|
```
|
||||||
@@ -205,16 +211,24 @@ Analyze → [Check Existing?] → [Confirm: Style + Reviews] → Storyboard →
|
|||||||
| 4 | Review outline (if requested) | User approval |
|
| 4 | Review outline (if requested) | User approval |
|
||||||
| 5 | Generate prompts | `prompts/*.md` |
|
| 5 | Generate prompts | `prompts/*.md` |
|
||||||
| 6 | Review prompts (if requested) | User approval |
|
| 6 | Review prompts (if requested) | User approval |
|
||||||
| **7.1** | **Generate character sheet FIRST** | `characters/characters.png` |
|
| 7.1 | Generate character sheet (if needed) | `characters/characters.png` |
|
||||||
| **7.2** | Generate pages **with character ref** | `*.png` files |
|
| 7.2 | Generate pages (with character ref if available) | `*.png` files |
|
||||||
| 8 | Merge to PDF | `{slug}.pdf` |
|
| 8 | Merge to PDF | `{slug}.pdf` |
|
||||||
| 9 | Completion report | Summary |
|
| 9 | Completion report | Summary |
|
||||||
|
|
||||||
### Step 7: Image Generation ⚠️ CRITICAL
|
### Step 7: Image Generation
|
||||||
|
|
||||||
**Character reference is MANDATORY for visual consistency.**
|
**7.1 Generate character sheet (conditional)**:
|
||||||
|
|
||||||
**7.1 Generate character sheet first**:
|
Character sheet is recommended for multi-page comics with recurring characters, but **NOT required** for all presets:
|
||||||
|
|
||||||
|
| Condition | Action |
|
||||||
|
|-----------|--------|
|
||||||
|
| Multi-page comic with detailed characters | Generate character sheet (recommended) |
|
||||||
|
| Preset with simplified characters (e.g., four-panel minimalist) | Skip — prompt descriptions are sufficient |
|
||||||
|
| Single-page comic | Skip unless characters are complex |
|
||||||
|
|
||||||
|
**When generating character sheet**:
|
||||||
- **Backup rule**: If `characters/characters.png` exists, rename to `characters/characters-backup-YYYYMMDD-HHMMSS.png`
|
- **Backup rule**: If `characters/characters.png` exists, rename to `characters/characters-backup-YYYYMMDD-HHMMSS.png`
|
||||||
- Invoke an installed image generation skill such as `baoyu-imagine`
|
- Invoke an installed image generation skill such as `baoyu-imagine`
|
||||||
- Read that skill's `SKILL.md` and follow its documented interface rather than calling its scripts directly
|
- Read that skill's `SKILL.md` and follow its documented interface rather than calling its scripts directly
|
||||||
@@ -222,18 +236,25 @@ Analyze → [Check Existing?] → [Confirm: Style + Reviews] → Storyboard →
|
|||||||
- Save output to `characters/characters.png`
|
- Save output to `characters/characters.png`
|
||||||
- Use aspect ratio `4:3`
|
- Use aspect ratio `4:3`
|
||||||
|
|
||||||
**Compress character sheet** (recommended):
|
**Compress character sheet** (recommended when using as `--ref`):
|
||||||
Compress to reduce token usage when used as reference image:
|
|
||||||
- Use available image compression skill (if any)
|
- Use available image compression skill (if any)
|
||||||
- Or system tools: `pngquant`, `optipng`, `sips` (macOS)
|
- Or system tools: `sips -s format jpeg -s formatOptions 80 input.png --out output.jpg` (macOS)
|
||||||
- **Keep PNG format**, lossless compression preferred
|
- Or: `pngquant --quality=65-80 input.png -o output.png`
|
||||||
|
- Compression reduces API payload size and avoids `--ref` failures
|
||||||
|
|
||||||
**7.2 Generate each page WITH character reference**:
|
**7.2 Generate each page**:
|
||||||
|
|
||||||
| Skill Capability | Strategy |
|
| Character Sheet | Skill Capability | Strategy |
|
||||||
|------------------|----------|
|
|-----------------|------------------|----------|
|
||||||
| Supports `--ref` | Pass `characters/characters.png` with EVERY page |
|
| Exists | Supports `--ref` | Pass `characters/characters.png` with EVERY page |
|
||||||
| No `--ref` support | Prepend character descriptions to EVERY prompt file |
|
| Exists | No `--ref` support | Prepend character descriptions to EVERY prompt file |
|
||||||
|
| Skipped | — | Prompt file contains all character descriptions inline |
|
||||||
|
|
||||||
|
**`--ref` failure recovery**: If generation fails with `--ref`:
|
||||||
|
1. **Compress**: Convert reference image to JPEG with reduced quality:
|
||||||
|
`sips -s format jpeg -s formatOptions 70 characters.png --out characters-compressed.jpg`
|
||||||
|
2. **Retry** with compressed image as `--ref`
|
||||||
|
3. **If still fails**: Fall back to generating WITHOUT `--ref` (prompt-only, character descriptions embedded in prompt text)
|
||||||
|
|
||||||
**Backup rules for page generation**:
|
**Backup rules for page generation**:
|
||||||
- If prompt file exists: rename to `prompts/NN-{cover|page}-[slug]-backup-YYYYMMDD-HHMMSS.md`
|
- If prompt file exists: rename to `prompts/NN-{cover|page}-[slug]-backup-YYYYMMDD-HHMMSS.md`
|
||||||
@@ -241,8 +262,8 @@ Compress to reduce token usage when used as reference image:
|
|||||||
- Invoke the installed image generation skill for each page
|
- Invoke the installed image generation skill for each page
|
||||||
- Use `prompts/01-page-xxx.md` as the prompt-file input
|
- Use `prompts/01-page-xxx.md` as the prompt-file input
|
||||||
- Save output to `01-page-xxx.png`
|
- Save output to `01-page-xxx.png`
|
||||||
- Use aspect ratio `3:4`
|
- Use aspect ratio from storyboard (default `3:4`, preset may override)
|
||||||
- If the chosen skill supports reference images, pass `characters/characters.png` as `--ref`
|
- If character sheet exists and skill supports reference images, pass as `--ref`
|
||||||
|
|
||||||
**Full workflow details**: [references/workflow.md](references/workflow.md)
|
**Full workflow details**: [references/workflow.md](references/workflow.md)
|
||||||
|
|
||||||
@@ -273,10 +294,10 @@ Schema: [references/config/preferences-schema.md](references/config/preferences-
|
|||||||
- [ohmsha-guide.md](references/ohmsha-guide.md) - Ohmsha manga specifics
|
- [ohmsha-guide.md](references/ohmsha-guide.md) - Ohmsha manga specifics
|
||||||
|
|
||||||
**Style Definitions**:
|
**Style Definitions**:
|
||||||
- `references/art-styles/` - Art styles (ligne-claire, manga, realistic, ink-brush, chalk)
|
- `references/art-styles/` - Art styles (ligne-claire, manga, realistic, ink-brush, chalk, minimalist)
|
||||||
- `references/tones/` - Tones (neutral, warm, dramatic, romantic, energetic, vintage, action)
|
- `references/tones/` - Tones (neutral, warm, dramatic, romantic, energetic, vintage, action)
|
||||||
- `references/presets/` - Presets with special rules (ohmsha, wuxia, shoujo)
|
- `references/presets/` - Presets with special rules (ohmsha, wuxia, shoujo, concept-story, four-panel)
|
||||||
- `references/layouts/` - Layouts (standard, cinematic, dense, splash, mixed, webtoon)
|
- `references/layouts/` - Layouts (standard, cinematic, dense, splash, mixed, webtoon, four-panel)
|
||||||
|
|
||||||
**Workflow**:
|
**Workflow**:
|
||||||
- [workflow.md](references/workflow.md) - Full workflow details
|
- [workflow.md](references/workflow.md) - Full workflow details
|
||||||
@@ -306,6 +327,6 @@ Schema: [references/config/preferences-schema.md](references/config/preferences-
|
|||||||
- Maintain style consistency via session ID
|
- Maintain style consistency via session ID
|
||||||
- **Step 2 confirmation required** - do not skip
|
- **Step 2 confirmation required** - do not skip
|
||||||
- **Steps 4/6 conditional** - only if user requested in Step 2
|
- **Steps 4/6 conditional** - only if user requested in Step 2
|
||||||
- **Step 7.1 character sheet MUST be generated before pages** - ensures consistency
|
- **Step 7.1 character sheet** - recommended for multi-page comics, optional for simple presets
|
||||||
- **Step 7.2 EVERY page MUST reference characters** - use `--ref` or embed descriptions
|
- **Step 7.2 character reference** - use `--ref` if sheet exists; compress/convert on failure; fall back to prompt-only
|
||||||
- Watermark/language configured once in EXTEND.md
|
- Watermark/language configured once in EXTEND.md
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# minimalist
|
||||||
|
|
||||||
|
极简画风 - Clean black line art, limited spot color, simplified stick-figure characters
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Minimalist cartoon illustration characterized by clean black line art on white background with very limited spot color for emphasis. Characters are simplified to near-stick-figure abstraction, focusing on gesture and concept rather than anatomical detail. Designed for business allegory, quick-read educational content, and concept illustration.
|
||||||
|
|
||||||
|
## Line Work
|
||||||
|
|
||||||
|
- Clean, uniform black lines (1.5-2px)
|
||||||
|
- No hatching, cross-hatching, or shading techniques
|
||||||
|
- Minimal detail — every line serves a purpose
|
||||||
|
- Bold outlines for characters, thinner lines for props/labels
|
||||||
|
- No decorative flourishes or ornamental lines
|
||||||
|
|
||||||
|
## Character Design
|
||||||
|
|
||||||
|
- Highly simplified, stick-figure-like business characters
|
||||||
|
- Circle or oval heads with minimal facial features (dot eyes, simple line mouth)
|
||||||
|
- Body as simple geometric shapes or line constructions
|
||||||
|
- Distinguishing features through props only (tie, hat, briefcase, glasses)
|
||||||
|
- No anatomical detail — expressive through posture and gesture
|
||||||
|
- 4-5 head height proportions (squat, iconic)
|
||||||
|
|
||||||
|
## Background Treatment
|
||||||
|
|
||||||
|
- Mostly blank/white — negative space is a design element
|
||||||
|
- Minimal environmental cues (a line for ground, simple desk outline)
|
||||||
|
- Concept labels and text annotations replace detailed environments
|
||||||
|
- Icons and symbols over realistic rendering
|
||||||
|
- No perspective or spatial depth
|
||||||
|
|
||||||
|
## Color Approach
|
||||||
|
|
||||||
|
- Primarily black and white (90%+ of the image)
|
||||||
|
- 1-2 spot accent colors for emphasis on key concepts
|
||||||
|
- Accent color used sparingly: highlighting key objects, text labels, concept indicators
|
||||||
|
- No gradients, no shading, no color fills on backgrounds
|
||||||
|
- Color draws the eye to the most important element in each panel
|
||||||
|
|
||||||
|
## Default Color Palette
|
||||||
|
|
||||||
|
| Role | Color | Hex |
|
||||||
|
|------|-------|-----|
|
||||||
|
| Primary | Black ink | `#1A1A1A` |
|
||||||
|
| Background | Clean white | `#FFFFFF` |
|
||||||
|
| Accent 1 | Spot orange | `#FF6B35` |
|
||||||
|
| Accent 2 | Spot blue (optional) | `#3182CE` |
|
||||||
|
| Text labels | Dark gray | `#4A4A4A` |
|
||||||
|
| Panel border | Medium gray | `#666666` |
|
||||||
|
|
||||||
|
## Visual Elements
|
||||||
|
|
||||||
|
- Text labels with accent-color backgrounds or underlines for key terms
|
||||||
|
- Simple icons: arrows, circles, checkmarks, crosses
|
||||||
|
- Concept highlight boxes with spot color
|
||||||
|
- Minimal speech bubbles (simple oval or rectangle, thin black outline)
|
||||||
|
- No sound effects, no motion lines, no screen tones
|
||||||
|
|
||||||
|
## Quality Markers
|
||||||
|
|
||||||
|
- ✓ Clean, purposeful line work with no unnecessary detail
|
||||||
|
- ✓ 90%+ black-and-white with strategic spot color
|
||||||
|
- ✓ Simplified characters readable at small sizes
|
||||||
|
- ✓ Text labels integrated naturally into panels
|
||||||
|
- ✓ Strong negative space usage
|
||||||
|
- ✓ Every element serves the narrative point
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
| Tone | Fit | Notes |
|
||||||
|
|------|-----|-------|
|
||||||
|
| neutral | ✓✓ | Ideal for business/educational content |
|
||||||
|
| warm | ✓ | Works for gentle stories, slight warmth in accent |
|
||||||
|
| energetic | ✓ | Works for punchy, high-energy content |
|
||||||
|
| dramatic | ✗ | Style too stripped down for dramatic intensity |
|
||||||
|
| vintage | ✗ | Minimalist aesthetic conflicts with aged/textured look |
|
||||||
|
| romantic | ✗ | No capacity for decorative/soft elements |
|
||||||
|
| action | ✗ | No dynamic line capability for speed/impact |
|
||||||
|
|
||||||
|
## Best For
|
||||||
|
|
||||||
|
Business allegory, management fables, short concept illustration, four-panel comic strips, quick-insight education, social media content
|
||||||
@@ -11,10 +11,13 @@ Content signals determine default art + tone + layout (or preset).
|
|||||||
| Technical explanation, educational | manga | neutral | webtoon | **ohmsha** |
|
| Technical explanation, educational | manga | neutral | webtoon | **ohmsha** |
|
||||||
| Pre-1950, classical, ancient | realistic | vintage | cinematic | - |
|
| Pre-1950, classical, ancient | realistic | vintage | cinematic | - |
|
||||||
| Personal story, mentor | ligne-claire | warm | standard | - |
|
| Personal story, mentor | ligne-claire | warm | standard | - |
|
||||||
|
| Psychology, motivation, self-help, coaching | manga | warm | standard | **concept-story** |
|
||||||
|
| Business narrative, management, leadership | manga | warm | standard | **concept-story** |
|
||||||
| Conflict, breakthrough | (inherit) | dramatic | splash | - |
|
| Conflict, breakthrough | (inherit) | dramatic | splash | - |
|
||||||
| Wine, food, business, lifestyle | realistic | neutral | cinematic | - |
|
| Wine, food, lifestyle | realistic | neutral | cinematic | - |
|
||||||
| Martial arts, wuxia, xianxia | ink-brush | action | splash | **wuxia** |
|
| Martial arts, wuxia, xianxia | ink-brush | action | splash | **wuxia** |
|
||||||
| Romance, love, school life | manga | romantic | standard | **shoujo** |
|
| Romance, love, school life | manga | romantic | standard | **shoujo** |
|
||||||
|
| Business allegory, fable, parable, short insight, 四格 | minimalist | neutral | four-panel | **four-panel** |
|
||||||
| Biography, balanced | ligne-claire | neutral | mixed | - |
|
| Biography, balanced | ligne-claire | neutral | mixed | - |
|
||||||
|
|
||||||
## Preset Recommendation Rules
|
## Preset Recommendation Rules
|
||||||
@@ -36,6 +39,16 @@ Content signals determine default art + tone + layout (or preset).
|
|||||||
- **Special rules**: Decorative elements, eye details, romantic beats
|
- **Special rules**: Decorative elements, eye details, romantic beats
|
||||||
- **Base**: manga + romantic + standard
|
- **Base**: manga + romantic + standard
|
||||||
|
|
||||||
|
### concept-story
|
||||||
|
- **Triggers**: Psychology, motivation, self-help, business narrative, management, leadership, personal growth, coaching, soft skills, abstract concept through story
|
||||||
|
- **Special rules**: Visual symbol system, growth arc, dialogue+action balance, original characters
|
||||||
|
- **Base**: manga + warm + standard
|
||||||
|
|
||||||
|
### four-panel
|
||||||
|
- **Triggers**: Business allegory, fable, parable, short insight, four-panel, 四格, 四格漫画, single-page comic, minimalist comic strip
|
||||||
|
- **Special rules**: Strict 起承转合 4-panel structure, B&W + spot color, simplified stick-figure characters, single-page story
|
||||||
|
- **Base**: minimalist + neutral + four-panel
|
||||||
|
|
||||||
## Compatibility Matrix
|
## Compatibility Matrix
|
||||||
|
|
||||||
Art Style × Tone combinations work best when matched appropriately:
|
Art Style × Tone combinations work best when matched appropriately:
|
||||||
@@ -47,6 +60,7 @@ Art Style × Tone combinations work best when matched appropriately:
|
|||||||
| realistic | neutral, warm, dramatic, vintage | action | romantic, energetic |
|
| realistic | neutral, warm, dramatic, vintage | action | romantic, energetic |
|
||||||
| ink-brush | neutral, dramatic, action, vintage | warm | romantic, energetic |
|
| ink-brush | neutral, dramatic, action, vintage | warm | romantic, energetic |
|
||||||
| chalk | neutral, warm, energetic | vintage | dramatic, action, romantic |
|
| chalk | neutral, warm, energetic | vintage | dramatic, action, romantic |
|
||||||
|
| minimalist | neutral | warm, energetic | dramatic, vintage, romantic, action |
|
||||||
|
|
||||||
**Note**: Art Style × Tone × Layout can be freely combined. Incompatible combinations work but may produce unexpected results.
|
**Note**: Art Style × Tone × Layout can be freely combined. Incompatible combinations work but may produce unexpected results.
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ watermark:
|
|||||||
content: ""
|
content: ""
|
||||||
position: bottom-right # bottom-right|bottom-left|bottom-center|top-right
|
position: bottom-right # bottom-right|bottom-left|bottom-center|top-right
|
||||||
|
|
||||||
preferred_art: null # ligne-claire|manga|realistic|ink-brush|chalk
|
preferred_art: null # ligne-claire|manga|realistic|ink-brush|chalk|minimalist
|
||||||
preferred_tone: null # neutral|warm|dramatic|romantic|energetic|vintage|action
|
preferred_tone: null # neutral|warm|dramatic|romantic|energetic|vintage|action
|
||||||
preferred_layout: null # standard|cinematic|dense|splash|mixed|webtoon
|
preferred_layout: null # standard|cinematic|dense|splash|mixed|webtoon|four-panel
|
||||||
preferred_aspect: null # 3:4|4:3|16:9
|
preferred_aspect: null # 3:4|4:3|16:9
|
||||||
|
|
||||||
language: null # zh|en|ja|ko|auto
|
language: null # zh|en|ja|ko|auto
|
||||||
@@ -41,7 +41,7 @@ character_presets:
|
|||||||
| `watermark.enabled` | bool | false | Enable watermark |
|
| `watermark.enabled` | bool | false | Enable watermark |
|
||||||
| `watermark.content` | string | "" | Watermark text (@username or custom) |
|
| `watermark.content` | string | "" | Watermark text (@username or custom) |
|
||||||
| `watermark.position` | enum | bottom-right | Position on image |
|
| `watermark.position` | enum | bottom-right | Position on image |
|
||||||
| `preferred_art` | string | null | Art style (ligne-claire, manga, realistic, ink-brush, chalk) |
|
| `preferred_art` | string | null | Art style (ligne-claire, manga, realistic, ink-brush, chalk, minimalist) |
|
||||||
| `preferred_tone` | string | null | Tone (neutral, warm, dramatic, romantic, energetic, vintage, action) |
|
| `preferred_tone` | string | null | Tone (neutral, warm, dramatic, romantic, energetic, vintage, action) |
|
||||||
| `preferred_layout` | string | null | Layout preference or null |
|
| `preferred_layout` | string | null | Layout preference or null |
|
||||||
| `preferred_aspect` | string | null | Aspect ratio (3:4, 4:3, 16:9) |
|
| `preferred_aspect` | string | null | Aspect ratio (3:4, 4:3, 16:9) |
|
||||||
@@ -57,6 +57,7 @@ character_presets:
|
|||||||
| `realistic` | 写实 | Digital painting, realistic proportions |
|
| `realistic` | 写实 | Digital painting, realistic proportions |
|
||||||
| `ink-brush` | 水墨 | Chinese brush strokes, ink wash effects |
|
| `ink-brush` | 水墨 | Chinese brush strokes, ink wash effects |
|
||||||
| `chalk` | 粉笔 | Chalkboard aesthetic, hand-drawn warmth |
|
| `chalk` | 粉笔 | Chalkboard aesthetic, hand-drawn warmth |
|
||||||
|
| `minimalist` | 极简 | Clean black line art, limited spot color, stick-figure characters |
|
||||||
|
|
||||||
## Tone Options
|
## Tone Options
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# four-panel
|
||||||
|
|
||||||
|
四格漫画 - Strict 2×2 grid, single-page story
|
||||||
|
|
||||||
|
## Panel Structure
|
||||||
|
|
||||||
|
- **Panels per page**: 4 (exactly, no variation)
|
||||||
|
- **Structure**: Strict 2×2 equal grid
|
||||||
|
- **Gutters**: Consistent white space (8-10px), uniform on all sides
|
||||||
|
|
||||||
|
## Grid Configuration
|
||||||
|
|
||||||
|
- 2 columns × 2 rows, all panels identical size
|
||||||
|
- Panel sizes: Exactly equal (each panel = 25% of content area)
|
||||||
|
- Reading flow: Z-pattern — Panel 1 (top-left) → Panel 2 (top-right) → Panel 3 (bottom-left) → Panel 4 (bottom-right)
|
||||||
|
|
||||||
|
## Narrative Structure
|
||||||
|
|
||||||
|
Each panel serves a specific narrative role (起承转合 / kishōtenketsu):
|
||||||
|
|
||||||
|
| Panel | Position | Role | Purpose |
|
||||||
|
|-------|----------|------|---------|
|
||||||
|
| 1 | Top-left | 起 Setup | Establish situation, introduce characters/problem |
|
||||||
|
| 2 | Top-right | 承 Development | Build on setup, add complication or attempt |
|
||||||
|
| 3 | Bottom-left | 转 Turn | Twist, key insight, or reversal — the pivotal moment |
|
||||||
|
| 4 | Bottom-right | 合 Conclusion | Resolution, punchline, or takeaway |
|
||||||
|
|
||||||
|
## Aspect Ratio
|
||||||
|
|
||||||
|
- Recommended page aspect: **4:3** (landscape)
|
||||||
|
- Landscape gives each panel a comfortable wide rectangle
|
||||||
|
- Portrait (3:4) makes panels tall and narrow — avoid for this layout
|
||||||
|
|
||||||
|
## Best For
|
||||||
|
|
||||||
|
Business allegory, quick-insight education, social media comics, fables, parables, single-concept explanation
|
||||||
|
|
||||||
|
## Best Style Pairings
|
||||||
|
|
||||||
|
minimalist, ligne-claire, chalk
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
# concept-story
|
||||||
|
|
||||||
|
概念故事预设 - Narrative comics that visualize abstract concepts through character-driven stories
|
||||||
|
|
||||||
|
## Base Configuration
|
||||||
|
|
||||||
|
| Dimension | Value |
|
||||||
|
|-----------|-------|
|
||||||
|
| Art Style | manga |
|
||||||
|
| Tone | warm |
|
||||||
|
| Layout | standard (default) |
|
||||||
|
|
||||||
|
Equivalent to: `--art manga --tone warm`
|
||||||
|
|
||||||
|
## Unique Rules
|
||||||
|
|
||||||
|
This preset includes special rules beyond the art+tone combination. When `--style concept-story` is used, ALL rules below must be applied.
|
||||||
|
|
||||||
|
### Concept Visualization System (CRITICAL)
|
||||||
|
|
||||||
|
Each major abstract concept SHOULD have a recurring visual symbol/metaphor:
|
||||||
|
|
||||||
|
| Concept Type | Visualization Approach |
|
||||||
|
|-------------|----------------------|
|
||||||
|
| Psychological need | Tangible object character holds or discovers (e.g., glowing energy ball = competence) |
|
||||||
|
| Management principle | Environmental metaphor character navigates (e.g., ship wheel = autonomy) |
|
||||||
|
| Growth/development | Living organic symbol that transforms (e.g., seed → flowering plant = relatedness) |
|
||||||
|
| Abstract framework | Spatial structure characters can enter or observe |
|
||||||
|
| Emotional state | Color/lighting shift in the scene atmosphere |
|
||||||
|
|
||||||
|
**Unlike ohmsha**: Dialogue panels are allowed and expected. The goal is to COMBINE visual metaphors WITH dialogue, not replace dialogue entirely.
|
||||||
|
|
||||||
|
**Pattern**: "Dialogue introduces idea" → "Visual metaphor illustrates it" → "Character reacts/applies it"
|
||||||
|
|
||||||
|
### Visual Symbol Continuity
|
||||||
|
|
||||||
|
Symbols must persist across the story:
|
||||||
|
|
||||||
|
| Stage | Treatment |
|
||||||
|
|-------|-----------|
|
||||||
|
| Introduction | Symbol appears with soft glow effect when concept is first mentioned |
|
||||||
|
| Recurrence | Same symbol reappears in background or character interaction when concept is referenced |
|
||||||
|
| Resolution | ALL symbols gather in the final composition, showing integration of learned concepts |
|
||||||
|
|
||||||
|
**Storyboard requirement**: Include a Symbol Mapping Table defining concept → visual symbol before panel breakdown.
|
||||||
|
|
||||||
|
### Character Archetypes (Flexible)
|
||||||
|
|
||||||
|
Create original characters based on content domain. No fixed defaults:
|
||||||
|
|
||||||
|
| Role | Archetype | Visual Cues |
|
||||||
|
|------|-----------|------------|
|
||||||
|
| Protagonist | Learner/worker facing a challenge | Modern professional or student, relatable, starts with constrained posture |
|
||||||
|
| Mentor | Experienced guide who teaches through experience | Slightly older, calm demeanor, warm color accents |
|
||||||
|
| Catalyst | Person or event that triggers transformation | Can be a colleague, situation, challenge, or opportunity |
|
||||||
|
|
||||||
|
**IMPORTANT**: Characters are created fresh each time based on the source content's domain (business, psychology, education, etc.). No default character set.
|
||||||
|
|
||||||
|
### Narrative Arc Structure
|
||||||
|
|
||||||
|
Enforce a five-stage growth arc:
|
||||||
|
|
||||||
|
| Act | Structure | Visual Tone |
|
||||||
|
|-----|-----------|------------|
|
||||||
|
| Opening | Protagonist stuck in routine, faces frustration | Muted warm tones, tight framing, constrained compositions |
|
||||||
|
| Inciting moment | Mentor appears or opportunity arrives | Brightness increases, panels open up |
|
||||||
|
| Learning | Concepts introduced through visual metaphors | Rich warm palette, symbols introduced one by one |
|
||||||
|
| Turning point | Protagonist applies knowledge, faces test | Contrast increases, dynamic compositions |
|
||||||
|
| Transformation | Growth demonstrated, new understanding visible | Full warm palette, expansive composition, all symbols present |
|
||||||
|
|
||||||
|
### Dialogue + Action Balance
|
||||||
|
|
||||||
|
- Dialogue is encouraged and expected (unlike ohmsha's NO talking heads rule)
|
||||||
|
- Every page should combine at least one dialogue panel with at least one visual/action panel
|
||||||
|
- Avoid pure "lecture" pages where a character explains for 4+ panels straight
|
||||||
|
- When a character explains a concept verbally, the NEXT panel should visualize it
|
||||||
|
|
||||||
|
**Wrong approach**: Four consecutive panels of mentor lecturing at protagonist
|
||||||
|
**Right approach**: Mentor introduces concept → visual metaphor panel → protagonist reacts → applies understanding
|
||||||
|
|
||||||
|
### Scene Atmosphere Rules
|
||||||
|
|
||||||
|
| Scene Type | Atmosphere |
|
||||||
|
|------------|-----------|
|
||||||
|
| Problem/frustration | Cool muted tones over warm base, tight framing, cluttered environment |
|
||||||
|
| Mentoring moment | Golden hour lighting, open composition, warm indoor glow |
|
||||||
|
| Concept visualization | Soft glow effects, clean simplified backgrounds, symbol spotlight |
|
||||||
|
| Growth/transformation | Warm light expanding outward, character posture opening up |
|
||||||
|
| Resolution | Full warm palette, spacious composition, all visual symbols visible |
|
||||||
|
|
||||||
|
### Ending Requirements
|
||||||
|
|
||||||
|
Final page MUST include:
|
||||||
|
|
||||||
|
1. Protagonist demonstrating transformed understanding (not just being told)
|
||||||
|
2. Visual callback showing contrast with opening state (e.g., wilted plant → thriving plant)
|
||||||
|
3. All concept symbols visible together in the composition
|
||||||
|
4. A forward-looking element suggesting ongoing growth (not a closed ending)
|
||||||
|
|
||||||
|
### Page Title Convention
|
||||||
|
|
||||||
|
Every page MUST have a narrative title:
|
||||||
|
|
||||||
|
**Wrong**: "Chapter 3: Self-Determination Theory"
|
||||||
|
**Right**: "The Day Xiao Ming Found His Own Engine"
|
||||||
|
|
||||||
|
## Quality Markers
|
||||||
|
|
||||||
|
- ✓ Each major concept has a recurring visual symbol
|
||||||
|
- ✓ Dialogue and visual metaphors work together (not one replacing the other)
|
||||||
|
- ✓ Clear growth arc from problem to transformation
|
||||||
|
- ✓ Original characters suited to the content domain
|
||||||
|
- ✓ Warm, professional atmosphere throughout
|
||||||
|
- ✓ Visual symbols recur and accumulate through the story
|
||||||
|
- ✓ Final page integrates all concept symbols with transformation callback
|
||||||
|
|
||||||
|
## Best For
|
||||||
|
|
||||||
|
Psychology concepts, business/management principles, motivation theory, personal development,
|
||||||
|
self-help content, leadership frameworks, coaching narratives, soft skill education,
|
||||||
|
abstract concept explanation through character-driven stories
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
# four-panel
|
||||||
|
|
||||||
|
四格漫画预设 - Minimalist four-panel business allegory comics
|
||||||
|
|
||||||
|
## Base Configuration
|
||||||
|
|
||||||
|
| Dimension | Value |
|
||||||
|
|-----------|-------|
|
||||||
|
| Art Style | minimalist |
|
||||||
|
| Tone | neutral |
|
||||||
|
| Layout | four-panel (default) |
|
||||||
|
| Aspect | 4:3 (landscape) |
|
||||||
|
|
||||||
|
Equivalent to: `--art minimalist --tone neutral --layout four-panel --aspect 4:3`
|
||||||
|
|
||||||
|
## Unique Rules
|
||||||
|
|
||||||
|
This preset includes special rules beyond the art+tone combination. When `--style four-panel` is used, ALL rules below must be applied.
|
||||||
|
|
||||||
|
### 起承转合 Narrative Structure (CRITICAL)
|
||||||
|
|
||||||
|
Every comic MUST follow the four-panel 起承转合 structure:
|
||||||
|
|
||||||
|
| Panel | Role | Requirements |
|
||||||
|
|-------|------|-------------|
|
||||||
|
| 1 (起 Setup) | Introduce the situation | Show character(s) in a recognizable context. Establish the "normal" state or problem |
|
||||||
|
| 2 (承 Development) | Build on the setup | Add complication, show an attempt, or introduce the concept. Stakes become clearer |
|
||||||
|
| 3 (转 Turn) | The twist or key insight | **Most important panel.** Show the unexpected reversal, contrast, or "aha" moment that makes the allegory work |
|
||||||
|
| 4 (合 Conclusion) | Resolution and takeaway | Show the result, consequence, or lesson learned. Can be a visual punchline or summary |
|
||||||
|
|
||||||
|
**CRITICAL**: Do NOT deviate from exactly 4 panels. No 5th panel, no title panel, no footer panel within the image.
|
||||||
|
|
||||||
|
### Single-Page Story Rule (CRITICAL)
|
||||||
|
|
||||||
|
- The entire story is told in ONE page with exactly 4 panels
|
||||||
|
- Page count: always 1 (plus optional cover)
|
||||||
|
- No multi-page four-panel stories — if content requires more, create multiple separate four-panel comics
|
||||||
|
- Storyboard structure: Cover (optional) + 1 page
|
||||||
|
|
||||||
|
### Accent Color System
|
||||||
|
|
||||||
|
- The image is primarily black-and-white line art
|
||||||
|
- Use exactly 1-2 spot colors per strip (default: orange `#FF6B35`)
|
||||||
|
- Rules:
|
||||||
|
- Key concept label or object: filled with accent color or outlined in accent
|
||||||
|
- Panel 3 (转 Turn) should have the strongest color emphasis
|
||||||
|
- Characters remain B&W — color is for concepts/objects/labels only
|
||||||
|
- Consistent accent color across all 4 panels (do not switch colors between panels)
|
||||||
|
|
||||||
|
### Character Design Rules
|
||||||
|
|
||||||
|
- Simplified stick-figure-like characters
|
||||||
|
- Distinguish characters through simple props: ties, glasses, hats, briefcases, aprons
|
||||||
|
- No detailed faces — dot eyes, line mouth at most
|
||||||
|
- Characters should be generic enough to represent archetypes (the manager, the employee, the customer)
|
||||||
|
- Maximum 2-3 characters per strip
|
||||||
|
|
||||||
|
### Text in Panels
|
||||||
|
|
||||||
|
- Chinese text for dialogue and labels (or match source language)
|
||||||
|
- Keep text minimal — 1-2 short lines per panel maximum
|
||||||
|
- Key concept terms can be highlighted with accent color background
|
||||||
|
- No narrator boxes — dialogue and labels only
|
||||||
|
- Speech bubbles: simple rectangles or ovals, thin black outline
|
||||||
|
|
||||||
|
### Optional Title & Caption
|
||||||
|
|
||||||
|
- A brief descriptive title above the 4 panels
|
||||||
|
- An optional one-line caption/moral below the panels
|
||||||
|
- These are part of the page composition, not separate panels
|
||||||
|
|
||||||
|
### Character Archetypes (Flexible)
|
||||||
|
|
||||||
|
Create simple stick-figure characters based on content. No fixed defaults:
|
||||||
|
|
||||||
|
| Role | Archetype | Visual Cues |
|
||||||
|
|------|-----------|------------|
|
||||||
|
| Protagonist | Worker/employee facing a situation | Simple figure, minimal distinguishing feature (glasses, tie) |
|
||||||
|
| Authority | Boss/manager/expert | Slightly larger figure, or prop like pointer/clipboard |
|
||||||
|
| Object | The concept itself | Labeled object, icon, or highlighted text with accent color |
|
||||||
|
|
||||||
|
### Prompt Template
|
||||||
|
|
||||||
|
When generating image prompts for four-panel comics, include these keywords:
|
||||||
|
|
||||||
|
> A minimalist, clean line art digital comic strip in a four-panel grid layout (2×2). The style is simplified cartoon illustration with clear black outlines and a minimal color palette of black, white, and specific spot [accent color] for key concepts.
|
||||||
|
|
||||||
|
Each panel description should specify:
|
||||||
|
- Panel position (Top Left / Top Right / Bottom Left / Bottom Right)
|
||||||
|
- Character poses and gestures (simple, stick-figure style)
|
||||||
|
- Dialogue text in Chinese (hand-drawn style)
|
||||||
|
- Any accent-colored elements (concept labels, key objects)
|
||||||
|
|
||||||
|
## Quality Markers
|
||||||
|
|
||||||
|
- ✓ Exactly 4 panels in strict 2×2 grid
|
||||||
|
- ✓ 起承转合 narrative arc clearly present
|
||||||
|
- ✓ 90%+ black-and-white with strategic spot color
|
||||||
|
- ✓ Simplified stick-figure characters
|
||||||
|
- ✓ Key concept visually highlighted with accent color
|
||||||
|
- ✓ Text is minimal and in Chinese (or source language)
|
||||||
|
- ✓ Single complete story in one page
|
||||||
|
- ✓ Panel 3 delivers a clear "turn" or insight
|
||||||
|
|
||||||
|
## Best For
|
||||||
|
|
||||||
|
Business allegory, management fables, short insights, workplace parables, concept contrasts, social media educational content, quick-read comics
|
||||||
@@ -18,6 +18,8 @@ Comic Progress:
|
|||||||
- [ ] Step 5: Generate prompts
|
- [ ] Step 5: Generate prompts
|
||||||
- [ ] Step 6: Review prompts (conditional)
|
- [ ] Step 6: Review prompts (conditional)
|
||||||
- [ ] Step 7: Generate images
|
- [ ] Step 7: Generate images
|
||||||
|
- [ ] 7.1 Character sheet (if needed)
|
||||||
|
- [ ] 7.2 Generate pages
|
||||||
- [ ] Step 8: Merge to PDF
|
- [ ] Step 8: Merge to PDF
|
||||||
- [ ] Step 9: Completion report
|
- [ ] Step 9: Completion report
|
||||||
```
|
```
|
||||||
@@ -410,28 +412,41 @@ options:
|
|||||||
|
|
||||||
With confirmed prompts from Step 5/6:
|
With confirmed prompts from Step 5/6:
|
||||||
|
|
||||||
### 7.1 Generate Character Reference Sheet (first)
|
### 7.1 Generate Character Reference Sheet (conditional)
|
||||||
|
|
||||||
|
Character sheet is recommended for multi-page comics with recurring characters, but **NOT required** for all presets.
|
||||||
|
|
||||||
|
**When to generate**:
|
||||||
|
|
||||||
|
| Condition | Action |
|
||||||
|
|-----------|--------|
|
||||||
|
| Multi-page comic with detailed/recurring characters | Generate character sheet (recommended) |
|
||||||
|
| Preset with simplified characters (e.g., four-panel minimalist) | Skip — prompt descriptions are sufficient |
|
||||||
|
| Single-page comic | Skip unless characters are complex |
|
||||||
|
|
||||||
|
**When generating**:
|
||||||
1. Use Reference Sheet Prompt from `characters/characters.md`
|
1. Use Reference Sheet Prompt from `characters/characters.md`
|
||||||
2. **Backup rule**: If `characters/characters.png` exists, rename to `characters/characters-backup-YYYYMMDD-HHMMSS.png`
|
2. **Backup rule**: If `characters/characters.png` exists, rename to `characters/characters-backup-YYYYMMDD-HHMMSS.png`
|
||||||
3. Generate → `characters/characters.png`
|
3. Generate → `characters/characters.png`
|
||||||
4. This ensures visual consistency for all subsequent pages
|
4. **Compress** to reduce API payload size when used as `--ref`:
|
||||||
|
- `sips -s format jpeg -s formatOptions 80 characters.png --out characters-compressed.jpg` (macOS)
|
||||||
|
- Or: `pngquant --quality=65-80 characters.png -o characters-compressed.png`
|
||||||
|
|
||||||
### 7.2 Generate Comic Pages
|
### 7.2 Generate Comic Pages
|
||||||
|
|
||||||
**CRITICAL: Character Reference is MANDATORY** for visual consistency across all pages.
|
|
||||||
|
|
||||||
**Before generating any page**:
|
**Before generating any page**:
|
||||||
1. Read the image generation skill's SKILL.md
|
1. Read the image generation skill's SKILL.md
|
||||||
2. Check if it supports reference image input (`--ref`, `--reference`, etc.)
|
2. Check if it supports reference image input (`--ref`, `--reference`, etc.)
|
||||||
3. Choose the appropriate strategy below
|
3. Determine if character sheet exists
|
||||||
|
4. Choose the appropriate strategy below
|
||||||
|
|
||||||
**Character Reference Strategy**:
|
**Page Generation Strategy**:
|
||||||
|
|
||||||
| Skill Capability | Strategy | Action |
|
| Character Sheet | Skill Capability | Strategy |
|
||||||
|------------------|----------|--------|
|
|-----------------|------------------|----------|
|
||||||
| Supports `--ref` | **Strategy A** | Pass `characters/characters.png` with EVERY page |
|
| Exists | Supports `--ref` | **A**: Pass character sheet as `--ref` with every page |
|
||||||
| Does NOT support `--ref` | **Strategy B** | Prepend character descriptions to EVERY prompt |
|
| Exists | No `--ref` support | **B**: Embed character descriptions in every prompt |
|
||||||
|
| Skipped | — | **C**: Prompt file contains all descriptions inline |
|
||||||
|
|
||||||
**Strategy A: Using `--ref` parameter** (e.g., baoyu-imagine)
|
**Strategy A: Using `--ref` parameter** (e.g., baoyu-imagine)
|
||||||
|
|
||||||
@@ -439,8 +454,16 @@ With confirmed prompts from Step 5/6:
|
|||||||
- Invoke that installed skill via its documented interface, not by calling its scripts directly
|
- Invoke that installed skill via its documented interface, not by calling its scripts directly
|
||||||
- For every page, use `prompts/01-page-xxx.md` as the prompt-file input
|
- For every page, use `prompts/01-page-xxx.md` as the prompt-file input
|
||||||
- Save output to `01-page-xxx.png`
|
- Save output to `01-page-xxx.png`
|
||||||
- Use aspect ratio `3:4`
|
- Use aspect ratio from storyboard (default `3:4`, preset may override)
|
||||||
- Pass `characters/characters.png` as `--ref` on every page generation
|
- Pass `characters/characters.png` (or compressed version) as `--ref`
|
||||||
|
|
||||||
|
**`--ref` failure recovery**:
|
||||||
|
If generation fails when using `--ref`:
|
||||||
|
1. **Compress/convert** reference image:
|
||||||
|
- `sips -s format jpeg -s formatOptions 70 characters.png --out characters-compressed.jpg`
|
||||||
|
- Or reduce resolution: `sips -Z 1024 characters.png --out characters-small.png`
|
||||||
|
2. **Retry** with compressed/converted image as `--ref`
|
||||||
|
3. **If still fails**: Fall back to **Strategy C** — generate WITHOUT `--ref`, with character descriptions embedded in prompt text
|
||||||
|
|
||||||
**Strategy B: Embedding character descriptions in prompt**
|
**Strategy B: Embedding character descriptions in prompt**
|
||||||
|
|
||||||
@@ -458,10 +481,17 @@ When skill does NOT support reference images, create combined prompt files:
|
|||||||
[Original page prompt here]
|
[Original page prompt here]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Strategy C: Prompt-only (no character sheet)**
|
||||||
|
|
||||||
|
When character sheet was skipped or `--ref` failed:
|
||||||
|
- Prompt file already contains all character descriptions inline
|
||||||
|
- No `--ref` parameter needed
|
||||||
|
- Rely on detailed text descriptions for character consistency
|
||||||
|
|
||||||
**For each page (cover + pages)**:
|
**For each page (cover + pages)**:
|
||||||
1. Read prompt from `prompts/NN-{cover|page}-[slug].md`
|
1. Read prompt from `prompts/NN-{cover|page}-[slug].md`
|
||||||
2. **Backup rule**: If image file exists, rename to `NN-{cover|page}-[slug]-backup-YYYYMMDD-HHMMSS.png`
|
2. **Backup rule**: If image file exists, rename to `NN-{cover|page}-[slug]-backup-YYYYMMDD-HHMMSS.png`
|
||||||
3. Generate image using Strategy A or B (based on skill capability)
|
3. Generate image using Strategy A, B, or C
|
||||||
4. Save to `NN-{cover|page}-[slug].png`
|
4. Save to `NN-{cover|page}-[slug].png`
|
||||||
5. Report progress after each generation: "Generated X/N: [page title]"
|
5. Report progress after each generation: "Generated X/N: [page title]"
|
||||||
|
|
||||||
@@ -493,7 +523,7 @@ Title: [title] | Art: [art] | Tone: [tone] | Pages: [count] | Aspect: [ratio] |
|
|||||||
Watermark: [enabled/disabled]
|
Watermark: [enabled/disabled]
|
||||||
Location: [path]
|
Location: [path]
|
||||||
✓ analysis.md
|
✓ analysis.md
|
||||||
✓ characters.png
|
✓ characters.png (if generated)
|
||||||
✓ 00-cover-[slug].png ... NN-page-[slug].png
|
✓ 00-cover-[slug].png ... NN-page-[slug].png
|
||||||
✓ {topic-slug}.pdf
|
✓ {topic-slug}.pdf
|
||||||
```
|
```
|
||||||
|
|||||||
+32
-1
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
+32
-1
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ WECHAT_APP_SECRET=<user_input>
|
|||||||
| Field | If Missing |
|
| Field | If Missing |
|
||||||
|-------|------------|
|
|-------|------------|
|
||||||
| Title | Prompt: "Enter title, or press Enter to auto-generate from content" |
|
| Title | Prompt: "Enter title, or press Enter to auto-generate from content" |
|
||||||
| Summary | Prompt: "Enter summary, or press Enter to auto-generate (recommended for SEO)" |
|
| Summary | Use fallback chain: frontmatter `description` → frontmatter `summary` → prompt user or auto-generate |
|
||||||
| Author | Use fallback chain: CLI `--author` → frontmatter `author` → EXTEND.md `default_author` |
|
| Author | Use fallback chain: CLI `--author` → frontmatter `author` → EXTEND.md `default_author` |
|
||||||
|
|
||||||
**Auto-Generation Logic**:
|
**Auto-Generation Logic**:
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
type WechatUploadAsset,
|
type WechatUploadAsset,
|
||||||
prepareWechatBodyImageUpload,
|
prepareWechatBodyImageUpload,
|
||||||
needsWechatBodyImageProcessing,
|
needsWechatBodyImageProcessing,
|
||||||
|
detectImageFormatFromBuffer,
|
||||||
} from "./wechat-image-processor.ts";
|
} from "./wechat-image-processor.ts";
|
||||||
|
|
||||||
interface AccessTokenResponse {
|
interface AccessTokenResponse {
|
||||||
@@ -138,6 +139,16 @@ async function loadUploadAsset(
|
|||||||
contentType = mimeTypes[fileExt] || "image/jpeg";
|
contentType = mimeTypes[fileExt] || "image/jpeg";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect actual format from magic bytes to fix extension/content-type mismatches
|
||||||
|
// (e.g. CDNs serving WebP for URLs with .png extension)
|
||||||
|
const detected = detectImageFormatFromBuffer(fileBuffer);
|
||||||
|
if (detected && detected.contentType !== contentType) {
|
||||||
|
console.error(`[wechat-api] Format mismatch: ${filename} declared as ${contentType}, actual ${detected.contentType}`);
|
||||||
|
contentType = detected.contentType;
|
||||||
|
fileExt = detected.fileExt;
|
||||||
|
filename = `${path.basename(filename, path.extname(filename))}${detected.fileExt}`;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
buffer: fileBuffer,
|
buffer: fileBuffer,
|
||||||
filename,
|
filename,
|
||||||
|
|||||||
@@ -52,6 +52,39 @@ const MIME_TO_EXT: Record<string, string> = {
|
|||||||
const JPEG_QUALITY_STEPS = [82, 74, 66, 58, 50, 42, 34];
|
const JPEG_QUALITY_STEPS = [82, 74, 66, 58, 50, 42, 34];
|
||||||
const MAX_WIDTH_STEPS = [2560, 2048, 1600, 1280, 1024, 800, 640, 480];
|
const MAX_WIDTH_STEPS = [2560, 2048, 1600, 1280, 1024, 800, 640, 480];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect actual image format from buffer magic bytes.
|
||||||
|
* Returns corrected { contentType, fileExt } or null if unknown.
|
||||||
|
*/
|
||||||
|
export function detectImageFormatFromBuffer(buffer: Buffer): { contentType: string; fileExt: string } | null {
|
||||||
|
if (buffer.length < 12) return null;
|
||||||
|
|
||||||
|
// WebP: RIFF....WEBP
|
||||||
|
if (
|
||||||
|
buffer[0] === 0x52 && buffer[1] === 0x49 && buffer[2] === 0x46 && buffer[3] === 0x46 &&
|
||||||
|
buffer[8] === 0x57 && buffer[9] === 0x45 && buffer[10] === 0x42 && buffer[11] === 0x50
|
||||||
|
) {
|
||||||
|
return { contentType: "image/webp", fileExt: ".webp" };
|
||||||
|
}
|
||||||
|
// PNG: 89 50 4E 47
|
||||||
|
if (buffer[0] === 0x89 && buffer[1] === 0x50 && buffer[2] === 0x4e && buffer[3] === 0x47) {
|
||||||
|
return { contentType: "image/png", fileExt: ".png" };
|
||||||
|
}
|
||||||
|
// JPEG: FF D8 FF
|
||||||
|
if (buffer[0] === 0xff && buffer[1] === 0xd8 && buffer[2] === 0xff) {
|
||||||
|
return { contentType: "image/jpeg", fileExt: ".jpg" };
|
||||||
|
}
|
||||||
|
// GIF: GIF8
|
||||||
|
if (buffer[0] === 0x47 && buffer[1] === 0x49 && buffer[2] === 0x46 && buffer[3] === 0x38) {
|
||||||
|
return { contentType: "image/gif", fileExt: ".gif" };
|
||||||
|
}
|
||||||
|
// BMP: BM
|
||||||
|
if (buffer[0] === 0x42 && buffer[1] === 0x4d) {
|
||||||
|
return { contentType: "image/bmp", fileExt: ".bmp" };
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
let webpDecoderReady: Promise<void> | undefined;
|
let webpDecoderReady: Promise<void> | undefined;
|
||||||
|
|
||||||
type JimpImage = Awaited<ReturnType<typeof Jimp.read>>;
|
type JimpImage = Awaited<ReturnType<typeof Jimp.read>>;
|
||||||
@@ -209,7 +242,8 @@ export async function prepareWechatBodyImageUpload(
|
|||||||
|
|
||||||
const image = await loadImageForProcessing(asset);
|
const image = await loadImageForProcessing(asset);
|
||||||
const widths = buildCandidateWidths(image.bitmap.width);
|
const widths = buildCandidateWidths(image.bitmap.width);
|
||||||
const preferPng = imageHasTransparency(image) || ensureFileExt(asset) === ".png";
|
const ext = ensureFileExt(asset);
|
||||||
|
const preferPng = imageHasTransparency(image) || ext === ".png" || ext === ".webp";
|
||||||
const processingNotes = buildProcessingNotes(asset);
|
const processingNotes = buildProcessingNotes(asset);
|
||||||
|
|
||||||
for (const width of widths) {
|
for (const width of widths) {
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
@@ -478,7 +478,7 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
chrome.kill("SIGTERM");
|
chrome.kill("SIGTERM");
|
||||||
} catch {}
|
} catch {}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!chrome.killed) {
|
if (chrome.exitCode === null && chrome.signalCode === null) {
|
||||||
try {
|
try {
|
||||||
chrome.kill("SIGKILL");
|
chrome.kill("SIGKILL");
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -486,6 +486,37 @@ export function killChrome(chrome: ChildProcess): void {
|
|||||||
}, 2_000).unref?.();
|
}, 2_000).unref?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gracefulKillChrome(
|
||||||
|
chrome: ChildProcess,
|
||||||
|
port?: number,
|
||||||
|
timeoutMs = 6_000,
|
||||||
|
): Promise<void> {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
chrome.once("exit", () => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
killChrome(chrome);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
while (Date.now() - start < timeoutMs) {
|
||||||
|
if (chrome.exitCode !== null || chrome.signalCode !== null) return;
|
||||||
|
if (port !== undefined && !await isPortListening(port, 250)) return;
|
||||||
|
|
||||||
|
const exited = await Promise.race([
|
||||||
|
exitPromise.then(() => true),
|
||||||
|
sleep(100).then(() => false),
|
||||||
|
]);
|
||||||
|
if (exited) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.race([
|
||||||
|
exitPromise,
|
||||||
|
sleep(250),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
export async function openPageSession(options: OpenPageSessionOptions): Promise<PageSession> {
|
||||||
let targetId: string;
|
let targetId: string;
|
||||||
let createdTarget = false;
|
let createdTarget = false;
|
||||||
|
|||||||
+16
@@ -399,6 +399,22 @@ export async function runConvertCommand(options: ConvertCommandOptions): Promise
|
|||||||
if (restored) logger.info(`Restored ${adapter.name} session cookies from sidecar.`);
|
if (restored) logger.info(`Restored ${adapter.name} session cookies from sidecar.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.waitMode === "interaction" && adapter.checkLogin) {
|
||||||
|
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
||||||
|
const preLogin = await adapter.checkLogin(context);
|
||||||
|
if (preLogin.state !== "logged_in") {
|
||||||
|
didLogin = true;
|
||||||
|
await waitForInteraction(adapter, context, {
|
||||||
|
type: "wait_for_interaction",
|
||||||
|
kind: "login",
|
||||||
|
provider: preLogin.provider ?? adapter.name,
|
||||||
|
prompt: `Please sign in to ${adapter.name === "x" ? "X" : adapter.name} in the opened Chrome window. Extraction will continue automatically once login is detected.`,
|
||||||
|
reason: preLogin.reason ?? `Not logged in to ${adapter.name}`,
|
||||||
|
requiresVisibleBrowser: true,
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (options.waitMode === "force") {
|
if (options.waitMode === "force") {
|
||||||
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
await context.browser.goto(url.toString(), options.timeoutMs).catch(() => {});
|
||||||
await waitForForceResume(adapter, context, options);
|
await waitForForceResume(adapter, context, options);
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ Break down complex content into eye-catching infographic series for Xiaohongshu
|
|||||||
# Direct input with options
|
# Direct input with options
|
||||||
/baoyu-xhs-images --style bold --layout comparison
|
/baoyu-xhs-images --style bold --layout comparison
|
||||||
[paste content]
|
[paste content]
|
||||||
|
|
||||||
|
# Non-interactive (for scheduled tasks / automation)
|
||||||
|
/baoyu-xhs-images posts/ai-future/article.md --yes
|
||||||
|
/baoyu-xhs-images posts/ai-future/article.md --yes --preset knowledge-card
|
||||||
```
|
```
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
@@ -48,6 +52,7 @@ Break down complex content into eye-catching infographic series for Xiaohongshu
|
|||||||
| `--style <name>` | Visual style (see Style Gallery) |
|
| `--style <name>` | Visual style (see Style Gallery) |
|
||||||
| `--layout <name>` | Information layout (see Layout Gallery) |
|
| `--layout <name>` | Information layout (see Layout Gallery) |
|
||||||
| `--preset <name>` | Style + layout shorthand (see [Style Presets](references/style-presets.md)) |
|
| `--preset <name>` | Style + layout shorthand (see [Style Presets](references/style-presets.md)) |
|
||||||
|
| `--yes` | Non-interactive mode: skip all confirmations. Uses EXTEND.md preferences if found, otherwise uses defaults (no watermark, auto style/layout). Auto-confirms recommended plan (Path A). Suitable for scheduled tasks and automation. |
|
||||||
|
|
||||||
## Two Dimensions
|
## Two Dimensions
|
||||||
|
|
||||||
@@ -237,11 +242,11 @@ Copy and track progress:
|
|||||||
|
|
||||||
```
|
```
|
||||||
XHS Infographic Progress:
|
XHS Infographic Progress:
|
||||||
- [ ] Step 0: Check preferences (EXTEND.md) ⛔ BLOCKING
|
- [ ] Step 0: Check preferences (EXTEND.md) ⛔ BLOCKING (--yes: use defaults if not found)
|
||||||
- [ ] Found → load preferences → continue
|
- [ ] Found → load preferences → continue
|
||||||
- [ ] Not found → run first-time setup → MUST complete before Step 1
|
- [ ] Not found → run first-time setup → MUST complete before Step 1 (--yes: skip setup, use defaults)
|
||||||
- [ ] Step 1: Analyze content → analysis.md
|
- [ ] Step 1: Analyze content → analysis.md
|
||||||
- [ ] Step 2: Smart Confirm ⚠️ REQUIRED
|
- [ ] Step 2: Smart Confirm ⚠️ REQUIRED (--yes: auto-confirm Path A)
|
||||||
- [ ] Path A: Quick confirm → generate recommended outline
|
- [ ] Path A: Quick confirm → generate recommended outline
|
||||||
- [ ] Path B: Customize → adjust then generate outline
|
- [ ] Path B: Customize → adjust then generate outline
|
||||||
- [ ] Path C: Detailed → 3 outlines → second confirm → generate outline
|
- [ ] Path C: Detailed → 3 outlines → second confirm → generate outline
|
||||||
@@ -252,26 +257,30 @@ XHS Infographic Progress:
|
|||||||
### Flow
|
### Flow
|
||||||
|
|
||||||
```
|
```
|
||||||
Input → [Step 0: Preferences] ─┬─ Found → Continue
|
Input → [--yes?] ─┬─ Yes → [Step 0: Load or defaults] → Analyze → Auto-confirm → Generate → Complete
|
||||||
│
|
│
|
||||||
└─ Not found → First-Time Setup ⛔ BLOCKING
|
└─ No → [Step 0: Preferences] ─┬─ Found → Continue
|
||||||
│
|
│
|
||||||
└─ Complete setup → Save EXTEND.md → Continue
|
└─ Not found → First-Time Setup ⛔ BLOCKING
|
||||||
│
|
│
|
||||||
┌───────────────────────────────────────────────────────────────────────────┘
|
└─ Complete setup → Save EXTEND.md → Continue
|
||||||
↓
|
│
|
||||||
Analyze → [Smart Confirm] ─┬─ Quick: confirm recommended → outline.md → Generate → Complete
|
┌─────────────────────────────────────────────────────────────────────────────────────┘
|
||||||
│
|
↓
|
||||||
├─ Customize: adjust options → outline.md → Generate → Complete
|
Analyze → [Smart Confirm] ─┬─ Quick: confirm recommended → outline.md → Generate → Complete
|
||||||
│
|
│
|
||||||
└─ Detailed: 3 outlines → [Confirm 2] → outline.md → Generate → Complete
|
├─ Customize: adjust options → outline.md → Generate → Complete
|
||||||
|
│
|
||||||
|
└─ Detailed: 3 outlines → [Confirm 2] → outline.md → Generate → Complete
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 0: Load Preferences (EXTEND.md) ⛔ BLOCKING
|
### Step 0: Load Preferences (EXTEND.md) ⛔ BLOCKING
|
||||||
|
|
||||||
**Purpose**: Load user preferences or run first-time setup.
|
**Purpose**: Load user preferences or run first-time setup.
|
||||||
|
|
||||||
**CRITICAL**: If EXTEND.md not found, MUST complete first-time setup before ANY other questions or steps. Do NOT proceed to content analysis, do NOT ask about style, do NOT ask about layout — ONLY complete the preferences setup first.
|
**`--yes` mode**: If EXTEND.md found → load it. If not found → use built-in defaults (no watermark, style/layout auto-select, language from content). Do NOT run first-time setup, do NOT create EXTEND.md, do NOT ask any questions. Proceed directly to Step 1.
|
||||||
|
|
||||||
|
**CRITICAL** (interactive mode only): If EXTEND.md not found, MUST complete first-time setup before ANY other questions or steps. Do NOT proceed to content analysis, do NOT ask about style, do NOT ask about layout — ONLY complete the preferences setup first.
|
||||||
|
|
||||||
Check EXTEND.md existence (priority order):
|
Check EXTEND.md existence (priority order):
|
||||||
|
|
||||||
@@ -340,7 +349,11 @@ Read source content, save it if needed, and perform deep analysis.
|
|||||||
|
|
||||||
### Step 2: Smart Confirm ⚠️
|
### Step 2: Smart Confirm ⚠️
|
||||||
|
|
||||||
**Purpose**: Present auto-recommended plan, let user confirm or adjust. **Do NOT skip.**
|
**Purpose**: Present auto-recommended plan, let user confirm or adjust.
|
||||||
|
|
||||||
|
**`--yes` mode**: Skip this entire step. Use auto-recommended strategy + style + layout from Step 1 analysis (or `--style`/`--layout`/`--preset` if provided). Generate outline directly using Path A logic → save to `outline.md` → proceed to Step 3. No AskUserQuestion calls.
|
||||||
|
|
||||||
|
**Interactive mode**: Do NOT skip.
|
||||||
|
|
||||||
**Auto-Recommendation Logic**:
|
**Auto-Recommendation Logic**:
|
||||||
1. Use Auto Selection table to match content signals → best strategy + style + layout
|
1. Use Auto Selection table to match content signals → best strategy + style + layout
|
||||||
@@ -491,7 +504,7 @@ Reference: `references/config/watermark-guide.md`
|
|||||||
|
|
||||||
**Image Generation Skill Selection**:
|
**Image Generation Skill Selection**:
|
||||||
- Check available image generation skills
|
- Check available image generation skills
|
||||||
- If multiple skills available, ask user preference
|
- If multiple skills available: ask user preference (interactive) or use first available skill (`--yes` mode)
|
||||||
|
|
||||||
**Session Management**:
|
**Session Management**:
|
||||||
If image generation skill supports `--sessionId`:
|
If image generation skill supports `--sessionId`:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import test from "node:test";
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
|
|
||||||
import { findTranscript, parseTranscriptJson3, parseWebVtt } from "./transcript.ts";
|
import { findTranscript, parseTranscriptJson3, parseWebVtt } from "./transcript.ts";
|
||||||
import { buildTranscriptListFromYtDlp, resolveVideoSource, selectYtDlpTrack } from "./youtube.ts";
|
import { buildTranscriptListFromYtDlp, fetchTranscriptWithFallback, resolveVideoSource, selectYtDlpTrack } from "./youtube.ts";
|
||||||
|
|
||||||
test("selectYtDlpTrack prefers json3 over xml and vtt", () => {
|
test("selectYtDlpTrack prefers json3 over xml and vtt", () => {
|
||||||
const track = selectYtDlpTrack([
|
const track = selectYtDlpTrack([
|
||||||
@@ -123,3 +123,61 @@ test("resolveVideoSource falls back to yt-dlp only after fallback-eligible error
|
|||||||
assert.equal(fallbackCalled, true);
|
assert.equal(fallbackCalled, true);
|
||||||
assert.equal(source.transcripts[0].languageCode, "en");
|
assert.equal(source.transcripts[0].languageCode, "en");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("fetchTranscriptWithFallback retries with yt-dlp when InnerTube transcript payload is empty", async () => {
|
||||||
|
const warnings: string[] = [];
|
||||||
|
let fallbackCalled = false;
|
||||||
|
const result = await fetchTranscriptWithFallback(
|
||||||
|
"video12345ab",
|
||||||
|
{
|
||||||
|
kind: "innertube",
|
||||||
|
data: { videoDetails: { title: "Primary" } },
|
||||||
|
transcripts: [{
|
||||||
|
language: "English",
|
||||||
|
languageCode: "en",
|
||||||
|
isGenerated: false,
|
||||||
|
isTranslatable: false,
|
||||||
|
baseUrl: "https://www.youtube.com/api/timedtext?v=video12345ab&lang=en&fmt=json3",
|
||||||
|
translationLanguages: [],
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
languages: ["en"],
|
||||||
|
translate: "",
|
||||||
|
excludeGenerated: false,
|
||||||
|
excludeManual: false,
|
||||||
|
},
|
||||||
|
async (info) => {
|
||||||
|
if (info.baseUrl.includes("youtube.com/api/timedtext")) {
|
||||||
|
return { snippets: [], language: info.language, languageCode: info.languageCode };
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
snippets: [{ text: "Recovered subtitle", start: 0, duration: 2 }],
|
||||||
|
language: info.language,
|
||||||
|
languageCode: info.languageCode,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
async () => {
|
||||||
|
fallbackCalled = true;
|
||||||
|
return {
|
||||||
|
kind: "yt-dlp",
|
||||||
|
info: { title: "Fallback" },
|
||||||
|
transcripts: [{
|
||||||
|
language: "English",
|
||||||
|
languageCode: "en",
|
||||||
|
isGenerated: false,
|
||||||
|
isTranslatable: false,
|
||||||
|
baseUrl: "https://example.com/subtitles.en.json3",
|
||||||
|
translationLanguages: [],
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
(message) => warnings.push(message)
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(fallbackCalled, true);
|
||||||
|
assert.equal(result.source.kind, "yt-dlp");
|
||||||
|
assert.equal(result.snippets.length, 1);
|
||||||
|
assert.equal(result.snippets[0].text, "Recovered subtitle");
|
||||||
|
assert.match(warnings[0] || "", /Retrying with yt-dlp fallback/);
|
||||||
|
});
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ import {
|
|||||||
registerVideoDir,
|
registerVideoDir,
|
||||||
resolveBaseDir,
|
resolveBaseDir,
|
||||||
} from "./storage.ts";
|
} from "./storage.ts";
|
||||||
import { findTranscript, formatListOutput, formatMarkdown, formatSrt, segmentIntoSentences } from "./transcript.ts";
|
import { formatListOutput, formatMarkdown, formatSrt, segmentIntoSentences } from "./transcript.ts";
|
||||||
import type { Options, Sentence, Snippet, VideoMeta, VideoResult } from "./types.ts";
|
import type { Options, Sentence, Snippet, VideoMeta, VideoResult } from "./types.ts";
|
||||||
import {
|
import {
|
||||||
buildVideoMeta,
|
buildVideoMeta,
|
||||||
buildVideoMetaFromYtDlp,
|
buildVideoMetaFromYtDlp,
|
||||||
downloadCoverImage,
|
downloadCoverImage,
|
||||||
fetchTranscriptSnippets,
|
fetchTranscriptWithFallback,
|
||||||
fetchVideoSource,
|
fetchVideoSource,
|
||||||
getThumbnailUrls,
|
getThumbnailUrls,
|
||||||
getYtDlpThumbnailUrls,
|
getYtDlpThumbnailUrls,
|
||||||
@@ -31,10 +31,12 @@ async function fetchAndCache(
|
|||||||
baseDir: string,
|
baseDir: string,
|
||||||
opts: Options
|
opts: Options
|
||||||
): Promise<{ meta: VideoMeta; snippets: Snippet[]; sentences: Sentence[]; videoDir: string }> {
|
): Promise<{ meta: VideoMeta; snippets: Snippet[]; sentences: Sentence[]; videoDir: string }> {
|
||||||
const source = await fetchVideoSource(videoId);
|
const initialSource = await fetchVideoSource(videoId);
|
||||||
const requestedLanguages = source.kind === "yt-dlp" && opts.translate ? [opts.translate] : opts.languages;
|
const { source, transcript, snippets, language, languageCode } = await fetchTranscriptWithFallback(
|
||||||
const transcript = findTranscript(source.transcripts, requestedLanguages, opts.excludeGenerated, opts.excludeManual);
|
videoId,
|
||||||
const result = await fetchTranscriptSnippets(transcript, source.kind === "yt-dlp" ? undefined : opts.translate || undefined);
|
initialSource,
|
||||||
|
opts
|
||||||
|
);
|
||||||
const description = source.kind === "yt-dlp"
|
const description = source.kind === "yt-dlp"
|
||||||
? source.info.description || ""
|
? source.info.description || ""
|
||||||
: source.data?.videoDetails?.shortDescription || "";
|
: source.data?.videoDetails?.shortDescription || "";
|
||||||
@@ -42,21 +44,21 @@ async function fetchAndCache(
|
|||||||
? Number(source.info.duration || 0)
|
? Number(source.info.duration || 0)
|
||||||
: parseInt(source.data?.videoDetails?.lengthSeconds || "0");
|
: parseInt(source.data?.videoDetails?.lengthSeconds || "0");
|
||||||
const chapters = parseChapters(description, duration);
|
const chapters = parseChapters(description, duration);
|
||||||
const language = {
|
const languageMeta = {
|
||||||
code: result.languageCode,
|
code: languageCode,
|
||||||
name: result.language,
|
name: language,
|
||||||
isGenerated: transcript.isGenerated,
|
isGenerated: transcript.isGenerated,
|
||||||
};
|
};
|
||||||
const meta = source.kind === "yt-dlp"
|
const meta = source.kind === "yt-dlp"
|
||||||
? buildVideoMetaFromYtDlp(source.info, videoId, language, chapters)
|
? buildVideoMetaFromYtDlp(source.info, videoId, languageMeta, chapters)
|
||||||
: buildVideoMeta(source.data, videoId, language, chapters);
|
: buildVideoMeta(source.data, videoId, languageMeta, chapters);
|
||||||
|
|
||||||
const videoDir = registerVideoDir(videoId, slugify(meta.channel), slugify(meta.title), baseDir);
|
const videoDir = registerVideoDir(videoId, slugify(meta.channel), slugify(meta.title), baseDir);
|
||||||
ensureDir(join(videoDir, "meta.json"));
|
ensureDir(join(videoDir, "meta.json"));
|
||||||
|
|
||||||
writeFileSync(join(videoDir, "transcript-raw.json"), JSON.stringify(result.snippets, null, 2));
|
writeFileSync(join(videoDir, "transcript-raw.json"), JSON.stringify(snippets, null, 2));
|
||||||
|
|
||||||
const sentences = segmentIntoSentences(result.snippets);
|
const sentences = segmentIntoSentences(snippets);
|
||||||
writeFileSync(join(videoDir, "transcript-sentences.json"), JSON.stringify(sentences, null, 2));
|
writeFileSync(join(videoDir, "transcript-sentences.json"), JSON.stringify(sentences, null, 2));
|
||||||
|
|
||||||
const imagePath = join(videoDir, "imgs", "cover.jpg");
|
const imagePath = join(videoDir, "imgs", "cover.jpg");
|
||||||
@@ -69,7 +71,7 @@ async function fetchAndCache(
|
|||||||
|
|
||||||
writeFileSync(join(videoDir, "meta.json"), JSON.stringify(meta, null, 2));
|
writeFileSync(join(videoDir, "meta.json"), JSON.stringify(meta, null, 2));
|
||||||
|
|
||||||
return { meta, snippets: result.snippets, sentences, videoDir };
|
return { meta, snippets, sentences, videoDir };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processVideo(videoId: string, opts: Options): Promise<VideoResult> {
|
async function processVideo(videoId: string, opts: Options): Promise<VideoResult> {
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { spawnSync } from "child_process";
|
|||||||
import { writeFileSync } from "fs";
|
import { writeFileSync } from "fs";
|
||||||
|
|
||||||
import { makeError, normalizeError, normalizePublishDate, shouldTryAlternateClient, shouldTryYtDlpFallback } from "./shared.ts";
|
import { makeError, normalizeError, normalizePublishDate, shouldTryAlternateClient, shouldTryYtDlpFallback } from "./shared.ts";
|
||||||
import { parseTranscriptPayload } from "./transcript.ts";
|
import { findTranscript, parseTranscriptPayload } from "./transcript.ts";
|
||||||
import type {
|
import type {
|
||||||
Chapter,
|
Chapter,
|
||||||
InnerTubeClient,
|
InnerTubeClient,
|
||||||
InnerTubeSession,
|
InnerTubeSession,
|
||||||
LanguageMeta,
|
LanguageMeta,
|
||||||
|
Options,
|
||||||
Snippet,
|
Snippet,
|
||||||
TranscriptInfo,
|
TranscriptInfo,
|
||||||
VideoMeta,
|
VideoMeta,
|
||||||
@@ -219,6 +220,68 @@ export async function fetchTranscriptSnippets(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildYtDlpVideoSource(videoId: string, info: YtDlpInfo): VideoSource {
|
||||||
|
const transcripts = buildTranscriptListFromYtDlp(info);
|
||||||
|
if (!transcripts.length) throw makeError(`Transcripts disabled for ${videoId}`, "TRANSCRIPTS_DISABLED");
|
||||||
|
return { kind: "yt-dlp", info, transcripts };
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRequestedLanguages(
|
||||||
|
source: VideoSource,
|
||||||
|
opts: Pick<Options, "languages" | "translate">
|
||||||
|
): string[] {
|
||||||
|
return source.kind === "yt-dlp" && opts.translate ? [opts.translate] : opts.languages;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchTranscriptWithFallback(
|
||||||
|
videoId: string,
|
||||||
|
source: VideoSource,
|
||||||
|
opts: Pick<Options, "languages" | "translate" | "excludeGenerated" | "excludeManual">,
|
||||||
|
fetchSnippets: (
|
||||||
|
info: TranscriptInfo,
|
||||||
|
translateTo?: string
|
||||||
|
) => Promise<{ snippets: Snippet[]; language: string; languageCode: string }> = fetchTranscriptSnippets,
|
||||||
|
fetchFallbackSource: (videoId: string) => Promise<VideoSource> | VideoSource = (requestedVideoId) =>
|
||||||
|
buildYtDlpVideoSource(requestedVideoId, fetchYtDlpInfo(requestedVideoId)),
|
||||||
|
logWarning: (message: string) => void = (message) => console.error(message)
|
||||||
|
): Promise<{
|
||||||
|
source: VideoSource;
|
||||||
|
transcript: TranscriptInfo;
|
||||||
|
snippets: Snippet[];
|
||||||
|
language: string;
|
||||||
|
languageCode: string;
|
||||||
|
}> {
|
||||||
|
const transcript = findTranscript(
|
||||||
|
source.transcripts,
|
||||||
|
getRequestedLanguages(source, opts),
|
||||||
|
opts.excludeGenerated,
|
||||||
|
opts.excludeManual
|
||||||
|
);
|
||||||
|
const result = await fetchSnippets(transcript, source.kind === "yt-dlp" ? undefined : opts.translate || undefined);
|
||||||
|
if (result.snippets.length > 0) return { source, transcript, ...result };
|
||||||
|
|
||||||
|
if (source.kind === "yt-dlp") {
|
||||||
|
throw makeError(`Transcript fetch returned empty snippets for ${videoId}`, "EMPTY_TRANSCRIPT");
|
||||||
|
}
|
||||||
|
|
||||||
|
logWarning(`Warning (${videoId}): Transcript fetch returned empty snippets. Retrying with yt-dlp fallback.`);
|
||||||
|
const fallbackSource = await fetchFallbackSource(videoId);
|
||||||
|
const fallbackTranscript = findTranscript(
|
||||||
|
fallbackSource.transcripts,
|
||||||
|
getRequestedLanguages(fallbackSource, opts),
|
||||||
|
opts.excludeGenerated,
|
||||||
|
opts.excludeManual
|
||||||
|
);
|
||||||
|
const fallbackResult = await fetchSnippets(
|
||||||
|
fallbackTranscript,
|
||||||
|
fallbackSource.kind === "yt-dlp" ? undefined : opts.translate || undefined
|
||||||
|
);
|
||||||
|
if (!fallbackResult.snippets.length) {
|
||||||
|
throw makeError(`Transcript fetch returned empty snippets for ${videoId} after yt-dlp fallback`, "EMPTY_TRANSCRIPT");
|
||||||
|
}
|
||||||
|
return { source: fallbackSource, transcript: fallbackTranscript, ...fallbackResult };
|
||||||
|
}
|
||||||
|
|
||||||
export function detectYtDlpCommand(): { command: string; args: string[]; label: string } | null {
|
export function detectYtDlpCommand(): { command: string; args: string[]; label: string } | null {
|
||||||
if (cachedYtDlpCommand !== undefined) return cachedYtDlpCommand;
|
if (cachedYtDlpCommand !== undefined) return cachedYtDlpCommand;
|
||||||
const candidates = [
|
const candidates = [
|
||||||
@@ -366,10 +429,7 @@ export async function resolveVideoSource(
|
|||||||
const normalized = normalizeError(error);
|
const normalized = normalizeError(error);
|
||||||
if (!shouldTryYtDlpFallback(normalized)) throw normalized;
|
if (!shouldTryYtDlpFallback(normalized)) throw normalized;
|
||||||
logWarning(`Warning (${videoId}): ${normalized.message}. Retrying with yt-dlp fallback.`);
|
logWarning(`Warning (${videoId}): ${normalized.message}. Retrying with yt-dlp fallback.`);
|
||||||
const info = fetchFallback(videoId);
|
return buildYtDlpVideoSource(videoId, fetchFallback(videoId));
|
||||||
const transcripts = buildTranscriptListFromYtDlp(info);
|
|
||||||
if (!transcripts.length) throw makeError(`Transcripts disabled for ${videoId}`, "TRANSCRIPTS_DISABLED");
|
|
||||||
return { kind: "yt-dlp", info, transcripts };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user