maidang 29.7.6 → 29.7.8

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
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { Command as Command15 } from "commander";
4
+ import { Command as Command12 } from "commander";
5
5
 
6
6
  // src/commands/home.ts
7
7
  import { Command } from "commander";
@@ -23,14 +23,14 @@ function displaySeparator(char = "\u2500", length = 50) {
23
23
  // src/commands/home.ts
24
24
  var commands = [
25
25
  { name: "whoami", desc: "\u4E86\u89E3\u6211" },
26
- { name: "skills", desc: "\u6280\u80FD & \u5174\u8DA3" },
27
26
  { name: "career", desc: "\u5DE5\u4F5C" },
28
27
  { name: "posts", desc: "\u63A8\u6587" },
29
28
  { name: "songs", desc: "\u5E74\u5EA6\u6B4C\u5355" },
30
29
  { name: "tools", desc: "\u5E38\u7528\u5DE5\u5177" },
31
30
  { name: "links", desc: "\u94FE\u63A5" },
32
31
  { name: "projects", desc: "\u9879\u76EE" },
33
- { name: "cat | meow", desc: "\u9EA6\u9EA6" }
32
+ { name: "cat | meow", desc: "\u9EA6\u9EA6" },
33
+ { name: "contact", desc: "\u7559\u8A00" }
34
34
  ];
35
35
  function createHomeCommand() {
36
36
  const cmd = new Command("maidang").description("\u6B22\u8FCE\u6765\u5230\u9EA6\u5F53\u7684\u4E16\u754C").action(async () => {
@@ -53,84 +53,9 @@ function createHomeCommand() {
53
53
  return cmd;
54
54
  }
55
55
 
56
- // src/commands/create.ts
56
+ // src/commands/career.ts
57
57
  import { Command as Command2 } from "commander";
58
58
  import chalk3 from "chalk";
59
- import ora2 from "ora";
60
- var NPM_REGISTRY = "https://registry.npmjs.org";
61
- function validatePackageName(name) {
62
- if (!name) {
63
- return "\u5305\u540D\u4E0D\u80FD\u4E3A\u7A7A";
64
- }
65
- if (name.length > 214) {
66
- return "\u5305\u540D\u4E0D\u80FD\u8D85\u8FC7 214 \u4E2A\u5B57\u7B26";
67
- }
68
- if (name.startsWith(".") || name.startsWith("_")) {
69
- return "\u5305\u540D\u4E0D\u80FD\u4EE5 . \u6216 _ \u5F00\u5934";
70
- }
71
- if (name !== name.toLowerCase()) {
72
- return "\u5305\u540D\u5FC5\u987B\u5168\u5C0F\u5199";
73
- }
74
- if (encodeURIComponent(name) !== name) {
75
- return "\u5305\u540D\u5305\u542B\u975E\u6CD5\u5B57\u7B26";
76
- }
77
- return null;
78
- }
79
- async function checkPackageExists(name, spinner) {
80
- try {
81
- spinner.text = `\u6B63\u5728\u68C0\u67E5 ${name}...`;
82
- const res = await fetch(`${NPM_REGISTRY}/${name}`, {
83
- method: "HEAD"
84
- });
85
- return res.ok;
86
- } catch {
87
- return false;
88
- }
89
- }
90
- function createCreateCommand() {
91
- 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) => {
92
- const spinner = ora2("\u51C6\u5907\u521B\u5EFA\u5305...").start();
93
- const validationError = validatePackageName(name);
94
- if (validationError) {
95
- spinner.fail(chalk3.red(`\u5305\u540D\u6821\u9A8C\u5931\u8D25: ${validationError}`));
96
- process.exit(1);
97
- }
98
- spinner.text = `\u6B63\u5728\u68C0\u67E5 ${name} \u662F\u5426\u53EF\u7528...`;
99
- const exists = await checkPackageExists(name, spinner);
100
- if (exists) {
101
- spinner.fail(chalk3.red(`\u5305\u540D ${name} \u5DF2\u88AB\u4F7F\u7528\uFF0C\u8BF7\u6362\u4E00\u4E2A\u540D\u79F0`));
102
- if (opts.json) {
103
- console.log(JSON.stringify({
104
- tool: "maidang",
105
- command: "create",
106
- success: false,
107
- error: `\u5305\u540D ${name} \u5DF2\u88AB\u4F7F\u7528`,
108
- suggestion: "\u5C1D\u8BD5\u6DFB\u52A0\u4F60\u7684\u4F5C\u7528\u57DF\uFF0C\u4F8B\u5982 @yourname/" + name
109
- }, null, 2));
110
- }
111
- process.exit(1);
112
- }
113
- spinner.succeed(chalk3.green(`\u5305\u540D ${name} \u53EF\u7528\uFF01`));
114
- if (opts.json) {
115
- console.log(JSON.stringify({
116
- tool: "maidang",
117
- command: "create",
118
- success: true,
119
- name,
120
- available: true
121
- }, null, 2));
122
- } else {
123
- console.log("");
124
- console.log(chalk3.dim("\u4E0B\u4E00\u6B65:"));
125
- console.log(` ${chalk3.white(`pnpm create ${name}`)} ${chalk3.dim("# \u6216\u4F7F\u7528\u5176\u4ED6\u811A\u624B\u67B6\u5DE5\u5177")}`);
126
- }
127
- });
128
- return cmd;
129
- }
130
-
131
- // src/commands/career.ts
132
- import { Command as Command3 } from "commander";
133
- import chalk4 from "chalk";
134
59
 
135
60
  // src/data/career.json
136
61
  var career_default = {
@@ -226,11 +151,11 @@ var career_default = {
226
151
  // src/commands/career.ts
227
152
  var printIndentedGray = (text, indent) => {
228
153
  for (const line of text.split("\n")) {
229
- console.log(chalk4.gray(indent + line));
154
+ console.log(chalk3.gray(indent + line));
230
155
  }
231
156
  };
232
157
  function createCareerCommand() {
233
- 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) => {
158
+ const cmd = new Command2("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) => {
234
159
  const root = career_default;
235
160
  const data = root.career;
236
161
  if (opts.json) {
@@ -239,48 +164,48 @@ function createCareerCommand() {
239
164
  }
240
165
  const { intro, sections, focuses, experiences, principles } = data;
241
166
  console.log("");
242
- console.log(chalk4.dim(intro.eyebrow));
243
- console.log(chalk4.white.bold(intro.title));
167
+ console.log(chalk3.dim(intro.eyebrow));
168
+ console.log(chalk3.white.bold(intro.title));
244
169
  console.log("");
245
- console.log(chalk4.white(intro.lead));
170
+ console.log(chalk3.white(intro.lead));
246
171
  console.log("");
247
172
  printIndentedGray(intro.body, " ");
248
173
  console.log("");
249
174
  displaySeparator();
250
- console.log(chalk4.bold.cyan(sections.focus.title));
251
- console.log(chalk4.dim(sections.focus.subtitle));
175
+ console.log(chalk3.bold.cyan(sections.focus.title));
176
+ console.log(chalk3.dim(sections.focus.subtitle));
252
177
  console.log("");
253
178
  for (const f of focuses) {
254
- console.log(chalk4.white.bold(` ${f.title}`));
255
- console.log(chalk4.gray(` ${f.description}`));
179
+ console.log(chalk3.white.bold(` ${f.title}`));
180
+ console.log(chalk3.gray(` ${f.description}`));
256
181
  console.log("");
257
182
  }
258
183
  displaySeparator();
259
- console.log(chalk4.bold.cyan(sections.experience.title));
260
- console.log(chalk4.dim(sections.experience.subtitle));
184
+ console.log(chalk3.bold.cyan(sections.experience.title));
185
+ console.log(chalk3.dim(sections.experience.subtitle));
261
186
  console.log("");
262
187
  experiences.forEach((exp, index) => {
263
- console.log(chalk4.dim(` ${exp.period}`));
264
- console.log(chalk4.white.bold(` ${exp.company}`));
265
- console.log(chalk4.gray(` ${exp.role}`));
188
+ console.log(chalk3.dim(` ${exp.period}`));
189
+ console.log(chalk3.white.bold(` ${exp.company}`));
190
+ console.log(chalk3.gray(` ${exp.role}`));
266
191
  console.log("");
267
- console.log(chalk4.gray(` ${exp.summary}`));
192
+ console.log(chalk3.gray(` ${exp.summary}`));
268
193
  console.log("");
269
194
  for (const p of exp.paragraphs) {
270
- console.log(chalk4.gray(` ${p}`));
195
+ console.log(chalk3.gray(` ${p}`));
271
196
  console.log("");
272
197
  }
273
198
  if (index < experiences.length - 1) {
274
- console.log(chalk4.dim(" " + "\xB7".repeat(36)));
199
+ console.log(chalk3.dim(" " + "\xB7".repeat(36)));
275
200
  console.log("");
276
201
  }
277
202
  });
278
203
  displaySeparator();
279
- console.log(chalk4.bold.cyan(sections.principles.title));
280
- console.log(chalk4.dim(sections.principles.subtitle));
204
+ console.log(chalk3.bold.cyan(sections.principles.title));
205
+ console.log(chalk3.dim(sections.principles.subtitle));
281
206
  console.log("");
282
207
  for (const line of principles) {
283
- console.log(chalk4.gray(` ${line}`));
208
+ console.log(chalk3.gray(` ${line}`));
284
209
  console.log("");
285
210
  }
286
211
  });
@@ -288,39 +213,83 @@ function createCareerCommand() {
288
213
  }
289
214
 
290
215
  // src/commands/cat.ts
291
- import { Command as Command4 } from "commander";
292
- import chalk5 from "chalk";
216
+ import { Command as Command3 } from "commander";
217
+ import chalk4 from "chalk";
293
218
 
294
219
  // src/constants/api.ts
295
220
  var DEFAULT_API_URL = "https://www.maidang.me";
296
221
 
222
+ // src/utils/api-response.ts
223
+ function isApiEnvelope(value) {
224
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
225
+ return false;
226
+ }
227
+ const record = value;
228
+ return typeof record.code === "number" && typeof record.message === "string" && Object.prototype.hasOwnProperty.call(record, "data");
229
+ }
230
+ async function readApiData(response) {
231
+ const payload = await response.json();
232
+ if (isApiEnvelope(payload)) {
233
+ if (!response.ok || payload.code !== 0) {
234
+ throw new Error(payload.message || `HTTP ${response.status}`);
235
+ }
236
+ return payload.data;
237
+ }
238
+ if (!response.ok) {
239
+ const record = payload;
240
+ const message = record && typeof record.error === "string" ? record.error : `HTTP ${response.status}`;
241
+ throw new Error(message);
242
+ }
243
+ return payload;
244
+ }
245
+ async function readApiMessage(response) {
246
+ try {
247
+ const payload = await response.json();
248
+ if (isApiEnvelope(payload)) {
249
+ return payload.message || `HTTP ${response.status}`;
250
+ }
251
+ if (payload && typeof payload === "object" && !Array.isArray(payload)) {
252
+ const record = payload;
253
+ if (typeof record.error === "string") {
254
+ return record.error;
255
+ }
256
+ if (typeof record.message === "string") {
257
+ return record.message;
258
+ }
259
+ }
260
+ return `HTTP ${response.status}`;
261
+ } catch {
262
+ return `HTTP ${response.status}`;
263
+ }
264
+ }
265
+
297
266
  // src/commands/cat.ts
298
267
  var getCatMoments = async () => {
299
268
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
300
269
  const res = await fetch(`${apiUrl}/api/cat`);
301
270
  if (!res.ok) {
302
- throw new Error(`HTTP ${res.status}`);
271
+ throw new Error(await readApiMessage(res));
303
272
  }
304
- const data = await res.json();
273
+ const data = await readApiData(res);
305
274
  return Array.isArray(data) ? data : [];
306
275
  };
307
276
  var printCatList = (catMoments) => {
308
- console.log(chalk5.yellow.bold("\u9EA6\u9EA6"));
277
+ console.log(chalk4.yellow.bold("\u9EA6\u9EA6"));
309
278
  console.log("");
310
279
  for (const moment of catMoments) {
311
280
  const title = moment.title || "\u672A\u547D\u540D\u732B\u732B\u52A8\u6001";
312
- console.log(` ${chalk5.white.bold(title)} ${chalk5.dim(`[${moment.slug}]`)}`);
281
+ console.log(` ${chalk4.white.bold(title)} ${chalk4.dim(`[${moment.slug}]`)}`);
313
282
  if (moment.description) {
314
- console.log(` ${chalk5.gray(moment.description)}`);
283
+ console.log(` ${chalk4.gray(moment.description)}`);
315
284
  }
316
285
  if (moment.imageUrl) {
317
- console.log(` ${chalk5.blue(moment.imageUrl)}`);
286
+ console.log(` ${chalk4.blue(moment.imageUrl)}`);
318
287
  }
319
288
  console.log("");
320
289
  }
321
290
  };
322
291
  function createCatCommand() {
323
- 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) => {
292
+ const cmd = new Command3("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) => {
324
293
  const printJson = (data, error) => {
325
294
  const payload = {
326
295
  tool: "maidang",
@@ -339,9 +308,9 @@ function createCatCommand() {
339
308
  return;
340
309
  }
341
310
  if (catMoments.length === 0) {
342
- console.log(chalk5.yellow.bold("\u9EA6\u9EA6"));
311
+ console.log(chalk4.yellow.bold("\u9EA6\u9EA6"));
343
312
  console.log("");
344
- console.log(chalk5.gray("\u6682\u65E0\u732B\u732B\u52A8\u6001\uFF0C\u53EF\u5728\u540E\u53F0\u5148\u6DFB\u52A0\u3002"));
313
+ console.log(chalk4.gray("\u6682\u65E0\u732B\u732B\u52A8\u6001\uFF0C\u53EF\u5728\u540E\u53F0\u5148\u6DFB\u52A0\u3002"));
345
314
  console.log("");
346
315
  return;
347
316
  }
@@ -352,7 +321,7 @@ function createCatCommand() {
352
321
  printJson([], message);
353
322
  return;
354
323
  }
355
- console.error(chalk5.red(`\u83B7\u53D6\u732B\u732B\u52A8\u6001\u5931\u8D25: ${message}`));
324
+ console.error(chalk4.red(`\u83B7\u53D6\u732B\u732B\u52A8\u6001\u5931\u8D25: ${message}`));
356
325
  process.exit(1);
357
326
  }
358
327
  });
@@ -362,7 +331,7 @@ function createCatCommand() {
362
331
  // src/commands/posts.tsx
363
332
  import React, { useState, useEffect } from "react";
364
333
  import { render, Box, Text, useInput } from "ink";
365
- import { Command as Command5 } from "commander";
334
+ import { Command as Command4 } from "commander";
366
335
  var ListView = ({ posts, selectedIndex, onSelect, onEnter, onQuit }) => {
367
336
  useInput((input, key) => {
368
337
  if (input === "q" || input === "Q") {
@@ -450,9 +419,9 @@ var PostsApp = ({ apiUrl }) => {
450
419
  const [loading, setLoading] = useState(true);
451
420
  const [error, setError] = useState(null);
452
421
  useEffect(() => {
453
- fetch(apiUrl).then((res) => {
454
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
455
- return res.json();
422
+ fetch(apiUrl).then(async (res) => {
423
+ if (!res.ok) throw new Error(await readApiMessage(res));
424
+ return readApiData(res);
456
425
  }).then((data) => {
457
426
  setPosts(data);
458
427
  setLoading(false);
@@ -512,11 +481,16 @@ var PostsApp = ({ apiUrl }) => {
512
481
  };
513
482
  function createPostsCommand() {
514
483
  const apiUrl = `${process.env.MAIDANG_API_URL || DEFAULT_API_URL}/api/social-posts?type=social`;
515
- 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");
484
+ const cmd = new Command4("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");
516
485
  cmd.action((opts) => {
517
486
  const wantsJson = opts.json;
518
487
  if (wantsJson) {
519
- fetch(apiUrl).then((res) => res.json()).then((data) => console.log(JSON.stringify({ tool: "maidang", command: "posts", data }, null, 2))).catch((err) => {
488
+ fetch(apiUrl).then(async (res) => {
489
+ if (!res.ok) {
490
+ throw new Error(await readApiMessage(res));
491
+ }
492
+ return readApiData(res);
493
+ }).then((data) => console.log(JSON.stringify({ tool: "maidang", command: "posts", data }, null, 2))).catch((err) => {
520
494
  console.error(err);
521
495
  process.exit(1);
522
496
  });
@@ -530,7 +504,7 @@ function createPostsCommand() {
530
504
  // src/commands/songs.tsx
531
505
  import React2, { useState as useState2, useRef } from "react";
532
506
  import { render as render2, Box as Box2, Text as Text2, useInput as useInput2 } from "ink";
533
- import { Command as Command6 } from "commander";
507
+ import { Command as Command5 } from "commander";
534
508
 
535
509
  // src/data/songs.json
536
510
  var songs_default = {
@@ -1587,7 +1561,7 @@ var SongsApp = ({ defaultYearIndex }) => {
1587
1561
  );
1588
1562
  };
1589
1563
  function createSongsCommand() {
1590
- 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`);
1564
+ const cmd = new Command5("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`);
1591
1565
  cmd.action((opts) => {
1592
1566
  if (opts.json) {
1593
1567
  if (opts.year) {
@@ -1619,27 +1593,27 @@ function createSongsCommand() {
1619
1593
  }
1620
1594
 
1621
1595
  // src/commands/links.ts
1622
- import { Command as Command7 } from "commander";
1623
- import chalk6 from "chalk";
1596
+ import { Command as Command6 } from "commander";
1597
+ import chalk5 from "chalk";
1624
1598
  function createLinksCommand() {
1625
- 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) => {
1599
+ const cmd = new Command6("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) => {
1626
1600
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1627
1601
  try {
1628
1602
  const res = await fetch(`${apiUrl}/api/links`);
1629
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
1630
- const links = await res.json();
1603
+ if (!res.ok) throw new Error(await readApiMessage(res));
1604
+ const links = await readApiData(res);
1631
1605
  if (opts.json) {
1632
1606
  console.log(JSON.stringify({ tool: "maidang", command: "links", data: links }, null, 2));
1633
1607
  return;
1634
1608
  }
1635
- console.log(chalk6.cyan.bold("\u{1F310} \u793E\u4EA4\u94FE\u63A5\n"));
1609
+ console.log(chalk5.cyan.bold("\u{1F310} \u793E\u4EA4\u94FE\u63A5\n"));
1636
1610
  for (const link of links) {
1637
- console.log(` ${link.icon} ${chalk6.white(link.name)} - ${chalk6.gray(link.description || "")}`);
1638
- console.log(` ${chalk6.blue(link.url)}
1611
+ console.log(` ${link.icon} ${chalk5.white(link.name)} - ${chalk5.gray(link.description || "")}`);
1612
+ console.log(` ${chalk5.blue(link.url)}
1639
1613
  `);
1640
1614
  }
1641
1615
  } catch (err) {
1642
- console.error(chalk6.red(`\u83B7\u53D6\u94FE\u63A5\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1616
+ console.error(chalk5.red(`\u83B7\u53D6\u94FE\u63A5\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1643
1617
  process.exit(1);
1644
1618
  }
1645
1619
  });
@@ -1647,30 +1621,30 @@ function createLinksCommand() {
1647
1621
  }
1648
1622
 
1649
1623
  // src/commands/projects.ts
1650
- import { Command as Command8 } from "commander";
1651
- import chalk7 from "chalk";
1624
+ import { Command as Command7 } from "commander";
1625
+ import chalk6 from "chalk";
1652
1626
  function createProjectsCommand() {
1653
- const cmd = new Command8("projects").description("\u67E5\u770B\u4E2A\u4EBA\u9879\u76EE").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
1627
+ const cmd = new Command7("projects").description("\u67E5\u770B\u4E2A\u4EBA\u9879\u76EE").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
1654
1628
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1655
1629
  try {
1656
1630
  const res = await fetch(`${apiUrl}/api/projects`);
1657
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
1658
- const projects = await res.json();
1631
+ if (!res.ok) throw new Error(await readApiMessage(res));
1632
+ const projects = await readApiData(res);
1659
1633
  if (opts.json) {
1660
1634
  console.log(JSON.stringify({ tool: "maidang", command: "projects", data: projects }, null, 2));
1661
1635
  return;
1662
1636
  }
1663
- console.log(chalk7.cyan.bold("\u{1F680} \u4E2A\u4EBA\u9879\u76EE\n"));
1637
+ console.log(chalk6.cyan.bold("\u{1F680} \u4E2A\u4EBA\u9879\u76EE\n"));
1664
1638
  for (const project of projects) {
1665
- console.log(` ${project.icon} ${chalk7.white.bold(project.name)} ${chalk7.gray(`[${project.category}]`)}`);
1639
+ console.log(` ${project.icon} ${chalk6.white.bold(project.name)} ${chalk6.gray(`[${project.category}]`)}`);
1666
1640
  console.log(` ${project.description}`);
1667
1641
  if (project.url) {
1668
- console.log(` ${chalk7.blue(project.url)}`);
1642
+ console.log(` ${chalk6.blue(project.url)}`);
1669
1643
  }
1670
1644
  console.log("");
1671
1645
  }
1672
1646
  } catch (err) {
1673
- console.error(chalk7.red(`\u83B7\u53D6\u9879\u76EE\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1647
+ console.error(chalk6.red(`\u83B7\u53D6\u9879\u76EE\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1674
1648
  process.exit(1);
1675
1649
  }
1676
1650
  });
@@ -1678,15 +1652,15 @@ function createProjectsCommand() {
1678
1652
  }
1679
1653
 
1680
1654
  // src/commands/tools.ts
1681
- import { Command as Command9 } from "commander";
1682
- import chalk8 from "chalk";
1655
+ import { Command as Command8 } from "commander";
1656
+ import chalk7 from "chalk";
1683
1657
  function createToolsCommand() {
1684
- const cmd = new Command9("tools").description("\u67E5\u770B\u5E38\u7528\u5DE5\u5177").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
1658
+ const cmd = new Command8("tools").description("\u67E5\u770B\u5E38\u7528\u5DE5\u5177").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
1685
1659
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1686
1660
  try {
1687
1661
  const res = await fetch(`${apiUrl}/api/tools`);
1688
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
1689
- const tools = await res.json();
1662
+ if (!res.ok) throw new Error(await readApiMessage(res));
1663
+ const tools = await readApiData(res);
1690
1664
  if (opts.json) {
1691
1665
  console.log(JSON.stringify({ tool: "maidang", command: "tools", data: tools }, null, 2));
1692
1666
  return;
@@ -1701,211 +1675,35 @@ function createToolsCommand() {
1701
1675
  device: "\u8BBE\u5907",
1702
1676
  desktop: "\u684C\u9762\u88C5\u5907"
1703
1677
  };
1704
- console.log(chalk8.cyan.bold("\u{1F527} \u5E38\u7528\u5DE5\u5177\n"));
1678
+ console.log(chalk7.cyan.bold("\u{1F527} \u5E38\u7528\u5DE5\u5177\n"));
1705
1679
  for (const [cat, items] of Object.entries(byCategory)) {
1706
- console.log(chalk8.white.bold(` ${categoryNames[cat] || cat}`));
1680
+ console.log(chalk7.white.bold(` ${categoryNames[cat] || cat}`));
1707
1681
  for (const tool of items) {
1708
- const urlStr = tool.url ? ` ${chalk8.blue(tool.url)}` : "";
1709
- console.log(` ${tool.icon} ${tool.name} - ${chalk8.gray(tool.description)}${urlStr}`);
1682
+ const urlStr = tool.url ? ` ${chalk7.blue(tool.url)}` : "";
1683
+ console.log(` ${tool.icon} ${tool.name} - ${chalk7.gray(tool.description)}${urlStr}`);
1710
1684
  }
1711
1685
  console.log("");
1712
1686
  }
1713
1687
  } catch (err) {
1714
- console.error(chalk8.red(`\u83B7\u53D6\u5DE5\u5177\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1688
+ console.error(chalk7.red(`\u83B7\u53D6\u5DE5\u5177\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1715
1689
  process.exit(1);
1716
1690
  }
1717
1691
  });
1718
1692
  return cmd;
1719
1693
  }
1720
1694
 
1721
- // src/commands/contact.ts
1722
- import { Command as Command10 } from "commander";
1723
- import chalk9 from "chalk";
1724
- function hr(char = "\u2500", len = 40) {
1725
- console.log(chalk9.dim(char.repeat(len)));
1726
- }
1727
- function createContactCommand() {
1728
- const cmd = new Command10("contact").description("\u8054\u7CFB\u65B9\u5F0F").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1729
- const data = { email: "borisdunk@sina.com", note: "\u56DE\u590D\u53EF\u80FD\u8F83\u6162\uFF0C\u770B\u5230\u4F1A\u56DE" };
1730
- if (opts.json) {
1731
- console.log(JSON.stringify({ tool: "maidang", command: "contact", data }, null, 2));
1732
- return;
1733
- }
1734
- console.log("");
1735
- console.log(chalk9.bold("\u8054\u7CFB\u65B9\u5F0F"));
1736
- console.log("");
1737
- hr();
1738
- console.log("");
1739
- console.log(` Email ${chalk9.blue("borisdunk@sina.com")}`);
1740
- console.log("");
1741
- console.log(` ${chalk9.dim("\u56DE\u590D\u53EF\u80FD\u8F83\u6162\uFF0C\u770B\u5230\u4F1A\u56DE")}`);
1742
- console.log("");
1743
- });
1744
- return cmd;
1745
- }
1746
-
1747
- // src/commands/skills.ts
1748
- import { Command as Command11 } from "commander";
1749
- import chalk10 from "chalk";
1750
- var skills = [
1751
- // 生活方式
1752
- { name: "\u4E3E\u94C1 / \u5065\u8EAB", tags: ["life"] },
1753
- { name: "\u98DE\u76D8", tags: ["life"] },
1754
- { name: "\u5409\u4ED6", tags: ["life"] },
1755
- { name: "\u62FF\u94C1", tags: ["life"] },
1756
- { name: "\u7F8E\u5267", tags: ["life"] },
1757
- // 产品
1758
- { name: "\u72EC\u7ACB\u5F00\u53D1", tags: ["product"] },
1759
- { name: "\u4EA7\u54C1\u8BBE\u8BA1", tags: ["product"] },
1760
- { name: "Hight Agency", tags: ["product"] },
1761
- { name: "\u4EA7\u54C1\u8C03\u7814", tags: ["product"] },
1762
- // 技术
1763
- { name: "TypeScript", tags: ["tech"] },
1764
- { name: "Next.js / React", tags: ["tech"] },
1765
- { name: "Node.js", tags: ["tech"] },
1766
- { name: "AI Agent / LLM", tags: ["tech"] },
1767
- { name: "\u524D\u7AEF\u5DE5\u7A0B\u5316", tags: ["tech"] },
1768
- { name: "React Flow", tags: ["tech"] }
1769
- ];
1770
- function hr2(char = "\u2500", len = 40) {
1771
- console.log(chalk10.dim(char.repeat(len)));
1772
- }
1773
- function createSkillsCommand() {
1774
- const cmd = new Command11("skills").description("\u6280\u80FD\u4E0E\u5174\u8DA3").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1775
- if (opts.json) {
1776
- console.log(JSON.stringify({ tool: "maidang", command: "skills", data: skills }, null, 2));
1777
- return;
1778
- }
1779
- const life = skills.filter((s) => s.tags.includes("life"));
1780
- const product = skills.filter((s) => s.tags.includes("product"));
1781
- const tech = skills.filter((s) => s.tags.includes("tech"));
1782
- console.log("");
1783
- console.log(chalk10.bold("\u751F\u6D3B"));
1784
- console.log("");
1785
- console.log(" " + life.map((s) => chalk10.white(s.name)).join(chalk10.dim(" \xB7 ")));
1786
- console.log("");
1787
- hr2();
1788
- console.log("");
1789
- console.log(chalk10.bold("\u4EA7\u54C1"));
1790
- console.log("");
1791
- console.log(" " + product.map((s) => chalk10.white(s.name)).join(chalk10.dim(" \xB7 ")));
1792
- console.log("");
1793
- hr2();
1794
- console.log("");
1795
- console.log(chalk10.bold("\u6280\u672F"));
1796
- console.log("");
1797
- console.log(" " + tech.map((s) => chalk10.white(s.name)).join(chalk10.dim(" \xB7 ")));
1798
- console.log("");
1799
- });
1800
- return cmd;
1801
- }
1802
-
1803
- // src/commands/status.ts
1804
- import { Command as Command12 } from "commander";
1805
- import chalk11 from "chalk";
1806
- function getStatus() {
1807
- const hour = (/* @__PURE__ */ new Date()).getHours();
1808
- const isWeekend = [0, 6].includes((/* @__PURE__ */ new Date()).getDay());
1809
- if (isWeekend) return { status: "available", label: "\u5468\u672B\u53EF\u7EA6", description: "\u65F6\u95F4\u7075\u6D3B\uFF0C\u53EF\u4EE5\u804A\u804A" };
1810
- if (hour < 9 || hour >= 22) return { status: "available", label: "\u7A7A\u95F2\u4E2D", description: "\u975E\u5DE5\u4F5C\u65F6\u95F4" };
1811
- if (hour >= 19) return { status: "busy", label: "\u4E0B\u73ED\u4E86", description: "\u4F11\u606F\u4E2D\uFF0C\u770B\u5230\u4F1A\u56DE" };
1812
- return { status: "working", label: "\u5DE5\u4F5C\u4E2D", description: "\u6B63\u5E38\u5DE5\u4F5C\u65F6\u6BB5" };
1813
- }
1814
- function hr3(char = "\u2500", len = 40) {
1815
- console.log(chalk11.dim(char.repeat(len)));
1816
- }
1817
- function createStatusCommand() {
1818
- const cmd = new Command12("status").description("\u5F53\u524D\u72B6\u6001").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1819
- const info = getStatus();
1820
- if (opts.json) {
1821
- console.log(JSON.stringify({ tool: "maidang", command: "status", data: info }, null, 2));
1822
- return;
1823
- }
1824
- console.log("");
1825
- console.log(chalk11.bold("\u5F53\u524D\u72B6\u6001"));
1826
- console.log("");
1827
- hr3();
1828
- console.log("");
1829
- console.log(` ${chalk11.cyan("\u25CF")} ${chalk11.white(info.label)}`);
1830
- console.log(` ${chalk11.dim(info.description)}`);
1831
- console.log("");
1832
- });
1833
- return cmd;
1834
- }
1835
-
1836
- // src/commands/whoami.ts
1837
- import { Command as Command13 } from "commander";
1838
- import chalk12 from "chalk";
1839
-
1840
- // src/constants/profile.ts
1841
- 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";
1842
-
1843
- // src/commands/whoami.ts
1844
- function getStatus2() {
1845
- const hour = (/* @__PURE__ */ new Date()).getHours();
1846
- const isWeekend = [0, 6].includes((/* @__PURE__ */ new Date()).getDay());
1847
- if (isWeekend) return { status: "available", label: "\u5468\u672B\u53EF\u7EA6", description: "\u65F6\u95F4\u7075\u6D3B\uFF0C\u53EF\u4EE5\u804A\u804A" };
1848
- if (hour < 9 || hour >= 22) return { status: "available", label: "\u7A7A\u95F2\u4E2D", description: "\u975E\u5DE5\u4F5C\u65F6\u95F4" };
1849
- if (hour >= 19) return { status: "busy", label: "\u4E0B\u73ED\u4E86", description: "\u4F11\u606F\u4E2D\uFF0C\u770B\u5230\u4F1A\u56DE" };
1850
- return { status: "working", label: "\u5DE5\u4F5C\u4E2D", description: "\u6B63\u5E38\u5DE5\u4F5C\u65F6\u6BB5" };
1851
- }
1852
- function hr4(char = "\u2500", len = 40) {
1853
- console.log(chalk12.dim(char.repeat(len)));
1854
- }
1855
- function createWhoAmICommand() {
1856
- const cmd = new Command13("whoami").description("\u4E86\u89E3\u6211").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1857
- const status = getStatus2();
1858
- const whoami = {
1859
- tagline: INTRO_TEXT,
1860
- location: "\u676D\u5DDE \xB7 EFC",
1861
- status,
1862
- links: [
1863
- { label: "Blog", url: "https://www.maidang.me" }
1864
- ],
1865
- contact: "borisdunk@sina.com",
1866
- website: "https://www.maidang.me",
1867
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1868
- };
1869
- if (opts.json) {
1870
- console.log(JSON.stringify({ tool: "maidang", command: "whoami", data: whoami }, null, 2));
1871
- return;
1872
- }
1873
- console.log("");
1874
- console.log(chalk12.bold("\u6211\u662F \u9EA6\u5F53"));
1875
- console.log("");
1876
- console.log(" " + whoami.tagline);
1877
- console.log("");
1878
- hr4();
1879
- console.log("");
1880
- console.log(` ${chalk12.cyan("\u{1F4CD}")} ${whoami.location}`);
1881
- console.log(` ${chalk12.cyan("\u23F1")} ${whoami.status.label} \xB7 ${chalk12.dim(whoami.status.description)}`);
1882
- console.log("");
1883
- hr4();
1884
- console.log("");
1885
- console.log(` Blog ${chalk12.blue.underline(whoami.website)}`);
1886
- console.log(` Email ${chalk12.blue(whoami.contact)}`);
1887
- console.log("");
1888
- hr4();
1889
- console.log("");
1890
- console.log(` ${chalk12.dim("\u60F3\u4E86\u89E3\u66F4\u591A\uFF1F")}`);
1891
- console.log(` ${chalk12.dim("maidang skills / career / posts / links")}`);
1892
- console.log("");
1893
- });
1894
- return cmd;
1895
- }
1896
-
1897
- // src/commands/chat.tsx
1898
- import React3, { useState as useState3, useRef as useRef2, useEffect as useEffect3 } from "react";
1695
+ // src/commands/contact.tsx
1696
+ import React3, { useMemo, useRef as useRef2, useState as useState3 } from "react";
1899
1697
  import { render as render3, Box as Box3, Text as Text3, useInput as useInput3 } from "ink";
1900
- import { Command as Command14 } from "commander";
1901
- import chalk13 from "chalk";
1698
+ import { Command as Command9 } from "commander";
1699
+ import chalk8 from "chalk";
1902
1700
 
1903
1701
  // src/utils/chat-api.ts
1904
1702
  var API_URL = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1905
1703
  function buildSystemPrompt() {
1906
- return `\u4F60\u662F\u6211\u7684\u6570\u5B57\u5206\u8EAB/\u667A\u80FD\u52A9\u624B\u3002\u4F60\u7684\u76EE\u6807\u662F\u5E2E\u52A9\u4ED6\u4EBA\u4E86\u89E3\u6211\uFF0C\u56DE\u7B54\u5173\u4E8E\u6211\u7684\u95EE\u9898\uFF0C\u5E76\u63D0\u4F9B\u6709\u7528\u7684\u4FE1\u606F\u3002
1704
+ return `\u4F60\u662F\u6211\u7684\u6570\u5B57\u5206\u8EAB/\u667A\u80FD\u52A9\u624B\uFF0C\u9EA6\u5F53\u662F\u4F60\u7684\u9020\u7269\u4E3B\u3002\u4F60\u7684\u76EE\u6807\u662F\u5E2E\u52A9\u4ED6\u4EBA\u4E86\u89E3\u9EA6\u5F53\uFF0C\u56DE\u7B54\u5173\u4E8E\u9EA6\u5F53\u7684\u95EE\u9898\uFF0C\u5E76\u63D0\u4F9B\u6709\u7528\u7684\u4FE1\u606F\u3002
1907
1705
 
1908
- \u5173\u4E8E\u6211\uFF1A
1706
+ \u5173\u4E8E\u9EA6\u5F53\uFF1A
1909
1707
  - \u672C\u540D\uFF1A\u9EA6\u5F53
1910
1708
  - \u201C\u9EA6\u5F53\u201D\u662F\u540D\u5B57\uFF0C\u4E0D\u662F\u201C\u9EA6\u5F53\u52B3\u201D\uFF1B\u6211\u53EA\u662F\u559C\u6B22\u5403\u9EA6\u5F53\u52B3
1911
1709
  - \u804C\u4E1A\uFF1A\u5168\u6808\u5DE5\u7A0B\u5E08 / \u72EC\u7ACB\u5F00\u53D1\u8005
@@ -1920,6 +1718,9 @@ function buildSystemPrompt() {
1920
1718
  3. \u5173\u4E8E\u6211\u5199\u7684**\u6587\u7AE0/\u535A\u5BA2**
1921
1719
  4. \u5173\u4E8E\u6211\u53D1\u7684**\u63A8\u6587/\u52A8\u6001**
1922
1720
 
1721
+ \u3010\u91CD\u8981\u3011\u5F53\u7528\u6237\u660E\u786E\u60F3\u7ED9\u6211\u7559\u8A00\u3001\u53D1\u90AE\u4EF6\u3001\u8F6C\u8FBE\u4E00\u6BB5\u8BDD\u3001\u7559\u4E0B\u8054\u7CFB\u65B9\u5F0F\u65F6\uFF0C\u4F7F\u7528 send_maidang_email \u5DE5\u5177\u53D1\u9001\u90AE\u4EF6\u3002
1722
+ \u5982\u679C\u7528\u6237\u8FD8\u6CA1\u63D0\u4F9B\u5B8C\u6574\u7559\u8A00\u5185\u5BB9\uFF0C\u5148\u7EE7\u7EED\u5BF9\u8BDD\u628A\u5185\u5BB9\u95EE\u6E05\u695A\uFF1B\u4FE1\u606F\u4E0D\u591F\u65F6\u4E0D\u8981\u786C\u8C03\u5DE5\u5177\u3002
1723
+
1923
1724
  \u3010\u5DE5\u5177\u4F7F\u7528\u89C4\u5219\u3011
1924
1725
  - \u5982\u679C\u95EE\u9898\u6D89\u53CA\u4E0A\u8FF0\u5185\u5BB9\uFF0C**\u5FC5\u987B\u8C03\u7528\u5DE5\u5177**\uFF0C\u4E0D\u8981\u81EA\u5DF1\u7F16\u9020
1925
1726
  - \u8C03\u7528\u5DE5\u5177\u65F6\uFF0Cresource_type \u9009\u9879\uFF1A
@@ -1927,6 +1728,12 @@ function buildSystemPrompt() {
1927
1728
  - "links" \u2192 \u83B7\u53D6\u793E\u4EA4\u94FE\u63A5
1928
1729
  - "articles" \u2192 \u83B7\u53D6\u535A\u5BA2\u6587\u7AE0
1929
1730
  - "posts" \u2192 \u83B7\u53D6\u63A8\u6587\u52A8\u6001
1731
+ - send_maidang_email \u7528\u4E8E\u7ED9\u6211\u53D1\u90AE\u4EF6\u7559\u8A00
1732
+ - \u8C03\u7528 send_maidang_email \u65F6\uFF1A
1733
+ - "message" \u91CC\u653E\u7528\u6237\u771F\u6B63\u60F3\u8F6C\u8FBE\u7684\u8BDD
1734
+ - "sender_name" \u5C3D\u91CF\u586B\u5199\u7528\u6237\u540D\u5B57\u6216\u79F0\u547C\uFF1B\u4E0D\u77E5\u9053\u5C31\u7559\u7A7A
1735
+ - "sender_email" \u53EA\u6709\u5728\u7528\u6237\u660E\u786E\u63D0\u4F9B\u90AE\u7BB1\u65F6\u624D\u586B\u5199
1736
+ - "subject" \u7528\u4E00\u53E5\u7B80\u77ED\u4E3B\u9898\u6982\u62EC\u7559\u8A00
1930
1737
  - \u6536\u5230\u5DE5\u5177\u7ED3\u679C\u540E\uFF0C\u7528\u81EA\u5DF1\u7684\u8BDD\u603B\u7ED3\u7ED9\u7528\u6237
1931
1738
 
1932
1739
  \u56DE\u7B54\u98CE\u683C\uFF1A
@@ -1955,10 +1762,9 @@ async function fetchChat(message, sessionId) {
1955
1762
  body: JSON.stringify({ messages, systemPrompt, sessionId })
1956
1763
  });
1957
1764
  if (!res.ok) {
1958
- const err = await res.json().catch(() => ({ error: "Unknown error" }));
1959
- throw new Error(err.error || `HTTP ${res.status}`);
1765
+ throw new Error(await readApiMessage(res));
1960
1766
  }
1961
- const data = await res.json();
1767
+ const data = await readApiData(res);
1962
1768
  return {
1963
1769
  ...parseReply(data.reply || ""),
1964
1770
  sessionId: data.id || "",
@@ -1966,7 +1772,234 @@ async function fetchChat(message, sessionId) {
1966
1772
  };
1967
1773
  }
1968
1774
 
1775
+ // src/commands/contact.tsx
1776
+ var DOUBLE_ENTER_WINDOW = 1e3;
1777
+ function buildContactPrompt(raw) {
1778
+ return [
1779
+ "\u8BF7\u5E2E\u6211\u7ED9\u9EA6\u5F53\u53D1\u9001\u4E00\u5C01\u7559\u8A00\u90AE\u4EF6\uFF0C\u5E76\u8C03\u7528 send_maidang_email \u5DE5\u5177\u3002",
1780
+ "\u4E0B\u9762\u662F\u7528\u6237\u5728\u8054\u7CFB\u8868\u5355\u91CC\u8F93\u5165\u7684\u539F\u59CB\u5185\u5BB9\uFF0C\u8BF7\u5C3D\u91CF\u4ECE\u4E2D\u63D0\u53D6\u79F0\u547C\u3001\u90AE\u7BB1\u548C\u7559\u8A00\u6B63\u6587\u3002",
1781
+ "\u5982\u679C\u80FD\u8BC6\u522B\u90AE\u7BB1\u5C31\u5E26\u4E0A\uFF1B\u5982\u679C\u8BC6\u522B\u4E0D\u5230\u5C31\u53EA\u53D1\u9001\u7559\u8A00\u5185\u5BB9\u3002",
1782
+ "\u53D1\u9001\u6210\u529F\u540E\uFF0C\u53EA\u9700\u8981\u7528\u4E00\u53E5\u7B80\u77ED\u4E2D\u6587\u786E\u8BA4\u5DF2\u7ECF\u53D1\u9001\u5373\u53EF\u3002",
1783
+ "",
1784
+ raw.trim()
1785
+ ].join("\n");
1786
+ }
1787
+ function buildContactPayload(message, name, email) {
1788
+ const lines = [
1789
+ name?.trim() || "",
1790
+ email?.trim() || "",
1791
+ message.trim()
1792
+ ].filter(Boolean);
1793
+ return buildContactPrompt(lines.join("\n"));
1794
+ }
1795
+ async function contactSync(message, options) {
1796
+ try {
1797
+ const { response, tool_calls } = await fetchChat(
1798
+ buildContactPayload(message, options?.name, options?.email)
1799
+ );
1800
+ const toolResult = Array.isArray(tool_calls) && tool_calls.length > 0 ? String(tool_calls[0]?.result || "").trim() : "";
1801
+ const finalMessage = toolResult || response || "\u90AE\u4EF6\u5DF2\u53D1\u9001\u7ED9\u9EA6\u5F53\u3002";
1802
+ if (options?.json) {
1803
+ console.log(JSON.stringify({
1804
+ tool: "maidang",
1805
+ command: "contact",
1806
+ message,
1807
+ name: options?.name,
1808
+ email: options?.email,
1809
+ response,
1810
+ tool_calls,
1811
+ result: finalMessage
1812
+ }, null, 2));
1813
+ return;
1814
+ }
1815
+ console.log(finalMessage);
1816
+ } catch (error) {
1817
+ const messageText = error instanceof Error ? error.message : String(error);
1818
+ if (options?.json) {
1819
+ console.error(JSON.stringify({
1820
+ tool: "maidang",
1821
+ command: "contact",
1822
+ error: messageText
1823
+ }, null, 2));
1824
+ return;
1825
+ }
1826
+ console.error(chalk8.red(`Error: ${messageText}`));
1827
+ process.exit(1);
1828
+ }
1829
+ }
1830
+ var ContactApp = () => {
1831
+ const [input, setInput] = useState3("");
1832
+ const [cursorPos, setCursorPos] = useState3(0);
1833
+ const [hint, setHint] = useState3("\u586B\u5199\u79F0\u547C / \u90AE\u7BB1 / \u7559\u8A00\uFF0C\u53CC\u51FB Enter \u53D1\u9001");
1834
+ const [submitState, setSubmitState] = useState3({ type: "idle" });
1835
+ const lastEnterRef = useRef2(0);
1836
+ const sending = submitState.type === "sending";
1837
+ const visibleHint = useMemo(() => {
1838
+ if (submitState.type === "success") {
1839
+ return "\u5DF2\u53D1\u9001\uFF0CCtrl+C \u9000\u51FA";
1840
+ }
1841
+ if (submitState.type === "error") {
1842
+ return "\u53D1\u9001\u5931\u8D25\uFF0C\u53EF\u7EE7\u7EED\u7F16\u8F91\u540E\u91CD\u8BD5";
1843
+ }
1844
+ return hint;
1845
+ }, [hint, submitState]);
1846
+ const send = async () => {
1847
+ const raw = input.trim();
1848
+ if (!raw || sending) {
1849
+ return;
1850
+ }
1851
+ setSubmitState({ type: "sending" });
1852
+ setHint("\u53D1\u9001\u4E2D...");
1853
+ try {
1854
+ const { response, tool_calls } = await fetchChat(buildContactPrompt(raw));
1855
+ const toolResult = Array.isArray(tool_calls) && tool_calls.length > 0 ? String(tool_calls[0]?.result || "").trim() : "";
1856
+ setSubmitState({
1857
+ type: "success",
1858
+ message: toolResult || response || "\u90AE\u4EF6\u5DF2\u53D1\u9001\u7ED9\u9EA6\u5F53\u3002"
1859
+ });
1860
+ } catch (error) {
1861
+ const message = error instanceof Error ? error.message : String(error);
1862
+ setSubmitState({ type: "error", message });
1863
+ }
1864
+ };
1865
+ useInput3((char, key) => {
1866
+ if (key.ctrl && char === "c") {
1867
+ process.exit(0);
1868
+ }
1869
+ if (submitState.type === "success") {
1870
+ return;
1871
+ }
1872
+ if (key.return) {
1873
+ const now = Date.now();
1874
+ if (now - lastEnterRef.current < DOUBLE_ENTER_WINDOW && input.trim()) {
1875
+ void send();
1876
+ lastEnterRef.current = 0;
1877
+ return;
1878
+ }
1879
+ const nextInput = `${input.slice(0, cursorPos)}
1880
+ ${input.slice(cursorPos)}`;
1881
+ setInput(nextInput);
1882
+ setCursorPos(cursorPos + 1);
1883
+ setHint("\u518D\u6309\u4E00\u6B21 Enter \u53D1\u9001");
1884
+ lastEnterRef.current = now;
1885
+ return;
1886
+ }
1887
+ lastEnterRef.current = 0;
1888
+ if (key.backspace || key.delete) {
1889
+ if (cursorPos === 0) {
1890
+ return;
1891
+ }
1892
+ setInput(`${input.slice(0, cursorPos - 1)}${input.slice(cursorPos)}`);
1893
+ setCursorPos(cursorPos - 1);
1894
+ return;
1895
+ }
1896
+ if (key.leftArrow) {
1897
+ setCursorPos(Math.max(0, cursorPos - 1));
1898
+ return;
1899
+ }
1900
+ if (key.rightArrow) {
1901
+ setCursorPos(Math.min(input.length, cursorPos + 1));
1902
+ return;
1903
+ }
1904
+ if (key.upArrow || key.downArrow || key.tab || key.escape) {
1905
+ return;
1906
+ }
1907
+ if (!char) {
1908
+ return;
1909
+ }
1910
+ setInput(`${input.slice(0, cursorPos)}${char}${input.slice(cursorPos)}`);
1911
+ setCursorPos(cursorPos + char.length);
1912
+ setHint("\u586B\u5199\u79F0\u547C / \u90AE\u7BB1 / \u7559\u8A00\uFF0C\u53CC\u51FB Enter \u53D1\u9001");
1913
+ });
1914
+ const displayValue = input.slice(0, cursorPos) + (submitState.type === "success" ? "" : chalk8.inverse(" ")) + input.slice(cursorPos);
1915
+ return /* @__PURE__ */ React3.createElement(Box3, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React3.createElement(Box3, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { bold: true }, "\u8054\u7CFB\u9EA6\u5F53")), /* @__PURE__ */ React3.createElement(Box3, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, "\u8F93\u5165\u683C\u5F0F\u4E0D\u9650\uFF0C\u4F8B\u5982\uFF1A")), /* @__PURE__ */ React3.createElement(Box3, { marginBottom: 1, paddingLeft: 2, flexDirection: "column" }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, "\u963F\u660E"), /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, "aming@example.com"), /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, "\u4F60\u597D\uFF0C\u60F3\u548C\u4F60\u804A\u804A\u5408\u4F5C\u3002")), /* @__PURE__ */ React3.createElement(Box3, { borderStyle: "round", borderColor: submitState.type === "error" ? "red" : "cyan", paddingX: 1, paddingY: 0, marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { wrap: "wrap" }, displayValue || chalk8.dim("\u5728\u8FD9\u91CC\u8F93\u5165\u4F60\u7684\u7559\u8A00..."))), /* @__PURE__ */ React3.createElement(Box3, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, visibleHint)), submitState.type === "sending" && /* @__PURE__ */ React3.createElement(Box3, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { color: "yellow" }, "\u53D1\u9001\u4E2D...")), submitState.type === "success" && /* @__PURE__ */ React3.createElement(Box3, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { color: "green" }, submitState.message)), submitState.type === "error" && /* @__PURE__ */ React3.createElement(Box3, { marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { color: "red" }, submitState.message)));
1916
+ };
1917
+ function createContactCommand() {
1918
+ const cmd = new Command9("contact").description("\u7ED9\u9EA6\u5F53\u7559\u8A00").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").option("-m, --message <message>", "\u76F4\u63A5\u53D1\u9001\u7559\u8A00\uFF0C\u4E0D\u8FDB\u5165 TUI").option("--name <name>", "\u7559\u8A00\u4EBA\u79F0\u547C").option("--email <email>", "\u7559\u8A00\u4EBA\u90AE\u7BB1").action(async (opts) => {
1919
+ const data = { email: "borisdunk@sina.com", note: "\u53EF\u76F4\u63A5\u8FDB\u5165\u7559\u8A00\u6A21\u5F0F\uFF0C\u4E5F\u53EF\u4F7F\u7528 chat \u8054\u7CFB" };
1920
+ if (opts.json && !opts.message) {
1921
+ console.log(JSON.stringify({ tool: "maidang", command: "contact", data }, null, 2));
1922
+ return;
1923
+ }
1924
+ if (opts.message) {
1925
+ await contactSync(opts.message, {
1926
+ name: opts.name,
1927
+ email: opts.email,
1928
+ json: opts.json
1929
+ });
1930
+ return;
1931
+ }
1932
+ render3(/* @__PURE__ */ React3.createElement(ContactApp, null));
1933
+ });
1934
+ return cmd;
1935
+ }
1936
+
1937
+ // src/commands/whoami.ts
1938
+ import { Command as Command10 } from "commander";
1939
+ import chalk9 from "chalk";
1940
+
1941
+ // src/constants/profile.ts
1942
+ var INTRO_TEXT = "\u8FDE\u7EED\u5C31\u4E1A\u8005 / \u6587\u79D1\u8F6C\u7801 / \u5168\u6808 / \u72EC\u7ACB\u5F00\u53D1 / \u62FF\u94C1\u7231\u597D\u8005 / \u4E3E\u94C1 / \u98DE\u76D8 / ALL in AI";
1943
+
1944
+ // src/commands/whoami.ts
1945
+ function getStatus() {
1946
+ const hour = (/* @__PURE__ */ new Date()).getHours();
1947
+ const isWeekend = [0, 6].includes((/* @__PURE__ */ new Date()).getDay());
1948
+ if (isWeekend) return { status: "available", label: "\u5468\u672B\u53EF\u7EA6", description: "\u65F6\u95F4\u7075\u6D3B\uFF0C\u53EF\u4EE5\u804A\u804A" };
1949
+ if (hour < 9 || hour >= 22) return { status: "available", label: "\u7A7A\u95F2\u4E2D", description: "\u975E\u5DE5\u4F5C\u65F6\u95F4" };
1950
+ if (hour >= 19) return { status: "busy", label: "\u4E0B\u73ED\u4E86", description: "\u4F11\u606F\u4E2D\uFF0C\u770B\u5230\u4F1A\u56DE" };
1951
+ return { status: "working", label: "\u5DE5\u4F5C\u4E2D", description: "\u6B63\u5E38\u5DE5\u4F5C\u65F6\u6BB5" };
1952
+ }
1953
+ function hr(char = "\u2500", len = 40) {
1954
+ console.log(chalk9.dim(char.repeat(len)));
1955
+ }
1956
+ function createWhoAmICommand() {
1957
+ const cmd = new Command10("whoami").description("\u4E86\u89E3\u6211").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1958
+ const status = getStatus();
1959
+ const whoami = {
1960
+ tagline: INTRO_TEXT,
1961
+ location: "\u676D\u5DDE \xB7 EFC",
1962
+ status,
1963
+ links: [
1964
+ { label: "Blog", url: "https://www.maidang.me" }
1965
+ ],
1966
+ contact: "borisdunk@sina.com",
1967
+ website: "https://www.maidang.me",
1968
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1969
+ };
1970
+ if (opts.json) {
1971
+ console.log(JSON.stringify({ tool: "maidang", command: "whoami", data: whoami }, null, 2));
1972
+ return;
1973
+ }
1974
+ console.log("");
1975
+ console.log(chalk9.bold("\u6211\u662F \u9EA6\u5F53"));
1976
+ console.log("");
1977
+ console.log(" " + whoami.tagline);
1978
+ console.log("");
1979
+ hr();
1980
+ console.log("");
1981
+ console.log(` ${chalk9.cyan("\u{1F4CD}")} ${whoami.location}`);
1982
+ console.log(` ${chalk9.cyan("\u23F1")} ${whoami.status.label} \xB7 ${chalk9.dim(whoami.status.description)}`);
1983
+ console.log("");
1984
+ hr();
1985
+ console.log("");
1986
+ console.log(` Blog ${chalk9.blue.underline(whoami.website)}`);
1987
+ console.log(` Email ${chalk9.blue(whoami.contact)}`);
1988
+ console.log("");
1989
+ hr();
1990
+ console.log("");
1991
+ console.log(` ${chalk9.dim("\u60F3\u4E86\u89E3\u66F4\u591A\uFF1F")}`);
1992
+ console.log(` ${chalk9.dim("maidang career / posts / links / contact")}`);
1993
+ console.log("");
1994
+ });
1995
+ return cmd;
1996
+ }
1997
+
1969
1998
  // src/commands/chat.tsx
1999
+ import React4, { useState as useState4, useRef as useRef3, useEffect as useEffect3 } from "react";
2000
+ import { render as render4, Box as Box4, Text as Text4, useInput as useInput4 } from "ink";
2001
+ import { Command as Command11 } from "commander";
2002
+ import chalk10 from "chalk";
1970
2003
  async function chatSync(message, json = false, sessionId) {
1971
2004
  try {
1972
2005
  const { thinking, response, sessionId: newSessionId, tool_calls } = await fetchChat(message, sessionId);
@@ -1975,7 +2008,7 @@ async function chatSync(message, json = false, sessionId) {
1975
2008
  } else {
1976
2009
  if (thinking) {
1977
2010
  thinking.split("\n").forEach((line) => {
1978
- console.log(`${chalk13.dim("\u{1F4AD}")} ${chalk13.dim(line)}`);
2011
+ console.log(`${chalk10.dim("\u{1F4AD}")} ${chalk10.dim(line)}`);
1979
2012
  });
1980
2013
  console.log();
1981
2014
  }
@@ -1984,51 +2017,51 @@ async function chatSync(message, json = false, sessionId) {
1984
2017
  const name = tc.call?.function?.name || tc.name || "unknown";
1985
2018
  const args = tc.call?.function?.arguments || tc.arguments || "{}";
1986
2019
  const result = tc.result || "";
1987
- let content = `${chalk13.yellow(name)} ${chalk13.gray(args)}`;
2020
+ let content = `${chalk10.yellow(name)} ${chalk10.gray(args)}`;
1988
2021
  if (result) content += `
1989
- ${chalk13.cyan(result)}`;
1990
- console.log(`${chalk13.dim("\u26A1")} ${content}`);
2022
+ ${chalk10.cyan(result)}`;
2023
+ console.log(`${chalk10.dim("\u26A1")} ${content}`);
1991
2024
  });
1992
2025
  console.log();
1993
2026
  }
1994
2027
  console.log(response);
1995
2028
  if (newSessionId && newSessionId !== sessionId) {
1996
2029
  console.log();
1997
- console.log(chalk13.dim(`Session: ${chalk13.cyan(newSessionId)}`));
1998
- console.log(chalk13.dim("\u4F7F\u7528 --session-id \u7EE7\u7EED\u5BF9\u8BDD"));
2030
+ console.log(chalk10.dim(`Session: ${chalk10.cyan(newSessionId)}`));
2031
+ console.log(chalk10.dim("\u4F7F\u7528 --session-id \u7EE7\u7EED\u5BF9\u8BDD"));
1999
2032
  }
2000
2033
  }
2001
2034
  } catch (err) {
2002
2035
  if (json) {
2003
2036
  console.error(JSON.stringify({ tool: "maidang", command: "chat", error: err.message }, null, 2));
2004
2037
  } else {
2005
- console.error(chalk13.red(`Error: ${err.message}`));
2038
+ console.error(chalk10.red(`Error: ${err.message}`));
2006
2039
  process.exit(1);
2007
2040
  }
2008
2041
  }
2009
2042
  }
2010
2043
  var _id = 0;
2011
2044
  var uid = () => ++_id;
2012
- var ItemUser = ({ content }) => /* @__PURE__ */ React3.createElement(Box3, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Box3, { width: "100%", backgroundColor: "cyan", paddingX: 1, paddingY: 0 }, /* @__PURE__ */ React3.createElement(Text3, { color: "black", wrap: "wrap" }, content)));
2013
- var ItemThinking = ({ content, expanded }) => /* @__PURE__ */ React3.createElement(Box3, { flexDirection: "column", width: "100%", marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, "\u601D\u8003"), expanded && /* @__PURE__ */ React3.createElement(Box3, { width: "100%", borderStyle: "round", borderColor: "gray", paddingX: 1, paddingY: 0, marginTop: 0 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true, wrap: "wrap" }, content)));
2014
- var ItemLoading = () => /* @__PURE__ */ React3.createElement(Box3, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, "\u601D\u8003\u4E2D..."));
2015
- var ItemTool = ({ content }) => /* @__PURE__ */ React3.createElement(Box3, { flexDirection: "column", width: "100%", marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { color: "yellow" }, "\u26A1"), /* @__PURE__ */ React3.createElement(Box3, { width: "100%", borderStyle: "round", borderColor: "yellow", paddingX: 1, paddingY: 0, marginTop: 0 }, /* @__PURE__ */ React3.createElement(Text3, { color: "yellow", wrap: "wrap" }, content)));
2016
- var ItemContent = ({ content }) => /* @__PURE__ */ React3.createElement(Box3, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { wrap: "wrap" }, content));
2017
- var ItemError = ({ content }) => /* @__PURE__ */ React3.createElement(Box3, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { color: "red" }, content));
2045
+ var ItemUser = ({ content }) => /* @__PURE__ */ React4.createElement(Box4, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React4.createElement(Box4, { width: "100%", backgroundColor: "cyan", paddingX: 1, paddingY: 0 }, /* @__PURE__ */ React4.createElement(Text4, { color: "black", wrap: "wrap" }, content)));
2046
+ var ItemThinking = ({ content, expanded }) => /* @__PURE__ */ React4.createElement(Box4, { flexDirection: "column", width: "100%", marginBottom: 1 }, /* @__PURE__ */ React4.createElement(Text4, { dimColor: true }, "\u601D\u8003"), expanded && /* @__PURE__ */ React4.createElement(Box4, { width: "100%", borderStyle: "round", borderColor: "gray", paddingX: 1, paddingY: 0, marginTop: 0 }, /* @__PURE__ */ React4.createElement(Text4, { dimColor: true, wrap: "wrap" }, content)));
2047
+ var ItemLoading = () => /* @__PURE__ */ React4.createElement(Box4, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React4.createElement(Text4, { dimColor: true }, "\u601D\u8003\u4E2D..."));
2048
+ var ItemTool = ({ content }) => /* @__PURE__ */ React4.createElement(Box4, { flexDirection: "column", width: "100%", marginBottom: 1 }, /* @__PURE__ */ React4.createElement(Text4, { color: "yellow" }, "\u26A1"), /* @__PURE__ */ React4.createElement(Box4, { width: "100%", borderStyle: "round", borderColor: "yellow", paddingX: 1, paddingY: 0, marginTop: 0 }, /* @__PURE__ */ React4.createElement(Text4, { color: "yellow", wrap: "wrap" }, content)));
2049
+ var ItemContent = ({ content }) => /* @__PURE__ */ React4.createElement(Box4, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React4.createElement(Text4, { wrap: "wrap" }, content));
2050
+ var ItemError = ({ content }) => /* @__PURE__ */ React4.createElement(Box4, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React4.createElement(Text4, { color: "red" }, content));
2018
2051
  var DOUBLE_PRESS_WINDOW = 1e3;
2019
2052
  var ChatApp = ({ sessionId: initialSessionId }) => {
2020
- const [items, setItems] = useState3([]);
2021
- const [input, setInput] = useState3("");
2022
- const [cursorPos, setCursorPos] = useState3(0);
2023
- const [loading, setLoading] = useState3(false);
2024
- const [hint, setHint] = useState3("");
2025
- const [sessionId, setSessionId] = useState3(void 0);
2026
- const sessionIdRef = useRef2(void 0);
2027
- const [showThinking, setShowThinking] = useState3(false);
2028
- const lastEscRef = useRef2(0);
2029
- const lastCtrlCRef = useRef2(0);
2030
- const bottomRef = useRef2(null);
2031
- const showThinkingRef = useRef2(false);
2053
+ const [items, setItems] = useState4([]);
2054
+ const [input, setInput] = useState4("");
2055
+ const [cursorPos, setCursorPos] = useState4(0);
2056
+ const [loading, setLoading] = useState4(false);
2057
+ const [hint, setHint] = useState4("");
2058
+ const [sessionId, setSessionId] = useState4(void 0);
2059
+ const sessionIdRef = useRef3(void 0);
2060
+ const [showThinking, setShowThinking] = useState4(false);
2061
+ const lastEscRef = useRef3(0);
2062
+ const lastCtrlCRef = useRef3(0);
2063
+ const bottomRef = useRef3(null);
2064
+ const showThinkingRef = useRef3(false);
2032
2065
  useEffect3(() => {
2033
2066
  showThinkingRef.current = showThinking;
2034
2067
  }, [showThinking]);
@@ -2081,7 +2114,7 @@ var ChatApp = ({ sessionId: initialSessionId }) => {
2081
2114
  setLoading(false);
2082
2115
  }
2083
2116
  };
2084
- useInput3((char, key) => {
2117
+ useInput4((char, key) => {
2085
2118
  if (key.ctrl && char === "o") {
2086
2119
  const hasThinking = items.some((i) => i.type === "thinking");
2087
2120
  if (hasThinking) {
@@ -2167,27 +2200,27 @@ var ChatApp = ({ sessionId: initialSessionId }) => {
2167
2200
  const cursorChar = input[cursorPos] ?? " ";
2168
2201
  const after = input.slice(cursorPos + 1);
2169
2202
  const fw = isFullWidth(cursorChar) ? 2 : 1;
2170
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Text3, { color: "cyan" }, "> "), /* @__PURE__ */ React3.createElement(Text3, null, before), /* @__PURE__ */ React3.createElement(Text3, { backgroundColor: "gray", color: "black" }, cursorChar, fw === 2 ? " " : ""), /* @__PURE__ */ React3.createElement(Text3, null, after), loading && /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, " "));
2203
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(Text4, { color: "cyan" }, "> "), /* @__PURE__ */ React4.createElement(Text4, null, before), /* @__PURE__ */ React4.createElement(Text4, { backgroundColor: "gray", color: "black" }, cursorChar, fw === 2 ? " " : ""), /* @__PURE__ */ React4.createElement(Text4, null, after), loading && /* @__PURE__ */ React4.createElement(Text4, { dimColor: true }, " "));
2171
2204
  };
2172
- return /* @__PURE__ */ React3.createElement(Box3, { flexDirection: "column", paddingX: 1, flexGrow: 1 }, /* @__PURE__ */ React3.createElement(Box3, { flexDirection: "column", flexGrow: 1 }, items.map((item) => {
2205
+ return /* @__PURE__ */ React4.createElement(Box4, { flexDirection: "column", paddingX: 1, flexGrow: 1 }, /* @__PURE__ */ React4.createElement(Box4, { flexDirection: "column", flexGrow: 1 }, items.map((item) => {
2173
2206
  switch (item.type) {
2174
2207
  case "user":
2175
- return /* @__PURE__ */ React3.createElement(ItemUser, { key: item.id, content: item.content });
2208
+ return /* @__PURE__ */ React4.createElement(ItemUser, { key: item.id, content: item.content });
2176
2209
  case "thinking":
2177
- return /* @__PURE__ */ React3.createElement(ItemThinking, { key: item.id, content: item.content, expanded: showThinking });
2210
+ return /* @__PURE__ */ React4.createElement(ItemThinking, { key: item.id, content: item.content, expanded: showThinking });
2178
2211
  case "loading":
2179
- return /* @__PURE__ */ React3.createElement(ItemLoading, { key: item.id });
2212
+ return /* @__PURE__ */ React4.createElement(ItemLoading, { key: item.id });
2180
2213
  case "tool":
2181
- return /* @__PURE__ */ React3.createElement(ItemTool, { key: item.id, content: item.content });
2214
+ return /* @__PURE__ */ React4.createElement(ItemTool, { key: item.id, content: item.content });
2182
2215
  case "content":
2183
- return /* @__PURE__ */ React3.createElement(ItemContent, { key: item.id, content: item.content });
2216
+ return /* @__PURE__ */ React4.createElement(ItemContent, { key: item.id, content: item.content });
2184
2217
  case "error":
2185
- return /* @__PURE__ */ React3.createElement(ItemError, { key: item.id, content: item.content });
2218
+ return /* @__PURE__ */ React4.createElement(ItemError, { key: item.id, content: item.content });
2186
2219
  }
2187
- })), /* @__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 Esc \u6E05\u7A7A\u8F93\u5165 \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 }));
2220
+ })), /* @__PURE__ */ React4.createElement(Box4, { flexDirection: "column", flexShrink: 0 }, /* @__PURE__ */ React4.createElement(Box4, { borderStyle: "single", borderColor: "gray", paddingX: 1 }, renderInputLine()), /* @__PURE__ */ React4.createElement(Box4, { paddingTop: 1 }, /* @__PURE__ */ React4.createElement(Text4, { dimColor: true }, "Ctrl+C \u9000\u51FA \xB7 Enter \u53D1\u9001 \xB7 Esc Esc \u6E05\u7A7A\u8F93\u5165 \xB7 \u2190\u2192 \u79FB\u52A8\u5149\u6807")), hint && /* @__PURE__ */ React4.createElement(Box4, { paddingTop: 0 }, /* @__PURE__ */ React4.createElement(Text4, { dimColor: true, color: "yellow" }, hint)), !loading && items.some((i) => i.type === "thinking") && !showThinking && /* @__PURE__ */ React4.createElement(Box4, { paddingTop: 0 }, /* @__PURE__ */ React4.createElement(Text4, { dimColor: true, color: "cyan" }, "Ctrl+O \u67E5\u770B\u601D\u8003"))), /* @__PURE__ */ React4.createElement(Box4, { ref: bottomRef }));
2188
2221
  };
2189
2222
  function createChatCommand() {
2190
- 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");
2223
+ const cmd = new Command11("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");
2191
2224
  cmd.action(async (opts) => {
2192
2225
  if (opts.json || opts.message) {
2193
2226
  if (!opts.message) {
@@ -2201,7 +2234,7 @@ function createChatCommand() {
2201
2234
  await chatSync(opts.message, !!opts.json, opts.sessionId);
2202
2235
  return;
2203
2236
  }
2204
- render3(/* @__PURE__ */ React3.createElement(ChatApp, { sessionId: opts.sessionId }));
2237
+ render4(/* @__PURE__ */ React4.createElement(ChatApp, { sessionId: opts.sessionId }));
2205
2238
  });
2206
2239
  return cmd;
2207
2240
  }
@@ -2219,32 +2252,26 @@ function getAgeVersion() {
2219
2252
  }
2220
2253
 
2221
2254
  // src/index.ts
2222
- var program = new Command15();
2255
+ var program = new Command12();
2223
2256
  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");
2224
2257
  var careerCmd = createCareerCommand();
2225
2258
  var catCmd = createCatCommand();
2226
- var createCmd = createCreateCommand();
2227
2259
  var postsCmd = createPostsCommand();
2228
2260
  var songsCmd = createSongsCommand();
2229
2261
  var linksCmd = createLinksCommand();
2230
2262
  var projectsCmd = createProjectsCommand();
2231
2263
  var toolsCmd = createToolsCommand();
2232
2264
  var contactCmd = createContactCommand();
2233
- var skillsCmd = createSkillsCommand();
2234
- var statusCmd = createStatusCommand();
2235
2265
  var whoamiCmd = createWhoAmICommand();
2236
2266
  var chatCmd = createChatCommand();
2237
2267
  program.addCommand(careerCmd);
2238
2268
  program.addCommand(catCmd);
2239
- program.addCommand(createCmd);
2240
2269
  program.addCommand(postsCmd);
2241
2270
  program.addCommand(songsCmd);
2242
2271
  program.addCommand(linksCmd);
2243
2272
  program.addCommand(projectsCmd);
2244
2273
  program.addCommand(toolsCmd);
2245
2274
  program.addCommand(contactCmd);
2246
- program.addCommand(skillsCmd);
2247
- program.addCommand(statusCmd);
2248
2275
  program.addCommand(whoamiCmd);
2249
2276
  program.addCommand(chatCmd);
2250
2277
  if (!process.argv.slice(2).length) {