Loading...
Loading...
Compare original and translation side by side
shared/shared/config-pattern.mdshared/common-patterns.md~/Downloads/.listenhub/jqshared/shared/config-pattern.mdshared/common-patterns.md~/Downloads/.listenhub/jqshared/config-pattern.mdmkdir -p ".listenhub/creator" ".listenhub/creator/styles"
cat > ".listenhub/creator/config.json" << 'EOF'
{"outputMode":"download","language":null,"preferences":{"wechat":{"history":[]},"xiaohongshu":{"mode":"both","history":[]},"narration":{"defaultSpeaker":null,"history":[]}}}
EOF
CONFIG_PATH=".listenhub/creator/config.json"
CONFIG=$(cat "$CONFIG_PATH").listenhub/creator/styles/.listenhub/creator/styles/wechat.md.listenhub/creator/styles/xiaohongshu.md.listenhub/creator/styles/narration.mdoutputMode"download""inline"CONFIG_PATH=".listenhub/creator/config.json"
[ ! -f "$CONFIG_PATH" ] && CONFIG_PATH="$HOME/.listenhub/creator/config.json"
CONFIG=$(cat "$CONFIG_PATH")shared/config-pattern.mdmkdir -p ".listenhub/creator" ".listenhub/creator/styles"
cat > ".listenhub/creator/config.json" << 'EOF'
{"outputMode":"download","language":null,"preferences":{"wechat":{"history":[]},"xiaohongshu":{"mode":"both","history":[]},"narration":{"defaultSpeaker":null,"history":[]}}}
EOF
CONFIG_PATH=".listenhub/creator/config.json"
CONFIG=$(cat "$CONFIG_PATH").listenhub/creator/styles/.listenhub/creator/styles/wechat.md.listenhub/creator/styles/xiaohongshu.md.listenhub/creator/styles/narration.mdoutputMode"download""inline"CONFIG_PATH=".listenhub/creator/config.json"
[ ! -f "$CONFIG_PATH" ] && CONFIG_PATH="$HOME/.listenhub/creator/config.json"
CONFIG=$(cat "$CONFIG_PATH")当前配置 (creator):
输出方式:{outputMode}
小红书模式:{both / cards / long-text}shared/output-mode.md当前配置 (creator):
输出方式:{outputMode}
小红书模式:{both / cards / long-text}shared/output-mode.md| Input Type | Detection | Auto Action |
|---|---|---|
| URL (web/article) | | Will call content-parser (requires API key) |
| URL (audio/video) | Extension | Will download + call |
| Local audio file | File path exists, extension is audio/video | Will call |
| Local text file | File path exists, extension is | Read file content |
| Raw text | Multi-line or >50 chars, not a URL/path | Use directly as material |
| Topic/keywords | Short text (<50 chars), no URL/path pattern | AI writes from scratch |
/tmp/creator-{slug}.{ext}curl -L -ocoliwhich coli 2>/dev/null && echo yes || echo nocolinpm install -g @marswave/colicoli asr -j --model sensevoice "/tmp/creator-{slug}.{ext}"rm "/tmp/creator-{slug}.{ext}"| 输入类型 | 检测方式 | 自动操作 |
|---|---|---|
| 网页/文章链接 | 带有 | 将调用content-parser(需要API密钥) |
| 音视频链接 | 扩展名是 | 将下载文件并调用 |
| 本地音视频文件 | 文件路径存在,且扩展名为音视频格式 | 直接调用 |
| 本地文本文件 | 文件路径存在,且扩展名为 | 读取文件内容 |
| 原始文本 | 多行内容或超过50个字符,且不是链接/路径 | 直接作为素材使用 |
| 主题/关键词 | 短文本(少于50字符),且无链接/路径格式 | AI从零开始创作 |
curl -L -o/tmp/creator-{slug}.{ext}coliwhich coli 2>/dev/null && echo yes || echo nocolinpm install -g @marswave/colicoli asr -j --model sensevoice "/tmp/creator-{slug}.{ext}"rm "/tmp/creator-{slug}.{ext}"从参考文章中提炼了以下风格特征:
1. {directive 1}
2. {directive 2}
3. {directive 3}
...
你可以修改或删除其中的条目。确认后本次生成会应用这些规则。sessionStyle要将这些风格规则保存吗?(保存后每次生成{platform}内容都会应用).listenhub/creator/styles/{platform}.md.listenhub/creator/styles/{platform}.md从参考文章中提炼了以下风格特征:
1. {指令1}
2. {指令2}
3. {指令3}
...
你可以修改或删除其中的条目。确认后本次生成会应用这些规则。sessionStyle要将这些风格规则保存吗?(保存后每次生成{platform}内容都会应用).listenhub/creator/styles/{platform}.md.listenhub/creator/styles/{platform}.mdpreferences.xiaohongshu.mode"long-text"labelpreferences.xiaohongshu.mode"long-text"labelcoli asrshared/authentication.md准备生成内容:
模板:{WeChat article / Xiaohongshu / Narration}
输入:{topic description / URL / text excerpt...}
输出目录:{slug}-{platform}/
需要 API 调用:{content-parser, image-gen, ...}
风格偏好:{styles/{platform}.md 已配置 / 使用默认风格}
配图/卡片预设:{preset label / 不适用}
本次风格参考:{M条来自参考文章 / 无}
确认开始?coli asrshared/authentication.md准备生成内容:
模板:{公众号文章 / 小红书 / 口播}
输入:{主题描述 / 链接 / 文本摘录...}
输出目录:{slug}-{platform}/
需要API调用:{content-parser, image-gen, ...}
风格偏好:{已配置styles/{platform}.md / 使用默认风格}
配图/卡片预设:{预设标签 / 不适用}
本次风格参考:{M条来自参考文章 / 无}
确认开始?undefinedundefined
**For URL inputs — extract content first:**
```bash
**对于链接输入——先提取内容**:
```bash
Then poll in background. Run this as a **separate Bash call** with `run_in_background: true` and `timeout: 600000` (per `shared/common-patterns.md`). The polling loop itself runs up to 300s (60 polls × 5s); `timeout: 600000` is set higher at the tool level to give the Bash process headroom beyond the poll budget:
```bash
然后在后台轮询。按照`shared/common-patterns.md`的要求,作为**独立Bash调用**执行,设置`run_in_background: true`和`timeout: 600000`。轮询循环最多运行300秒(60次轮询×5秒);工具层面设置`timeout: 600000`是为了给Bash进程留出超出轮询预算的空间:
```bash
Extract content: `MATERIAL=$(echo "$RESULT" | jq -r '.data.data.content')`
If extraction fails: tell user "URL 解析失败,你可以直接粘贴文字内容给我" and stop.
**Then follow the platform template** — read `template.md` and execute each step. The template specifies the exact writing instructions and API calls. See `creator/templates/{platform}/template.md` for template contents.
**Style application:** When writing content, apply style directives in this priority order (higher overrides lower):
1. `sessionStyle` — directives from the current style reference (Step 3), if any
2. `.listenhub/creator/styles/{platform}.md` — persisted user style directives (if file exists)
3. `templates/{platform}/style.md` — baseline platform style
**For image generation** (called by wechat and xiaohongshu templates):
```bash
RESPONSE=$(curl -sS -X POST "https://api.marswave.ai/openapi/v1/images/generation" \
-H "Authorization: Bearer $LISTENHUB_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Source: skills" \
--max-time 600 \
-d '{
"provider": "google",
"model": "gemini-3-pro-image-preview",
"prompt": "<generated prompt>",
"imageConfig": {"imageSize": "2K", "aspectRatio": "<ratio>"}
}')
BASE64_DATA=$(echo "$RESPONSE" | jq -r '.candidates[0].content.parts[0].inlineData.data // .data')
提取内容:`MATERIAL=$(echo "$RESULT" | jq -r '.data.data.content')`
如果提取失败:告知用户“URL解析失败,你可以直接粘贴文字内容给我”并停止执行。
**然后遵循平台模板**——读取`template.md`并执行每一步。模板指定了具体的写作指令和API调用。详见`creator/templates/{platform}/template.md`中的模板内容。
**风格应用优先级**:生成内容时,按以下优先级应用风格指令(优先级高的覆盖优先级低的):
1. `sessionStyle`——当前风格参考的指令(步骤3)(如有)
2. `.listenhub/creator/styles/{platform}.md`——用户保存的风格指令(如果文件存在)
3. `templates/{platform}/style.md`——平台基础风格
**图片生成**(由公众号和小红书模板调用):
```bash
RESPONSE=$(curl -sS -X POST "https://api.marswave.ai/openapi/v1/images/generation" \
-H "Authorization: Bearer $LISTENHUB_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Source: skills" \
--max-time 600 \
-d '{
"provider": "google",
"model": "gemini-3-pro-image-preview",
"prompt": "<generated prompt>",
"imageConfig": {"imageSize": "2K", "aspectRatio": "<ratio>"}
}')
BASE64_DATA=$(echo "$RESPONSE" | jq -r '.candidates[0].content.parts[0].inlineData.data // .data')
On 429: exponential backoff (wait 15s → 30s → 60s), retry up to 3 times. On failure after retries: skip this image, annotate in output summary.
Generate images **sequentially** (not parallel) to respect rate limits.
**For TTS** (called by narration template when user wants audio):
Use `@file` pattern per `shared/common-patterns.md` to handle special chars in script text:
```bash
遇到429错误:指数退避等待(15秒→30秒→60秒),最多重试3次。如果重试后仍失败:跳过该图片,在输出摘要中注明。
**按顺序生成图片**(而非并行),以遵守速率限制。
**TTS语音合成**(当用户需要音频时由口播模板调用):
按照`shared/common-patterns.md`中的`@file`模式处理脚本文本中的特殊字符:
```bashundefinedundefinedSLUG="{topic-slug}"
OUTPUT_DIR="${SLUG}-{platform}"SLUG="{topic-slug}"
OUTPUT_DIR="${SLUG}-{platform}"
Write content files per template spec. Then write `meta.json`:
```json
{
"title": "...",
"slug": "...",
"platform": "wechat|xiaohongshu|narration",
"date": "YYYY-MM-DD",
"tags": ["...", "..."],
"summary": "..."
}
按照模板规范写入内容文件。然后写入`meta.json`:
```json
{
"title": "...",
"slug": "...",
"platform": "wechat|xiaohongshu|narration",
"date": "YYYY-MM-DD",
"tags": ["...", "..."],
"summary": "..."
}✅ 内容已生成!保存在 {OUTPUT_DIR}/
📄 {main files list}
🖼️ images/ — N 张配图(如有)
📋 meta.json — 标题、标签、摘要✅ 内容已生成!保存在 {OUTPUT_DIR}/
📄 {主要文件列表}
🖼️ images/ — N 张配图(如有)
📋 meta.json — 标题、标签、摘要NEW_CONFIG=$(echo "$CONFIG" | jq \
--arg platform "$PLATFORM" \
--arg date "$(date +%Y-%m-%d)" \
--arg topic "$TOPIC" \
'.preferences[$platform].history = (.preferences[$platform].history + [{"date": $date, "topic": $topic}])[-5:]')
echo "$NEW_CONFIG" > "$CONFIG_PATH"cardStyleNEW_CONFIG=$(echo "$CONFIG" | jq \
--arg platform "$PLATFORM" \
--arg date "$(date +%Y-%m-%d)" \
--arg topic "$TOPIC" \
'.preferences[$platform].history = (.preferences[$platform].history + [{"date": $date, "topic": $topic}])[-5:]')
echo "$NEW_CONFIG" > "$CONFIG_PATH"cardStyle.listenhub/creator/styles/{platform}.md.listenhub/creator/styles/{platform}.md.listenhub/creator/styles/{platform}.md.listenhub/creator/styles/{platform}.md.listenhub/creator/styles/{platform}.md.listenhub/creator/styles/{platform}.mdshared/authentication.mdshared/api-image.mdshared/api-content-extract.mdshared/api-tts.mdshared/speaker-selection.mdshared/config-pattern.mdshared/common-patterns.mdshared/output-mode.mdshared/authentication.mdshared/api-image.mdshared/api-content-extract.mdshared/api-tts.mdshared/speaker-selection.mdshared/config-pattern.mdshared/common-patterns.mdshared/output-mode.mdcolicreator/templates/{wechat,xiaohongshu,narration}/template.mdcreator/templates/{wechat,xiaohongshu,narration}/style.mdcolicreator/templates/{wechat,xiaohongshu,narration}/template.mdcreator/templates/{wechat,xiaohongshu,narration}/style.md