Skip to content
CAI
Software that uses CAICheck a score

Eric-Guo/wechat

70.9

Strong · 19 September 2026

2.8k

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is a Ruby gem that provides comprehensive integration with the WeChat platform, supporting both public accounts and enterprise (WeChat Work) scenarios. It offers a structured API for user management, message handling, and menu operations, along with dedicated tools for managing access tokens and JSAPI tickets across various storage backends. The library includes Rails generators to scaffold configuration, sessions, and controllers, facilitating seamless integration into both standard and API-only Rails applications.

How it got here

2014 — Library modernization and enterprise support

10 changes.

The project underwent a major refactoring to rename the gem from wechat-rails to wechat, replacing the HTTP client with HTTPX and adopting Zeitwerk for code loading. This period introduced comprehensive support for WeChat Enterprise accounts, including new CLI tools, API architectures, and OAuth2 agentid handling, while removing legacy components and updating the test suite.

2015–2020 — WeChat integration and multi-account support

11 changes.

This period focused on expanding the library's capabilities for WeChat integration by introducing dedicated generators for configuration, sessions, and menu management. Significant architectural improvements included refactoring token and ticket storage to support pluggable backends like Redis and databases, enabling robust multi-account setups. The work also extended functionality to include Mini Program APIs and Tencent Cloud Base services.

Features

Added Redis-based storage for WeChat access tokens and JSAPI tickets

A new initializer template, \wechat\_redis\_store.rb\, is now provided to enable persistent storage of WeChat access tokens and JSAPI tickets in Redis. This change allows the application to share token and ticket state across multiple processes or instances, replacing in-memory storage with a durable backend that uses Redis keys prefixed by the specific app secret to differentiate between multiple WeChat accounts.

lib/generators/wechat/templates/config/initializers · high confidence

Added database migration templates for WeChat configuration and session storage

The generator now includes new migration templates to set up the required database schema for WeChat integration. The \config\_migration\ template creates a \wechat\_configs\ table to store account details (including environment, account type, credentials for public and corp accounts, and security settings like SSL verification) with a unique index on environment and account. The \session\_migration\ template creates a \wechat\_sessions\ table to track user sessions via unique OpenIDs.

lib/generators/wechat/templates/db · high confidence

Added new certificate for Eric Guo

A new X.509 certificate file (Eric-Guo.pem) has been added to the repository, containing a public key certificate for the identity 'eric.guoc' associated with the email '[e-mail redacted]'. This certificate is valid from May 22, 2026, to May 22, 2027, and is intended for use in signing or verification processes within the certs directory.

certs · high confidence

New API concerns for WeChat, Mini Program, and Tencent Cloud

Added three new concern modules to the Wechat library: \Common\ provides methods for user management, QR code generation, message sending, material management, and menu operations; \Draft\ adds CRUD operations for draft articles; and \Qcloud\ introduces support for Tencent Cloud Base (TCB) including cloud function invocation, database migration, collection management, and file storage operations.

lib/wechat/concern · high confidence

New WeChat configuration and session models for multi-account support

The generator now includes templates for \WechatConfig\ and \WechatSession\ models to support multi-WeChat-account setups within a single Rails application. \WechatConfig\ manages environment-specific credentials (including \account\_type\ for mini-programs vs public accounts) and enforces validation rules for app IDs, secrets, and encryption keys. \WechatSession\ handles user session persistence using a YAML-serialized \hash\_store\ and ensures the \updated\_at\ timestamp is refreshed on every save. These models replace previous inline logic, providing a structured way to store and retrieve WeChat configuration and session data.

lib/generators/wechat/templates/app/models · high confidence

New generators for WeChat configuration, sessions, and menu management

The library now provides dedicated Rails generators to scaffold WeChat integration components. The \config\ generator creates database migrations and models for storing WeChat configuration, while the \session\ generator adds support for managing WeChat sessions via database migrations and models. A new \menu\ generator allows users to create WeChat menus, including conditional menus via a \--conditional\ flag. Additionally, an \install\ generator copies the default WeChat configuration file, sets up the necessary routes, and generates a controller, and a \redis\_store\ generator configures Redis as an alternative token/ticket store by adding the \redis\ gem and an initializer.

