maidang 29.7.7 → 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,8 +213,8 @@ 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";
@@ -349,22 +274,22 @@ var getCatMoments = async () => {
349
274
  return Array.isArray(data) ? data : [];
350
275
  };
351
276
  var printCatList = (catMoments) => {
352
- console.log(chalk5.yellow.bold("\u9EA6\u9EA6"));
277
+ console.log(chalk4.yellow.bold("\u9EA6\u9EA6"));
353
278
  console.log("");
354
279
  for (const moment of catMoments) {
355
280
  const title = moment.title || "\u672A\u547D\u540D\u732B\u732B\u52A8\u6001";
356
- console.log(` ${chalk5.white.bold(title)} ${chalk5.dim(`[${moment.slug}]`)}`);
281
+ console.log(` ${chalk4.white.bold(title)} ${chalk4.dim(`[${moment.slug}]`)}`);
357
282
  if (moment.description) {
358
- console.log(` ${chalk5.gray(moment.description)}`);
283
+ console.log(` ${chalk4.gray(moment.description)}`);
359
284
  }
360
285
  if (moment.imageUrl) {
361
- console.log(` ${chalk5.blue(moment.imageUrl)}`);
286
+ console.log(` ${chalk4.blue(moment.imageUrl)}`);
362
287
  }
363
288
  console.log("");
364
289
  }
365
290
  };
366
291
  function createCatCommand() {
367
- 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) => {
368
293
  const printJson = (data, error) => {
369
294
  const payload = {
370
295
  tool: "maidang",
@@ -383,9 +308,9 @@ function createCatCommand() {
383
308
  return;
384
309
  }
385
310
  if (catMoments.length === 0) {
386
- console.log(chalk5.yellow.bold("\u9EA6\u9EA6"));
311
+ console.log(chalk4.yellow.bold("\u9EA6\u9EA6"));
387
312
  console.log("");
388
- 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"));
389
314
  console.log("");
390
315
  return;
391
316
  }
@@ -396,7 +321,7 @@ function createCatCommand() {
396
321
  printJson([], message);
397
322
  return;
398
323
  }
399
- 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}`));
400
325
  process.exit(1);
401
326
  }
402
327
  });
@@ -406,7 +331,7 @@ function createCatCommand() {
406
331
  // src/commands/posts.tsx
407
332
  import React, { useState, useEffect } from "react";
408
333
  import { render, Box, Text, useInput } from "ink";
409
- import { Command as Command5 } from "commander";
334
+ import { Command as Command4 } from "commander";
410
335
  var ListView = ({ posts, selectedIndex, onSelect, onEnter, onQuit }) => {
411
336
  useInput((input, key) => {
412
337
  if (input === "q" || input === "Q") {
@@ -556,7 +481,7 @@ var PostsApp = ({ apiUrl }) => {
556
481
  };
557
482
  function createPostsCommand() {
558
483
  const apiUrl = `${process.env.MAIDANG_API_URL || DEFAULT_API_URL}/api/social-posts?type=social`;
559
- 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");
560
485
  cmd.action((opts) => {
561
486
  const wantsJson = opts.json;
562
487
  if (wantsJson) {
@@ -579,7 +504,7 @@ function createPostsCommand() {
579
504
  // src/commands/songs.tsx
580
505
  import React2, { useState as useState2, useRef } from "react";
581
506
  import { render as render2, Box as Box2, Text as Text2, useInput as useInput2 } from "ink";
582
- import { Command as Command6 } from "commander";
507
+ import { Command as Command5 } from "commander";
583
508
 
584
509
  // src/data/songs.json
585
510
  var songs_default = {
@@ -1636,7 +1561,7 @@ var SongsApp = ({ defaultYearIndex }) => {
1636
1561
  );
1637
1562
  };
1638
1563
  function createSongsCommand() {
1639
- 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`);
1640
1565
  cmd.action((opts) => {
1641
1566
  if (opts.json) {
1642
1567
  if (opts.year) {
@@ -1668,10 +1593,10 @@ function createSongsCommand() {
1668
1593
  }
1669
1594
 
1670
1595
  // src/commands/links.ts
1671
- import { Command as Command7 } from "commander";
1672
- import chalk6 from "chalk";
1596
+ import { Command as Command6 } from "commander";
1597
+ import chalk5 from "chalk";
1673
1598
  function createLinksCommand() {
1674
- 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) => {
1675
1600
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1676
1601
  try {
1677
1602
  const res = await fetch(`${apiUrl}/api/links`);
@@ -1681,14 +1606,14 @@ function createLinksCommand() {
1681
1606
  console.log(JSON.stringify({ tool: "maidang", command: "links", data: links }, null, 2));
1682
1607
  return;
1683
1608
  }
1684
- 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"));
1685
1610
  for (const link of links) {
1686
- console.log(` ${link.icon} ${chalk6.white(link.name)} - ${chalk6.gray(link.description || "")}`);
1687
- 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)}
1688
1613
  `);
1689
1614
  }
1690
1615
  } catch (err) {
1691
- 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}`));
1692
1617
  process.exit(1);
1693
1618
  }
1694
1619
  });
@@ -1696,10 +1621,10 @@ function createLinksCommand() {
1696
1621
  }
1697
1622
 
1698
1623
  // src/commands/projects.ts
1699
- import { Command as Command8 } from "commander";
1700
- import chalk7 from "chalk";
1624
+ import { Command as Command7 } from "commander";
1625
+ import chalk6 from "chalk";
1701
1626
  function createProjectsCommand() {
1702
- 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) => {
1703
1628
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1704
1629
  try {
1705
1630
  const res = await fetch(`${apiUrl}/api/projects`);
@@ -1709,17 +1634,17 @@ function createProjectsCommand() {
1709
1634
  console.log(JSON.stringify({ tool: "maidang", command: "projects", data: projects }, null, 2));
1710
1635
  return;
1711
1636
  }
1712
- 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"));
1713
1638
  for (const project of projects) {
1714
- 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}]`)}`);
1715
1640
  console.log(` ${project.description}`);
1716
1641
  if (project.url) {
1717
- console.log(` ${chalk7.blue(project.url)}`);
1642
+ console.log(` ${chalk6.blue(project.url)}`);
1718
1643
  }
1719
1644
  console.log("");
1720
1645
  }
