Skip to content

Commit 8e59748

Browse files
wxkingstarclaude
andcommitted
feat: add --profile flag for running multiple WeChat accounts
Each profile gets its own data directory under ~/.clawrelay-weixin/<profile>/ with independent config.yaml and account.json. Backward compatible: default profile falls back to the legacy root directory if config exists. Usage: node dist/cli.js --profile work Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 999c3a1 commit 8e59748

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clawrelay-weixin-server",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "Chat with Claude in WeChat using your Claude Code subscription. No API key needed.",
55
"type": "module",
66
"bin": {

src/cli.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
import { existsSync } from "node:fs";
34
import { join } from "node:path";
45
import { homedir } from "node:os";
56
import chalk from "chalk";
@@ -8,12 +9,37 @@ import { login, loadAccount, type Account } from "./auth.js";
89
import { WeixinClient } from "./weixin.js";
910
import { Orchestrator } from "./orchestrator.js";
1011

11-
const DATA_DIR = join(homedir(), ".clawrelay-weixin");
12+
function parseProfile(): string {
13+
const args = process.argv.slice(2);
14+
for (let i = 0; i < args.length; i++) {
15+
if (args[i] === "--profile" && args[i + 1]) {
16+
return args[i + 1];
17+
}
18+
if (args[i]?.startsWith("--profile=")) {
19+
return args[i].slice("--profile=".length);
20+
}
21+
}
22+
return "default";
23+
}
24+
25+
function resolveDataDir(profile: string): string {
26+
const base = join(homedir(), ".clawrelay-weixin");
27+
if (profile === "default") {
28+
// Backward compat: if old root-level config exists, use it
29+
const legacyConfig = join(base, "config.yaml");
30+
if (existsSync(legacyConfig)) return base;
31+
}
32+
return join(base, profile);
33+
}
34+
35+
const profile = parseProfile();
36+
const DATA_DIR = resolveDataDir(profile);
1237
const CONFIG_PATH = join(DATA_DIR, "config.yaml");
1338
const ACCOUNT_PATH = join(DATA_DIR, "account.json");
1439

1540
async function main(): Promise<void> {
16-
console.log(chalk.bold("\n🚀 ClawRelay 微信服务器 v1.0.0\n"));
41+
const profileLabel = profile === "default" ? "" : chalk.cyan(` [${profile}]`);
42+
console.log(chalk.bold(`\n🚀 ClawRelay 微信服务器 v1.1.0${profileLabel}\n`));
1743

1844
// Step 1: Load or create config
1945
let config: Config | null = loadConfig(CONFIG_PATH);
@@ -33,6 +59,9 @@ async function main(): Promise<void> {
3359
if (config.model) {
3460
console.log(chalk.gray(` model: ${config.model}`));
3561
}
62+
if (profile !== "default") {
63+
console.log(chalk.gray(` profile: ${profile}`));
64+
}
3665

3766
// Step 2: Load or login
3867
let account: Account | null = loadAccount(ACCOUNT_PATH);

0 commit comments

Comments
 (0)