lib/generators/wechat · high confidence

Release 1.2.0 with new getuserid API and OAuth2 agentid requirement

The gem has been updated to version 1.2.0. This release introduces a new \getuserid\ API for converting WeChat IDs to user IDs. It also includes a fix for the WeChat OAuth2 flow in enterprise (corp) accounts, which now requires the \agentid\ parameter to be configured.

(repo-wide) · high confidence

Removals

Removed WechatRails library components

The WechatRails library has been removed from the codebase. This change deletes the core implementation files including the HTTP client, API wrapper, access token management, message handler, and response builder, effectively eliminating the ability to interact with the WeChat API and process incoming WeChat messages within this module.

lib/wechat-rails · high confidence

Behavioural changes

Extracted WechatResponder to simplify controller integration

The WechatResponder module has been extracted into its own file (lib/action\_controller/wechat\_responder.rb) to provide a cleaner interface for integrating WeChat APIs into Rails controllers. This change introduces dedicated helper methods (wechat\_api, wechat\_responder, wechat) that handle the initialization of WeChat API clients, including support for multiple accounts, dynamic configuration loading, and network settings like proxy and SSL verification. Users can now more easily configure WeChat integration in their controllers with improved support for enterprise accounts and OAuth2 cookie duration settings.

_lib/action\controller · high confidence

Generated WeChat controller now inherits from ApplicationController for API-only Rails apps

The generated WechatsController template now conditionally inherits from ApplicationController when the application is defined as an API-only Rails app (checking for ActionController::API), while continuing to inherit from ActionController::Base for standard Rails applications. This ensures the generated controller is compatible with both standard and API-only Rails setups out of the box.

lib/generators/wechat/templates/app/controllers · high confidence

Introduce dedicated Qcloud token management and settings classes

Added new \Wechat::Qcloud::Setting\ and \Wechat::Qcloud::Token\ classes to centralize configuration and handle token lifecycle. The \Token\ class now manages fetching, caching, and refreshing Qcloud access tokens via file-based storage, automatically refreshing when the token is nearing expiration or if an \AccessTokenExpiredError\ occurs. This refactors the previous logic into a dedicated component that reduces parameter passing complexity and ensures robust token availability for API calls.

lib/wechat/qcloud · high confidence

Refactored JSAPI ticket management with pluggable storage and OAuth2 state support

The JSAPI ticket handling logic has been restructured to support pluggable storage backends (defaulting to file but allowing Redis or database integration) and to correctly manage OAuth2 state. Users will now benefit from more robust ticket refreshing that avoids invalid state issues, consistent state across threads/servers via the new store interface, and the ability to override read/write methods for custom persistence. The API surface remains compatible, but the internal implementation now separates base logic into JsapiBase with specific implementations for Corp and Public tickets.

lib/wechat/ticket · high confidence

Refactored token storage to support record-based and pluggable stores

The token management logic in lib/wechat/token has been refactored to introduce AccessTokenBase, which abstracts token persistence. This change allows tokens to be stored in database-backed records (via an optional 'record' parameter) instead of exclusively on the file system, and provides a structure for future pluggable stores like Redis. The specific implementations for CorpAccessToken and PublicAccessToken now inherit from this base, ensuring consistent behavior for reading, writing, and refreshing tokens across different WeChat API contexts.

lib/wechat/token · high confidence

Rewritten WeChat CLI with Enterprise Account Support

The \bin/wechat\ command-line interface has been completely rewritten to support both public and enterprise (WeChat Work) accounts. The new implementation uses the \Wechat::ApiLoader\ to dynamically switch between API clients based on configuration, enabling enterprise-specific commands for department and user management (create, delete, update, batch operations) alongside existing public account features. Configuration is now handled via a YAML file with support for multiple accounts, and the CLI provides structured output for listing departments and users.

bin · high confidence

Wechat library refactored with new API architecture and HTTP client