1721
1646
  } catch (err) {
1722
- 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}`));
1723
1648
  process.exit(1);
1724
1649
  }
1725
1650
  });
@@ -1727,10 +1652,10 @@ function createProjectsCommand() {
1727
1652
  }
1728
1653
 
1729
1654
  // src/commands/tools.ts
1730
- import { Command as Command9 } from "commander";
1731
- import chalk8 from "chalk";
1655
+ import { Command as Command8 } from "commander";
1656
+ import chalk7 from "chalk";
1732
1657
  function createToolsCommand() {
1733
- 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) => {
1734
1659
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1735
1660
  try {
1736
1661
  const res = await fetch(`${apiUrl}/api/tools`);
@@ -1750,204 +1675,28 @@ function createToolsCommand() {
1750
1675
  device: "\u8BBE\u5907",
1751
1676
  desktop: "\u684C\u9762\u88C5\u5907"
1752
1677
  };
1753
- 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"));
1754
1679
  for (const [cat, items] of Object.entries(byCategory)) {
1755
- console.log(chalk8.white.bold(` ${categoryNames[cat] || cat}`));
1680
+ console.log(chalk7.white.bold(` ${categoryNames[cat] || cat}`));
1756
1681
  for (const tool of items) {
1757
- const urlStr = tool.url ? ` ${chalk8.blue(tool.url)}` : "";
1758
- 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}`);
1759
1684
  }
1760
1685
  console.log("");
