lewxclaw 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -408,10 +408,10 @@ var init_dist = __esm({
408
408
  });
409
409
 
410
410
  // src/index.ts
411
- import { Command as Command7 } from "commander";
412
- import chalk7 from "chalk";
413
- import { existsSync as existsSync8 } from "fs";
414
- import { join as join8 } from "path";
411
+ import { Command as Command8 } from "commander";
412
+ import chalk8 from "chalk";
413
+ import { existsSync as existsSync9 } from "fs";
414
+ import { join as join9 } from "path";
415
415
  import { homedir as homedir3 } from "os";
416
416
 
417
417
  // src/commands/create.ts
@@ -2529,7 +2529,7 @@ async function createRealLLMClient() {
2529
2529
  if (deepseek.isConfigured()) registry.register(deepseek);
2530
2530
  if (registry.list().length === 0) {
2531
2531
  console.error(chalk.red("\u6CA1\u6709\u53EF\u7528\u7684 LLM Provider\u3002\u8BF7\u5728 .wxclaw/config.json \u4E2D\u914D\u7F6E API Key\u3002"));
2532
- console.error(chalk.gray(' \u6216\u4F7F\u7528 --mock \u6A21\u5F0F\uFF1Awxclaw create --mock --topic "\u4E3B\u9898"'));
2532
+ console.error(chalk.gray(' \u6216\u4F7F\u7528 --mock \u6A21\u5F0F\uFF1Alewxclaw create --mock --topic "\u4E3B\u9898"'));
2533
2533
  process.exit(1);
2534
2534
  }
2535
2535
  return {
@@ -2734,7 +2734,7 @@ configCommand.command("get <key>").description("\u83B7\u53D6\u914D\u7F6E\u9879")
2734
2734
  configCommand.command("list").description("\u663E\u793A\u6240\u6709\u914D\u7F6E\uFF08API Key \u8131\u654F\uFF09").action(() => {
2735
2735
  const config = readConfig();
2736
2736
  if (Object.keys(config).length === 0) {
2737
- console.log(chalk2.yellow("\u6682\u65E0\u914D\u7F6E\u3002\u4F7F\u7528 wxclaw config set <key> <value> \u6765\u8BBE\u7F6E\u3002"));
2737
+ console.log(chalk2.yellow("\u6682\u65E0\u914D\u7F6E\u3002\u4F7F\u7528 lewxclaw config set <key> <value> \u6765\u8BBE\u7F6E\u3002"));
2738
2738
  return;
2739
2739
  }
2740
2740
  const masked = maskConfig(config);
@@ -2814,13 +2814,13 @@ topicsCommand.command("fetch").description("\u6293\u53D6\u6700\u65B0\u70ED\u70B9
2814
2814
  console.log(chalk3.green("\n\u5DF2\u7F13\u5B58\u5230 .wxclaw/topics-cache.json"));
2815
2815
  } catch {
2816
2816
  console.log(chalk3.yellow("scrapers \u5305\u5C1A\u672A\u53EF\u7528\uFF0C\u8BF7\u4F7F\u7528 --mock \u6A21\u5F0F\uFF1A"));
2817
- console.log(chalk3.gray(" wxclaw topics fetch --mock"));
2817
+ console.log(chalk3.gray(" lewxclaw topics fetch --mock"));
2818
2818
  }
2819
2819
  });
2820
2820
  topicsCommand.command("list").description("\u663E\u793A\u7F13\u5B58\u7684\u70ED\u70B9\u8BDD\u9898").action(() => {
2821
2821
  if (!existsSync4(CACHE_PATH)) {
2822
2822
  console.log(chalk3.yellow("\u6682\u65E0\u7F13\u5B58\u6570\u636E\u3002\u8BF7\u5148\u8FD0\u884C\uFF1A"));
2823
- console.log(chalk3.gray(" wxclaw topics fetch --mock"));
2823
+ console.log(chalk3.gray(" lewxclaw topics fetch --mock"));
2824
2824
  return;
2825
2825
  }
2826
2826
  const raw = JSON.parse(readFileSync5(CACHE_PATH, "utf-8"));
@@ -2862,7 +2862,7 @@ var cronCommand = new Command4("cron").description("\u5B9A\u65F6\u4EFB\u52A1\u7B
2862
2862
  cronCommand.command("list").description("\u663E\u793A\u6240\u6709\u5B9A\u65F6\u4EFB\u52A1").action(() => {
2863
2863
  const tasks = loadTasks();
2864
2864
  if (tasks.length === 0) {
2865
- console.log(chalk4.yellow("\u6682\u65E0\u5B9A\u65F6\u4EFB\u52A1\u3002\u4F7F\u7528 wxclaw cron add \u521B\u5EFA\u4EFB\u52A1\u3002"));
2865
+ console.log(chalk4.yellow("\u6682\u65E0\u5B9A\u65F6\u4EFB\u52A1\u3002\u4F7F\u7528 lewxclaw cron add \u521B\u5EFA\u4EFB\u52A1\u3002"));
2866
2866
  return;
2867
2867
  }
2868
2868
  console.log(
@@ -3064,7 +3064,7 @@ styleCommand.command("learn").description("\u4ECE\u8303\u6587\u5B66\u4E60\u98CE\
3064
3064
  llm = createLLMClient();
3065
3065
  } catch {
3066
3066
  console.log(chalk5.red("providers \u5305\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4F7F\u7528 --mock \u6A21\u5F0F\uFF1A"));
3067
- console.log(chalk5.gray(` wxclaw style learn --file ${options.file} --name "${options.name}" --mock`));
3067
+ console.log(chalk5.gray(` lewxclaw style learn --file ${options.file} --name "${options.name}" --mock`));
3068
3068
  process.exit(1);
3069
3069
  }
3070
3070
  }
@@ -3157,8 +3157,8 @@ var setupCommand = new Command6("setup").description("\u4EA4\u4E92\u5F0F\u914D\u
3157
3157
  }
3158
3158
  console.log("");
3159
3159
  if (!minimaxKey && !deepseekKey && !openaiKey) {
3160
- console.log(chalk6.yellow(" \u26A0 \u672A\u914D\u7F6E\u4EFB\u4F55 LLM Provider\u3002\u4F60\u53EF\u4EE5\u4E4B\u540E\u901A\u8FC7 wxclaw config set \u6DFB\u52A0\u3002"));
3161
- console.log(chalk6.gray(" \u793A\u4F8B\uFF1Awxclaw config set providers.minimax.apiKey sk-xxx"));
3160
+ console.log(chalk6.yellow(" \u26A0 \u672A\u914D\u7F6E\u4EFB\u4F55 LLM Provider\u3002\u4F60\u53EF\u4EE5\u4E4B\u540E\u901A\u8FC7 lewxclaw config set \u6DFB\u52A0\u3002"));
3161
+ console.log(chalk6.gray(" \u793A\u4F8B\uFF1Alewxclaw config set providers.minimax.apiKey sk-xxx"));
3162
3162
  }
3163
3163
  console.log("");
3164
3164
  console.log(chalk6.yellow("\u{1F4F1} Step 2/4: \u5FAE\u4FE1\u516C\u4F17\u53F7\u914D\u7F6E"));
@@ -3251,16 +3251,88 @@ var setupCommand = new Command6("setup").description("\u4EA4\u4E92\u5F0F\u914D\u
3251
3251
  console.log(" \u98CE\u683C\u76EE\u5F55\uFF1A" + chalk6.gray(soulDir));
3252
3252
  console.log("");
3253
3253
  console.log(" \u5FEB\u901F\u5F00\u59CB\uFF1A");
3254
- console.log(chalk6.cyan(' wxclaw create --topic "\u4F60\u611F\u5174\u8DA3\u7684\u4E3B\u9898"'));
3254
+ console.log(chalk6.cyan(' lewxclaw create --topic "\u4F60\u611F\u5174\u8DA3\u7684\u4E3B\u9898"'));
3255
3255
  console.log("");
3256
3256
  console.log(" \u66F4\u591A\u547D\u4EE4\uFF1A");
3257
- console.log(chalk6.gray(" wxclaw --help"));
3257
+ console.log(chalk6.gray(" lewxclaw --help"));
3258
3258
  console.log("");
3259
3259
  rl.close();
3260
3260
  });
3261
3261
 
3262
+ // src/commands/web.ts
3263
+ import { Command as Command7 } from "commander";
3264
+ import chalk7 from "chalk";
3265
+ import { existsSync as existsSync8 } from "fs";
3266
+ import { join as join8 } from "path";
3267
+ import { spawn } from "child_process";
3268
+ var webCommand = new Command7("web").description("\u542F\u52A8 Web \u7BA1\u7406\u540E\u53F0").option("-p, --port <port>", "\u7AEF\u53E3\u53F7", "3000").option("--no-open", "\u4E0D\u81EA\u52A8\u6253\u5F00\u6D4F\u89C8\u5668").action(async (options) => {
3269
+ const port = options.port;
3270
+ const webDir = findWebPackage();
3271
+ if (!webDir) {
3272
+ console.log(chalk7.yellow("\u672A\u627E\u5230 Web \u7BA1\u7406\u540E\u53F0\u3002"));
3273
+ console.log("");
3274
+ console.log("\u4E24\u79CD\u65B9\u5F0F\u4F7F\u7528 Web \u7BA1\u7406\u540E\u53F0\uFF1A");
3275
+ console.log("");
3276
+ console.log(chalk7.white("\u65B9\u5F0F 1\uFF1A\u4ECE\u6E90\u7801\u8FD0\u884C\uFF08\u5F00\u53D1\u6A21\u5F0F\uFF09"));
3277
+ console.log(chalk7.gray(" git clone https://github.com/your-username/lewxclaw.git"));
3278
+ console.log(chalk7.gray(" cd lewxclaw && pnpm install"));
3279
+ console.log(chalk7.gray(" lewxclaw web"));
3280
+ console.log("");
3281
+ console.log(chalk7.white("\u65B9\u5F0F 2\uFF1ADocker \u90E8\u7F72"));
3282
+ console.log(chalk7.gray(" docker compose up"));
3283
+ console.log("");
3284
+ return;
3285
+ }
3286
+ console.log(chalk7.cyan("\u{1F99E} WxClaw Web \u7BA1\u7406\u540E\u53F0"));
3287
+ console.log(chalk7.gray("\u2501".repeat(50)));
3288
+ console.log(` \u5730\u5740\uFF1A${chalk7.green(`http://localhost:${port}`)}`);
3289
+ console.log(` \u76EE\u5F55\uFF1A${chalk7.gray(webDir)}`);
3290
+ console.log(chalk7.gray("\u2501".repeat(50)));
3291
+ console.log("");
3292
+ console.log(chalk7.gray("\u6309 Ctrl+C \u505C\u6B62\u670D\u52A1"));
3293
+ console.log("");
3294
+ const child = spawn("npx", ["next", "dev", "--port", port], {
3295
+ cwd: webDir,
3296
+ stdio: "inherit",
3297
+ shell: true
3298
+ });
3299
+ if (options.open !== false) {
3300
+ setTimeout(() => {
3301
+ const url = `http://localhost:${port}`;
3302
+ const openCmd = process.platform === "win32" ? "start" : process.platform === "darwin" ? "open" : "xdg-open";
3303
+ spawn(openCmd, [url], { shell: true, stdio: "ignore" });
3304
+ }, 3e3);
3305
+ }
3306
+ child.on("error", (err) => {
3307
+ console.error(chalk7.red(`\u542F\u52A8\u5931\u8D25\uFF1A${err.message}`));
3308
+ process.exit(1);
3309
+ });
3310
+ child.on("exit", (code) => {
3311
+ process.exit(code ?? 0);
3312
+ });
3313
+ process.on("SIGINT", () => {
3314
+ child.kill("SIGINT");
3315
+ });
3316
+ });
3317
+ function findWebPackage() {
3318
+ const candidates = [
3319
+ join8(process.cwd(), "packages", "web"),
3320
+ join8(process.cwd(), "..", "packages", "web"),
3321
+ join8(process.cwd(), "..", "..", "packages", "web")
3322
+ ];
3323
+ const scriptDir = new URL(".", import.meta.url).pathname.replace(/^\/([A-Z]:)/, "$1");
3324
+ const monorepoWeb = join8(scriptDir, "..", "..", "..", "web");
3325
+ candidates.push(monorepoWeb);
3326
+ for (const dir of candidates) {
3327
+ if (existsSync8(join8(dir, "package.json")) && existsSync8(join8(dir, "src"))) {
3328
+ return dir;
3329
+ }
3330
+ }
3331
+ return null;
3332
+ }
3333
+
3262
3334
  // src/index.ts
3263
- var program = new Command7();
3335
+ var program = new Command8();
3264
3336
  program.name("lewxclaw").description("WxClaw \u2014 \u516C\u4F17\u53F7\u521B\u4F5C Agent").version("0.1.0");
3265
3337
  program.addCommand(setupCommand);
3266
3338
  program.addCommand(createCommand);
@@ -3268,14 +3340,15 @@ program.addCommand(configCommand);
3268
3340
  program.addCommand(topicsCommand);
3269
3341
  program.addCommand(cronCommand);
3270
3342
  program.addCommand(styleCommand);
3271
- var configPath = join8(homedir3(), ".lewxclaw", "config.json");
3343
+ program.addCommand(webCommand);
3344
+ var configPath = join9(homedir3(), ".lewxclaw", "config.json");
3272
3345
  var args = process.argv.slice(2);
3273
3346
  var isSetup = args[0] === "setup";
3274
3347
  var isHelp = args.includes("--help") || args.includes("-h");
3275
3348
  var isVersion = args.includes("--version") || args.includes("-V");
3276
- if (!existsSync8(configPath) && !isSetup && !isHelp && !isVersion && args.length > 0) {
3277
- console.log(chalk7.yellow("\u{1F99E} \u9996\u6B21\u4F7F\u7528 WxClaw\uFF1F\u8FD0\u884C lewxclaw setup \u6765\u914D\u7F6E\u4F60\u7684 Agent\u3002"));
3278
- console.log(chalk7.gray(' \u6216\u4F7F\u7528 --mock \u6A21\u5F0F\u514D\u914D\u7F6E\u4F53\u9A8C\uFF1Alewxclaw create --mock --topic "AI \u8D8B\u52BF"'));
3349
+ if (!existsSync9(configPath) && !isSetup && !isHelp && !isVersion && args.length > 0) {
3350
+ console.log(chalk8.yellow("\u{1F99E} \u9996\u6B21\u4F7F\u7528 WxClaw\uFF1F\u8FD0\u884C lewxclaw setup \u6765\u914D\u7F6E\u4F60\u7684 Agent\u3002"));
3351
+ console.log(chalk8.gray(' \u6216\u4F7F\u7528 --mock \u6A21\u5F0F\u514D\u914D\u7F6E\u4F53\u9A8C\uFF1Alewxclaw create --mock --topic "AI \u8D8B\u52BF"'));
3279
3352
  console.log("");
3280
3353
  }
3281
3354
  program.parse();