The Wechat library has been significantly refactored to improve maintainability and reliability. The HTTP communication layer now uses the HTTPX gem instead of the previous HTTP client, with a new HttpClient class handling requests, proxy settings, and SSL verification. The API structure has been reorganized into a base class (ApiBase) with specialized implementations for public accounts (Api, MpApi) and enterprise accounts (CorpApi), each managing their own access tokens and JSAPI tickets. Configuration loading has been centralized in a new ApiLoader module that supports multiple accounts, YAML files, environment variables, and database storage. A new Cipher module handles AES-256-CBC encryption/decryption for secure message handling. The responder system has been enhanced with better event matching using Hash instead of Array for click and batch\_job events, and improved scan event handling. Controller integration now uses a ControllerApi concern with OAuth2 support for both public and enterprise accounts.

lib/wechat · high confidence

Wechat library restructured with Zeitwerk and Rails integration

The Wechat library has been refactored to use Zeitwerk for automatic code loading, replacing the previous manual autoload and require structure. The main entry point is now lib/wechat.rb, which consolidates configuration and API access through an ApiLoader, and automatically includes the WechatResponder in both standard and API controllers when available. The old lib/wechat-rails.rb file has been removed, and the library now supports multiple WeChat accounts via a config method that accepts an account symbol.

lib · high confidence

Test coverage

Added comprehensive test coverage for Wechat API configuration, loading, and core components; Removal of WechatRails library test suite; Updated dummy Rails application for testing; Updated test suite configuration and added Zeitwerk eager-load verification.

Dependencies

WeChat gem dependencies updated and gem renamed

The \wechat-rails\ gem has been renamed to \wechat\ and its dependencies have been significantly updated. The runtime dependency on \rest-client\ has been replaced with \httpx\ (\>= 1.3.4), and \zeitwerk\ (\~\> 2.4) has been added. The minimum Ruby version is now 2.7, and the gem now depends on \activesupport\ (\>= 6.0, \< 9), \nokogiri\ (\>= 1.6.0), \ostruct\, \thor\, and \rexml\. Development dependencies have been bumped to \rails\ (\>= 7.2), \rspec-rails\ (\~\> 8.0), \rspec-mocks\ (\~\> 3.13), \sqlite3\ (\~\> 2.0), and \rubocop\ (\~\> 1.87.0). The \Gemfile\ has also been updated to use \simplecov\ for testing and added \tzinfo-data\ for Windows platforms.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 71.

Lenses

  • Code Health 93
  • Architecture 96
  • Maturity 65
  • Readiness 65
  • Security 81

Changes since last survey

  • 300 commits — 255 feature/other, 45 fixes

By area

  • (root) — 134 commits
  • lib/wechat — 83 commits
  • (repo) — 20 commits
  • spec/lib — 18 commits
  • bin/wechat — 11 commits
  • .semaphore/semaphore.yml — 8 commits
  • certs/Eric-Guo.pem — 7 commits
  • lib/generators — 6 commits
  • lib/wechat.rb — 6 commits
  • lib/action_controller — 4 commits
  • spec/dummy — 2 commits
  • spec/spec_helper.rb — 1 commit

Notable commits

  • fix: #275 Fix the wechat get_material API changed.
  • fix: Another rubocop -A fix.
  • fix: FIX: FrozenError: can't modify frozen String
  • fix: FIX: rubocop offense
  • fix: Fix #266, don't using '/' if possible.
  • fix: Fix #307
  • fix: Fix ActionController responder inclusion
  • fix: Fix CI.
  • fix: Fix CI.
  • fix: Fix DEPRECATION WARNING.
  • fix: Fix DEPRECATION WARNING: .represent_boolean_as_integer= is now always true, so setting this is deprecated and will be removed in Rails 6.1.
  • fix: Fix MpApi initialize bug. #296
  • fix: Fix This will be rejected in the future unless you explicitly pass the options check_default_type: false or call allow_incompatible_default_type! in your code You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
  • fix: Fix WARNING: Zeitwerk defines the constant ActionController after the directory
  • fix: Fix add merge #309
  • fix: Fix all warning in Ruby 2.7.1
  • fix: Fix break.
  • fix: Fix codeclimate
  • fix: Fix loading YML with more compatibility way.
  • fix: Fix missing CI
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

Eric-Guo/wechat was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit dd2d07aad51dabed8c224e8f8a7cbdb5127bbc21 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.