1761
1686
  }
1762
1687
  } catch (err) {
1763
- 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}`));
1764
1689
  process.exit(1);
1765
1690
  }
1766
1691
  });
1767
1692
  return cmd;
1768
1693
  }
1769
1694
 
1770
- // src/commands/contact.ts
1771
- import { Command as Command10 } from "commander";
1772
- import chalk9 from "chalk";
1773
- function hr(char = "\u2500", len = 40) {
1774
- console.log(chalk9.dim(char.repeat(len)));
1775
- }
1776
- function createContactCommand() {
1777
- const cmd = new Command10("contact").description("\u8054\u7CFB\u65B9\u5F0F").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1778
- const data = { email: "borisdunk@sina.com", note: "\u56DE\u590D\u53EF\u80FD\u8F83\u6162\uFF0C\u770B\u5230\u4F1A\u56DE" };
1779
- if (opts.json) {
1780
- console.log(JSON.stringify({ tool: "maidang", command: "contact", data }, null, 2));
1781
- return;
1782
- }
1783
- console.log("");
1784
- console.log(chalk9.bold("\u8054\u7CFB\u65B9\u5F0F"));
1785
- console.log("");
1786
- hr();
1787
- console.log("");
1788
- console.log(` Email ${chalk9.blue("borisdunk@sina.com")}`);
1789
- console.log("");
1790
- console.log(` ${chalk9.dim("\u56DE\u590D\u53EF\u80FD\u8F83\u6162\uFF0C\u770B\u5230\u4F1A\u56DE")}`);
1791
- console.log("");
1792
- });
1793
- return cmd;
1794
- }
1795
-
1796
- // src/commands/skills.ts
1797
- import { Command as Command11 } from "commander";
1798
- import chalk10 from "chalk";
1799
- var skills = [
1800
- // 生活方式
1801
- { name: "\u4E3E\u94C1 / \u5065\u8EAB", tags: ["life"] },
1802
- { name: "\u98DE\u76D8", tags: ["life"] },
1803
- { name: "\u5409\u4ED6", tags: ["life"] },
1804
- { name: "\u62FF\u94C1", tags: ["life"] },
1805
- { name: "\u7F8E\u5267", tags: ["life"] },
1806
- // 产品
1807
- { name: "\u72EC\u7ACB\u5F00\u53D1", tags: ["product"] },
1808
- { name: "\u4EA7\u54C1\u8BBE\u8BA1", tags: ["product"] },
1809
- { name: "Hight Agency", tags: ["product"] },
1810
- { name: "\u4EA7\u54C1\u8C03\u7814", tags: ["product"] },
1811
- // 技术
1812
- { name: "TypeScript", tags: ["tech"] },
1813
- { name: "Next.js / React", tags: ["tech"] },
1814
- { name: "Node.js", tags: ["tech"] },
1815
- { name: "AI Agent / LLM", tags: ["tech"] },
1816
- { name: "\u524D\u7AEF\u5DE5\u7A0B\u5316", tags: ["tech"] },
1817
- { name: "React Flow", tags: ["tech"] }
1818
- ];
1819
- function hr2(char = "\u2500", len = 40) {
1820
- console.log(chalk10.dim(char.repeat(len)));
1821
- }
1822
- function createSkillsCommand() {
1823
- const cmd = new Command11("skills").description("\u6280\u80FD\u4E0E\u5174\u8DA3").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1824
- if (opts.json) {
1825
- console.log(JSON.stringify({ tool: "maidang", command: "skills", data: skills }, null, 2));
1826
- return;
1827
- }
1828
- const life = skills.filter((s) => s.tags.includes("life"));
1829
- const product = skills.filter((s) => s.tags.includes("product"));
1830
- const tech = skills.filter((s) => s.tags.includes("tech"));
1831
- console.log("");
1832
- console.log(chalk10.bold("\u751F\u6D3B"));
1833
- console.log("");
1834
- console.log(" " + life.map((s) => chalk10.white(s.name)).join(chalk10.dim(" \xB7 ")));
1835
- console.log("");
1836
- hr2();
1837
- console.log("");
1838
- console.log(chalk10.bold("\u4EA7\u54C1"));
1839
- console.log("");
1840
- console.log(" " + product.map((s) => chalk10.white(s.name)).join(chalk10.dim(" \xB7 ")));
1841
- console.log("");
1842
- hr2();
1843
- console.log("");
1844
- console.log(chalk10.bold("\u6280\u672F"));
1845
- console.log("");
1846
- console.log(" " + tech.map((s) => chalk10.white(s.name)).join(chalk10.dim(" \xB7 ")));
1847
- console.log("");
1848
- });
1849
- return cmd;
1850
- }
1851
-
1852
- // src/commands/status.ts
1853
- import { Command as Command12 } from "commander";
1854
- import chalk11 from "chalk";
1855
- function getStatus() {
1856
- const hour = (/* @__PURE__ */ new Date()).getHours();
1857
- const isWeekend = [0, 6].includes((/* @__PURE__ */ new Date()).getDay());
1858
- if (isWeekend) return { status: "available", label: "\u5468\u672B\u53EF\u7EA6", description: "\u65F6\u95F4\u7075\u6D3B\uFF0C\u53EF\u4EE5\u804A\u804A" };
1859
- if (hour < 9 || hour >= 22) return { status: "available", label: "\u7A7A\u95F2\u4E2D", description: "\u975E\u5DE5\u4F5C\u65F6\u95F4" };
1860
- if (hour >= 19) return { status: "busy", label: "\u4E0B\u73ED\u4E86", description: "\u4F11\u606F\u4E2D\uFF0C\u770B\u5230\u4F1A\u56DE" };
1861
- return { status: "working", label: "\u5DE5\u4F5C\u4E2D", description: "\u6B63\u5E38\u5DE5\u4F5C\u65F6\u6BB5" };
1862
- }
1863
- function hr3(char = "\u2500", len = 40) {
1864
- console.log(chalk11.dim(char.repeat(len)));
1865
- }
1866
- function createStatusCommand() {
1867
- const cmd = new Command12("status").description("\u5F53\u524D\u72B6\u6001").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1868
- const info = getStatus();
1869
- if (opts.json) {
1870
- console.log(JSON.stringify({ tool: "maidang", command: "status", data: info }, null, 2));
1871
- return;
1872
- }
1873
- console.log("");
1874
- console.log(chalk11.bold("\u5F53\u524D\u72B6\u6001"));
1875
- console.log("");
1876
- hr3();
1877
- console.log("");
1878
- console.log(` ${chalk11.cyan("\u25CF")} ${chalk11.white(info.label)}`);
1879
- console.log(` ${chalk11.dim(info.description)}`);
1880
- console.log("");
1881
- });
1882
- return cmd;
1883
- }
1884
-
1885
- // src/commands/whoami.ts
1886
- import { Command as Command13 } from "commander";
1887
- import chalk12 from "chalk";
1888
-
1889
- // src/constants/profile.ts
1890
- 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";
1891
-
1892
- // src/commands/whoami.ts
1893
- function getStatus2() {
1894
- const hour = (/* @__PURE__ */ new Date()).getHours();
1895
- const isWeekend = [0, 6].includes((/* @__PURE__ */ new Date()).getDay());
1896
- if (isWeekend) return { status: "available", label: "\u5468\u672B\u53EF\u7EA6", description: "\u65F6\u95F4\u7075\u6D3B\uFF0C\u53EF\u4EE5\u804A\u804A" };
1897
- if (hour < 9 || hour >= 22) return { status: "available", label: "\u7A7A\u95F2\u4E2D", description: "\u975E\u5DE5\u4F5C\u65F6\u95F4" };
1898
- if (hour >= 19) return { status: "busy", label: "\u4E0B\u73ED\u4E86", description: "\u4F11\u606F\u4E2D\uFF0C\u770B\u5230\u4F1A\u56DE" };
1899
- return { status: "working", label: "\u5DE5\u4F5C\u4E2D", description: "\u6B63\u5E38\u5DE5\u4F5C\u65F6\u6BB5" };
1900
- }
1901
- function hr4(char = "\u2500", len = 40) {
1902
- console.log(chalk12.dim(char.repeat(len)));
1903
- }
1904
- function createWhoAmICommand() {
1905
- const cmd = new Command13("whoami").description("\u4E86\u89E3\u6211").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1906
- const status = getStatus2();
1907
- const whoami = {
1908
- tagline: INTRO_TEXT,
1909
- location: "\u676D\u5DDE \xB7 EFC",
1910
- status,
1911
- links: [
1912
- { label: "Blog", url: "https://www.maidang.me" }
1913
- ],
1914
- contact: "borisdunk@sina.com",
1915
- website: "https://www.maidang.me",
1916
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1917
- };
1918
- if (opts.json) {
1919
- console.log(JSON.stringify({ tool: "maidang", command: "whoami", data: whoami }, null, 2));
1920
- return;
1921
- }
1922
- console.log("");
1923
- console.log(chalk12.bold("\u6211\u662F \u9EA6\u5F53"));
1924
- console.log("");
1925
- console.log(" " + whoami.tagline);
1926
- console.log("");
1927
- hr4();
1928
- console.log("");
1929
- console.log(` ${chalk12.cyan("\u{1F4CD}")} ${whoami.location}`);
1930
- console.log(` ${chalk12.cyan("\u23F1")} ${whoami.status.label} \xB7 ${chalk12.dim(whoami.status.description)}`);
1931
- console.log("");
1932
- hr4();
1933
- console.log("");
1934
- console.log(` Blog ${chalk12.blue.underline(whoami.website)}`);
1935
- console.log(` Email ${chalk12.blue(whoami.contact)}`);
1936
- console.log("");
1937
- hr4();
1938
- console.log("");
1939
- console.log(` ${chalk12.dim("\u60F3\u4E86\u89E3\u66F4\u591A\uFF1F")}`);
1940
- console.log(` ${chalk12.dim("maidang skills / career / posts / links")}`);
1941
- console.log("");
1942
- });
1943
- return cmd;
1944
- }
1945
-
1946
- // src/commands/chat.tsx
1947
- 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";
1948
1697
  import { render as render3, Box as Box3, Text as Text3, useInput as useInput3 } from "ink";
1949
- import { Command as Command14 } from "commander";
1950
- import chalk13 from "chalk";
1698
+ import { Command as Command9 } from "commander";
1699
+ import chalk8 from "chalk";
1951
1700
 
1952
1701
  // src/utils/chat-api.ts
1953
1702
  var API_URL = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
@@ -2023,7 +1772,234 @@ async function fetchChat(message, sessionId) {
2023
1772
  };
2024
1773
  }
2025
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
+
2026
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";
2027
2003
  async function chatSync(message, json = false, sessionId) {
2028
2004
  try {
2029
2005
  const { thinking, response, sessionId: newSessionId, tool_calls } = await fetchChat(message, sessionId);
@@ -2032,7 +2008,7 @@ async function chatSync(message, json = false, sessionId) {
2032
2008
  } else {
2033
2009
  if (thinking) {
2034
2010
  thinking.split("\n").forEach((line) => {
2035
- console.log(`${chalk13.dim("\u{1F4AD}")} ${chalk13.dim(line)}`);
2011
+ console.log(`${chalk10.dim("\u{1F4AD}")} ${chalk10.dim(line)}`);
2036
2012
  });
2037
2013
  console.log();
2038
2014
  }
@@ -2041,51 +2017,51 @@ async function chatSync(message, json = false, sessionId) {
2041
2017
  const name = tc.call?.function?.name || tc.name || "unknown";
2042
2018
  const args = tc.call?.function?.arguments || tc.arguments || "{}";
2043
2019
  const result = tc.result || "";
2044
- let content = `${chalk13.yellow(name)} ${chalk13.gray(args)}`;
2020
+ let content = `${chalk10.yellow(name)} ${chalk10.gray(args)}`;
2045
2021
  if (result) content += `
