maidang 29.5.6 → 29.6.1
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 +249 -118
- package/dist/index.js.map +4 -4
- package/package.json +8 -9
package/dist/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { Command as
|
|
4
|
+
import { Command as Command15 } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/commands/home.ts
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
import chalk2 from "chalk";
|
|
9
|
+
import boxen2 from "boxen";
|
|
10
|
+
import figlet2 from "figlet";
|
|
11
|
+
import terminalImage from "terminal-image";
|
|
9
12
|
|
|
10
13
|
// src/constants/profile.ts
|
|
11
14
|
var INTRO_TEXT = "\u8FDE\u7EED\u5C31\u4E1A\u8005 / \u6587\u79D1\u8F6C\u7801 / \u5168\u6808 / \u72EC\u7ACB\u5F00\u53D1\uFF0C\u62FF\u94C1\u7231\u597D\u8005\uFF0C\u4E3E\u94C1\uFF0C\u98DE\u76D8\uFF0CALL in AI";
|
|
@@ -26,6 +29,10 @@ function displaySeparator(char = "\u2500", length = 50) {
|
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
// src/commands/home.ts
|
|
32
|
+
import path from "node:path";
|
|
33
|
+
import { fileURLToPath } from "node:url";
|
|
34
|
+
var __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
35
|
+
var heroGifPath = path.join(__dirname, "../assets/hero.gif");
|
|
29
36
|
var commands = [
|
|
30
37
|
{ name: "whoami", desc: "\u4E86\u89E3\u6211" },
|
|
31
38
|
{ name: "skills", desc: "\u6280\u80FD & \u5174\u8DA3" },
|
|
@@ -36,31 +43,134 @@ var commands = [
|
|
|
36
43
|
{ name: "projects", desc: "\u9879\u76EE" },
|
|
37
44
|
{ name: "cat | meow", desc: "\u9EA6\u9EA6" }
|
|
38
45
|
];
|
|
46
|
+
var displayHero = async () => {
|
|
47
|
+
try {
|
|
48
|
+
const fs = await import("node:fs");
|
|
49
|
+
if (fs.existsSync(heroGifPath)) {
|
|
50
|
+
const gif = await terminalImage.file(heroGifPath, { width: 60, height: 30 });
|
|
51
|
+
console.log(gif);
|
|
52
|
+
}
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var displayAsciiArt = () => {
|
|
57
|
+
return figlet2.textSync("Maidang", {
|
|
58
|
+
font: "Big",
|
|
59
|
+
horizontalLayout: "default",
|
|
60
|
+
verticalLayout: "default",
|
|
61
|
+
width: 80,
|
|
62
|
+
whitespaceBreak: true
|
|
63
|
+
});
|
|
64
|
+
};
|
|
39
65
|
function createHomeCommand() {
|
|
40
|
-
const cmd = new Command("maidang").description("\u6B22\u8FCE\u6765\u5230\u9EA6\u5F53\u7684\u4E16\u754C").action(async () => {
|
|
66
|
+
const cmd = new Command("maidang").description("\u6B22\u8FCE\u6765\u5230\u9EA6\u5F53\u52B3\u7684\u4E16\u754C").action(async () => {
|
|
41
67
|
const spinner = createSpinner("\u6B63\u5728\u53EC\u5524...");
|
|
42
68
|
spinner.start();
|
|
43
69
|
await new Promise((resolve) => setTimeout(resolve, 800));
|
|
44
70
|
spinner.stop();
|
|
45
71
|
console.clear();
|
|
46
|
-
|
|
47
|
-
console.log(chalk2.
|
|
48
|
-
console.log("");
|
|
49
|
-
console.log(chalk2.dim("\u2500".repeat(40)));
|
|
72
|
+
await displayHero();
|
|
73
|
+
console.log(chalk2.cyan.bold(displayAsciiArt()));
|
|
50
74
|
console.log("");
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
75
|
+
const introBox = boxen2(chalk2.dim(INTRO_TEXT), {
|
|
76
|
+
padding: 1,
|
|
77
|
+
margin: 0,
|
|
78
|
+
borderStyle: "round",
|
|
79
|
+
borderColor: "cyan"
|
|
80
|
+
});
|
|
81
|
+
console.log(introBox);
|
|
54
82
|
console.log("");
|
|
55
|
-
|
|
83
|
+
const cmdCol = commands.map((c) => `${chalk2.white(c.name.padEnd(12))} ${chalk2.dim(c.desc)}`).join("\n");
|
|
84
|
+
console.log(chalk2.dim("\u250C" + "\u2500".repeat(38) + "\u2510"));
|
|
85
|
+
console.log(chalk2.dim("\u2502") + chalk2.bold.white(" \u547D\u4EE4\u5217\u8868".padEnd(38)) + chalk2.dim("\u2502"));
|
|
86
|
+
console.log(chalk2.dim("\u251C" + "\u2500".repeat(38) + "\u2524"));
|
|
87
|
+
cmdCol.split("\n").forEach((line) => {
|
|
88
|
+
console.log(chalk2.dim("\u2502") + ` ${line.padEnd(36)}` + chalk2.dim("\u2502"));
|
|
89
|
+
});
|
|
90
|
+
console.log(chalk2.dim("\u2514" + "\u2500".repeat(38) + "\u2518"));
|
|
56
91
|
console.log("");
|
|
57
92
|
});
|
|
58
93
|
return cmd;
|
|
59
94
|
}
|
|
60
95
|
|
|
61
|
-
// src/commands/
|
|
96
|
+
// src/commands/create.ts
|
|
62
97
|
import { Command as Command2 } from "commander";
|
|
63
98
|
import chalk3 from "chalk";
|
|
99
|
+
import ora2 from "ora";
|
|
100
|
+
var NPM_REGISTRY = "https://registry.npmjs.org";
|
|
101
|
+
function validatePackageName(name) {
|
|
102
|
+
if (!name) {
|
|
103
|
+
return "\u5305\u540D\u4E0D\u80FD\u4E3A\u7A7A";
|
|
104
|
+
}
|
|
105
|
+
if (name.length > 214) {
|
|
106
|
+
return "\u5305\u540D\u4E0D\u80FD\u8D85\u8FC7 214 \u4E2A\u5B57\u7B26";
|
|
107
|
+
}
|
|
108
|
+
if (name.startsWith(".") || name.startsWith("_")) {
|
|
109
|
+
return "\u5305\u540D\u4E0D\u80FD\u4EE5 . \u6216 _ \u5F00\u5934";
|
|
110
|
+
}
|
|
111
|
+
if (name !== name.toLowerCase()) {
|
|
112
|
+
return "\u5305\u540D\u5FC5\u987B\u5168\u5C0F\u5199";
|
|
113
|
+
}
|
|
114
|
+
if (encodeURIComponent(name) !== name) {
|
|
115
|
+
return "\u5305\u540D\u5305\u542B\u975E\u6CD5\u5B57\u7B26";
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
async function checkPackageExists(name, spinner) {
|
|
120
|
+
try {
|
|
121
|
+
spinner.text = `\u6B63\u5728\u68C0\u67E5 ${name}...`;
|
|
122
|
+
const res = await fetch(`${NPM_REGISTRY}/${name}`, {
|
|
123
|
+
method: "HEAD"
|
|
124
|
+
});
|
|
125
|
+
return res.ok;
|
|
126
|
+
} catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function createCreateCommand() {
|
|
131
|
+
const cmd = new Command2("create").description("\u521B\u5EFA\u65B0\u5305\uFF08\u81EA\u52A8\u6821\u9A8C\u5305\u540D\u662F\u5426\u53EF\u7528\uFF09").argument("<name>", "\u5305\u540D\u79F0").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (name, opts) => {
|
|
132
|
+
const spinner = ora2("\u51C6\u5907\u521B\u5EFA\u5305...").start();
|
|
133
|
+
const validationError = validatePackageName(name);
|
|
134
|
+
if (validationError) {
|
|
135
|
+
spinner.fail(chalk3.red(`\u5305\u540D\u6821\u9A8C\u5931\u8D25: ${validationError}`));
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
spinner.text = `\u6B63\u5728\u68C0\u67E5 ${name} \u662F\u5426\u53EF\u7528...`;
|
|
139
|
+
const exists = await checkPackageExists(name, spinner);
|
|
140
|
+
if (exists) {
|
|
141
|
+
spinner.fail(chalk3.red(`\u5305\u540D ${name} \u5DF2\u88AB\u4F7F\u7528\uFF0C\u8BF7\u6362\u4E00\u4E2A\u540D\u79F0`));
|
|
142
|
+
if (opts.json) {
|
|
143
|
+
console.log(JSON.stringify({
|
|
144
|
+
tool: "maidang",
|
|
145
|
+
command: "create",
|
|
146
|
+
success: false,
|
|
147
|
+
error: `\u5305\u540D ${name} \u5DF2\u88AB\u4F7F\u7528`,
|
|
148
|
+
suggestion: "\u5C1D\u8BD5\u6DFB\u52A0\u4F60\u7684\u4F5C\u7528\u57DF\uFF0C\u4F8B\u5982 @yourname/" + name
|
|
149
|
+
}, null, 2));
|
|
150
|
+
}
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
spinner.succeed(chalk3.green(`\u5305\u540D ${name} \u53EF\u7528\uFF01`));
|
|
154
|
+
if (opts.json) {
|
|
155
|
+
console.log(JSON.stringify({
|
|
156
|
+
tool: "maidang",
|
|
157
|
+
command: "create",
|
|
158
|
+
success: true,
|
|
159
|
+
name,
|
|
160
|
+
available: true
|
|
161
|
+
}, null, 2));
|
|
162
|
+
} else {
|
|
163
|
+
console.log("");
|
|
164
|
+
console.log(chalk3.dim("\u4E0B\u4E00\u6B65:"));
|
|
165
|
+
console.log(` ${chalk3.white(`pnpm create ${name}`)} ${chalk3.dim("# \u6216\u4F7F\u7528\u5176\u4ED6\u811A\u624B\u67B6\u5DE5\u5177")}`);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return cmd;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/commands/career.ts
|
|
172
|
+
import { Command as Command3 } from "commander";
|
|
173
|
+
import chalk4 from "chalk";
|
|
64
174
|
|
|
65
175
|
// src/data/career.json
|
|
66
176
|
var career_default = {
|
|
@@ -156,11 +266,11 @@ var career_default = {
|
|
|
156
266
|
// src/commands/career.ts
|
|
157
267
|
var printIndentedGray = (text, indent) => {
|
|
158
268
|
for (const line of text.split("\n")) {
|
|
159
|
-
console.log(
|
|
269
|
+
console.log(chalk4.gray(indent + line));
|
|
160
270
|
}
|
|
161
271
|
};
|
|
162
272
|
function createCareerCommand() {
|
|
163
|
-
const cmd = new
|
|
273
|
+
const cmd = new Command3("career").description("\u804C\u4E1A\u5207\u7247\uFF08\u4E0E\u7AD9\u70B9 career \u9875\u540C\u6E90\uFF0C--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E\uFF09").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
|
|
164
274
|
const root = career_default;
|
|
165
275
|
const data = root.career;
|
|
166
276
|
if (opts.json) {
|
|
@@ -169,48 +279,48 @@ function createCareerCommand() {
|
|
|
169
279
|
}
|
|
170
280
|
const { intro, sections, focuses, experiences, principles } = data;
|
|
171
281
|
console.log("");
|
|
172
|
-
console.log(
|
|
173
|
-
console.log(
|
|
282
|
+
console.log(chalk4.dim(intro.eyebrow));
|
|
283
|
+
console.log(chalk4.white.bold(intro.title));
|
|
174
284
|
console.log("");
|
|
175
|
-
console.log(
|
|
285
|
+
console.log(chalk4.white(intro.lead));
|
|
176
286
|
console.log("");
|
|
177
287
|
printIndentedGray(intro.body, " ");
|
|
178
288
|
console.log("");
|
|
179
289
|
displaySeparator();
|
|
180
|
-
console.log(
|
|
181
|
-
console.log(
|
|
290
|
+
console.log(chalk4.bold.cyan(sections.focus.title));
|
|
291
|
+
console.log(chalk4.dim(sections.focus.subtitle));
|
|
182
292
|
console.log("");
|
|
183
293
|
for (const f of focuses) {
|
|
184
|
-
console.log(
|
|
185
|
-
console.log(
|
|
294
|
+
console.log(chalk4.white.bold(` ${f.title}`));
|
|
295
|
+
console.log(chalk4.gray(` ${f.description}`));
|
|
186
296
|
console.log("");
|
|
187
297
|
}
|
|
188
298
|
displaySeparator();
|
|
189
|
-
console.log(
|
|
190
|
-
console.log(
|
|
299
|
+
console.log(chalk4.bold.cyan(sections.experience.title));
|
|
300
|
+
console.log(chalk4.dim(sections.experience.subtitle));
|
|
191
301
|
console.log("");
|
|
192
302
|
experiences.forEach((exp, index) => {
|
|
193
|
-
console.log(
|
|
194
|
-
console.log(
|
|
195
|
-
console.log(
|
|
303
|
+
console.log(chalk4.dim(` ${exp.period}`));
|
|
304
|
+
console.log(chalk4.white.bold(` ${exp.company}`));
|
|
305
|
+
console.log(chalk4.gray(` ${exp.role}`));
|
|
196
306
|
console.log("");
|
|
197
|
-
console.log(
|
|
307
|
+
console.log(chalk4.gray(` ${exp.summary}`));
|
|
198
308
|
console.log("");
|
|
199
309
|
for (const p of exp.paragraphs) {
|
|
200
|
-
console.log(
|
|
310
|
+
console.log(chalk4.gray(` ${p}`));
|
|
201
311
|
console.log("");
|
|
202
312
|
}
|
|
203
313
|
if (index < experiences.length - 1) {
|
|
204
|
-
console.log(
|
|
314
|
+
console.log(chalk4.dim(" " + "\xB7".repeat(36)));
|
|
205
315
|
console.log("");
|
|
206
316
|
}
|
|
207
317
|
});
|
|
208
318
|
displaySeparator();
|
|
209
|
-
console.log(
|
|
210
|
-
console.log(
|
|
319
|
+
console.log(chalk4.bold.cyan(sections.principles.title));
|
|
320
|
+
console.log(chalk4.dim(sections.principles.subtitle));
|
|
211
321
|
console.log("");
|
|
212
322
|
for (const line of principles) {
|
|
213
|
-
console.log(
|
|
323
|
+
console.log(chalk4.gray(` ${line}`));
|
|
214
324
|
console.log("");
|
|
215
325
|
}
|
|
216
326
|
});
|
|
@@ -218,8 +328,8 @@ function createCareerCommand() {
|
|
|
218
328
|
}
|
|
219
329
|
|
|
220
330
|
// src/commands/cat.ts
|
|
221
|
-
import { Command as
|
|
222
|
-
import
|
|
331
|
+
import { Command as Command4 } from "commander";
|
|
332
|
+
import chalk5 from "chalk";
|
|
223
333
|
|
|
224
334
|
// src/constants/api.ts
|
|
225
335
|
var DEFAULT_API_URL = "https://www.maidang.me";
|
|
@@ -235,22 +345,22 @@ var getCatMoments = async () => {
|
|
|
235
345
|
return Array.isArray(data) ? data : [];
|
|
236
346
|
};
|
|
237
347
|
var printCatList = (catMoments) => {
|
|
238
|
-
console.log(
|
|
348
|
+
console.log(chalk5.yellow.bold("\u9EA6\u9EA6"));
|
|
239
349
|
console.log("");
|
|
240
350
|
for (const moment of catMoments) {
|
|
241
351
|
const title = moment.title || "\u672A\u547D\u540D\u732B\u732B\u52A8\u6001";
|
|
242
|
-
console.log(` ${
|
|
352
|
+
console.log(` ${chalk5.white.bold(title)} ${chalk5.dim(`[${moment.slug}]`)}`);
|
|
243
353
|
if (moment.description) {
|
|
244
|
-
console.log(` ${
|
|
354
|
+
console.log(` ${chalk5.gray(moment.description)}`);
|
|
245
355
|
}
|
|
246
356
|
if (moment.imageUrl) {
|
|
247
|
-
console.log(` ${
|
|
357
|
+
console.log(` ${chalk5.blue(moment.imageUrl)}`);
|
|
248
358
|
}
|
|
249
359
|
console.log("");
|
|
250
360
|
}
|
|
251
361
|
};
|
|
252
362
|
function createCatCommand() {
|
|
253
|
-
const cmd = new
|
|
363
|
+
const cmd = new Command4("cat").alias("meow").description("\u67E5\u770B\u732B\u732B\u52A8\u6001\u5217\u8868 (--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E)").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
|
|
254
364
|
const printJson = (data, error) => {
|
|
255
365
|
const payload = {
|
|
256
366
|
tool: "maidang",
|
|
@@ -269,9 +379,9 @@ function createCatCommand() {
|
|
|
269
379
|
return;
|
|
270
380
|
}
|
|
271
381
|
if (catMoments.length === 0) {
|
|
272
|
-
console.log(
|
|
382
|
+
console.log(chalk5.yellow.bold("\u9EA6\u9EA6"));
|
|
273
383
|
console.log("");
|
|
274
|
-
console.log(
|
|
384
|
+
console.log(chalk5.gray("\u6682\u65E0\u732B\u732B\u52A8\u6001\uFF0C\u53EF\u5728\u540E\u53F0\u5148\u6DFB\u52A0\u3002"));
|
|
275
385
|
console.log("");
|
|
276
386
|
return;
|
|
277
387
|
}
|
|
@@ -282,7 +392,7 @@ function createCatCommand() {
|
|
|
282
392
|
printJson([], message);
|
|
283
393
|
return;
|
|
284
394
|
}
|
|
285
|
-
console.error(
|
|
395
|
+
console.error(chalk5.red(`\u83B7\u53D6\u732B\u732B\u52A8\u6001\u5931\u8D25: ${message}`));
|
|
286
396
|
process.exit(1);
|
|
287
397
|
}
|
|
288
398
|
});
|
|
@@ -292,7 +402,7 @@ function createCatCommand() {
|
|
|
292
402
|
// src/commands/posts.tsx
|
|
293
403
|
import React, { useState, useEffect } from "react";
|
|
294
404
|
import { render, Box, Text, useInput } from "ink";
|
|
295
|
-
import { Command as
|
|
405
|
+
import { Command as Command5 } from "commander";
|
|
296
406
|
var ListView = ({ posts, selectedIndex, onSelect, onEnter, onQuit }) => {
|
|
297
407
|
useInput((input, key) => {
|
|
298
408
|
if (input === "q" || input === "Q") {
|
|
@@ -442,7 +552,7 @@ var PostsApp = ({ apiUrl }) => {
|
|
|
442
552
|
};
|
|
443
553
|
function createPostsCommand() {
|
|
444
554
|
const apiUrl = `${process.env.MAIDANG_API_URL || DEFAULT_API_URL}/api/social-posts?type=social`;
|
|
445
|
-
const cmd = new
|
|
555
|
+
const cmd = new Command5("posts").description("\u63A8\u6587\u5217\u8868\uFF0C\u8FDB\u5165\u540E\u53EF\u67E5\u770B\u8BE6\u60C5 (--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E)").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F");
|
|
446
556
|
cmd.action((opts) => {
|
|
447
557
|
const wantsJson = opts.json;
|
|
448
558
|
if (wantsJson) {
|
|
@@ -460,7 +570,7 @@ function createPostsCommand() {
|
|
|
460
570
|
// src/commands/songs.tsx
|
|
461
571
|
import React2, { useState as useState2, useRef } from "react";
|
|
462
572
|
import { render as render2, Box as Box2, Text as Text2, useInput as useInput2 } from "ink";
|
|
463
|
-
import { Command as
|
|
573
|
+
import { Command as Command6 } from "commander";
|
|
464
574
|
|
|
465
575
|
// src/data/songs.json
|
|
466
576
|
var songs_default = {
|
|
@@ -1517,7 +1627,7 @@ var SongsApp = ({ defaultYearIndex }) => {
|
|
|
1517
1627
|
);
|
|
1518
1628
|
};
|
|
1519
1629
|
function createSongsCommand() {
|
|
1520
|
-
const cmd = new
|
|
1630
|
+
const cmd = new Command6("songs").description(`\u5E74\u5EA6\u6B4C\u5355\uFF0C\u652F\u6301: ${AVAILABLE_YEARS.join(", ")} (--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E)`).option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").option("--year <year>", `\u8DF3\u8F6C\u81F3\u6307\u5B9A\u5E74\u4EFD\u7684\u6B4C\u66F2\u5217\u8868`);
|
|
1521
1631
|
cmd.action((opts) => {
|
|
1522
1632
|
if (opts.json) {
|
|
1523
1633
|
if (opts.year) {
|
|
@@ -1549,10 +1659,10 @@ function createSongsCommand() {
|
|
|
1549
1659
|
}
|
|
1550
1660
|
|
|
1551
1661
|
// src/commands/links.ts
|
|
1552
|
-
import { Command as
|
|
1553
|
-
import
|
|
1662
|
+
import { Command as Command7 } from "commander";
|
|
1663
|
+
import chalk6 from "chalk";
|
|
1554
1664
|
function createLinksCommand() {
|
|
1555
|
-
const cmd = new
|
|
1665
|
+
const cmd = new Command7("links").description("\u67E5\u770B\u793E\u4EA4\u94FE\u63A5 (--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E)").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
|
|
1556
1666
|
const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
|
|
1557
1667
|
try {
|
|
1558
1668
|
const res = await fetch(`${apiUrl}/api/links`);
|
|
@@ -1562,14 +1672,14 @@ function createLinksCommand() {
|
|
|
1562
1672
|
console.log(JSON.stringify({ tool: "maidang", command: "links", data: links }, null, 2));
|
|
1563
1673
|
return;
|
|
1564
1674
|
}
|
|
1565
|
-
console.log(
|
|
1675
|
+
console.log(chalk6.cyan.bold("\u{1F310} \u793E\u4EA4\u94FE\u63A5\n"));
|
|
1566
1676
|
for (const link of links) {
|
|
1567
|
-
console.log(` ${link.icon} ${
|
|
1568
|
-
console.log(` ${
|
|
1677
|
+
console.log(` ${link.icon} ${chalk6.white(link.name)} - ${chalk6.gray(link.description || "")}`);
|
|
1678
|
+
console.log(` ${chalk6.blue(link.url)}
|
|
1569
1679
|
`);
|
|
1570
1680
|
}
|
|
1571
1681
|
} catch (err) {
|
|
1572
|
-
console.error(
|
|
1682
|
+
console.error(chalk6.red(`\u83B7\u53D6\u94FE\u63A5\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
|
|
1573
1683
|
process.exit(1);
|
|
1574
1684
|
}
|
|
1575
1685
|
});
|
|
@@ -1577,10 +1687,10 @@ function createLinksCommand() {
|
|
|
1577
1687
|
}
|
|
1578
1688
|
|
|
1579
1689
|
// src/commands/projects.ts
|
|
1580
|
-
import { Command as
|
|
1581
|
-
import
|
|
1690
|
+
import { Command as Command8 } from "commander";
|
|
1691
|
+
import chalk7 from "chalk";
|
|
1582
1692
|
function createProjectsCommand() {
|
|
1583
|
-
const cmd = new
|
|
1693
|
+
const cmd = new Command8("projects").description("\u67E5\u770B\u4E2A\u4EBA\u9879\u76EE").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
|
|
1584
1694
|
const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
|
|
1585
1695
|
try {
|
|
1586
1696
|
const res = await fetch(`${apiUrl}/api/projects`);
|
|
@@ -1590,17 +1700,17 @@ function createProjectsCommand() {
|
|
|
1590
1700
|
console.log(JSON.stringify({ tool: "maidang", command: "projects", data: projects }, null, 2));
|
|
1591
1701
|
return;
|
|
1592
1702
|
}
|
|
1593
|
-
console.log(
|
|
1703
|
+
console.log(chalk7.cyan.bold("\u{1F680} \u4E2A\u4EBA\u9879\u76EE\n"));
|
|
1594
1704
|
for (const project of projects) {
|
|
1595
|
-
console.log(` ${project.icon} ${
|
|
1705
|
+
console.log(` ${project.icon} ${chalk7.white.bold(project.name)} ${chalk7.gray(`[${project.category}]`)}`);
|
|
1596
1706
|
console.log(` ${project.description}`);
|
|
1597
1707
|
if (project.url) {
|
|
1598
|
-
console.log(` ${
|
|
1708
|
+
console.log(` ${chalk7.blue(project.url)}`);
|
|
1599
1709
|
}
|
|
1600
1710
|
console.log("");
|
|
1601
1711
|
}
|
|
1602
1712
|
} catch (err) {
|
|
1603
|
-
console.error(
|
|
1713
|
+
console.error(chalk7.red(`\u83B7\u53D6\u9879\u76EE\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
|
|
1604
1714
|
process.exit(1);
|
|
1605
1715
|
}
|
|
1606
1716
|
});
|
|
@@ -1608,10 +1718,10 @@ function createProjectsCommand() {
|
|
|
1608
1718
|
}
|
|
1609
1719
|
|
|
1610
1720
|
// src/commands/tools.ts
|
|
1611
|
-
import { Command as
|
|
1612
|
-
import
|
|
1721
|
+
import { Command as Command9 } from "commander";
|
|
1722
|
+
import chalk8 from "chalk";
|
|
1613
1723
|
function createToolsCommand() {
|
|
1614
|
-
const cmd = new
|
|
1724
|
+
const cmd = new Command9("tools").description("\u67E5\u770B\u5E38\u7528\u5DE5\u5177").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
|
|
1615
1725
|
const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
|
|
1616
1726
|
try {
|
|
1617
1727
|
const res = await fetch(`${apiUrl}/api/tools`);
|
|
@@ -1631,17 +1741,17 @@ function createToolsCommand() {
|
|
|
1631
1741
|
device: "\u8BBE\u5907",
|
|
1632
1742
|
desktop: "\u684C\u9762\u88C5\u5907"
|
|
1633
1743
|
};
|
|
1634
|
-
console.log(
|
|
1744
|
+
console.log(chalk8.cyan.bold("\u{1F527} \u5E38\u7528\u5DE5\u5177\n"));
|
|
1635
1745
|
for (const [cat, items] of Object.entries(byCategory)) {
|
|
1636
|
-
console.log(
|
|
1746
|
+
console.log(chalk8.white.bold(` ${categoryNames[cat] || cat}`));
|
|
1637
1747
|
for (const tool of items) {
|
|
1638
|
-
const urlStr = tool.url ? ` ${
|
|
1639
|
-
console.log(` ${tool.icon} ${tool.name} - ${
|
|
1748
|
+
const urlStr = tool.url ? ` ${chalk8.blue(tool.url)}` : "";
|
|
1749
|
+
console.log(` ${tool.icon} ${tool.name} - ${chalk8.gray(tool.description)}${urlStr}`);
|
|
1640
1750
|
}
|
|
1641
1751
|
console.log("");
|
|
1642
1752
|
}
|
|
1643
1753
|
} catch (err) {
|
|
1644
|
-
console.error(
|
|
1754
|
+
console.error(chalk8.red(`\u83B7\u53D6\u5DE5\u5177\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
|
|
1645
1755
|
process.exit(1);
|
|
1646
1756
|
}
|
|
1647
1757
|
});
|
|
@@ -1649,34 +1759,34 @@ function createToolsCommand() {
|
|
|
1649
1759
|
}
|
|
1650
1760
|
|
|
1651
1761
|
// src/commands/contact.ts
|
|
1652
|
-
import { Command as
|
|
1653
|
-
import
|
|
1762
|
+
import { Command as Command10 } from "commander";
|
|
1763
|
+
import chalk9 from "chalk";
|
|
1654
1764
|
function hr(char = "\u2500", len = 40) {
|
|
1655
|
-
console.log(
|
|
1765
|
+
console.log(chalk9.dim(char.repeat(len)));
|
|
1656
1766
|
}
|
|
1657
1767
|
function createContactCommand() {
|
|
1658
|
-
const cmd = new
|
|
1768
|
+
const cmd = new Command10("contact").description("\u8054\u7CFB\u65B9\u5F0F").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
|
|
1659
1769
|
const data = { email: "borisdunk@sina.com", note: "\u56DE\u590D\u53EF\u80FD\u8F83\u6162\uFF0C\u770B\u5230\u4F1A\u56DE" };
|
|
1660
1770
|
if (opts.json) {
|
|
1661
1771
|
console.log(JSON.stringify({ tool: "maidang", command: "contact", data }, null, 2));
|
|
1662
1772
|
return;
|
|
1663
1773
|
}
|
|
1664
1774
|
console.log("");
|
|
1665
|
-
console.log(
|
|
1775
|
+
console.log(chalk9.bold("\u8054\u7CFB\u65B9\u5F0F"));
|
|
1666
1776
|
console.log("");
|
|
1667
1777
|
hr();
|
|
1668
1778
|
console.log("");
|
|
1669
|
-
console.log(` Email ${
|
|
1779
|
+
console.log(` Email ${chalk9.blue("borisdunk@sina.com")}`);
|
|
1670
1780
|
console.log("");
|
|
1671
|
-
console.log(` ${
|
|
1781
|
+
console.log(` ${chalk9.dim("\u56DE\u590D\u53EF\u80FD\u8F83\u6162\uFF0C\u770B\u5230\u4F1A\u56DE")}`);
|
|
1672
1782
|
console.log("");
|
|
1673
1783
|
});
|
|
1674
1784
|
return cmd;
|
|
1675
1785
|
}
|
|
1676
1786
|
|
|
1677
1787
|
// src/commands/skills.ts
|
|
1678
|
-
import { Command as
|
|
1679
|
-
import
|
|
1788
|
+
import { Command as Command11 } from "commander";
|
|
1789
|
+
import chalk10 from "chalk";
|
|
1680
1790
|
var skills = [
|
|
1681
1791
|
// 生活方式
|
|
1682
1792
|
{ name: "\u4E3E\u94C1 / \u5065\u8EAB", tags: ["life"] },
|
|
@@ -1698,10 +1808,10 @@ var skills = [
|
|
|
1698
1808
|
{ name: "React Flow", tags: ["tech"] }
|
|
1699
1809
|
];
|
|
1700
1810
|
function hr2(char = "\u2500", len = 40) {
|
|
1701
|
-
console.log(
|
|
1811
|
+
console.log(chalk10.dim(char.repeat(len)));
|
|
1702
1812
|
}
|
|
1703
1813
|
function createSkillsCommand() {
|
|
1704
|
-
const cmd = new
|
|
1814
|
+
const cmd = new Command11("skills").description("\u6280\u80FD\u4E0E\u5174\u8DA3").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
|
|
1705
1815
|
if (opts.json) {
|
|
1706
1816
|
console.log(JSON.stringify({ tool: "maidang", command: "skills", data: skills }, null, 2));
|
|
1707
1817
|
return;
|
|
@@ -1710,29 +1820,29 @@ function createSkillsCommand() {
|
|
|
1710
1820
|
const product = skills.filter((s) => s.tags.includes("product"));
|
|
1711
1821
|
const tech = skills.filter((s) => s.tags.includes("tech"));
|
|
1712
1822
|
console.log("");
|
|
1713
|
-
console.log(
|
|
1823
|
+
console.log(chalk10.bold("\u751F\u6D3B"));
|
|
1714
1824
|
console.log("");
|
|
1715
|
-
console.log(" " + life.map((s) =>
|
|
1825
|
+
console.log(" " + life.map((s) => chalk10.white(s.name)).join(chalk10.dim(" \xB7 ")));
|
|
1716
1826
|
console.log("");
|
|
1717
1827
|
hr2();
|
|
1718
1828
|
console.log("");
|
|
1719
|
-
console.log(
|
|
1829
|
+
console.log(chalk10.bold("\u4EA7\u54C1"));
|
|
1720
1830
|
console.log("");
|
|
1721
|
-
console.log(" " + product.map((s) =>
|
|
1831
|
+
console.log(" " + product.map((s) => chalk10.white(s.name)).join(chalk10.dim(" \xB7 ")));
|
|
1722
1832
|
console.log("");
|
|
1723
1833
|
hr2();
|
|
1724
1834
|
console.log("");
|
|
1725
|
-
console.log(
|
|
1835
|
+
console.log(chalk10.bold("\u6280\u672F"));
|
|
1726
1836
|
console.log("");
|
|
1727
|
-
console.log(" " + tech.map((s) =>
|
|
1837
|
+
console.log(" " + tech.map((s) => chalk10.white(s.name)).join(chalk10.dim(" \xB7 ")));
|
|
1728
1838
|
console.log("");
|
|
1729
1839
|
});
|
|
1730
1840
|
return cmd;
|
|
1731
1841
|
}
|
|
1732
1842
|
|
|
1733
1843
|
// src/commands/status.ts
|
|
1734
|
-
import { Command as
|
|
1735
|
-
import
|
|
1844
|
+
import { Command as Command12 } from "commander";
|
|
1845
|
+
import chalk11 from "chalk";
|
|
1736
1846
|
function getStatus() {
|
|
1737
1847
|
const hour = (/* @__PURE__ */ new Date()).getHours();
|
|
1738
1848
|
const isWeekend = [0, 6].includes((/* @__PURE__ */ new Date()).getDay());
|
|
@@ -1742,30 +1852,30 @@ function getStatus() {
|
|
|
1742
1852
|
return { status: "working", label: "\u5DE5\u4F5C\u4E2D", description: "\u6B63\u5E38\u5DE5\u4F5C\u65F6\u6BB5" };
|
|
1743
1853
|
}
|
|
1744
1854
|
function hr3(char = "\u2500", len = 40) {
|
|
1745
|
-
console.log(
|
|
1855
|
+
console.log(chalk11.dim(char.repeat(len)));
|
|
1746
1856
|
}
|
|
1747
1857
|
function createStatusCommand() {
|
|
1748
|
-
const cmd = new
|
|
1858
|
+
const cmd = new Command12("status").description("\u5F53\u524D\u72B6\u6001").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
|
|
1749
1859
|
const info = getStatus();
|
|
1750
1860
|
if (opts.json) {
|
|
1751
1861
|
console.log(JSON.stringify({ tool: "maidang", command: "status", data: info }, null, 2));
|
|
1752
1862
|
return;
|
|
1753
1863
|
}
|
|
1754
1864
|
console.log("");
|
|
1755
|
-
console.log(
|
|
1865
|
+
console.log(chalk11.bold("\u5F53\u524D\u72B6\u6001"));
|
|
1756
1866
|
console.log("");
|
|
1757
1867
|
hr3();
|
|
1758
1868
|
console.log("");
|
|
1759
|
-
console.log(` ${
|
|
1760
|
-
console.log(` ${
|
|
1869
|
+
console.log(` ${chalk11.cyan("\u25CF")} ${chalk11.white(info.label)}`);
|
|
1870
|
+
console.log(` ${chalk11.dim(info.description)}`);
|
|
1761
1871
|
console.log("");
|
|
1762
1872
|
});
|
|
1763
1873
|
return cmd;
|
|
1764
1874
|
}
|
|
1765
1875
|
|
|
1766
1876
|
// src/commands/whoami.ts
|
|
1767
|
-
import { Command as
|
|
1768
|
-
import
|
|
1877
|
+
import { Command as Command13 } from "commander";
|
|
1878
|
+
import chalk12 from "chalk";
|
|
1769
1879
|
function getStatus2() {
|
|
1770
1880
|
const hour = (/* @__PURE__ */ new Date()).getHours();
|
|
1771
1881
|
const isWeekend = [0, 6].includes((/* @__PURE__ */ new Date()).getDay());
|
|
@@ -1775,10 +1885,10 @@ function getStatus2() {
|
|
|
1775
1885
|
return { status: "working", label: "\u5DE5\u4F5C\u4E2D", description: "\u6B63\u5E38\u5DE5\u4F5C\u65F6\u6BB5" };
|
|
1776
1886
|
}
|
|
1777
1887
|
function hr4(char = "\u2500", len = 40) {
|
|
1778
|
-
console.log(
|
|
1888
|
+
console.log(chalk12.dim(char.repeat(len)));
|
|
1779
1889
|
}
|
|
1780
1890
|
function createWhoAmICommand() {
|
|
1781
|
-
const cmd = new
|
|
1891
|
+
const cmd = new Command13("whoami").description("\u4E86\u89E3\u6211").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
|
|
1782
1892
|
const status = getStatus2();
|
|
1783
1893
|
const whoami = {
|
|
1784
1894
|
tagline: INTRO_TEXT,
|
|
@@ -1796,24 +1906,24 @@ function createWhoAmICommand() {
|
|
|
1796
1906
|
return;
|
|
1797
1907
|
}
|
|
1798
1908
|
console.log("");
|
|
1799
|
-
console.log(
|
|
1909
|
+
console.log(chalk12.bold("\u6211\u662F \u9EA6\u5F53"));
|
|
1800
1910
|
console.log("");
|
|
1801
1911
|
console.log(" " + whoami.tagline);
|
|
1802
1912
|
console.log("");
|
|
1803
1913
|
hr4();
|
|
1804
1914
|
console.log("");
|
|
1805
|
-
console.log(` ${
|
|
1806
|
-
console.log(` ${
|
|
1915
|
+
console.log(` ${chalk12.cyan("\u{1F4CD}")} ${whoami.location}`);
|
|
1916
|
+
console.log(` ${chalk12.cyan("\u23F1")} ${whoami.status.label} \xB7 ${chalk12.dim(whoami.status.description)}`);
|
|
1807
1917
|
console.log("");
|
|
1808
1918
|
hr4();
|
|
1809
1919
|
console.log("");
|
|
1810
|
-
console.log(` Blog ${
|
|
1811
|
-
console.log(` Email ${
|
|
1920
|
+
console.log(` Blog ${chalk12.blue.underline(whoami.website)}`);
|
|
1921
|
+
console.log(` Email ${chalk12.blue(whoami.contact)}`);
|
|
1812
1922
|
console.log("");
|
|
1813
1923
|
hr4();
|
|
1814
1924
|
console.log("");
|
|
1815
|
-
console.log(` ${
|
|
1816
|
-
console.log(` ${
|
|
1925
|
+
console.log(` ${chalk12.dim("\u60F3\u4E86\u89E3\u66F4\u591A\uFF1F")}`);
|
|
1926
|
+
console.log(` ${chalk12.dim("maidang skills / career / posts / links")}`);
|
|
1817
1927
|
console.log("");
|
|
1818
1928
|
});
|
|
1819
1929
|
return cmd;
|
|
@@ -1822,8 +1932,8 @@ function createWhoAmICommand() {
|
|
|
1822
1932
|
// src/commands/chat.tsx
|
|
1823
1933
|
import React3, { useState as useState3, useRef as useRef2, useEffect as useEffect3 } from "react";
|
|
1824
1934
|
import { render as render3, Box as Box3, Text as Text3, useInput as useInput3 } from "ink";
|
|
1825
|
-
import { Command as
|
|
1826
|
-
import
|
|
1935
|
+
import { Command as Command14 } from "commander";
|
|
1936
|
+
import chalk13 from "chalk";
|
|
1827
1937
|
|
|
1828
1938
|
// src/utils/chat-api.ts
|
|
1829
1939
|
var API_URL = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
|
|
@@ -1855,42 +1965,50 @@ function parseReply(raw) {
|
|
|
1855
1965
|
}
|
|
1856
1966
|
return { thinking: null, response: raw.trim() };
|
|
1857
1967
|
}
|
|
1858
|
-
async function fetchChat(message) {
|
|
1968
|
+
async function fetchChat(message, sessionId) {
|
|
1859
1969
|
const messages = [{ role: "user", content: message }];
|
|
1860
1970
|
const systemPrompt = buildSystemPrompt();
|
|
1861
1971
|
const res = await fetch(`${API_URL}/api/chat`, {
|
|
1862
1972
|
method: "POST",
|
|
1863
1973
|
headers: { "Content-Type": "application/json" },
|
|
1864
|
-
body: JSON.stringify({ messages, systemPrompt })
|
|
1974
|
+
body: JSON.stringify({ messages, systemPrompt, sessionId })
|
|
1865
1975
|
});
|
|
1866
1976
|
if (!res.ok) {
|
|
1867
1977
|
const err = await res.json().catch(() => ({ error: "Unknown error" }));
|
|
1868
1978
|
throw new Error(err.error || `HTTP ${res.status}`);
|
|
1869
1979
|
}
|
|
1870
1980
|
const data = await res.json();
|
|
1871
|
-
return
|
|
1981
|
+
return {
|
|
1982
|
+
...parseReply(data.reply || ""),
|
|
1983
|
+
sessionId: data.id || ""
|
|
1984
|
+
};
|
|
1872
1985
|
}
|
|
1873
1986
|
|
|
1874
1987
|
// src/commands/chat.tsx
|
|
1875
|
-
async function chatSync(message, json = false) {
|
|
1988
|
+
async function chatSync(message, json = false, sessionId) {
|
|
1876
1989
|
try {
|
|
1877
|
-
const { thinking, response } = await fetchChat(message);
|
|
1990
|
+
const { thinking, response, sessionId: newSessionId } = await fetchChat(message, sessionId);
|
|
1878
1991
|
if (json) {
|
|
1879
|
-
console.log(JSON.stringify({ tool: "maidang", command: "chat", message, thinking, response }, null, 2));
|
|
1992
|
+
console.log(JSON.stringify({ tool: "maidang", command: "chat", message, thinking, response, sessionId: newSessionId }, null, 2));
|
|
1880
1993
|
} else {
|
|
1881
1994
|
if (thinking) {
|
|
1882
1995
|
thinking.split("\n").forEach((line) => {
|
|
1883
|
-
console.log(`${
|
|
1996
|
+
console.log(`${chalk13.dim("\u{1F4AD}")} ${chalk13.dim(line)}`);
|
|
1884
1997
|
});
|
|
1885
1998
|
console.log();
|
|
1886
1999
|
}
|
|
1887
2000
|
console.log(response);
|
|
2001
|
+
if (newSessionId && newSessionId !== sessionId) {
|
|
2002
|
+
console.log();
|
|
2003
|
+
console.log(chalk13.dim(`Session: ${chalk13.cyan(newSessionId)}`));
|
|
2004
|
+
console.log(chalk13.dim("\u4F7F\u7528 --session-id \u7EE7\u7EED\u5BF9\u8BDD"));
|
|
2005
|
+
}
|
|
1888
2006
|
}
|
|
1889
2007
|
} catch (err) {
|
|
1890
2008
|
if (json) {
|
|
1891
2009
|
console.error(JSON.stringify({ tool: "maidang", command: "chat", error: err.message }, null, 2));
|
|
1892
2010
|
} else {
|
|
1893
|
-
console.error(
|
|
2011
|
+
console.error(chalk13.red(`Error: ${err.message}`));
|
|
1894
2012
|
process.exit(1);
|
|
1895
2013
|
}
|
|
1896
2014
|
}
|
|
@@ -1904,12 +2022,14 @@ var ItemTool = ({ content }) => /* @__PURE__ */ React3.createElement(Box3, { fle
|
|
|
1904
2022
|
var ItemContent = ({ content }) => /* @__PURE__ */ React3.createElement(Box3, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { wrap: "wrap" }, content));
|
|
1905
2023
|
var ItemError = ({ content }) => /* @__PURE__ */ React3.createElement(Box3, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { color: "red" }, content));
|
|
1906
2024
|
var DOUBLE_PRESS_WINDOW = 1e3;
|
|
1907
|
-
var ChatApp = () => {
|
|
2025
|
+
var ChatApp = ({ sessionId: initialSessionId }) => {
|
|
1908
2026
|
const [items, setItems] = useState3([]);
|
|
1909
2027
|
const [input, setInput] = useState3("");
|
|
1910
2028
|
const [cursorPos, setCursorPos] = useState3(0);
|
|
1911
2029
|
const [loading, setLoading] = useState3(false);
|
|
1912
2030
|
const [hint, setHint] = useState3("");
|
|
2031
|
+
const [sessionId, setSessionId] = useState3(void 0);
|
|
2032
|
+
const sessionIdRef = useRef2(void 0);
|
|
1913
2033
|
const [showThinking, setShowThinking] = useState3(false);
|
|
1914
2034
|
const lastEscRef = useRef2(0);
|
|
1915
2035
|
const lastCtrlCRef = useRef2(0);
|
|
@@ -1918,6 +2038,12 @@ var ChatApp = () => {
|
|
|
1918
2038
|
useEffect3(() => {
|
|
1919
2039
|
showThinkingRef.current = showThinking;
|
|
1920
2040
|
}, [showThinking]);
|
|
2041
|
+
useEffect3(() => {
|
|
2042
|
+
if (initialSessionId) {
|
|
2043
|
+
setSessionId(initialSessionId);
|
|
2044
|
+
sessionIdRef.current = initialSessionId;
|
|
2045
|
+
}
|
|
2046
|
+
}, [initialSessionId]);
|
|
1921
2047
|
useEffect3(() => {
|
|
1922
2048
|
if (hint) {
|
|
1923
2049
|
const t = setTimeout(() => setHint(""), 1500);
|
|
@@ -1931,7 +2057,10 @@ var ChatApp = () => {
|
|
|
1931
2057
|
setLoading(true);
|
|
1932
2058
|
setItems((prev) => [...prev, { id: uid(), type: "loading", content: "" }]);
|
|
1933
2059
|
try {
|
|
1934
|
-
const { thinking, response } = await fetchChat(text);
|
|
2060
|
+
const { thinking, response, sessionId: sessionId2 } = await fetchChat(text, sessionIdRef.current);
|
|
2061
|
+
if (sessionId2 && sessionId2 !== sessionIdRef.current) {
|
|
2062
|
+
sessionIdRef.current = sessionId2;
|
|
2063
|
+
}
|
|
1935
2064
|
setItems((prev) => {
|
|
1936
2065
|
const withoutLoading = prev.filter((i) => i.type !== "loading");
|
|
1937
2066
|
const newItems = [...withoutLoading];
|
|
@@ -2057,7 +2186,7 @@ var ChatApp = () => {
|
|
|
2057
2186
|
})), /* @__PURE__ */ React3.createElement(Box3, { flexDirection: "column", flexShrink: 0 }, /* @__PURE__ */ React3.createElement(Box3, { borderStyle: "single", borderColor: "gray", paddingX: 1 }, renderInputLine()), /* @__PURE__ */ React3.createElement(Box3, { paddingTop: 1 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, "Ctrl+C \u9000\u51FA \xB7 Enter \u53D1\u9001 \xB7 Esc \u6E05\u7A7A \xB7 \u2190\u2192 \u79FB\u52A8\u5149\u6807")), hint && /* @__PURE__ */ React3.createElement(Box3, { paddingTop: 0 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true, color: "yellow" }, hint)), !loading && items.some((i) => i.type === "thinking") && !showThinking && /* @__PURE__ */ React3.createElement(Box3, { paddingTop: 0 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true, color: "cyan" }, "Ctrl+O \u67E5\u770B\u601D\u8003"))), /* @__PURE__ */ React3.createElement(Box3, { ref: bottomRef }));
|
|
2058
2187
|
};
|
|
2059
2188
|
function createChatCommand() {
|
|
2060
|
-
const cmd = new
|
|
2189
|
+
const cmd = new Command14("chat").description("\u548C\u9EA6\u5F53\u5BF9\u8BDD").option("-m, --message <text>", "\u76F4\u63A5\u53D1\u9001\u6D88\u606F\uFF08\u975E\u4EA4\u4E92\u6A21\u5F0F\uFF09").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").option("--session-id <id>", "\u7EED\u63A5\u5DF2\u6709\u5BF9\u8BDD");
|
|
2061
2190
|
cmd.action(async (opts) => {
|
|
2062
2191
|
if (opts.json || opts.message) {
|
|
2063
2192
|
if (!opts.message) {
|
|
@@ -2068,10 +2197,10 @@ function createChatCommand() {
|
|
|
2068
2197
|
}
|
|
2069
2198
|
process.exit(1);
|
|
2070
2199
|
}
|
|
2071
|
-
await chatSync(opts.message, !!opts.json);
|
|
2200
|
+
await chatSync(opts.message, !!opts.json, opts.sessionId);
|
|
2072
2201
|
return;
|
|
2073
2202
|
}
|
|
2074
|
-
render3(/* @__PURE__ */ React3.createElement(ChatApp,
|
|
2203
|
+
render3(/* @__PURE__ */ React3.createElement(ChatApp, { sessionId: opts.sessionId }));
|
|
2075
2204
|
});
|
|
2076
2205
|
return cmd;
|
|
2077
2206
|
}
|
|
@@ -2089,10 +2218,11 @@ function getAgeVersion() {
|
|
|
2089
2218
|
}
|
|
2090
2219
|
|
|
2091
2220
|
// src/index.ts
|
|
2092
|
-
var program = new
|
|
2221
|
+
var program = new Command15();
|
|
2093
2222
|
program.name("maidang").description("\u4E86\u89E3\u9EA6\u5F53 - \u4E00\u4E2A AI \u65F6\u4EE3\u7684\u63A2\u7D22\u8005").version(getAgeVersion(), "-v, --version", "\u663E\u793A\u7248\u672C\u53F7");
|
|
2094
2223
|
var careerCmd = createCareerCommand();
|
|
2095
2224
|
var catCmd = createCatCommand();
|
|
2225
|
+
var createCmd = createCreateCommand();
|
|
2096
2226
|
var postsCmd = createPostsCommand();
|
|
2097
2227
|
var songsCmd = createSongsCommand();
|
|
2098
2228
|
var linksCmd = createLinksCommand();
|
|
@@ -2105,6 +2235,7 @@ var whoamiCmd = createWhoAmICommand();
|
|
|
2105
2235
|
var chatCmd = createChatCommand();
|
|
2106
2236
|
program.addCommand(careerCmd);
|
|
2107
2237
|
program.addCommand(catCmd);
|
|
2238
|
+
program.addCommand(createCmd);
|
|
2108
2239
|
program.addCommand(postsCmd);
|
|
2109
2240
|
program.addCommand(songsCmd);
|
|
2110
2241
|
program.addCommand(linksCmd);
|