Skip to content

Sync the getting-started toolchain with Wechaty 2 - #328

Merged
huan merged 5 commits into
mainfrom
cursor/wechaty-2-toolchain-d406
Nov 23, 2026
Merged

huan merged 5 commits into
mainfrom
cursor/wechaty-2-toolchain-d406

Conversation

@huan

@huan huan commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

I'm submitting a...

[ ] Bug Fix
[x] Feature
[ ] Other (Refactoring, Added tests, Documentation, ...)

Checklist

  • Commit Messages follow the Conventional Commits pattern
    • A feature commit message is prefixed "feat:"
    • A bugfix commit message is prefixed "fix:"
  • Tests for the changes have been added

Description

Bring this repository onto the Wechaty 2 toolchain. The bot examples stay on wechaty ^1.20.2.

  • Replace @chatie/tsconfig with a local TypeScript 7 config (NodeNext, type stripping, erasableSyntaxOnly). npm run lint:ts is the typecheck.
  • Replace ESLint with Biome. npm run lint is Biome, then the typecheck.
  • Run every example as TypeScript. Node 26 executes the .ts files directly, with no ts-node loader. Entry points and the smoke tests have a #!/usr/bin/env node shebang.
  • Move the smoke tests to node:test (tests/*.test.ts). npm test lints, then runs them with --test-force-exit.
  • Add an experimental Deno 2.9.8 job. It does not fail the workflow.
  • Replace .devcontainer/ with the Wechaty devcontainer (Ubuntu 24.04, Node 26, Deno). Codespaces still opens examples/ding-dong-bot.ts.
  • Require Node.js 26 and npm 10. CI stays on macOS, Windows, and Ubuntu, weekly, and installs with npm install.
  • Keep package-lock.json gitignored on purpose. DEVELOPMENT.md records why: a lockfile would hide a broken range until a new user installed the repo.
  • Remove the fingerpose, codesandbox, chatgpt-bot, hot-import-bot, and monster-bot examples.
  • examples/third-parties/maodou and xiaoli stay, now as ESM TypeScript with their own package.json. Root tsc does not include them.

Does this PR introduce a breaking change?

[x] Yes
[ ] No

npm start and the examples now require Node.js 26. ts-node and the JavaScript entry points are gone. The removed example directories are no longer in the tree.

Open in Web Open in Cursor 

fix #327

Node 26 runs the TypeScript examples directly. Biome and a local TypeScript 7
config replace the Chatie ESLint and tsconfig packages, and the smoke tests
use node:test. The fingerpose, codesandbox, chatgpt, hot-import, and monster
examples are removed.

Co-authored-by: Huan Li <huan@chatie.io>
@cursor

cursor Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Breaking runtime and dependency requirements (Node 26, Wechaty 2 prerelease) affect every contributor and beginner install path; example API churn may confuse users on older tutorials.

Reviewed by Cursor Bugbot for commit 8c9f2d2. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T08:37:36.108598Z e737931 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 987a13a260

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/advanced/room-bot.ts Outdated

function errorDetail (e: unknown): string {
if (e instanceof Error) {
return errorDetail(e) ?? e.message

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return the error details instead of recursing on the same error

Whenever a room operation throws an Error, this helper calls itself with the identical argument indefinitely and throws RangeError: Maximum call stack size exceeded; the e.message fallback is never reached. Multiple catch handlers now use this helper, so failures in room lookup, membership changes, or topic updates produce another exception instead of logging the original failure. Return e.stack ?? e.message rather than calling errorDetail(e) again.

Useful? React with 👍 / 👎.

Comment thread package.json Outdated
"test": "npm-run-all lint test:smoke",
"test:smoke": "cross-env NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" tap --timeout=150 \"tests/**/*.spec.ts\""
"test": "npm run lint && npm run test:smoke",
"test:smoke": "node --test --test-force-exit --test-timeout=180000 tests",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pass a test-file glob instead of the tests directory

The trailing tests argument is treated as a test entry point rather than recursively discovering the directory's test files. Running npm run test:smoke locally on Node 24.15.0 fails with Cannot find module '/workspace/getting-started/tests' before executing any smoke tests. The target Node 26 documentation specifies that “one or more glob patterns can be provided as the final argument(s).” Use an explicitly quoted tests/*.test.ts glob, or omit the positional argument to use automatic discovery; otherwise npm test and the Node CI job cannot run the migrated suite.

Useful? React with 👍 / 👎.

Comment thread examples/advanced/busy-bot.ts Outdated
log.info('Bot', '(message) %s', msg)

const filehelper = bot.Contact.load('filehelper')
const filehelper = impls.ContactImpl.load('filehelper')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve contacts through the bot-bound Contact class

On every incoming message, this now calls load() on the unbound implementation class rather than the bot's Contact class. load() constructs a contact, and Wechaty's wechatify constructor guard rejects implementation classes that have not been bound to a bot, so the handler throws before processing any busy-mode commands or automatic replies. The same replacement also breaks friendship handling in examples/advanced/friend-bot.ts and the fcontact command in examples/advanced/self-testing-bot.ts. Use await bot.Contact.find({ id: 'filehelper' }) with an appropriate missing-contact check, and resolve the forwarding contact through its bot as well.

Useful? React with 👍 / 👎.

cursoragent and others added 2 commits November 23, 2026 08:32
ContactImpl.load() builds an unbound contact, which Wechaty rejects. The
busy, friend, and self-testing examples now use bot.Contact.find(). The
room-bot error helper returned another call to itself, so a caught Error
never reached its stack or message.

Co-authored-by: Huan Li <huan@chatie.io>
…echaty-2-toolchain-d406

# Conflicts:
#	.github/workflows/node.js.yml
#	README.md
#	examples/basic/ding-dong-bot.ts
#	examples/third-parties/maodou/maodou-classes-bot.ts
#	examples/third-parties/maodou/maodou-course-api.ts
#	examples/third-parties/maodou/maodou-nlp.ts
#	examples/third-parties/maodou/package.json
#	examples/third-parties/xiaoli/package.json
#	examples/third-parties/xiaoli/xiaoli-news-bot.ts
#	examples/tutorials/google-cloud-shell-tutorial.md
#	package.json
#	tests/wechaty-puppet-service.test.ts
#	tests/wechaty-puppet-wechat.test.ts
#	tsconfig.json

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e737931. Configure here.

Comment thread tests/wechaty-puppet-neo.test.ts Resolved
Comment thread examples/advanced/friend-bot.ts Resolved
Comment thread tsconfig.json Resolved
@huan

huan commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

@cursor read review comments and ship fixes

@cursor

cursor Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The review comments are fixed on #328.

  • errorDetail() now returns e.stack ?? e.message instead of calling itself.
  • Busy, friend, and self-testing bots load contacts with bot.Contact.find(). A missing filehelper only skips those replies, so friend requests and busy replies still run.
  • The Neo smoke test treats a login rejection after the QR code as a finished test, so CI does not fail when nobody scans it.
  • npm run lint:ts typechecks the nested examples again. The CQRS example stays out of that check because wechaty-cqrs is not part of the Wechaty 2 install.
  • npm run test:smoke now passes the quoted glob tests/*.test.ts, so the Node test runner expands the files itself. The mock and Neo smoke tests both passed with that glob.

I’m waiting on CI for this commit.

View PR

Open in Web Open in Cursor 

cursoragent and others added 2 commits November 23, 2026 08:43
Ignore a Neo login rejection after the QR code is shown, so node:test does
not fail CI when nobody scans. Filehelper lookups no longer skip the rest of
the busy and friend handlers. Typecheck covers the nested examples, and the
Deno job can load the Puppet Neo addon.

Co-authored-by: Huan Li <huan@chatie.io>
Node's test runner treats a directory argument as one entry point on some
releases. Quote tests/*.test.ts so the runner expands the smoke tests itself.

Co-authored-by: Huan Li <huan@chatie.io>
@huan
huan merged commit 6395eb2 into main Nov 23, 2026
6 checks passed
@huan
huan deleted the cursor/wechaty-2-toolchain-d406 branch November 23, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update tool chain to modern Wechaty 2.0

3 participants