2046
- ${chalk13.cyan(result)}`;
2047
- console.log(`${chalk13.dim("\u26A1")} ${content}`);
2022
+ ${chalk10.cyan(result)}`;
2023
+ console.log(`${chalk10.dim("\u26A1")} ${content}`);
2048
2024
  });
2049
2025
  console.log();
2050
2026
  }
2051
2027
  console.log(response);
2052
2028
  if (newSessionId && newSessionId !== sessionId) {
2053
2029
  console.log();
2054
- console.log(chalk13.dim(`Session: ${chalk13.cyan(newSessionId)}`));
2055
- 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"));
2056
2032
  }
2057
2033
  }
2058
2034
  } catch (err) {
2059
2035
  if (json) {
2060
2036
  console.error(JSON.stringify({ tool: "maidang", command: "chat", error: err.message }, null, 2));
2061
2037
  } else {
2062
- console.error(chalk13.red(`Error: ${err.message}`));
2038
+ console.error(chalk10.red(`Error: ${err.message}`));
2063
2039
  process.exit(1);
2064
2040
  }
2065
2041
  }
2066
2042
  }
2067
2043
  var _id = 0;
2068
2044
  var uid = () => ++_id;
2069
- 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)));
2070
- 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)));
2071
- var ItemLoading = () => /* @__PURE__ */ React3.createElement(Box3, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { dimColor: true }, "\u601D\u8003\u4E2D..."));
2072
- 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)));
2073
- var ItemContent = ({ content }) => /* @__PURE__ */ React3.createElement(Box3, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React3.createElement(Text3, { wrap: "wrap" }, content));
2074
- 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));
2075
2051
  var DOUBLE_PRESS_WINDOW = 1e3;
