feat(channels): add channels enable wechat for one-command, no-portal setup#66
Merged
Conversation
…al setup Setting up a WeChat gateway required either the interactive `channels portal` or hand-editing channels.toml — and a missing/empty `instance_id` there is a common footgun (`config error: required field 'instance_id' is missing`). There was also no environment-variable path for base_url, so a pure-env deploy was impossible. Add `coding-bridge channels enable wechat`: it writes a valid, enabled [[channels.wechat]] block non-interactively from a --base-url flag or the new `WECHAT_BASE_URL` env var (with `WECHAT_INSTANCE_ID` / `WECHAT_TOKEN_ENV` optional overrides). It derives a stable instance_id from the gateway host, creates channels.toml at 0600 if missing, or merges by instance_id into an existing file without touching other channels. Idempotent; refuses to edit an already-invalid file. export WECHAT_BASE_URL=https://<id>.wisdom.acedata.cloud export WECHAT_TOKEN=<token> coding-bridge channels enable wechat # writes channels.toml, no editor coding-bridge channels doctor && coding-bridge channels start Tested live against a real *.wisdom.acedata.cloud gateway (doctor [OK]). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Germey
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Setting up a WeChat gateway required either the interactive
channels portalorhand-editing
channels.toml— and a missing/emptyinstance_idthere is acommon footgun (
config error: [[channels.wechat]] #0: required field 'instance_id' is missing or empty). There was also no env-var path forbase_url, so a pure-env deploy was impossible.Add
coding-bridge channels enable wechat— writes a valid, enabled[[channels.wechat]]block non-interactively:base_urlfrom--base-urlorWECHAT_BASE_URL;instance_idfrom--id/WECHAT_INSTANCE_ID/ derived from the gateway host;token_envfrom--token-env/WECHAT_TOKEN_ENV(defaultWECHAT_TOKEN).channels.tomlat0600if missing; otherwise merges byinstance_id, preserving every other channel and, on update of an existinginstance, preserving its other fields (allowed_senders/groups, rate limits,
approval, provider) — only
--senderoverrides the allowlist.base_urlup front (http/https, has host, rejectsuser:pass@host) so it never persists a URL the loader would later reject.Tests / evidence
tests/test_channels_cli.py::TestChannelsEnable— 11 cases: create-from-flag,env fallback, missing-url error, idempotent update, restriction-preservation on
re-run without --sender, non-http reject, embedded-credentials reject,
full-host id derivation, other-instance preservation, invalid-existing refusal,
0600 perms. Full
test_channels_cli.pygreen (34 passed); ruff clean.Live, against a real
*.wisdom.acedata.cloudgateway:🤖 对抗评审
Reviewer: Codex (round 1) → Claude general-purpose subagent (round 2,
after Codex hit a mid-review timeout — see memory
codex-exec-stdin-gotcha).Round 1 found 5 RISKs, all fixed with tests:
base_urlwritten before validation → now validated first (http/https, host,no embedded creds); rc=1 without writing.
dataclasses.replaceon the prior instance;--senderoptional._derive_instance_idcollapsed non-wisdom hosts to the first label(
foo.example.com==foo.other.com) → now full host, dots→dashes.exportbroke on Windows → PowerShell pair (paired PR).>= 2026.7.23(paired PR).Round 2 (re-review) verified all five and hunted for new defects (frozen-dataclass
replace, IPv6/empty-host edges, TOML injection via id/url): VERDICT: CLEAN.