maidang 29.7.18 → 29.7.20

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,63 +1,89 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { Command as Command12 } from "commander";
4
+ import { Command as Command13 } from "commander";
5
5
 
6
6
  // src/commands/home.ts
7
7
  import { Command } from "commander";
8
- import chalk2 from "chalk";
9
8
 
10
- // src/utils/display.ts
9
+ // src/utils/theme.ts
11
10
  import chalk from "chalk";
12
- import ora from "ora";
13
- function createSpinner(text) {
14
- return ora({
15
- text,
16
- color: "cyan"
17
- });
11
+ var theme = {
12
+ // 文字层级(对应 blog 的 ink / ink-soft / ink-muted / ink-faint)
13
+ ink: chalk.white.bold,
14
+ // 主标题、强调
15
+ inkBody: chalk.white,
16
+ // 正文
17
+ inkSoft: chalk.gray,
18
+ // 次级正文 / 描述
19
+ inkMuted: chalk.dim,
20
+ // 元信息、时间、占位
21
+ inkFaint: chalk.dim.gray,
22
+ // 极弱:分隔线、装饰
23
+ // 重音色(cyan 不饱和,跟 blog 的 sage 同质感)
24
+ accent: chalk.cyan,
25
+ accentBold: chalk.cyan.bold,
26
+ accentDim: chalk.cyan.dim,
27
+ // 链接(跟 blog 一样用 accent 而不是 blue)
28
+ link: chalk.cyan,
29
+ linkUnderline: chalk.cyan.underline,
30
+ // 状态
31
+ ok: chalk.green,
32
+ warn: chalk.yellow,
33
+ err: chalk.red
34
+ };
35
+ function eyebrow(text) {
36
+ return chalk.dim(text.toUpperCase());
37
+ }
38
+ function hairline() {
39
+ const cols = process.stdout.columns || 80;
40
+ const len = Math.max(32, Math.min(60, cols - 4));
41
+ return chalk.dim("\u2500".repeat(len));
42
+ }
43
+ function printKV(key, value, keyWidth = 12) {
44
+ console.log(` ${theme.inkBody(key.padEnd(keyWidth))} ${theme.inkSoft(value)}`);
18
45
  }
19
46
 
20
47
  // src/commands/home.ts
21
48
  var commands = [
22
- { name: "whoami", desc: "\u4E86\u89E3\u6211" },
23
- { name: "career", desc: "\u5DE5\u4F5C" },
24
- { name: "posts", desc: "\u63A8\u6587" },
49
+ { name: "whoami", desc: "\u4E00\u53E5\u8BDD\u4ECB\u7ECD\u6211" },
50
+ { name: "career", desc: "\u5DE5\u4F5C\u7ECF\u5386" },
51
+ { name: "projects", desc: "\u4E00\u4E9B\u5DF2\u7ECF\u843D\u5730\u7684\u4E1C\u897F" },
52
+ { name: "posts", desc: "\u6700\u8FD1\u5728\u5199\u3001\u5728\u60F3\u7684" },
53
+ { name: "tools", desc: "\u6700\u8FD1\u5728\u7528\u7684\u597D\u7269" },
25
54
  { name: "songs", desc: "\u5E74\u5EA6\u6B4C\u5355" },
26
- { name: "tools", desc: "\u5E38\u7528\u5DE5\u5177" },
27
- { name: "links", desc: "\u94FE\u63A5" },
28
- { name: "projects", desc: "\u9879\u76EE" },
29
- { name: "cat | meow", desc: "\u9EA6\u9EA6" },
30
- { name: "contact", desc: "\u7559\u8A00" }
55
+ { name: "links", desc: "\u793E\u4EA4\u4E0E\u5916\u94FE" },
56
+ { name: "cat", desc: "\u9EA6\u9EA6" },
57
+ { name: "contact", desc: "\u7ED9\u6211\u7559\u8A00" },
58
+ { name: "manifest", desc: "\u4E00\u6B21\u6027\u7ED9 AI \u7684\u5168\u90E8\u6570\u636E (JSON)" }
31
59
  ];
32
60
  function createHomeCommand() {
33
- const cmd = new Command("maidang").description("\u6B22\u8FCE\u6765\u5230\u9EA6\u5F53\u7684\u4E16\u754C").action(async () => {
34
- const spinner = createSpinner("\u6B63\u5728\u53EC\u5524...");
35
- spinner.start();
36
- await new Promise((resolve) => setTimeout(resolve, 600));
37
- spinner.stop();
38
- console.clear();
39
- console.log(chalk2.bold("\u9EA6\u5F53"));
40
- console.log(
41
- `${chalk2.cyan("\u4E2A\u4EBA\u7F51\u7AD9")} ${chalk2.blueBright.underline("https://maidang.me")}`
42
- );
43
- console.log(chalk2.gray("\u6587\u7AE0 / \u9879\u76EE / \u8054\u7CFB\u65B9\u5F0F / \u5728\u7EBF\u5165\u53E3"));
44
- console.log(chalk2.gray("Agent \u5F00\u53D1 / AI \u5DE5\u4F5C\u6D41 / \u5168\u6808"));
45
- console.log(chalk2.gray("\u5F00\u653E\u5408\u4F5C\uFF0C\u6B22\u8FCE\u627E\u6211\u804A\u804A"));
61
+ const cmd = new Command("maidang").description("\u4E00\u4EFD\u53EF\u4EE5\u88AB AI \u8BFB\u53D6\u7684\u4E2A\u4EBA\u624B\u518C").action(() => {
46
62
  console.log("");
47
- const nameWidth = 14;
48
- commands.forEach((c) => {
49
- console.log(` ${chalk2.white(c.name.padEnd(nameWidth))} ${chalk2.gray(c.desc)}`);
50
- });
63
+ console.log(" " + eyebrow("maidang.me"));
64
+ console.log(" " + theme.ink("\u6211\u662F\u9EA6\u5F53\uFF0C\u5168\u6808\u5F00\u53D1\u5DE5\u7A0B\u5E08\u3002"));
65
+ console.log("");
66
+ console.log(" " + theme.inkSoft("Agent \u5F00\u53D1 / AI \u5DE5\u4F5C\u6D41 / \u5168\u6808"));
67
+ console.log(" " + theme.inkSoft("\u5F00\u653E\u5408\u4F5C\uFF0C\u6B22\u8FCE\u627E\u6211\u804A\u804A"));
68
+ console.log(" " + theme.link("https://maidang.me"));
69
+ console.log("");
70
+ console.log(" " + hairline());
71
+ console.log("");
72
+ for (const c of commands) {
73
+ printKV(c.name, c.desc, 12);
74
+ }
75
+ console.log("");
76
+ console.log(" " + hairline());
77
+ console.log("");
78
+ console.log(" " + theme.inkMuted("\u7528\u6CD5\uFF1A") + theme.inkSoft("npx maidang ") + theme.inkMuted("<command>"));
79
+ console.log(" " + theme.inkMuted("\u6BCF\u4E2A\u547D\u4EE4\u652F\u6301 ") + theme.inkSoft("--json") + theme.inkMuted("\uFF0C\u65B9\u4FBF agent \u8BFB\u53D6"));
51
80
  console.log("");
52
- console.log(chalk2.gray(" \u5982\u679C\u4F60\u662F Agent\uFF0C\u53EF\u5148\u770B\u8FD9\u91CC\uFF1A"));
53
- console.log(chalk2.gray(" maidang --help"));
54
81
  });
55
82
  return cmd;
56
83
  }
57
84
 
58
85
  // src/commands/career.ts
59
86
  import { Command as Command2 } from "commander";
60
- import chalk3 from "chalk";
61
87
 
62
88
  // src/data/career.json
63
89
  var career_default = {
@@ -110,7 +136,7 @@ var career_default = {
110
136
 
111
137
  // src/commands/career.ts
112
138
  function createCareerCommand() {
113
- const cmd = new Command2("career").description("\u804C\u4E1A\u7ECF\u5386\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) => {
139
+ const cmd = new Command2("career").description("\u5DE5\u4F5C\u7ECF\u5386\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) => {
114
140
  const root = career_default;
115
141
  const data = root.career;
116
142
  if (opts.json) {
@@ -119,20 +145,22 @@ function createCareerCommand() {
119
145
  }
120
146
  const { intro, experiences } = data;
121
147
  console.log("");
122
- console.log(chalk3.dim(intro.eyebrow));
123
- console.log(chalk3.white.bold(intro.title));
148
+ console.log(" " + eyebrow(intro.eyebrow));
149
+ console.log(" " + theme.ink(intro.title));
150
+ console.log("");
151
+ console.log(" " + hairline());
124
152
  console.log("");
125
153
  experiences.forEach((exp, index) => {
126
- console.log(chalk3.dim(` ${exp.period}`));
127
- console.log(chalk3.white.bold(` ${exp.company}`));
128
- console.log(chalk3.gray(` ${exp.role}`));
154
+ console.log(" " + theme.inkMuted(exp.period));
155
+ console.log(" " + theme.ink(exp.company));
156
+ console.log(" " + theme.inkSoft(exp.role));
129
157
  console.log("");
130
158
  for (const p of exp.projects) {
131
- console.log(chalk3.gray(` \xB7 ${p}`));
159
+ console.log(" " + theme.inkMuted("\xB7") + " " + theme.inkSoft(p));
132
160
  }
133
161
  console.log("");
134
162
  if (index < experiences.length - 1) {
135
- console.log(chalk3.dim(" " + "\xB7".repeat(36)));
163
+ console.log(" " + hairline());
136
164
  console.log("");
137
165
  }
138
166
  });
@@ -142,7 +170,6 @@ function createCareerCommand() {
142
170
 
143
171
  // src/commands/cat.ts
144
172
  import { Command as Command3 } from "commander";
145
- import chalk4 from "chalk";
146
173
 
147
174
  // src/constants/api.ts
148
175
  var DEFAULT_API_URL = "https://www.maidang.me";
@@ -201,55 +228,49 @@ var getCatMoments = async () => {
201
228
  const data = await readApiData(res);
202
229
  return Array.isArray(data) ? data : [];
203
230
  };
204
- var printCatList = (catMoments) => {
205
- console.log(chalk4.yellow.bold("\u9EA6\u9EA6"));
206
- console.log("");
207
- for (const moment of catMoments) {
208
- const title = moment.title || "\u672A\u547D\u540D\u732B\u732B\u52A8\u6001";
209
- console.log(` ${chalk4.white.bold(title)} ${chalk4.dim(`[${moment.slug}]`)}`);
210
- if (moment.description) {
211
- console.log(` ${chalk4.gray(moment.description)}`);
212
- }
213
- if (moment.imageUrl) {
214
- console.log(` ${chalk4.blue(moment.imageUrl)}`);
215
- }
216
- console.log("");
217
- }
218
- };
219
231
  function createCatCommand() {
220
- 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) => {
232
+ const cmd = new Command3("cat").alias("meow").description("\u9EA6\u9EA6\uFF0C\u4E00\u53EA\u5728\u5DE1\u89C6\u3001\u53D1\u5446\u3001\u8FFD\u5149\u7684\u732B (--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E)").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
221
233
  const printJson = (data, error) => {
222
- const payload = {
223
- tool: "maidang",
224
- command: "cat",
225
- data
226
- };
227
- if (error) {
228
- payload.error = error;
229
- }
234
+ const payload = { tool: "maidang", command: "cat", data };
235
+ if (error) payload.error = error;
230
236
  console.log(JSON.stringify(payload, null, 2));
231
237
  };
232
238
  try {
233
- const catMoments = await getCatMoments();
239
+ const moments = await getCatMoments();
234
240
  if (opts.json) {
235
- printJson(catMoments);
241
+ printJson(moments);
236
242
  return;
237
243
  }
238
- if (catMoments.length === 0) {
239
- console.log(chalk4.yellow.bold("\u9EA6\u9EA6"));
240
- console.log("");
241
- console.log(chalk4.gray("\u6682\u65E0\u732B\u732B\u52A8\u6001\uFF0C\u53EF\u5728\u540E\u53F0\u5148\u6DFB\u52A0\u3002"));
244
+ console.log("");
245
+ console.log(" " + eyebrow("today with maimai"));
246
+ console.log(" " + theme.ink("\u9EA6\u9EA6"));
247
+ console.log("");
248
+ if (moments.length === 0) {
249
+ console.log(" " + theme.inkSoft("\u6682\u65E0\u732B\u732B\u52A8\u6001\uFF0C\u53EF\u5728\u540E\u53F0\u5148\u6DFB\u52A0\u3002"));
242
250
  console.log("");
243
251
  return;
244
252
  }
245
- printCatList(catMoments);
253
+ moments.forEach((m, i) => {
254
+ const title = m.title || "\u672A\u547D\u540D";
255
+ console.log(" " + theme.inkBody(title) + " " + theme.inkMuted(m.slug));
256
+ if (m.description) {
257
+ console.log(" " + theme.inkSoft(m.description));
258
+ }
259
+ if (m.imageUrl) {
260
+ console.log(" " + theme.linkUnderline(m.imageUrl));
261
+ }
262
+ if (i < moments.length - 1) {
263
+ console.log("");
264
+ }
265
+ });
266
+ console.log("");
246
267
  } catch (err) {
247
268
  const message = err instanceof Error ? err.message : String(err);
248
269
  if (opts.json) {
249
270
  printJson([], message);
250
271
  return;
251
272
  }
252
- console.error(chalk4.red(`\u83B7\u53D6\u732B\u732B\u52A8\u6001\u5931\u8D25: ${message}`));
273
+ console.error(theme.err(`\u83B7\u53D6\u732B\u732B\u52A8\u6001\u5931\u8D25: ${message}`));
253
274
  process.exit(1);
254
275
  }
255
276
  });
@@ -408,10 +429,35 @@ var PostsApp = ({ apiUrl }) => {
408
429
  );
409
430
  };
410
431
  function createPostsCommand() {
411
- const apiUrl = `${process.env.MAIDANG_API_URL || DEFAULT_API_URL}/api/social-posts`;
412
- 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");
432
+ const baseApiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
433
+ const apiUrl = `${baseApiUrl}/api/social-posts`;
434
+ 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").option("-s, --slug <slug>", "\u6309 slug \u83B7\u53D6\u5355\u7BC7\u6587\u7AE0/\u52A8\u6001");
413
435
  cmd.action((opts) => {
414
436
  const wantsJson = opts.json;
437
+ const slug = opts.slug?.trim();
438
+ if (slug) {
439
+ const detailUrl = `${baseApiUrl}/api/posts/${encodeURIComponent(slug)}`;
440
+ fetch(detailUrl).then(async (res) => {
441
+ if (!res.ok) {
442
+ throw new Error(await readApiMessage(res));
443
+ }
444
+ return readApiData(res);
445
+ }).then((data) => {
446
+ if (wantsJson) {
447
+ console.log(JSON.stringify({ tool: "maidang", command: "posts", slug, data }, null, 2));
448
+ return;
449
+ }
450
+ console.log("");
451
+ console.log(`${data.title || data.slug}`);
452
+ console.log("");
453
+ console.log(data.content);
454
+ console.log("");
455
+ }).catch((err) => {
456
+ console.error(err);
457
+ process.exit(1);
458
+ });
459
+ return;
460
+ }
415
461
  if (wantsJson) {
416
462
  fetch(apiUrl).then(async (res) => {
417
463
  if (!res.ok) {
@@ -1522,9 +1568,8 @@ function createSongsCommand() {
1522
1568
 
1523
1569
  // src/commands/links.ts
1524
1570
  import { Command as Command6 } from "commander";
1525
- import chalk5 from "chalk";
1526
1571
  function createLinksCommand() {
1527
- 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) => {
1572
+ const cmd = new Command6("links").description("\u793E\u4EA4\u4E0E\u5916\u94FE (--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E)").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
1528
1573
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1529
1574
  try {
1530
1575
  const res = await fetch(`${apiUrl}/api/links`);
@@ -1534,14 +1579,23 @@ function createLinksCommand() {
1534
1579
  console.log(JSON.stringify({ tool: "maidang", command: "links", data: links }, null, 2));
1535
1580
  return;
1536
1581
  }
1537
- console.log(chalk5.cyan.bold("\u{1F310} \u793E\u4EA4\u94FE\u63A5\n"));
1538
- for (const link of links) {
1539
- console.log(` ${link.icon} ${chalk5.white(link.name)} - ${chalk5.gray(link.description || "")}`);
1540
- console.log(` ${chalk5.blue(link.url)}
1541
- `);
1542
- }
1582
+ console.log("");
1583
+ console.log(" " + eyebrow("links"));
1584
+ console.log(" " + theme.ink("\u793E\u4EA4\u4E0E\u5916\u94FE"));
1585
+ console.log("");
1586
+ console.log(" " + hairline());
1587
+ console.log("");
1588
+ links.forEach((link, i) => {
1589
+ console.log(" " + theme.inkBody(link.name));
1590
+ if (link.description) {
1591
+ console.log(" " + theme.inkSoft(link.description));
1592
+ }
1593
+ console.log(" " + theme.linkUnderline(link.url));
1594
+ if (i < links.length - 1) console.log("");
1595
+ });
1596
+ console.log("");
1543
1597
  } catch (err) {
1544
- console.error(chalk5.red(`\u83B7\u53D6\u94FE\u63A5\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1598
+ console.error(theme.err(`\u83B7\u53D6\u94FE\u63A5\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1545
1599
  process.exit(1);
1546
1600
  }
1547
1601
  });
@@ -1550,9 +1604,8 @@ function createLinksCommand() {
1550
1604
 
1551
1605
  // src/commands/projects.ts
1552
1606
  import { Command as Command7 } from "commander";
1553
- import chalk6 from "chalk";
1554
1607
  function createProjectsCommand() {
1555
- const cmd = new Command7("projects").description("\u67E5\u770B\u4E2A\u4EBA\u9879\u76EE").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
1608
+ const cmd = new Command7("projects").description("\u4E00\u4E9B\u5DF2\u7ECF\u843D\u5730\u7684\u9879\u76EE\uFF08--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E\uFF09").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
1556
1609
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1557
1610
  try {
1558
1611
  const res = await fetch(`${apiUrl}/api/projects`);
@@ -1562,17 +1615,27 @@ function createProjectsCommand() {
1562
1615
  console.log(JSON.stringify({ tool: "maidang", command: "projects", data: projects }, null, 2));
1563
1616
  return;
1564
1617
  }
1565
- console.log(chalk6.cyan.bold("\u{1F680} \u4E2A\u4EBA\u9879\u76EE\n"));
1566
- for (const project of projects) {
1567
- console.log(` ${project.icon} ${chalk6.white.bold(project.name)} ${chalk6.gray(`[${project.category}]`)}`);
1568
- console.log(` ${project.description}`);
1618
+ console.log("");
1619
+ console.log(" " + eyebrow("projects"));
1620
+ console.log(" " + theme.ink("\u4E00\u4E9B\u5DF2\u7ECF\u843D\u5730\u7684\u4E1C\u897F"));
1621
+ console.log("");
1622
+ console.log(" " + hairline());
1623
+ console.log("");
1624
+ projects.forEach((project, idx) => {
1625
+ const num = theme.inkMuted(String(idx + 1).padStart(2, "0"));
1626
+ const cat = theme.inkMuted(`\xB7 ${project.category}`);
1627
+ console.log(` ${num} ${theme.inkBody(project.name)} ${cat}`);
1628
+ console.log(` ${theme.inkSoft(project.description)}`);
1569
1629
  if (project.url) {
1570
- console.log(` ${chalk6.blue(project.url)}`);
1630
+ console.log(` ${theme.linkUnderline(project.url)}`);
1571
1631
  }
1572
- console.log("");
1573
- }
1632
+ if (idx < projects.length - 1) {
1633
+ console.log("");
1634
+ }
1635
+ });
1636
+ console.log("");
1574
1637
  } catch (err) {
1575
- console.error(chalk6.red(`\u83B7\u53D6\u9879\u76EE\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1638
+ console.error(theme.err(`\u83B7\u53D6\u9879\u76EE\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1576
1639
  process.exit(1);
1577
1640
  }
1578
1641
  });
@@ -1581,9 +1644,13 @@ function createProjectsCommand() {
1581
1644
 
1582
1645
  // src/commands/tools.ts
1583
1646
  import { Command as Command8 } from "commander";
1584
- import chalk7 from "chalk";
1647
+ var categoryNames = {
1648
+ software: "\u8F6F\u4EF6",
1649
+ device: "\u8BBE\u5907",
1650
+ desktop: "\u684C\u9762"
1651
+ };
1585
1652
  function createToolsCommand() {
1586
- const cmd = new Command8("tools").description("\u67E5\u770B\u5E38\u7528\u5DE5\u5177").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
1653
+ const cmd = new Command8("tools").description("\u6700\u8FD1\u5728\u7528\u7684\u597D\u7269 (--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E)").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
1587
1654
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1588
1655
  try {
1589
1656
  const res = await fetch(`${apiUrl}/api/tools`);
@@ -1598,22 +1665,26 @@ function createToolsCommand() {
1598
1665
  acc[tool.category].push(tool);
1599
1666
  return acc;
1600
1667
  }, {});
1601
- const categoryNames = {
1602
- software: "\u5E38\u7528\u8F6F\u4EF6",
1603
- device: "\u8BBE\u5907",
1604
- desktop: "\u684C\u9762\u88C5\u5907"
1605
- };
1606
- console.log(chalk7.cyan.bold("\u{1F527} \u5E38\u7528\u5DE5\u5177\n"));
1607
- for (const [cat, items] of Object.entries(byCategory)) {
1608
- console.log(chalk7.white.bold(` ${categoryNames[cat] || cat}`));
1609
- for (const tool of items) {
1610
- const urlStr = tool.url ? ` ${chalk7.blue(tool.url)}` : "";
1611
- console.log(` ${tool.icon} ${tool.name} - ${chalk7.gray(tool.description)}${urlStr}`);
1668
+ console.log("");
1669
+ console.log(" " + eyebrow("tools"));
1670
+ console.log(" " + theme.ink("\u6700\u8FD1\u5728\u7528\u7684\u597D\u7269"));
1671
+ console.log("");
1672
+ console.log(" " + hairline());
1673
+ console.log("");
1674
+ const cats = Object.keys(byCategory);
1675
+ cats.forEach((cat, i) => {
1676
+ console.log(" " + theme.inkMuted(categoryNames[cat] || cat));
1677
+ for (const tool of byCategory[cat]) {
1678
+ console.log(` ${theme.inkBody(tool.name)} ${theme.inkSoft(tool.description)}`);
1679
+ if (tool.url) {
1680
+ console.log(` ${theme.link(tool.url)}`);
1681
+ }
1612
1682
  }
1613
- console.log("");
1614
- }
1683
+ if (i < cats.length - 1) console.log("");
1684
+ });
1685
+ console.log("");
1615
1686
  } catch (err) {
1616
- console.error(chalk7.red(`\u83B7\u53D6\u5DE5\u5177\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1687
+ console.error(theme.err(`\u83B7\u53D6\u5DE5\u5177\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1617
1688
  process.exit(1);
1618
1689
  }
1619
1690
  });
@@ -1624,7 +1695,7 @@ function createToolsCommand() {
1624
1695
  import React3, { useRef as useRef2, useState as useState3 } from "react";
1625
1696
  import { render as render3, Box as Box3, Text as Text3, useInput as useInput3 } from "ink";
1626
1697
  import { Command as Command9 } from "commander";
1627
- import chalk8 from "chalk";
1698
+ import chalk2 from "chalk";
1628
1699
 
1629
1700
  // src/utils/contact-api.ts
1630
1701
  async function sendContactMessage(input) {
@@ -1674,7 +1745,7 @@ async function contactSync(message, options) {
1674
1745
  }, null, 2));
1675
1746
  return;
1676
1747
  }
1677
- console.error(chalk8.red(`Error: ${messageText}`));
1748
+ console.error(chalk2.red(`Error: ${messageText}`));
1678
1749
  process.exit(1);
1679
1750
  }
1680
1751
  }
@@ -1761,8 +1832,8 @@ ${input.slice(cursorPos)}`;
1761
1832
  setInput(`${input.slice(0, cursorPos)}${char}${input.slice(cursorPos)}`);
1762
1833
  setCursorPos(cursorPos + char.length);
1763
1834
  });
1764
- const displayValue = input.slice(0, cursorPos) + (submitState.type === "success" ? "" : chalk8.inverse(" ")) + input.slice(cursorPos);
1765
- 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)));
1835
+ const displayValue = input.slice(0, cursorPos) + (submitState.type === "success" ? "" : chalk2.inverse(" ")) + input.slice(cursorPos);
1836
+ 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 || chalk2.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)));
1766
1837
  };
1767
1838
  function createContactCommand() {
1768
1839
  const cmd = new Command9("contact").description("\u7ED9\u9EA6\u5F53\u7559\u8A00\uFF08-m \u76F4\u63A5\u53D1\u9001\uFF0C--json \u8F93\u51FA\u7ED3\u6784\u5316\u7ED3\u679C\uFF09").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) => {
@@ -1786,7 +1857,6 @@ function createContactCommand() {
1786
1857
 
1787
1858
  // src/commands/whoami.ts
1788
1859
  import { Command as Command10 } from "commander";
1789
- import chalk9 from "chalk";
1790
1860
 
1791
1861
  // src/constants/profile.ts
1792
1862
  var INTRO_TEXT = "Agent \u5F00\u53D1 / AI \u5DE5\u4F5C\u6D41 / \u5168\u6808 \xB7 \u5F00\u653E\u5408\u4F5C\uFF0C\u6B22\u8FCE\u627E\u6211\u804A\u804A";
@@ -1800,19 +1870,14 @@ function getStatus() {
1800
1870
  if (hour >= 19) return { status: "busy", label: "\u4E0B\u73ED\u4E86", description: "\u4F11\u606F\u4E2D\uFF0C\u770B\u5230\u4F1A\u56DE" };
1801
1871
  return { status: "working", label: "\u5DE5\u4F5C\u4E2D", description: "\u6B63\u5E38\u5DE5\u4F5C\u65F6\u6BB5" };
1802
1872
  }
1803
- function hr(char = "\u2500", len = 40) {
1804
- console.log(chalk9.dim(char.repeat(len)));
1805
- }
1806
1873
  function createWhoAmICommand() {
1807
- const cmd = new Command10("whoami").description("\u4E86\u89E3\u6211").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1874
+ const cmd = new Command10("whoami").description("\u4E00\u53E5\u8BDD\u4ECB\u7ECD\u6211\uFF08--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E\uFF09").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action((opts) => {
1808
1875
  const status = getStatus();
1809
1876
  const whoami = {
1810
1877
  tagline: INTRO_TEXT,
1811
1878
  location: "\u676D\u5DDE \xB7 EFC",
1812
1879
  status,
1813
- links: [
1814
- { label: "Blog", url: "https://www.maidang.me" }
1815
- ],
1880
+ links: [{ label: "Blog", url: "https://www.maidang.me" }],
1816
1881
  contact: "borisdunk@sina.com",
1817
1882
  website: "https://www.maidang.me",
1818
1883
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -1822,24 +1887,22 @@ function createWhoAmICommand() {
1822
1887
  return;
1823
1888
  }
1824
1889
  console.log("");
1825
- console.log(chalk9.bold("\u6211\u662F \u9EA6\u5F53"));
1826
- console.log("");
1827
- console.log(" " + whoami.tagline);
1890
+ console.log(" " + eyebrow("whoami"));
1891
+ console.log(" " + theme.ink("\u6211\u662F\u9EA6\u5F53"));
1828
1892
  console.log("");
1829
- hr();
1893
+ console.log(" " + theme.inkSoft(whoami.tagline));
1830
1894
  console.log("");
1831
- console.log(` ${chalk9.cyan("\u{1F4CD}")} ${whoami.location}`);
1832
- console.log(` ${chalk9.cyan("\u23F1")} ${whoami.status.label} \xB7 ${chalk9.dim(whoami.status.description)}`);
1895
+ console.log(" " + hairline());
1833
1896
  console.log("");
1834
- hr();
1897
+ printKV("\u5750\u6807", whoami.location);
1898
+ printKV("\u72B6\u6001", `${whoami.status.label} \xB7 ${theme.inkMuted(whoami.status.description)}`);
1835
1899
  console.log("");
1836
- console.log(` Blog ${chalk9.blue.underline(whoami.website)}`);
1837
- console.log(` Email ${chalk9.blue(whoami.contact)}`);
1900
+ console.log(" " + hairline());
1838
1901
  console.log("");
1839
- hr();
1902
+ printKV("Blog", theme.linkUnderline(whoami.website));
1903
+ printKV("Email", theme.link(whoami.contact));
1840
1904
  console.log("");
1841
- console.log(` ${chalk9.dim("\u60F3\u4E86\u89E3\u66F4\u591A\uFF1F")}`);
1842
- console.log(` ${chalk9.dim("maidang career / posts / links / contact")}`);
1905
+ console.log(" " + theme.inkMuted("\u60F3\u4E86\u89E3\u66F4\u591A\uFF1A") + theme.inkSoft("npx maidang ") + theme.inkMuted("career / posts / projects"));
1843
1906
  console.log("");
1844
1907
  });
1845
1908
  return cmd;
@@ -1849,7 +1912,7 @@ function createWhoAmICommand() {
1849
1912
  import React4, { useState as useState4, useRef as useRef3, useEffect as useEffect3 } from "react";
1850
1913
  import { render as render4, Box as Box4, Text as Text4, useInput as useInput4 } from "ink";
1851
1914
  import { Command as Command11 } from "commander";
1852
- import chalk10 from "chalk";
1915
+ import chalk3 from "chalk";
1853
1916
 
1854
1917
  // src/utils/chat-api.ts
1855
1918
  var API_URL = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
@@ -1934,7 +1997,7 @@ async function chatSync(message, json = false, sessionId) {
1934
1997
  } else {
1935
1998
  if (thinking) {
1936
1999
  thinking.split("\n").forEach((line) => {
1937
- console.log(`${chalk10.dim("\u{1F4AD}")} ${chalk10.dim(line)}`);
2000
+ console.log(`${chalk3.dim("\u{1F4AD}")} ${chalk3.dim(line)}`);
1938
2001
  });
1939
2002
  console.log();
1940
2003
  }
@@ -1943,25 +2006,25 @@ async function chatSync(message, json = false, sessionId) {
1943
2006
  const name = tc.call?.function?.name || tc.name || "unknown";
1944
2007
  const args = tc.call?.function?.arguments || tc.arguments || "{}";
1945
2008
  const result = tc.result || "";
1946
- let content = `${chalk10.yellow(name)} ${chalk10.gray(args)}`;
2009
+ let content = `${chalk3.yellow(name)} ${chalk3.gray(args)}`;
1947
2010
  if (result) content += `
1948
- ${chalk10.cyan(result)}`;
1949
- console.log(`${chalk10.dim("\u26A1")} ${content}`);
2011
+ ${chalk3.cyan(result)}`;
2012
+ console.log(`${chalk3.dim("\u26A1")} ${content}`);
1950
2013
  });
1951
2014
  console.log();
1952
2015
  }
1953
2016
  console.log(response);
1954
2017
  if (newSessionId && newSessionId !== sessionId) {
1955
2018
  console.log();
1956
- console.log(chalk10.dim(`Session: ${chalk10.cyan(newSessionId)}`));
1957
- console.log(chalk10.dim("\u4F7F\u7528 --session-id \u7EE7\u7EED\u5BF9\u8BDD"));
2019
+ console.log(chalk3.dim(`Session: ${chalk3.cyan(newSessionId)}`));
2020
+ console.log(chalk3.dim("\u4F7F\u7528 --session-id \u7EE7\u7EED\u5BF9\u8BDD"));
1958
2021
  }
1959
2022
  }
1960
2023
  } catch (err) {
1961
2024
  if (json) {
1962
2025
  console.error(JSON.stringify({ tool: "maidang", command: "chat", error: err.message }, null, 2));
1963
2026
  } else {
1964
- console.error(chalk10.red(`Error: ${err.message}`));
2027
+ console.error(chalk3.red(`Error: ${err.message}`));
1965
2028
  process.exit(1);
1966
2029
  }
1967
2030
  }
@@ -2165,6 +2228,9 @@ function createChatCommand() {
2165
2228
  return cmd;
2166
2229
  }
2167
2230
 
2231
+ // src/commands/manifest.ts
2232
+ import { Command as Command12 } from "commander";
2233
+
2168
2234
  // src/utils/version.ts
2169
2235
  function getAgeVersion() {
2170
2236
  const birthDate = new Date(1997, 2, 10);
@@ -2177,29 +2243,100 @@ function getAgeVersion() {
2177
2243
  return `${age}.0.0`;
2178
2244
  }
2179
2245
 
2246
+ // src/commands/manifest.ts
2247
+ async function fetchOrEmpty(url) {
2248
+ try {
2249
+ const res = await fetch(url);
2250
+ if (!res.ok) {
2251
+ throw new Error(await readApiMessage(res));
2252
+ }
2253
+ return await readApiData(res);
2254
+ } catch {
2255
+ return null;
2256
+ }
2257
+ }
2258
+ function createManifestCommand() {
2259
+ const cmd = new Command12("manifest").description("\u4E00\u6B21\u6027\u8F93\u51FA\u5168\u90E8\u516C\u5F00\u6570\u636E\uFF0C\u7ED9 AI agent \u7528").option("--json", "\u8F93\u51FA JSON\uFF08\u9ED8\u8BA4\u5C31\u662F JSON\uFF0C\u52A0\u4E0D\u52A0\u90FD\u4E00\u6837\uFF09").option("--pretty", "\u4EBA\u7C7B\u53EF\u8BFB\u7684\u7B80\u7248\u6982\u89C8\uFF08\u4E0D\u542B\u6B63\u6587\uFF09").action(async (opts) => {
2260
+ const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
2261
+ const [projects, tools, links] = await Promise.all([
2262
+ fetchOrEmpty(`${apiUrl}/api/projects`),
2263
+ fetchOrEmpty(`${apiUrl}/api/tools`),
2264
+ fetchOrEmpty(`${apiUrl}/api/links`)
2265
+ ]);
2266
+ const manifest = {
2267
+ tool: "maidang",
2268
+ command: "manifest",
2269
+ version: getAgeVersion(),
2270
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2271
+ source: apiUrl,
2272
+ identity: {
2273
+ name: "\u9EA6\u5F53",
2274
+ tagline: "Agent \u5F00\u53D1 / AI \u5DE5\u4F5C\u6D41 / \u5168\u6808",
2275
+ location: "\u676D\u5DDE \xB7 EFC",
2276
+ website: "https://maidang.me",
2277
+ contact: "borisdunk@sina.com",
2278
+ openTo: ["\u5408\u4F5C", "AI \u4EA7\u54C1", "Agent", "\u5168\u6808\u5F00\u53D1"]
2279
+ },
2280
+ career: career_default.career,
2281
+ projects: projects ?? [],
2282
+ tools: tools ?? [],
2283
+ links: links ?? [],
2284
+ commands: [
2285
+ { name: "whoami", desc: "\u4E00\u53E5\u8BDD\u4ECB\u7ECD" },
2286
+ { name: "career", desc: "\u5DE5\u4F5C\u7ECF\u5386" },
2287
+ { name: "projects", desc: "\u9879\u76EE" },
2288
+ { name: "posts", desc: "\u63A8\u6587" },
2289
+ { name: "tools", desc: "\u5DE5\u5177" },
2290
+ { name: "songs", desc: "\u6B4C\u5355" },
2291
+ { name: "links", desc: "\u5916\u94FE" },
2292
+ { name: "cat", desc: "\u732B\u732B" },
2293
+ { name: "contact", desc: "\u7559\u8A00" }
2294
+ ]
2295
+ };
2296
+ if (opts.pretty) {
2297
+ console.log("");
2298
+ console.log(" " + eyebrow("manifest"));
2299
+ console.log(" " + theme.ink("\u9EA6\u5F53 \xB7 \u516C\u5F00\u6570\u636E\u6982\u89C8"));
2300
+ console.log("");
2301
+ console.log(" " + hairline());
2302
+ console.log("");
2303
+ printKV("\u8EAB\u4EFD", `${manifest.identity.name} \xB7 ${manifest.identity.tagline}`);
2304
+ printKV("\u5750\u6807", manifest.identity.location);
2305
+ printKV("\u7F51\u7AD9", theme.linkUnderline(manifest.identity.website));
2306
+ printKV("\u90AE\u7BB1", theme.link(manifest.identity.contact));
2307
+ console.log("");
2308
+ console.log(" " + hairline());
2309
+ console.log("");
2310
+ printKV("career", `${manifest.career.experiences.length} \u6BB5\u7ECF\u5386`);
2311
+ printKV("projects", `${manifest.projects.length} \u4E2A\u9879\u76EE`);
2312
+ printKV("tools", `${manifest.tools.length} \u4E2A\u5DE5\u5177`);
2313
+ printKV("links", `${manifest.links.length} \u4E2A\u5916\u94FE`);
2314
+ console.log("");
2315
+ console.log(" " + hairline());
2316
+ console.log("");
2317
+ console.log(" " + theme.inkMuted("\u5B8C\u6574 JSON\uFF1A") + theme.inkSoft("npx maidang manifest"));
2318
+ console.log("");
2319
+ return;
2320
+ }
2321
+ console.log(JSON.stringify(manifest, null, 2));
2322
+ });
2323
+ return cmd;
2324
+ }
2325
+
2180
2326
  // src/index.ts
2181
- var program = new Command12();
2182
- 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");
2183
- var careerCmd = createCareerCommand();
2184
- var catCmd = createCatCommand();
2185
- var postsCmd = createPostsCommand();
2186
- var songsCmd = createSongsCommand();
2187
- var linksCmd = createLinksCommand();
2188
- var projectsCmd = createProjectsCommand();
2189
- var toolsCmd = createToolsCommand();
2190
- var contactCmd = createContactCommand();
2191
- var whoamiCmd = createWhoAmICommand();
2192
- var chatCmd = createChatCommand();
2193
- program.addCommand(careerCmd);
2194
- program.addCommand(catCmd);
2195
- program.addCommand(postsCmd);
2196
- program.addCommand(songsCmd);
2197
- program.addCommand(linksCmd);
2198
- program.addCommand(projectsCmd);
2199
- program.addCommand(toolsCmd);
2200
- program.addCommand(contactCmd);
2201
- program.addCommand(whoamiCmd);
2202
- program.addCommand(chatCmd);
2327
+ var program = new Command13();
2328
+ program.name("maidang").description("\u4E00\u4EFD\u53EF\u4EE5\u88AB AI \u8BFB\u53D6\u7684\u4E2A\u4EBA\u624B\u518C").version(getAgeVersion(), "-v, --version", "\u663E\u793A\u7248\u672C\u53F7");
2329
+ program.addCommand(createCareerCommand());
2330
+ program.addCommand(createCatCommand());
2331
+ program.addCommand(createPostsCommand());
2332
+ program.addCommand(createSongsCommand());
2333
+ program.addCommand(createLinksCommand());
2334
+ program.addCommand(createProjectsCommand());
2335
+ program.addCommand(createToolsCommand());
2336
+ program.addCommand(createContactCommand());
2337
+ program.addCommand(createWhoAmICommand());
2338
+ program.addCommand(createChatCommand());
2339
+ program.addCommand(createManifestCommand());
2203
2340
  if (!process.argv.slice(2).length) {
2204
2341
  const homeCmd = createHomeCommand();
2205
2342
  homeCmd.parse(process.argv);