2076
2052
  var ChatApp = ({ sessionId: initialSessionId }) => {
2077
- const [items, setItems] = useState3([]);
2078
- const [input, setInput] = useState3("");
2079
- const [cursorPos, setCursorPos] = useState3(0);
2080
- const [loading, setLoading] = useState3(false);
2081
- const [hint, setHint] = useState3("");
2082
- const [sessionId, setSessionId] = useState3(void 0);
2083
- const sessionIdRef = useRef2(void 0);
2084
- const [showThinking, setShowThinking] = useState3(false);
2085
- const lastEscRef = useRef2(0);
2086
- const lastCtrlCRef = useRef2(0);
2087
- const bottomRef = useRef2(null);
2088
- 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);
2089
2065
  useEffect3(() => {
2090
2066
  showThinkingRef.current = showThinking;
2091
2067
  }, [showThinking]);
@@ -2138,7 +2114,7 @@ var ChatApp = ({ sessionId: initialSessionId }) => {
2138
2114
  setLoading(false);
2139
2115
  }
2140
2116
  };
2141
- useInput3((char, key) => {
2117
+ useInput4((char, key) => {
2142
2118
  if (key.ctrl && char === "o") {
2143
2119
  const hasThinking = items.some((i) => i.type === "thinking");
2144
2120
  if (hasThinking) {
@@ -2224,27 +2200,27 @@ var ChatApp = ({ sessionId: initialSessionId }) => {
2224
2200
  const cursorChar = input[cursorPos] ?? " ";
2225
2201
  const after = input.slice(cursorPos + 1);
2226
2202
  const fw = isFullWidth(cursorChar) ? 2 : 1;
2227
- 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 }, " "));
2228
2204
  };
2229
- 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) => {
2230
2206
  switch (item.type) {
2231
2207
  case "user":
2232
- return /* @__PURE__ */ React3.createElement(ItemUser, { key: item.id, content: item.content });
2208
+ return /* @__PURE__ */ React4.createElement(ItemUser, { key: item.id, content: item.content });
2233
2209
  case "thinking":
2234
- 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 });
2235
2211
  case "loading":
2236
- return /* @__PURE__ */ React3.createElement(ItemLoading, { key: item.id });
2212
+ return /* @__PURE__ */ React4.createElement(ItemLoading, { key: item.id });
2237
2213
  case "tool":
2238
- return /* @__PURE__ */ React3.createElement(ItemTool, { key: item.id, content: item.content });
2214
+ return /* @__PURE__ */ React4.createElement(ItemTool, { key: item.id, content: item.content });
2239
2215
  case "content":
2240
- return /* @__PURE__ */ React3.createElement(ItemContent, { key: item.id, content: item.content });
2216
+ return /* @__PURE__ */ React4.createElement(ItemContent, { key: item.id, content: item.content });
2241
2217
  case "error":
2242
- return /* @__PURE__ */ React3.createElement(ItemError, { key: item.id, content: item.content });
2218
+ return /* @__PURE__ */ React4.createElement(ItemError, { key: item.id, content: item.content });
2243
2219
  }
2244
- })), /* @__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 }));
2245
2221
  };
2246
2222
  function createChatCommand() {
2247
- 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");
2248
2224
  cmd.action(async (opts) => {
2249
2225
  if (opts.json || opts.message) {
2250
2226
  if (!opts.message) {
@@ -2258,7 +2234,7 @@ function createChatCommand() {
2258
2234
  await chatSync(opts.message, !!opts.json, opts.sessionId);
2259
2235
  return;
2260
2236
  }
2261
- render3(/* @__PURE__ */ React3.createElement(ChatApp, { sessionId: opts.sessionId }));
2237
+ render4(/* @__PURE__ */ React4.createElement(ChatApp, { sessionId: opts.sessionId }));
2262
2238
  });
