Skip to content

JimLiu/baoyu-skills / skills/baoyu-post-to-wechat

baoyu-post-to-wechat

Flagged

Posts content to WeChat Official Account (微信公众号) via API or Chrome CDP. Supports article posting (文章) with HTML, markdown, or plain text input, and image-text posting (贴图, formerly 图文) with multiple images. Markdown article workflows default to converting ordinary external links into bottom citations for WeChat-friendly output. Use when user mentions "发布公众号", "post to wechat", "微信公众号", or "贴图/图文/文章".

scripts/wechat-article-focus.test.ts

View on GitHub
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import test from "node:test";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const articleScript = fs.readFileSync(path.join(__dirname, "wechat-article.ts"), "utf8");

test("browser article paste uses CDP-targeted paste instead of global macOS keystrokes", () => {
  assert.equal(
    articleScript.includes('tell application "System Events" to keystroke "v" using command down'),
    false,
  );
});

test("browser article publishing verifies the title before saving drafts", () => {
  assert.match(articleScript, /verifyTitleUnchangedBeforeSave/);
  assert.match(articleScript, /Title was modified during paste/);
});

test("browser article body insertion does not paste HTML through the active form field", () => {
  assert.match(articleScript, /insertHtmlIntoEditorFromFile/);
  assert.doesNotMatch(articleScript, /await copyHtmlFromBrowser\(cdp, effectiveHtmlFile, contentImages\)/);
});

test("browser article body operations target the body ProseMirror, not the title ProseMirror", () => {
  assert.match(articleScript, /BODY_EDITOR_SELECTOR = '\.rich_media_content \.ProseMirror'/);
  assert.doesNotMatch(articleScript, /clickElement\(session, '\\.ProseMirror'\)/);
});

test("browser article reuses the selected account Chrome profile before launching", () => {
  assert.match(articleScript, /await findExistingChromeDebugPort\(profileDir\)/);
});

test("browser article inserts inline images through WeChat local upload instead of clipboard paste", () => {
  assert.match(articleScript, /uploadImageThroughFileInput/);
  assert.match(articleScript, /DOM\.setFileInputFiles/);
  assert.doesNotMatch(articleScript, /await copyImageToClipboard\(img\.localPath\)/);
});

test("browser article uploads original images before fallback processing", () => {
  const rawUploadIndex = articleScript.indexOf("await uploadImagePathThroughFileInput(session, absolutePath, beforeCount)");
  const fallbackIndex = articleScript.indexOf("const fallback = await prepareFallbackWechatBodyImageUpload(absolutePath)");

  assert.notEqual(rawUploadIndex, -1);
  assert.notEqual(fallbackIndex, -1);
  assert.ok(rawUploadIndex < fallbackIndex);
  assert.match(articleScript, /prepareWechatBodyImageUpload/);
  assert.match(articleScript, /Raw image upload failed, retrying with fallback processing/);
});

test("browser article waits for a saved draft appmsgid before reporting success", () => {
  assert.match(articleScript, /waitForDraftSaved/);
  assert.match(articleScript, /appmsgid/);
  assert.doesNotMatch(articleScript, /Waiting for save confirmation/);
});
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall