lewxclaw 0.1.1 → 0.1.3
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 +116 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
412
|
-
import
|
|
413
|
-
import { existsSync as
|
|
414
|
-
import { join as
|
|
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
|
|
@@ -2528,8 +2528,8 @@ async function createRealLLMClient() {
|
|
|
2528
2528
|
if (minimax.isConfigured()) registry.register(minimax);
|
|
2529
2529
|
if (deepseek.isConfigured()) registry.register(deepseek);
|
|
2530
2530
|
if (registry.list().length === 0) {
|
|
2531
|
-
console.error(chalk.red("\u6CA1\u6709\u53EF\u7528\u7684 LLM Provider\u3002\u8BF7\u5728 .
|
|
2532
|
-
console.error(chalk.gray(' \u6216\u4F7F\u7528 --mock \u6A21\u5F0F\
|
|
2531
|
+
console.error(chalk.red("\u6CA1\u6709\u53EF\u7528\u7684 LLM Provider\u3002\u8BF7\u5728 .lewxclaw/config.json \u4E2D\u914D\u7F6E API Key\u3002"));
|
|
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 {
|
|
@@ -2573,7 +2573,7 @@ function withSpinner(step, label, successLabel) {
|
|
|
2573
2573
|
};
|
|
2574
2574
|
}
|
|
2575
2575
|
var createCommand = new Command("create").description("\u521B\u5EFA\u516C\u4F17\u53F7\u6587\u7AE0").requiredOption("--topic <topic>", "\u6587\u7AE0\u4E3B\u9898").option("--style <style>", "\u5199\u4F5C\u98CE\u683C", "tech").option("--mock", "\u4F7F\u7528 Mock LLM\uFF08\u4E0D\u9700\u8981 API Key\uFF09").action(async (options) => {
|
|
2576
|
-
console.log(chalk.cyan("
|
|
2576
|
+
console.log(chalk.cyan("LeWxClaw \u6587\u7AE0\u521B\u4F5C"));
|
|
2577
2577
|
console.log(chalk.gray("\u2501".repeat(50)));
|
|
2578
2578
|
console.log(`\u4E3B\u9898\uFF1A${chalk.bold(options.topic)}`);
|
|
2579
2579
|
console.log(`\u98CE\u683C\uFF1A${chalk.bold(options.style)}`);
|
|
@@ -2661,7 +2661,7 @@ import { Command as Command2 } from "commander";
|
|
|
2661
2661
|
import chalk2 from "chalk";
|
|
2662
2662
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, existsSync as existsSync3, mkdirSync as mkdirSync2 } from "fs";
|
|
2663
2663
|
import { join as join4, dirname } from "path";
|
|
2664
|
-
var CONFIG_PATH = join4(process.cwd(), ".
|
|
2664
|
+
var CONFIG_PATH = join4(process.cwd(), ".lewxclaw", "config.json");
|
|
2665
2665
|
function readConfig() {
|
|
2666
2666
|
if (!existsSync3(CONFIG_PATH)) return {};
|
|
2667
2667
|
return JSON.parse(readFileSync4(CONFIG_PATH, "utf-8"));
|
|
@@ -2709,7 +2709,7 @@ function maskConfig(obj) {
|
|
|
2709
2709
|
}
|
|
2710
2710
|
return result;
|
|
2711
2711
|
}
|
|
2712
|
-
var configCommand = new Command2("config").description("\u7BA1\u7406
|
|
2712
|
+
var configCommand = new Command2("config").description("\u7BA1\u7406 LeWxClaw \u914D\u7F6E");
|
|
2713
2713
|
configCommand.command("set <key> <value>").description("\u8BBE\u7F6E\u914D\u7F6E\u9879\uFF08\u5982 providers.minimax.apiKey\uFF09").action((key, value) => {
|
|
2714
2714
|
if (value.trim() === "") {
|
|
2715
2715
|
console.error(chalk2.red("\u9519\u8BEF\uFF1Avalue \u4E0D\u80FD\u4E3A\u7A7A"));
|
|
@@ -2734,11 +2734,11 @@ 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
|
|
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);
|
|
2741
|
-
console.log(chalk2.cyan("
|
|
2741
|
+
console.log(chalk2.cyan("LeWxClaw \u914D\u7F6E\uFF08.lewxclaw/config.json\uFF09\uFF1A"));
|
|
2742
2742
|
console.log(chalk2.gray("\u2500".repeat(50)));
|
|
2743
2743
|
console.log(JSON.stringify(masked, null, 2));
|
|
2744
2744
|
});
|
|
@@ -2748,7 +2748,7 @@ import { Command as Command3 } from "commander";
|
|
|
2748
2748
|
import chalk3 from "chalk";
|
|
2749
2749
|
import { readFileSync as readFileSync5, writeFileSync as writeFileSync3, existsSync as existsSync4, mkdirSync as mkdirSync3 } from "fs";
|
|
2750
2750
|
import { join as join5 } from "path";
|
|
2751
|
-
var CACHE_PATH = join5(process.cwd(), ".
|
|
2751
|
+
var CACHE_PATH = join5(process.cwd(), ".lewxclaw", "topics-cache.json");
|
|
2752
2752
|
var MOCK_TOPICS = [
|
|
2753
2753
|
{ title: "AI Agent 2026\u8D8B\u52BF", heat: 95, source: "weibo" },
|
|
2754
2754
|
{ title: "GPT-5.4 \u53D1\u5E03", heat: 88, source: "zhihu" },
|
|
@@ -2782,7 +2782,7 @@ function printTopics(topics) {
|
|
|
2782
2782
|
console.log(chalk3.gray(`\u5171 ${topics.length} \u6761\u70ED\u70B9`));
|
|
2783
2783
|
}
|
|
2784
2784
|
function saveCache(topics) {
|
|
2785
|
-
const dir = join5(process.cwd(), ".
|
|
2785
|
+
const dir = join5(process.cwd(), ".lewxclaw");
|
|
2786
2786
|
if (!existsSync4(dir)) mkdirSync3(dir, { recursive: true });
|
|
2787
2787
|
writeFileSync3(CACHE_PATH, JSON.stringify({ fetchedAt: (/* @__PURE__ */ new Date()).toISOString(), topics }, null, 2), "utf-8");
|
|
2788
2788
|
}
|
|
@@ -2800,7 +2800,7 @@ topicsCommand.command("fetch").description("\u6293\u53D6\u6700\u65B0\u70ED\u70B9
|
|
|
2800
2800
|
console.log(chalk3.cyan(`\u6B63\u5728\u83B7\u53D6\u70ED\u70B9\uFF08Mock \u6A21\u5F0F${options.source ? ` - ${options.source}` : ""}\uFF09...`));
|
|
2801
2801
|
saveCache(topics);
|
|
2802
2802
|
printTopics(topics);
|
|
2803
|
-
console.log(chalk3.green("\n\u5DF2\u7F13\u5B58\u5230 .
|
|
2803
|
+
console.log(chalk3.green("\n\u5DF2\u7F13\u5B58\u5230 .lewxclaw/topics-cache.json"));
|
|
2804
2804
|
return;
|
|
2805
2805
|
}
|
|
2806
2806
|
try {
|
|
@@ -2811,16 +2811,16 @@ topicsCommand.command("fetch").description("\u6293\u53D6\u6700\u65B0\u70ED\u70B9
|
|
|
2811
2811
|
const topics = aggregator.aggregate(raw);
|
|
2812
2812
|
saveCache(topics);
|
|
2813
2813
|
printTopics(topics);
|
|
2814
|
-
console.log(chalk3.green("\n\u5DF2\u7F13\u5B58\u5230 .
|
|
2814
|
+
console.log(chalk3.green("\n\u5DF2\u7F13\u5B58\u5230 .lewxclaw/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("
|
|
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("
|
|
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"));
|
|
@@ -2833,7 +2833,7 @@ import { Command as Command4 } from "commander";
|
|
|
2833
2833
|
import chalk4 from "chalk";
|
|
2834
2834
|
import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, existsSync as existsSync5, mkdirSync as mkdirSync4 } from "fs";
|
|
2835
2835
|
import { join as join6 } from "path";
|
|
2836
|
-
var TASKS_PATH = join6(process.cwd(), ".
|
|
2836
|
+
var TASKS_PATH = join6(process.cwd(), ".lewxclaw", "scheduler-tasks.json");
|
|
2837
2837
|
function loadTasks() {
|
|
2838
2838
|
if (!existsSync5(TASKS_PATH)) {
|
|
2839
2839
|
return [];
|
|
@@ -2846,7 +2846,7 @@ function loadTasks() {
|
|
|
2846
2846
|
}
|
|
2847
2847
|
}
|
|
2848
2848
|
function saveTasks(tasks) {
|
|
2849
|
-
const dir = join6(process.cwd(), ".
|
|
2849
|
+
const dir = join6(process.cwd(), ".lewxclaw");
|
|
2850
2850
|
if (!existsSync5(dir)) {
|
|
2851
2851
|
mkdirSync4(dir, { recursive: true });
|
|
2852
2852
|
}
|
|
@@ -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
|
|
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(
|
|
@@ -3018,7 +3018,7 @@ styleCommand.command("list").description("\u663E\u793A\u6240\u6709\u98CE\u683C")
|
|
|
3018
3018
|
);
|
|
3019
3019
|
console.log(chalk5.gray("\u2500".repeat(40)));
|
|
3020
3020
|
if (styles.length === 0) {
|
|
3021
|
-
console.log(chalk5.yellow("\u6682\u65E0\u98CE\u683C\u6587\u4EF6\u3002\u8BF7\u68C0\u67E5 .
|
|
3021
|
+
console.log(chalk5.yellow("\u6682\u65E0\u98CE\u683C\u6587\u4EF6\u3002\u8BF7\u68C0\u67E5 .lewxclaw/styles/ \u76EE\u5F55\u3002"));
|
|
3022
3022
|
return;
|
|
3023
3023
|
}
|
|
3024
3024
|
for (const s of styles) {
|
|
@@ -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(`
|
|
3067
|
+
console.log(chalk5.gray(` lewxclaw style learn --file ${options.file} --name "${options.name}" --mock`));
|
|
3068
3068
|
process.exit(1);
|
|
3069
3069
|
}
|
|
3070
3070
|
}
|
|
@@ -3091,15 +3091,15 @@ import { homedir as homedir2 } from "os";
|
|
|
3091
3091
|
import { createInterface } from "readline";
|
|
3092
3092
|
var setupCommand = new Command6("setup").description("\u4EA4\u4E92\u5F0F\u914D\u7F6E\u5411\u5BFC").action(async () => {
|
|
3093
3093
|
console.log("");
|
|
3094
|
-
console.log(chalk6.cyan("\u{1F99E}
|
|
3094
|
+
console.log(chalk6.cyan("\u{1F99E} LeWxClaw \u914D\u7F6E\u5411\u5BFC"));
|
|
3095
3095
|
console.log(chalk6.gray("\u2501".repeat(50)));
|
|
3096
3096
|
console.log("");
|
|
3097
|
-
console.log("\u6B22\u8FCE\u4F7F\u7528
|
|
3097
|
+
console.log("\u6B22\u8FCE\u4F7F\u7528 LeWxClaw\uFF01\u8BA9\u6211\u4EEC\u914D\u7F6E\u4F60\u7684\u516C\u4F17\u53F7\u521B\u4F5C Agent\u3002");
|
|
3098
3098
|
console.log("");
|
|
3099
|
-
const
|
|
3100
|
-
const configPath2 = join7(
|
|
3101
|
-
if (!existsSync7(
|
|
3102
|
-
mkdirSync5(
|
|
3099
|
+
const lewxclawDir = join7(homedir2(), ".lewxclaw");
|
|
3100
|
+
const configPath2 = join7(lewxclawDir, "config.json");
|
|
3101
|
+
if (!existsSync7(lewxclawDir)) {
|
|
3102
|
+
mkdirSync5(lewxclawDir, { recursive: true });
|
|
3103
3103
|
}
|
|
3104
3104
|
let config = {};
|
|
3105
3105
|
if (existsSync7(configPath2)) {
|
|
@@ -3124,7 +3124,7 @@ var setupCommand = new Command6("setup").description("\u4EA4\u4E92\u5F0F\u914D\u
|
|
|
3124
3124
|
});
|
|
3125
3125
|
};
|
|
3126
3126
|
console.log(chalk6.yellow("\u{1F4E6} Step 1/4: LLM Provider \u914D\u7F6E"));
|
|
3127
|
-
console.log(chalk6.gray("
|
|
3127
|
+
console.log(chalk6.gray(" LeWxClaw \u9700\u8981\u81F3\u5C11\u4E00\u4E2A LLM API Key \u6765\u751F\u6210\u5185\u5BB9\u3002"));
|
|
3128
3128
|
console.log("");
|
|
3129
3129
|
console.log(chalk6.white(" MiniMax\uFF08\u9ED8\u8BA4 Provider\uFF0C\u63A8\u8350\uFF09"));
|
|
3130
3130
|
const minimaxKey = await ask(" MiniMax API Key\uFF08\u7559\u7A7A\u8DF3\u8FC7\uFF09");
|
|
@@ -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
|
|
3161
|
-
console.log(chalk6.gray(" \u793A\u4F8B\
|
|
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"));
|
|
@@ -3179,7 +3179,7 @@ var setupCommand = new Command6("setup").description("\u4EA4\u4E92\u5F0F\u914D\u
|
|
|
3179
3179
|
console.log(chalk6.gray(" \u4F60\u7684\u516C\u4F17\u53F7\u5B9A\u4F4D\u662F\u4EC0\u4E48\uFF1F\u8FD9\u4F1A\u5F71\u54CD AI \u7684\u5199\u4F5C\u98CE\u683C\u3002"));
|
|
3180
3180
|
console.log("");
|
|
3181
3181
|
const positioning = await ask(" \u516C\u4F17\u53F7\u5B9A\u4F4D\uFF08\u5982\uFF1A\u79D1\u6280\u8BC4\u8BBA\u3001\u804C\u573A\u6210\u957F\uFF09", "\u79D1\u6280\u8BC4\u8BBA");
|
|
3182
|
-
const soulDir = join7(
|
|
3182
|
+
const soulDir = join7(lewxclawDir, "styles");
|
|
3183
3183
|
if (!existsSync7(soulDir)) {
|
|
3184
3184
|
mkdirSync5(soulDir, { recursive: true });
|
|
3185
3185
|
}
|
|
@@ -3203,7 +3203,7 @@ var setupCommand = new Command6("setup").description("\u4EA4\u4E92\u5F0F\u914D\u
|
|
|
3203
3203
|
- \u4E0D\u5806\u780C\u7F51\u7EDC\u6D41\u884C\u8BED
|
|
3204
3204
|
- \u4E0D\u5199\u6807\u9898\u515A\u5185\u5BB9
|
|
3205
3205
|
`;
|
|
3206
|
-
writeFileSync5(join7(
|
|
3206
|
+
writeFileSync5(join7(lewxclawDir, "soul.md"), soulContent, "utf-8");
|
|
3207
3207
|
console.log(chalk6.green(` \u2713 \u516C\u4F17\u53F7\u4EBA\u8BBE\u5DF2\u4FDD\u5B58\uFF08${positioning}\uFF09`));
|
|
3208
3208
|
console.log("");
|
|
3209
3209
|
console.log(chalk6.yellow("\u{1F3A8} Step 4/4: \u9ED8\u8BA4\u5199\u4F5C\u98CE\u683C"));
|
|
@@ -3244,38 +3244,111 @@ var setupCommand = new Command6("setup").description("\u4EA4\u4E92\u5F0F\u914D\u
|
|
|
3244
3244
|
}
|
|
3245
3245
|
console.log("");
|
|
3246
3246
|
console.log(chalk6.cyan("\u2501".repeat(50)));
|
|
3247
|
-
console.log(chalk6.green("\u2705
|
|
3247
|
+
console.log(chalk6.green("\u2705 LeWxClaw \u914D\u7F6E\u5B8C\u6210\uFF01"));
|
|
3248
3248
|
console.log("");
|
|
3249
3249
|
console.log(" \u914D\u7F6E\u6587\u4EF6\uFF1A" + chalk6.gray(configPath2));
|
|
3250
|
-
console.log(" \u4EBA\u8BBE\u6587\u4EF6\uFF1A" + chalk6.gray(join7(
|
|
3250
|
+
console.log(" \u4EBA\u8BBE\u6587\u4EF6\uFF1A" + chalk6.gray(join7(lewxclawDir, "soul.md")));
|
|
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('
|
|
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("
|
|
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} LeWxClaw 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
|
|
3264
|
-
program.name("lewxclaw").description("
|
|
3335
|
+
var program = new Command8();
|
|
3336
|
+
program.name("lewxclaw").description("LeWxClaw \u2014 \u516C\u4F17\u53F7\u521B\u4F5C Agent").version("0.1.0");
|
|
3265
3337
|
program.addCommand(setupCommand);
|
|
3266
3338
|
program.addCommand(createCommand);
|
|
3267
3339
|
program.addCommand(configCommand);
|
|
3268
3340
|
program.addCommand(topicsCommand);
|
|
3269
3341
|
program.addCommand(cronCommand);
|
|
3270
3342
|
program.addCommand(styleCommand);
|
|
3271
|
-
|
|
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 (!
|
|
3277
|
-
console.log(
|
|
3278
|
-
console.log(
|
|
3349
|
+
if (!existsSync9(configPath) && !isSetup && !isHelp && !isVersion && args.length > 0) {
|
|
3350
|
+
console.log(chalk8.yellow("\u{1F99E} \u9996\u6B21\u4F7F\u7528 LeWxClaw\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();
|