2263
2239
  return cmd;
2264
2240
  }
@@ -2276,32 +2252,26 @@ function getAgeVersion() {
2276
2252
  }
2277
2253
 
2278
2254
  // src/index.ts
2279
- var program = new Command15();
2255
+ var program = new Command12();
2280
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");
2281
2257
  var careerCmd = createCareerCommand();
2282
2258
  var catCmd = createCatCommand();
2283
- var createCmd = createCreateCommand();
2284
2259
  var postsCmd = createPostsCommand();
2285
2260
  var songsCmd = createSongsCommand();
2286
2261
  var linksCmd = createLinksCommand();
2287
2262
  var projectsCmd = createProjectsCommand();
2288
2263
  var toolsCmd = createToolsCommand();
2289
2264
  var contactCmd = createContactCommand();
2290
- var skillsCmd = createSkillsCommand();
2291
- var statusCmd = createStatusCommand();
2292
2265
  var whoamiCmd = createWhoAmICommand();
2293
2266
  var chatCmd = createChatCommand();
2294
2267
  program.addCommand(careerCmd);
2295
2268
  program.addCommand(catCmd);
2296
- program.addCommand(createCmd);
2297
2269
  program.addCommand(postsCmd);
2298
2270
  program.addCommand(songsCmd);
2299
2271
  program.addCommand(linksCmd);
2300
2272
  program.addCommand(projectsCmd);
2301
2273
  program.addCommand(toolsCmd);
2302
2274
  program.addCommand(contactCmd);
2303
- program.addCommand(skillsCmd);
2304
- program.addCommand(statusCmd);
2305
2275
  program.addCommand(whoamiCmd);
2306
2276
  program.addCommand(chatCmd);
2307
2277
  if (!process.argv.slice(2).length) {