mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-07-19 08:59:48 +08:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e4d4ec8334 | |||
| 4935dc8b1a | |||
| c43ed57ffc | |||
| d96368492e | |||
| cfc647fd38 | |||
| a702513487 | |||
| 6b2b28b421 | |||
| 0df63c3a0b | |||
| 7834d632e0 | |||
| ca9a0a1404 | |||
| 366e7b5403 | |||
| 709e026be1 |
@@ -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.57.0"
|
"version": "1.58.0"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,21 @@
|
|||||||
|
|
||||||
English | [中文](./CHANGELOG.zh.md)
|
English | [中文](./CHANGELOG.zh.md)
|
||||||
|
|
||||||
|
## 1.58.0 - 2026-03-08
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Add XDG config path support for EXTEND.md (by @liby)
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- `baoyu-post-to-wechat`: surface agent-browser startup errors
|
||||||
|
- `baoyu-post-to-wechat`: harden agent-browser command and eval handling (by @luojiyin1987)
|
||||||
|
- `baoyu-image-gen`: use execFileSync for google curl requests (by @luojiyin1987)
|
||||||
|
- `baoyu-format-markdown`: use spawnSync for autocorrect command (by @luojiyin1987)
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
- Fix CLAUDE dependency statement (by @luojiyin1987)
|
||||||
|
- Add markdown-to-html to README utility skills (by @luojiyin1987)
|
||||||
|
|
||||||
## 1.57.0 - 2026-03-08
|
## 1.57.0 - 2026-03-08
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -2,6 +2,21 @@
|
|||||||
|
|
||||||
[English](./CHANGELOG.md) | 中文
|
[English](./CHANGELOG.md) | 中文
|
||||||
|
|
||||||
|
## 1.58.0 - 2026-03-08
|
||||||
|
|
||||||
|
### 新功能
|
||||||
|
- 新增 EXTEND.md 的 XDG 配置路径支持 (by @liby)
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
- `baoyu-post-to-wechat`:暴露 agent-browser 启动错误信息
|
||||||
|
- `baoyu-post-to-wechat`:加固 agent-browser 命令和 eval 处理 (by @luojiyin1987)
|
||||||
|
- `baoyu-image-gen`:使用 execFileSync 替代 shell 执行 Google curl 请求 (by @luojiyin1987)
|
||||||
|
- `baoyu-format-markdown`:使用 spawnSync 替代 shell 执行 autocorrect 命令 (by @luojiyin1987)
|
||||||
|
|
||||||
|
### 文档
|
||||||
|
- 修正 CLAUDE 依赖说明 (by @luojiyin1987)
|
||||||
|
- 将 markdown-to-html 添加到 README 工具技能列表 (by @luojiyin1987)
|
||||||
|
|
||||||
## 1.57.0 - 2026-03-08
|
## 1.57.0 - 2026-03-08
|
||||||
|
|
||||||
### 新功能
|
### 新功能
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ ${BUN_X} skills/baoyu-danger-gemini-web/scripts/main.ts --promptfiles system.md
|
|||||||
|
|
||||||
- **Bun**: TypeScript runtime (native `bun` preferred, fallback `npx -y bun`)
|
- **Bun**: TypeScript runtime (native `bun` preferred, fallback `npx -y bun`)
|
||||||
- **Chrome**: Required for `baoyu-danger-gemini-web` auth and `baoyu-post-to-x` automation
|
- **Chrome**: Required for `baoyu-danger-gemini-web` auth and `baoyu-post-to-x` automation
|
||||||
- **No npm packages**: Self-contained TypeScript, no external dependencies
|
- **npm packages (per skill)**: Some skill subprojects include `package.json`/lockfiles and require dependency installation in their own `scripts/` directories
|
||||||
|
|
||||||
## Chrome Profile (Unified)
|
## Chrome Profile (Unified)
|
||||||
|
|
||||||
@@ -472,22 +472,27 @@ Check EXTEND.md existence (priority order):
|
|||||||
\`\`\`bash
|
\`\`\`bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/<skill-name>/EXTEND.md && echo "project"
|
test -f .baoyu-skills/<skill-name>/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/<skill-name>/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/<skill-name>/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/<skill-name>/EXTEND.md" && echo "user"
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
\`\`\`powershell
|
\`\`\`powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/<skill-name>/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/<skill-name>/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/<skill-name>/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/<skill-name>/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/<skill-name>/EXTEND.md") { "user" }
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
┌────────────────────────────────────────────┬───────────────────┐
|
┌────────────────────────────────────────────────────────┬──────────────────────────┐
|
||||||
│ Path │ Location │
|
│ Path │ Location │
|
||||||
├────────────────────────────────────────────┼───────────────────┤
|
├────────────────────────────────────────────────────────┼──────────────────────────┤
|
||||||
│ .baoyu-skills/<skill-name>/EXTEND.md │ Project directory │
|
│ .baoyu-skills/<skill-name>/EXTEND.md │ Project directory │
|
||||||
├────────────────────────────────────────────┼───────────────────┤
|
├────────────────────────────────────────────────────────┼──────────────────────────┤
|
||||||
│ $HOME/.baoyu-skills/<skill-name>/EXTEND.md │ User home │
|
│ $XDG_CONFIG_HOME/baoyu-skills/<skill-name>/EXTEND.md │ XDG config (~/.config) │
|
||||||
└────────────────────────────────────────────┴───────────────────┘
|
├────────────────────────────────────────────────────────┼──────────────────────────┤
|
||||||
|
│ $HOME/.baoyu-skills/<skill-name>/EXTEND.md │ User home (legacy) │
|
||||||
|
└────────────────────────────────────────────────────────┴──────────────────────────┘
|
||||||
|
|
||||||
┌───────────┬───────────────────────────────────────────────────────────────────────────┐
|
┌───────────┬───────────────────────────────────────────────────────────────────────────┐
|
||||||
│ Result │ Action │
|
│ Result │ Action │
|
||||||
@@ -523,5 +528,6 @@ Custom configurations via EXTEND.md. See **Preferences** section for paths and s
|
|||||||
**Notes**:
|
**Notes**:
|
||||||
- Replace `<skill-name>` with actual skill name (e.g., `baoyu-cover-image`)
|
- Replace `<skill-name>` with actual skill name (e.g., `baoyu-cover-image`)
|
||||||
- Use `$HOME` instead of `~` for cross-platform compatibility (macOS/Linux/WSL/PowerShell)
|
- Use `$HOME` instead of `~` for cross-platform compatibility (macOS/Linux/WSL/PowerShell)
|
||||||
|
- `$XDG_CONFIG_HOME` defaults to `~/.config` when unset
|
||||||
- Use `test -f` (Bash) or `Test-Path` (PowerShell) for explicit file existence check
|
- Use `test -f` (Bash) or `Test-Path` (PowerShell) for explicit file existence check
|
||||||
- ASCII tables for clear visual formatting
|
- ASCII tables for clear visual formatting
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ Simply tell Claude Code:
|
|||||||
|--------|-------------|--------|
|
|--------|-------------|--------|
|
||||||
| **content-skills** | Content generation and publishing | [xhs-images](#baoyu-xhs-images), [infographic](#baoyu-infographic), [cover-image](#baoyu-cover-image), [slide-deck](#baoyu-slide-deck), [comic](#baoyu-comic), [article-illustrator](#baoyu-article-illustrator), [post-to-x](#baoyu-post-to-x), [post-to-wechat](#baoyu-post-to-wechat), [post-to-weibo](#baoyu-post-to-weibo) |
|
| **content-skills** | Content generation and publishing | [xhs-images](#baoyu-xhs-images), [infographic](#baoyu-infographic), [cover-image](#baoyu-cover-image), [slide-deck](#baoyu-slide-deck), [comic](#baoyu-comic), [article-illustrator](#baoyu-article-illustrator), [post-to-x](#baoyu-post-to-x), [post-to-wechat](#baoyu-post-to-wechat), [post-to-weibo](#baoyu-post-to-weibo) |
|
||||||
| **ai-generation-skills** | AI-powered generation backends | [image-gen](#baoyu-image-gen), [danger-gemini-web](#baoyu-danger-gemini-web) |
|
| **ai-generation-skills** | AI-powered generation backends | [image-gen](#baoyu-image-gen), [danger-gemini-web](#baoyu-danger-gemini-web) |
|
||||||
| **utility-skills** | Utility tools for content processing | [url-to-markdown](#baoyu-url-to-markdown), [danger-x-to-markdown](#baoyu-danger-x-to-markdown), [compress-image](#baoyu-compress-image), [format-markdown](#baoyu-format-markdown), [translate](#baoyu-translate) |
|
| **utility-skills** | Utility tools for content processing | [url-to-markdown](#baoyu-url-to-markdown), [danger-x-to-markdown](#baoyu-danger-x-to-markdown), [compress-image](#baoyu-compress-image), [format-markdown](#baoyu-format-markdown), [markdown-to-html](#baoyu-markdown-to-html), [translate](#baoyu-translate) |
|
||||||
|
|
||||||
## Update Skills
|
## Update Skills
|
||||||
|
|
||||||
@@ -798,6 +798,21 @@ Format plain text or markdown files with proper frontmatter, titles, summaries,
|
|||||||
| Code/commands | `` `inline` `` or ` ```block``` ` |
|
| Code/commands | `` `inline` `` or ` ```block``` ` |
|
||||||
| Quotes | `>` blockquote |
|
| Quotes | `>` blockquote |
|
||||||
|
|
||||||
|
#### baoyu-markdown-to-html
|
||||||
|
|
||||||
|
Convert markdown files into styled HTML with WeChat-compatible themes, syntax highlighting, and optional bottom citations for external links.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Basic conversion
|
||||||
|
/baoyu-markdown-to-html article.md
|
||||||
|
|
||||||
|
# Theme + color
|
||||||
|
/baoyu-markdown-to-html article.md --theme grace --color red
|
||||||
|
|
||||||
|
# Convert ordinary external links to bottom citations
|
||||||
|
/baoyu-markdown-to-html article.md --cite
|
||||||
|
```
|
||||||
|
|
||||||
#### baoyu-translate
|
#### baoyu-translate
|
||||||
|
|
||||||
Translate articles and documents between languages with three modes: quick (direct), normal (analysis-informed), and refined (full publication-quality workflow with review and polish).
|
Translate articles and documents between languages with three modes: quick (direct), normal (analysis-informed), and refined (full publication-quality workflow with review and polish).
|
||||||
|
|||||||
+16
-1
@@ -76,7 +76,7 @@ clawhub install baoyu-markdown-to-html
|
|||||||
|------|------|----------|
|
|------|------|----------|
|
||||||
| **content-skills** | 内容生成和发布 | [xhs-images](#baoyu-xhs-images), [infographic](#baoyu-infographic), [cover-image](#baoyu-cover-image), [slide-deck](#baoyu-slide-deck), [comic](#baoyu-comic), [article-illustrator](#baoyu-article-illustrator), [post-to-x](#baoyu-post-to-x), [post-to-wechat](#baoyu-post-to-wechat), [post-to-weibo](#baoyu-post-to-weibo) |
|
| **content-skills** | 内容生成和发布 | [xhs-images](#baoyu-xhs-images), [infographic](#baoyu-infographic), [cover-image](#baoyu-cover-image), [slide-deck](#baoyu-slide-deck), [comic](#baoyu-comic), [article-illustrator](#baoyu-article-illustrator), [post-to-x](#baoyu-post-to-x), [post-to-wechat](#baoyu-post-to-wechat), [post-to-weibo](#baoyu-post-to-weibo) |
|
||||||
| **ai-generation-skills** | AI 生成后端 | [image-gen](#baoyu-image-gen), [danger-gemini-web](#baoyu-danger-gemini-web) |
|
| **ai-generation-skills** | AI 生成后端 | [image-gen](#baoyu-image-gen), [danger-gemini-web](#baoyu-danger-gemini-web) |
|
||||||
| **utility-skills** | 内容处理工具 | [url-to-markdown](#baoyu-url-to-markdown), [danger-x-to-markdown](#baoyu-danger-x-to-markdown), [compress-image](#baoyu-compress-image), [format-markdown](#baoyu-format-markdown), [translate](#baoyu-translate) |
|
| **utility-skills** | 内容处理工具 | [url-to-markdown](#baoyu-url-to-markdown), [danger-x-to-markdown](#baoyu-danger-x-to-markdown), [compress-image](#baoyu-compress-image), [format-markdown](#baoyu-format-markdown), [markdown-to-html](#baoyu-markdown-to-html), [translate](#baoyu-translate) |
|
||||||
|
|
||||||
## 更新技能
|
## 更新技能
|
||||||
|
|
||||||
@@ -798,6 +798,21 @@ AI 驱动的生成后端。
|
|||||||
| 代码/命令 | `` `行内` `` 或 ` ```代码块``` ` |
|
| 代码/命令 | `` `行内` `` 或 ` ```代码块``` ` |
|
||||||
| 引用 | `>` 引用块 |
|
| 引用 | `>` 引用块 |
|
||||||
|
|
||||||
|
#### baoyu-markdown-to-html
|
||||||
|
|
||||||
|
将 Markdown 文件转换为样式化 HTML,支持微信公众号兼容主题、代码高亮,以及可选的外链底部引用。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 基础转换
|
||||||
|
/baoyu-markdown-to-html article.md
|
||||||
|
|
||||||
|
# 主题 + 颜色
|
||||||
|
/baoyu-markdown-to-html article.md --theme grace --color red
|
||||||
|
|
||||||
|
# 将普通外链转换为文末引用
|
||||||
|
/baoyu-markdown-to-html article.md --cite
|
||||||
|
```
|
||||||
|
|
||||||
#### baoyu-translate
|
#### baoyu-translate
|
||||||
|
|
||||||
三模式翻译技能:快速(直接翻译)、标准(分析后翻译)、精翻(完整出版级工作流,含审校与润色)。
|
三模式翻译技能:快速(直接翻译)、标准(分析后翻译)、精翻(完整出版级工作流,含审校与润色)。
|
||||||
|
|||||||
@@ -55,12 +55,15 @@ See [references/styles.md](references/styles.md) for Core Styles, full gallery,
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-article-illustrator/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-article-illustrator/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-article-illustrator/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-article-illustrator/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-article-illustrator/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-article-illustrator/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-article-illustrator/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-article-illustrator/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-article-illustrator/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-article-illustrator/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -88,12 +88,15 @@ Check preferences and existing state, then ask ALL needed questions in ONE AskUs
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-article-illustrator/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-article-illustrator/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-article-illustrator/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-article-illustrator/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-article-illustrator/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-article-illustrator/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-article-illustrator/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-article-illustrator/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-article-illustrator/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-article-illustrator/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -39,12 +39,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-comic/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-comic/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-comic/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-comic/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-comic/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-comic/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-comic/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-comic/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-comic/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-comic/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -30,12 +30,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-compress-image/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-compress-image/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-compress-image/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-compress-image/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-compress-image/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-compress-image/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -134,12 +134,15 @@ Check EXTEND.md existence (priority: project → user):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-cover-image/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-cover-image/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-cover-image/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-cover-image/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-cover-image/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-cover-image/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-cover-image/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-cover-image/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-cover-image/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-cover-image/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -57,12 +57,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-danger-gemini-web/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-danger-gemini-web/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-danger-gemini-web/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-danger-gemini-web/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-danger-gemini-web/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-danger-gemini-web/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-danger-gemini-web/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-danger-gemini-web/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-danger-gemini-web/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-danger-gemini-web/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -83,12 +83,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-format-markdown/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-format-markdown/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-format-markdown/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-format-markdown/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-format-markdown/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-format-markdown/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-format-markdown/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-format-markdown/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-format-markdown/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-format-markdown/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { execSync } from "child_process";
|
import { spawnSync } from "node:child_process";
|
||||||
|
import process from "node:process";
|
||||||
|
|
||||||
export function applyAutocorrect(filePath: string): boolean {
|
export function applyAutocorrect(filePath: string): boolean {
|
||||||
try {
|
const npxCmd = process.platform === "win32" ? "npx.cmd" : "npx";
|
||||||
execSync(`npx autocorrect-node --fix "${filePath}"`, { stdio: "inherit" });
|
const result = spawnSync(npxCmd, ["autocorrect-node", "--fix", filePath], {
|
||||||
return true;
|
stdio: "inherit",
|
||||||
} catch {
|
});
|
||||||
return false;
|
return result.status === 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,12 +31,15 @@ Check EXTEND.md existence (priority: project → user):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-image-gen/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-image-gen/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-image-gen/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-image-gen/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-image-gen/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-image-gen/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-image-gen/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-image-gen/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-image-gen/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-image-gen/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { execSync } from "node:child_process";
|
import { execFileSync } from "node:child_process";
|
||||||
import type { CliArgs } from "../types";
|
import type { CliArgs } from "../types";
|
||||||
|
|
||||||
const GOOGLE_MULTIMODAL_MODELS = [
|
const GOOGLE_MULTIMODAL_MODELS = [
|
||||||
@@ -76,14 +76,43 @@ async function postGoogleJsonViaCurl<T>(
|
|||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
const proxy = getHttpProxy();
|
const proxy = getHttpProxy();
|
||||||
const bodyStr = JSON.stringify(body);
|
const bodyStr = JSON.stringify(body);
|
||||||
const proxyArgs = proxy ? `-x "${proxy}"` : "";
|
const args = [
|
||||||
|
"-s",
|
||||||
|
"--connect-timeout",
|
||||||
|
"30",
|
||||||
|
"--max-time",
|
||||||
|
"300",
|
||||||
|
...(proxy ? ["-x", proxy] : []),
|
||||||
|
url,
|
||||||
|
"-H",
|
||||||
|
"Content-Type: application/json",
|
||||||
|
"-H",
|
||||||
|
`x-goog-api-key: ${apiKey}`,
|
||||||
|
"-d",
|
||||||
|
"@-",
|
||||||
|
];
|
||||||
|
|
||||||
const result = execSync(
|
let result = "";
|
||||||
`curl -s --connect-timeout 30 --max-time 300 ${proxyArgs} "${url}" -H "Content-Type: application/json" -H "x-goog-api-key: ${apiKey}" -d @-`,
|
try {
|
||||||
{ input: bodyStr, maxBuffer: 100 * 1024 * 1024, timeout: 310000 },
|
result = execFileSync("curl", args, {
|
||||||
);
|
input: bodyStr,
|
||||||
|
encoding: "utf8",
|
||||||
|
maxBuffer: 100 * 1024 * 1024,
|
||||||
|
timeout: 310000,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
const e = error as { message?: string; stderr?: string | Buffer };
|
||||||
|
const stderrText =
|
||||||
|
typeof e.stderr === "string"
|
||||||
|
? e.stderr
|
||||||
|
: e.stderr
|
||||||
|
? e.stderr.toString("utf8")
|
||||||
|
: "";
|
||||||
|
const details = stderrText.trim() || e.message || "curl request failed";
|
||||||
|
throw new Error(`Google API request failed via curl: ${details}`);
|
||||||
|
}
|
||||||
|
|
||||||
const parsed = JSON.parse(result.toString()) as any;
|
const parsed = JSON.parse(result) as any;
|
||||||
if (parsed.error) {
|
if (parsed.error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Google API error (${parsed.error.code}): ${parsed.error.message}`,
|
`Google API error (${parsed.error.code}): ${parsed.error.message}`,
|
||||||
|
|||||||
@@ -147,12 +147,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-infographic/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-infographic/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-infographic/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-infographic/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-infographic/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-infographic/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-infographic/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-infographic/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-infographic/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-infographic/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -30,12 +30,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-markdown-to-html/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-markdown-to-html/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-markdown-to-html/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-markdown-to-html/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-markdown-to-html/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-markdown-to-html/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-markdown-to-html/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-markdown-to-html/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-markdown-to-html/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-markdown-to-html/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ function parseExtendYaml(yaml: string): Partial<ExtendConfig> {
|
|||||||
export function loadExtendConfig(): Partial<ExtendConfig> {
|
export function loadExtendConfig(): Partial<ExtendConfig> {
|
||||||
const paths = [
|
const paths = [
|
||||||
path.join(process.cwd(), ".baoyu-skills", "baoyu-markdown-to-html", "EXTEND.md"),
|
path.join(process.cwd(), ".baoyu-skills", "baoyu-markdown-to-html", "EXTEND.md"),
|
||||||
|
path.join(
|
||||||
|
process.env.XDG_CONFIG_HOME || path.join(homedir(), ".config"),
|
||||||
|
"baoyu-skills", "baoyu-markdown-to-html", "EXTEND.md"
|
||||||
|
),
|
||||||
path.join(homedir(), ".baoyu-skills", "baoyu-markdown-to-html", "EXTEND.md"),
|
path.join(homedir(), ".baoyu-skills", "baoyu-markdown-to-html", "EXTEND.md"),
|
||||||
];
|
];
|
||||||
for (const p of paths) {
|
for (const p of paths) {
|
||||||
|
|||||||
@@ -36,12 +36,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-post-to-wechat/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-post-to-wechat/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-post-to-wechat/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-post-to-wechat/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-post-to-wechat/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ function parseExtendYaml(yaml: string): Partial<ExtendConfig> {
|
|||||||
export function loadExtendConfig(): Partial<ExtendConfig> {
|
export function loadExtendConfig(): Partial<ExtendConfig> {
|
||||||
const paths = [
|
const paths = [
|
||||||
path.join(process.cwd(), ".baoyu-skills", "baoyu-markdown-to-html", "EXTEND.md"),
|
path.join(process.cwd(), ".baoyu-skills", "baoyu-markdown-to-html", "EXTEND.md"),
|
||||||
|
path.join(
|
||||||
|
process.env.XDG_CONFIG_HOME || path.join(homedir(), ".config"),
|
||||||
|
"baoyu-skills", "baoyu-markdown-to-html", "EXTEND.md"
|
||||||
|
),
|
||||||
path.join(homedir(), ".baoyu-skills", "baoyu-markdown-to-html", "EXTEND.md"),
|
path.join(homedir(), ".baoyu-skills", "baoyu-markdown-to-html", "EXTEND.md"),
|
||||||
];
|
];
|
||||||
for (const p of paths) {
|
for (const p of paths) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { execSync, spawnSync } from 'node:child_process';
|
import { spawnSync } from 'node:child_process';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
@@ -10,30 +10,51 @@ function sleep(ms: number): Promise<void> {
|
|||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
function ab(cmd: string, json = false): string {
|
function quoteForLog(arg: string): string {
|
||||||
const fullCmd = `agent-browser --session ${SESSION} ${cmd}${json ? ' --json' : ''}`;
|
return /[\s"'\\]/.test(arg) ? JSON.stringify(arg) : arg;
|
||||||
console.log(`[ab] ${fullCmd}`);
|
|
||||||
try {
|
|
||||||
const result = execSync(fullCmd, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
||||||
return result.trim();
|
|
||||||
} catch (e: unknown) {
|
|
||||||
const err = e as { stdout?: string; stderr?: string; message?: string };
|
|
||||||
console.error(`[ab] Error: ${err.stderr || err.message}`);
|
|
||||||
return err.stdout || '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function abRaw(args: string[]): { success: boolean; output: string } {
|
function toSafeJsStringLiteral(value: string): string {
|
||||||
|
return JSON.stringify(value)
|
||||||
|
.replace(/\u2028/g, '\\u2028')
|
||||||
|
.replace(/\u2029/g, '\\u2029');
|
||||||
|
}
|
||||||
|
|
||||||
|
function runAgentBrowser(args: string[]): {
|
||||||
|
success: boolean;
|
||||||
|
output: string;
|
||||||
|
spawnError?: string;
|
||||||
|
} {
|
||||||
const result = spawnSync('agent-browser', ['--session', SESSION, ...args], {
|
const result = spawnSync('agent-browser', ['--session', SESSION, ...args], {
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
stdio: ['pipe', 'pipe', 'pipe']
|
stdio: ['pipe', 'pipe', 'pipe']
|
||||||
});
|
});
|
||||||
|
const spawnError = result.error?.message?.trim();
|
||||||
|
const output = result.stdout || result.stderr || '';
|
||||||
return {
|
return {
|
||||||
success: result.status === 0,
|
success: result.status === 0,
|
||||||
output: result.stdout || result.stderr || ''
|
output: output || spawnError || '',
|
||||||
|
spawnError
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ab(args: string[], json = false): string {
|
||||||
|
const fullArgs = json ? [...args, '--json'] : args;
|
||||||
|
console.log(`[ab] agent-browser --session ${SESSION} ${fullArgs.map(quoteForLog).join(' ')}`);
|
||||||
|
const result = runAgentBrowser(fullArgs);
|
||||||
|
if (result.spawnError) {
|
||||||
|
throw new Error(`agent-browser failed to start: ${result.spawnError}`);
|
||||||
|
}
|
||||||
|
if (!result.success) {
|
||||||
|
console.error(`[ab] Error: ${result.output.trim()}`);
|
||||||
|
}
|
||||||
|
return result.output.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function abRaw(args: string[]): { success: boolean; output: string } {
|
||||||
|
return runAgentBrowser(args);
|
||||||
|
}
|
||||||
|
|
||||||
interface SnapshotElement {
|
interface SnapshotElement {
|
||||||
ref: string;
|
ref: string;
|
||||||
role: string;
|
role: string;
|
||||||
@@ -99,17 +120,17 @@ async function postToWeChat(options: WeChatOptions): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('[wechat] Opening WeChat Official Account...');
|
console.log('[wechat] Opening WeChat Official Account...');
|
||||||
ab(`open ${WECHAT_URL} --headed`);
|
ab(['open', WECHAT_URL, '--headed']);
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
|
|
||||||
console.log('[wechat] Checking login status...');
|
console.log('[wechat] Checking login status...');
|
||||||
let url = ab('get url');
|
let url = ab(['get', 'url']);
|
||||||
console.log(`[wechat] Current URL: ${url}`);
|
console.log(`[wechat] Current URL: ${url}`);
|
||||||
|
|
||||||
const waitForLogin = async (timeoutMs = 120_000): Promise<boolean> => {
|
const waitForLogin = async (timeoutMs = 120_000): Promise<boolean> => {
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
while (Date.now() - start < timeoutMs) {
|
while (Date.now() - start < timeoutMs) {
|
||||||
url = ab('get url');
|
url = ab(['get', 'url']);
|
||||||
if (url.includes('/cgi-bin/home')) return true;
|
if (url.includes('/cgi-bin/home')) return true;
|
||||||
console.log('[wechat] Waiting for login...');
|
console.log('[wechat] Waiting for login...');
|
||||||
await sleep(3000);
|
await sleep(3000);
|
||||||
@@ -126,7 +147,7 @@ async function postToWeChat(options: WeChatOptions): Promise<void> {
|
|||||||
await sleep(2000);
|
await sleep(2000);
|
||||||
|
|
||||||
console.log('[wechat] Getting page snapshot...');
|
console.log('[wechat] Getting page snapshot...');
|
||||||
let snapshot = ab('snapshot');
|
let snapshot = ab(['snapshot']);
|
||||||
console.log(snapshot);
|
console.log(snapshot);
|
||||||
|
|
||||||
console.log('[wechat] Looking for "图文" menu...');
|
console.log('[wechat] Looking for "图文" menu...');
|
||||||
@@ -134,16 +155,16 @@ async function postToWeChat(options: WeChatOptions): Promise<void> {
|
|||||||
|
|
||||||
if (!tuWenRef) {
|
if (!tuWenRef) {
|
||||||
console.log('[wechat] Using eval to find and click menu...');
|
console.log('[wechat] Using eval to find and click menu...');
|
||||||
ab(`eval "document.querySelectorAll('.new-creation__menu .new-creation__menu-item')[2].click()"`);
|
ab(['eval', "document.querySelectorAll('.new-creation__menu .new-creation__menu-item')[2].click()"]);
|
||||||
} else {
|
} else {
|
||||||
console.log(`[wechat] Clicking menu ref: ${tuWenRef}`);
|
console.log(`[wechat] Clicking menu ref: ${tuWenRef}`);
|
||||||
ab(`click ${tuWenRef}`);
|
ab(['click', tuWenRef]);
|
||||||
}
|
}
|
||||||
|
|
||||||
await sleep(4000);
|
await sleep(4000);
|
||||||
|
|
||||||
console.log('[wechat] Checking for new tab...');
|
console.log('[wechat] Checking for new tab...');
|
||||||
const tabsOutput = ab('tab');
|
const tabsOutput = ab(['tab']);
|
||||||
console.log(`[wechat] Tabs: ${tabsOutput}`);
|
console.log(`[wechat] Tabs: ${tabsOutput}`);
|
||||||
|
|
||||||
const tabLines = tabsOutput.split('\n');
|
const tabLines = tabsOutput.split('\n');
|
||||||
@@ -153,14 +174,14 @@ async function postToWeChat(options: WeChatOptions): Promise<void> {
|
|||||||
const tabMatch = tabsOutput.match(/\[(\d+)\].*(?:appmsg|edit)/i);
|
const tabMatch = tabsOutput.match(/\[(\d+)\].*(?:appmsg|edit)/i);
|
||||||
if (tabMatch) {
|
if (tabMatch) {
|
||||||
console.log(`[wechat] Switching to editor tab ${tabMatch[1]}...`);
|
console.log(`[wechat] Switching to editor tab ${tabMatch[1]}...`);
|
||||||
ab(`tab ${tabMatch[1]}`);
|
ab(['tab', tabMatch[1]]);
|
||||||
} else {
|
} else {
|
||||||
const lastTabMatch = tabsOutput.match(/\[(\d+)\]/g);
|
const lastTabMatch = tabsOutput.match(/\[(\d+)\]/g);
|
||||||
if (lastTabMatch && lastTabMatch.length > 1) {
|
if (lastTabMatch && lastTabMatch.length > 1) {
|
||||||
const lastTab = lastTabMatch[lastTabMatch.length - 1].match(/\d+/)?.[0];
|
const lastTab = lastTabMatch[lastTabMatch.length - 1].match(/\d+/)?.[0];
|
||||||
if (lastTab) {
|
if (lastTab) {
|
||||||
console.log(`[wechat] Switching to last tab ${lastTab}...`);
|
console.log(`[wechat] Switching to last tab ${lastTab}...`);
|
||||||
ab(`tab ${lastTab}`);
|
ab(['tab', lastTab]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,38 +189,44 @@ async function postToWeChat(options: WeChatOptions): Promise<void> {
|
|||||||
|
|
||||||
await sleep(3000);
|
await sleep(3000);
|
||||||
|
|
||||||
url = ab('get url');
|
url = ab(['get', 'url']);
|
||||||
console.log(`[wechat] Editor URL: ${url}`);
|
console.log(`[wechat] Editor URL: ${url}`);
|
||||||
|
|
||||||
console.log('[wechat] Getting editor snapshot...');
|
console.log('[wechat] Getting editor snapshot...');
|
||||||
snapshot = ab('snapshot');
|
snapshot = ab(['snapshot']);
|
||||||
console.log(snapshot.substring(0, 2000));
|
console.log(snapshot.substring(0, 2000));
|
||||||
|
|
||||||
console.log('[wechat] Uploading images...');
|
console.log('[wechat] Uploading images...');
|
||||||
const fileInputSelector = '.js_upload_btn_container input[type=file]';
|
const fileInputSelector = '.js_upload_btn_container input[type=file]';
|
||||||
|
const fileInputSelectorJs = toSafeJsStringLiteral(fileInputSelector);
|
||||||
|
|
||||||
ab(`eval "document.querySelector('${fileInputSelector}').style.display = 'block'"`);
|
ab(['eval', `{
|
||||||
|
const input = document.querySelector(${fileInputSelectorJs});
|
||||||
|
if (input) input.style.display = 'block';
|
||||||
|
}`]);
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
|
|
||||||
const uploadResult = abRaw(['upload', `"${fileInputSelector}"`, ...absoluteImages]);
|
const uploadResult = abRaw(['upload', fileInputSelector, ...absoluteImages]);
|
||||||
console.log(`[wechat] Upload result: ${uploadResult.output}`);
|
console.log(`[wechat] Upload result: ${uploadResult.output}`);
|
||||||
|
|
||||||
if (!uploadResult.success) {
|
if (!uploadResult.success) {
|
||||||
console.log('[wechat] Using alternative upload method...');
|
console.log('[wechat] Using alternative upload method...');
|
||||||
for (const img of absoluteImages) {
|
for (const img of absoluteImages) {
|
||||||
console.log(`[wechat] Uploading: ${img}`);
|
console.log(`[wechat] Uploading: ${img}`);
|
||||||
ab(`eval "
|
const imgUrlJs = toSafeJsStringLiteral(`file://${img}`);
|
||||||
const input = document.querySelector('${fileInputSelector}');
|
const imgFileNameJs = toSafeJsStringLiteral(path.basename(img));
|
||||||
|
ab(['eval', `
|
||||||
|
const input = document.querySelector(${fileInputSelectorJs});
|
||||||
if (input) {
|
if (input) {
|
||||||
const dt = new DataTransfer();
|
const dt = new DataTransfer();
|
||||||
fetch('file://${img}').then(r => r.blob()).then(b => {
|
fetch(${imgUrlJs}).then(r => r.blob()).then(b => {
|
||||||
const file = new File([b], '${path.basename(img)}', { type: 'image/png' });
|
const file = new File([b], ${imgFileNameJs}, { type: 'image/png' });
|
||||||
dt.items.add(file);
|
dt.items.add(file);
|
||||||
input.files = dt.files;
|
input.files = dt.files;
|
||||||
input.dispatchEvent(new Event('change', { bubbles: true }));
|
input.dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
"`);
|
`]);
|
||||||
await sleep(2000);
|
await sleep(2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,13 +235,14 @@ async function postToWeChat(options: WeChatOptions): Promise<void> {
|
|||||||
await sleep(10000);
|
await sleep(10000);
|
||||||
|
|
||||||
console.log('[wechat] Filling title...');
|
console.log('[wechat] Filling title...');
|
||||||
snapshot = ab('snapshot -i');
|
snapshot = ab(['snapshot', '-i']);
|
||||||
const titleRef = findElementByText(snapshot, 'title') || findElementByText(snapshot, '标题');
|
const titleRef = findElementByText(snapshot, 'title') || findElementByText(snapshot, '标题');
|
||||||
|
|
||||||
if (titleRef) {
|
if (titleRef) {
|
||||||
ab(`fill ${titleRef} "${title.replace(/"/g, '\\"')}"`);
|
ab(['fill', titleRef, title]);
|
||||||
} else {
|
} else {
|
||||||
ab(`eval "const t = document.querySelector('#title'); if(t) { t.value = '${title.replace(/'/g, "\\'")}'; t.dispatchEvent(new Event('input', {bubbles: true})); }"`);
|
const titleJs = toSafeJsStringLiteral(title);
|
||||||
|
ab(['eval', `const t = document.querySelector('#title'); if(t) { t.value = ${titleJs}; t.dispatchEvent(new Event('input', {bubbles: true})); }`]);
|
||||||
}
|
}
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
|
|
||||||
@@ -222,9 +250,9 @@ async function postToWeChat(options: WeChatOptions): Promise<void> {
|
|||||||
const editorRef = findElementByText(snapshot, 'js_pmEditorArea') || findElementByText(snapshot, 'textbox');
|
const editorRef = findElementByText(snapshot, 'js_pmEditorArea') || findElementByText(snapshot, 'textbox');
|
||||||
|
|
||||||
if (editorRef) {
|
if (editorRef) {
|
||||||
ab(`click ${editorRef}`);
|
ab(['click', editorRef]);
|
||||||
} else {
|
} else {
|
||||||
ab(`eval "document.querySelector('.js_pmEditorArea')?.click()"`);
|
ab(['eval', "document.querySelector('.js_pmEditorArea')?.click()"]);
|
||||||
}
|
}
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
|
|
||||||
@@ -233,11 +261,11 @@ async function postToWeChat(options: WeChatOptions): Promise<void> {
|
|||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
const line = lines[i];
|
const line = lines[i];
|
||||||
if (line.length > 0) {
|
if (line.length > 0) {
|
||||||
const escapedLine = line.replace(/"/g, '\\"').replace(/'/g, "\\'");
|
const lineJs = toSafeJsStringLiteral(line);
|
||||||
ab(`eval "document.execCommand('insertText', false, '${escapedLine}')"`);
|
ab(['eval', `document.execCommand('insertText', false, ${lineJs})`]);
|
||||||
}
|
}
|
||||||
if (i < lines.length - 1) {
|
if (i < lines.length - 1) {
|
||||||
ab('press Enter');
|
ab(['press', 'Enter']);
|
||||||
}
|
}
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
}
|
}
|
||||||
@@ -249,9 +277,9 @@ async function postToWeChat(options: WeChatOptions): Promise<void> {
|
|||||||
console.log('[wechat] Saving as draft...');
|
console.log('[wechat] Saving as draft...');
|
||||||
const submitRef = findElementByText(snapshot, 'js_submit') || findElementByText(snapshot, '保存');
|
const submitRef = findElementByText(snapshot, 'js_submit') || findElementByText(snapshot, '保存');
|
||||||
if (submitRef) {
|
if (submitRef) {
|
||||||
ab(`click ${submitRef}`);
|
ab(['click', submitRef]);
|
||||||
} else {
|
} else {
|
||||||
ab(`eval "document.querySelector('#js_submit')?.click()"`);
|
ab(['eval', "document.querySelector('#js_submit')?.click()"]);
|
||||||
}
|
}
|
||||||
await sleep(3000);
|
await sleep(3000);
|
||||||
console.log('[wechat] Draft saved!');
|
console.log('[wechat] Draft saved!');
|
||||||
@@ -261,7 +289,7 @@ async function postToWeChat(options: WeChatOptions): Promise<void> {
|
|||||||
|
|
||||||
if (!keepOpen) {
|
if (!keepOpen) {
|
||||||
console.log('[wechat] Closing browser...');
|
console.log('[wechat] Closing browser...');
|
||||||
ab('close');
|
ab(['close']);
|
||||||
} else {
|
} else {
|
||||||
console.log('[wechat] Done. Browser window left open.');
|
console.log('[wechat] Done. Browser window left open.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,12 +40,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-post-to-weibo/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-post-to-weibo/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-post-to-weibo/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-post-to-weibo/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-post-to-weibo/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-post-to-weibo/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -44,12 +44,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-post-to-x/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-post-to-x/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-post-to-x/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-post-to-x/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-post-to-x/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-post-to-x/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -203,12 +203,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-slide-deck/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-slide-deck/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-slide-deck/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-slide-deck/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-slide-deck/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-slide-deck/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-slide-deck/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-slide-deck/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-slide-deck/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-slide-deck/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -30,12 +30,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-translate/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-translate/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-translate/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-translate/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-translate/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-translate/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-translate/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-translate/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-translate/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-translate/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -38,12 +38,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-url-to-markdown/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-url-to-markdown/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-url-to-markdown/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-url-to-markdown/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-url-to-markdown/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-url-to-markdown/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-url-to-markdown/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-url-to-markdown/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-url-to-markdown/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-url-to-markdown/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -278,12 +278,15 @@ Check EXTEND.md existence (priority order):
|
|||||||
```bash
|
```bash
|
||||||
# macOS, Linux, WSL, Git Bash
|
# macOS, Linux, WSL, Git Bash
|
||||||
test -f .baoyu-skills/baoyu-xhs-images/EXTEND.md && echo "project"
|
test -f .baoyu-skills/baoyu-xhs-images/EXTEND.md && echo "project"
|
||||||
|
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-xhs-images/EXTEND.md" && echo "xdg"
|
||||||
test -f "$HOME/.baoyu-skills/baoyu-xhs-images/EXTEND.md" && echo "user"
|
test -f "$HOME/.baoyu-skills/baoyu-xhs-images/EXTEND.md" && echo "user"
|
||||||
```
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# PowerShell (Windows)
|
# PowerShell (Windows)
|
||||||
if (Test-Path .baoyu-skills/baoyu-xhs-images/EXTEND.md) { "project" }
|
if (Test-Path .baoyu-skills/baoyu-xhs-images/EXTEND.md) { "project" }
|
||||||
|
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
|
||||||
|
if (Test-Path "$xdg/baoyu-skills/baoyu-xhs-images/EXTEND.md") { "xdg" }
|
||||||
if (Test-Path "$HOME/.baoyu-skills/baoyu-xhs-images/EXTEND.md") { "user" }
|
if (Test-Path "$HOME/.baoyu-skills/baoyu-xhs-images/EXTEND.md") { "user" }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user