maidang 29.7.19 → 29.7.21

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 Command13 } from "commander";
4
+ import { Command as Command14 } from "commander";
5
5
 
6
6
  // src/commands/home.ts
7
7
  import { Command } from "commander";
@@ -51,6 +51,7 @@ var commands = [
51
51
  { name: "projects", desc: "\u4E00\u4E9B\u5DF2\u7ECF\u843D\u5730\u7684\u4E1C\u897F" },
52
52
  { name: "posts", desc: "\u6700\u8FD1\u5728\u5199\u3001\u5728\u60F3\u7684" },
53
53
  { name: "tools", desc: "\u6700\u8FD1\u5728\u7528\u7684\u597D\u7269" },
54
+ { name: "skills", desc: "\u53EF\u5206\u4EAB\u7684 Agent Skills" },
54
55
  { name: "songs", desc: "\u5E74\u5EA6\u6B4C\u5355" },
55
56
  { name: "links", desc: "\u793E\u4EA4\u4E0E\u5916\u94FE" },
56
57
  { name: "cat", desc: "\u9EA6\u9EA6" },
@@ -277,182 +278,82 @@ function createCatCommand() {
277
278
  return cmd;
278
279
  }
279
280
 
280
- // src/commands/posts.tsx
281
- import React, { useState, useEffect } from "react";
282
- import { render, Box, Text, useInput } from "ink";
281
+ // src/commands/posts.ts
283
282
  import { Command as Command4 } from "commander";
284
- var ListView = ({ posts, selectedIndex, onSelect, onEnter, onQuit }) => {
285
- useInput((input, key) => {
286
- if (input === "q" || input === "Q") {
287
- onQuit();
288
- return;
289
- }
290
- if (key.upArrow) {
291
- onSelect(Math.max(0, selectedIndex - 1));
292
- } else if (key.downArrow) {
293
- onSelect(Math.min(posts.length - 1, selectedIndex + 1));
294
- } else if (key.return) {
295
- onEnter();
296
- }
297
- });
298
- return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingX: 2, paddingY: 1 }, /* @__PURE__ */ React.createElement(Box, { marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { bold: true, color: "cyan" }, "\u{1F426} \u63A8\u6587\u5217\u8868"), /* @__PURE__ */ React.createElement(Text, { dimColor: true }, " \xB7 ", posts.length, " \u6761")), /* @__PURE__ */ React.createElement(Text, { dimColor: true, marginBottom: 1 }, "\u2191\u2193 \u9009\u62E9 \xB7 Enter \u67E5\u770B\u8BE6\u60C5 \xB7 q \u9000\u51FA"), /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", borderStyle: "single", borderColor: "gray", paddingX: 0, paddingY: 0 }, posts.map((post, index) => {
299
- const isSelected = selectedIndex === index;
300
- const num = String(index + 1).padStart(2, " ");
301
- const title = post.title || post.summary?.substring(0, 40) || post.content.substring(0, 40);
302
- const meta = [post.date, post.time].filter(Boolean).join(" ");
303
- return /* @__PURE__ */ React.createElement(
304
- Box,
305
- {
306
- key: post.slug,
307
- paddingX: 1,
308
- paddingY: 0,
309
- marginY: 0,
310
- borderStyle: "single",
311
- borderColor: isSelected ? "cyan" : "gray"
312
- },
313
- /* @__PURE__ */ React.createElement(Text, { dimColor: true }, num),
314
- /* @__PURE__ */ React.createElement(Text, { dimColor: true }, " \u2502 "),
315
- /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", flexGrow: 1 }, /* @__PURE__ */ React.createElement(Text, { bold: isSelected, color: isSelected ? "cyan" : void 0 }, title), meta && /* @__PURE__ */ React.createElement(Text, { dimColor: true }, meta)),
316
- isSelected && /* @__PURE__ */ React.createElement(Text, { dimColor: true }, " \u2190")
317
- );
318
- })));
319
- };
320
- var DetailView = ({ post, onBack, onQuit, onPrev, onNext, hasPrev, hasNext }) => {
321
- useInput((input, key) => {
322
- if (input === "q" || input === "Q") {
323
- onQuit();
324
- return;
325
- }
326
- if (key.escape || input === "b" || input === "B") {
327
- onBack();
328
- return;
329
- }
330
- if (key.leftArrow && hasPrev) {
331
- onPrev();
332
- } else if (key.rightArrow && hasNext) {
333
- onNext();
334
- }
335
- });
336
- const paragraphs = post.content.split("\n").reduce((acc, line) => {
337
- if (line.trim() === "") {
338
- acc.push([]);
339
- } else {
340
- if (acc.length === 0 || acc[acc.length - 1].length === 0) {
341
- acc.push([line]);
342
- } else {
343
- acc[acc.length - 1].push(line);
344
- }
345
- }
346
- return acc;
347
- }, []).filter((p) => p.length > 0);
348
- const tags = post.tags || [];
349
- const meta = [post.date, post.time].filter(Boolean).join(" ");
350
- return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingX: 2, paddingY: 1, flexShrink: 0 }, /* @__PURE__ */ React.createElement(Box, { marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { bold: true, color: "cyan" }, "\u{1F4C4} \u63A8\u6587\u8BE6\u60C5"), /* @__PURE__ */ React.createElement(Text, { dimColor: true }, " \xB7 Esc/q \u8FD4\u56DE \xB7 \u2190\u2192 \u5207\u6362")), /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", borderStyle: "single", borderColor: "cyan", paddingX: 1, marginBottom: 0, flexShrink: 0 }, /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Text, { bold: true, color: "white" }, post.author || "\u9EA6\u5F53"), /* @__PURE__ */ React.createElement(Text, { dimColor: true }, " ", post.handle || "@maidang"), meta && /* @__PURE__ */ React.createElement(Text, { dimColor: true }, " \xB7 ", meta)), post.title && /* @__PURE__ */ React.createElement(Text, { bold: true, color: "cyan" }, post.title)), /* @__PURE__ */ React.createElement(
351
- Box,
352
- {
353
- flexDirection: "column",
354
- borderStyle: "single",
355
- borderColor: "gray",
356
- paddingX: 1,
357
- marginY: 0,
358
- flexShrink: 1,
359
- overflow: "hidden"
360
- },
361
- paragraphs.map((para, pi) => /* @__PURE__ */ React.createElement(Box, { key: pi, flexDirection: "column", marginBottom: pi < paragraphs.length - 1 ? 1 : 0, flexShrink: 0 }, para.map((line, li) => /* @__PURE__ */ React.createElement(Text, { key: li, wrap: "wrap" }, line))))
362
- ), tags.length > 0 && /* @__PURE__ */ React.createElement(Box, { borderStyle: "single", borderColor: "gray", paddingX: 1, marginY: 0, flexShrink: 0 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, tags.map((tag) => /* @__PURE__ */ React.createElement(Text, { key: tag, color: "cyan" }, "#", tag, " ")))), /* @__PURE__ */ React.createElement(Box, { marginTop: 1, flexShrink: 0 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "\u2190 ", hasPrev ? "\u4E0A\u4E00\u7BC7" : "\u65E0", "\u3000\u3000\u2192 ", hasNext ? "\u4E0B\u4E00\u7BC7" : "\u65E0", "\u3000\u3000Esc \u8FD4\u56DE")));
363
- };
364
- var PostsApp = ({ apiUrl }) => {
365
- const [posts, setPosts] = useState([]);
366
- const [selectedIndex, setSelectedIndex] = useState(0);
367
- const [view, setView] = useState("LIST");
368
- const [loading, setLoading] = useState(true);
369
- const [error, setError] = useState(null);
370
- useEffect(() => {
371
- fetch(apiUrl).then(async (res) => {
372
- if (!res.ok) throw new Error(await readApiMessage(res));
373
- return readApiData(res);
374
- }).then((data) => {
375
- setPosts(data);
376
- setLoading(false);
377
- }).catch((err) => {
378
- setError(err.message);
379
- setLoading(false);
380
- });
381
- }, [apiUrl]);
382
- const handleQuit = () => {
383
- process.exit(0);
384
- };
385
- const handleEnter = () => {
386
- setView("DETAIL");
387
- };
388
- const handleBack = () => {
389
- setView("LIST");
390
- };
391
- const handlePrev = () => {
392
- setSelectedIndex((i) => Math.max(0, i - 1));
393
- };
394
- const handleNext = () => {
395
- setSelectedIndex((i) => Math.min(posts.length - 1, i + 1));
396
- };
397
- if (loading) {
398
- return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingX: 2, paddingY: 1 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "\u52A0\u8F7D\u4E2D..."));
399
- }
400
- if (error) {
401
- return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingX: 2, paddingY: 1 }, /* @__PURE__ */ React.createElement(Text, { color: "red" }, "\u52A0\u8F7D\u5931\u8D25: ", error), /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "\u8BF7\u68C0\u67E5\u7F51\u7EDC\u6216API\u5730\u5740"));
402
- }
403
- if (posts.length === 0) {
404
- return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingX: 2, paddingY: 1 }, /* @__PURE__ */ React.createElement(Text, { color: "yellow" }, "\u6682\u65E0\u63A8\u6587"));
283
+
284
+ // src/utils/pagination.ts
285
+ var DEFAULT_PAGE_SIZE = 10;
286
+ function parseCliPagination(value, name, fallback) {
287
+ if (value === void 0) return fallback;
288
+ const parsed = Number(value);
289
+ if (!Number.isInteger(parsed) || parsed < 1) {
290
+ throw new Error(`${name} must be a positive integer`);
405
291
  }
406
- if (view === "DETAIL") {
407
- return /* @__PURE__ */ React.createElement(
408
- DetailView,
409
- {
410
- post: posts[selectedIndex],
411
- onBack: handleBack,
412
- onQuit: handleQuit,
413
- onPrev: handlePrev,
414
- onNext: handleNext,
415
- hasPrev: selectedIndex > 0,
416
- hasNext: selectedIndex < posts.length - 1
417
- }
418
- );
292
+ return parsed;
293
+ }
294
+ function buildPaginationUrl(baseUrl, options, extra = {}) {
295
+ const url = new URL(baseUrl);
296
+ for (const [key, value] of Object.entries(extra)) {
297
+ url.searchParams.set(key, value);
419
298
  }
420
- return /* @__PURE__ */ React.createElement(
421
- ListView,
422
- {
423
- posts,
424
- selectedIndex,
425
- onSelect: setSelectedIndex,
426
- onEnter: handleEnter,
427
- onQuit: handleQuit
428
- }
429
- );
430
- };
299
+ url.searchParams.set("page", String(parseCliPagination(options.page, "page", 1)));
300
+ url.searchParams.set("pageSize", String(parseCliPagination(options.pageSize, "pageSize", DEFAULT_PAGE_SIZE)));
301
+ return url.toString();
302
+ }
303
+
304
+ // src/commands/posts.ts
431
305
  function createPostsCommand() {
432
- const apiUrl = `${process.env.MAIDANG_API_URL || DEFAULT_API_URL}/api/social-posts`;
433
- 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");
434
- cmd.action((opts) => {
435
- const wantsJson = opts.json;
436
- if (wantsJson) {
437
- fetch(apiUrl).then(async (res) => {
438
- if (!res.ok) {
439
- throw new Error(await readApiMessage(res));
306
+ const baseApiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
307
+ const cmd = new Command4("posts").description("\u52A8\u6001\u5217\u8868\uFF0C\u9ED8\u8BA4\u6BCF\u9875 10 \u6761\uFF08--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E\uFF09").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").option("-s, --slug <slug>", "\u6309 slug \u83B7\u53D6\u5355\u7BC7\u6587\u7AE0/\u52A8\u6001").option("--page <page>", "\u9875\u7801\uFF0C\u4ECE 1 \u5F00\u59CB", "1").option("--page-size <size>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 10", "10");
308
+ cmd.action(async (opts) => {
309
+ const slug = opts.slug?.trim();
310
+ try {
311
+ if (slug) {
312
+ const response2 = await fetch(`${baseApiUrl}/api/posts/${encodeURIComponent(slug)}`);
313
+ if (!response2.ok) throw new Error(await readApiMessage(response2));
314
+ const data2 = await readApiData(response2);
315
+ if (opts.json) {
316
+ console.log(JSON.stringify({ tool: "maidang", command: "posts", slug, data: data2 }, null, 2));
317
+ return;
440
318
  }
441
- return readApiData(res);
442
- }).then((data) => console.log(JSON.stringify({ tool: "maidang", command: "posts", data }, null, 2))).catch((err) => {
443
- console.error(err);
444
- process.exit(1);
319
+ console.log("");
320
+ console.log(data2.title || data2.slug);
321
+ console.log("");
322
+ console.log(data2.content);
323
+ console.log("");
324
+ return;
325
+ }
326
+ const response = await fetch(buildPaginationUrl(`${baseApiUrl}/api/social-posts`, opts, { type: "social" }));
327
+ if (!response.ok) throw new Error(await readApiMessage(response));
328
+ const data = await readApiData(response);
329
+ if (opts.json) {
330
+ console.log(JSON.stringify({ tool: "maidang", command: "posts", data }, null, 2));
331
+ return;
332
+ }
333
+ console.log("");
334
+ console.log(" " + eyebrow("posts"));
335
+ console.log(" " + theme.ink(`\u7B2C ${data.pagination.page}/${data.pagination.totalPages || 1} \u9875 \xB7 \u5171 ${data.pagination.total} \u6761`));
336
+ console.log("");
337
+ console.log(" " + hairline());
338
+ console.log("");
339
+ data.items.forEach((post, index) => {
340
+ const title = post.title || post.summary || post.content.split("\n")[0] || post.slug;
341
+ const meta = [post.date, post.time].filter(Boolean).join(" ");
342
+ console.log(` ${theme.inkMuted(String((data.pagination.page - 1) * data.pagination.pageSize + index + 1).padStart(2, "0"))} ${theme.inkBody(title)}`);
343
+ if (meta) console.log(` ${theme.inkMuted(meta)}`);
344
+ console.log(` ${theme.inkSoft(post.slug)}`);
345
+ if (index < data.items.length - 1) console.log("");
445
346
  });
446
- return;
347
+ console.log("");
348
+ } catch (error) {
349
+ console.error(theme.err(`\u83B7\u53D6\u52A8\u6001\u5931\u8D25: ${error instanceof Error ? error.message : error}`));
350
+ process.exit(1);
447
351
  }
448
- render(/* @__PURE__ */ React.createElement(PostsApp, { apiUrl }));
449
352
  });
450
353
  return cmd;
451
354
  }
452
355
 
453
- // src/commands/songs.tsx
454
- import React2, { useState as useState2, useRef } from "react";
455
- import { render as render2, Box as Box2, Text as Text2, useInput as useInput2 } from "ink";
356
+ // src/commands/songs.ts
456
357
  import { Command as Command5 } from "commander";
457
358
 
458
359
  // src/data/songs.json
@@ -1342,203 +1243,70 @@ function copyToClipboard(text) {
1342
1243
  execSync(`printf '${text.replace(/'/g, "'\\''")}' | pbcopy`, { stdio: "ignore" });
1343
1244
  }
1344
1245
 
1345
- // src/commands/songs.tsx
1346
- var ALL_YEARS = songs_default.data;
1347
- var AVAILABLE_YEARS = songs_default.years;
1348
- var ALL_META = songs_default.meta;
1246
+ // src/commands/songs.ts
1247
+ var allYears = songs_default.data;
1248
+ var availableYears = songs_default.years;
1249
+ var allMeta = songs_default.meta;
1349
1250
  function formatDuration(ms) {
1350
- const s = Math.round(ms / 1e3);
1351
- const m = Math.floor(s / 60);
1352
- const sec = s % 60;
1353
- return `${m}:${sec.toString().padStart(2, "0")}`;
1251
+ const seconds = Math.round(ms / 1e3);
1252
+ return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
1354
1253
  }
1355
- var YearPicker = ({ selectedIndex, onSelect, onConfirm, onQuit }) => {
1356
- useInput2((input, key) => {
1357
- if (input === "q" || input === "Q") {
1358
- onQuit();
1359
- return;
1360
- }
1361
- if (key.upArrow) {
1362
- onSelect(Math.max(0, selectedIndex - 1));
1363
- } else if (key.downArrow) {
1364
- onSelect(Math.min(ALL_YEARS.length - 1, selectedIndex + 1));
1365
- } else if (key.return) {
1366
- onConfirm();
1367
- }
1368
- });
1369
- return /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", paddingX: 2, paddingY: 1 }, /* @__PURE__ */ React2.createElement(Box2, { marginBottom: 1 }, /* @__PURE__ */ React2.createElement(Text2, { bold: true, color: "cyan" }, "\u{1F3B5} \u5E74\u5EA6\u6B4C\u5355"), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, " \xB7 ", ALL_YEARS.length, " \u4E2A\u5E74\u4EFD")), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true, marginBottom: 1 }, "\u2191\u2193 \u9009\u62E9\u5E74\u4EFD \xB7 Enter \u8FDB\u5165 \xB7 q \u9000\u51FA"), /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", borderStyle: "single", borderColor: "gray", paddingX: 0, paddingY: 0 }, ALL_YEARS.map((entry, index) => {
1370
- const isSelected = selectedIndex === index;
1371
- const meta = ALL_META.find((m) => m.year === entry.year);
1372
- const preview = entry.songs[0] ? `${entry.songs[0].artists[0] || ""} \xB7 ${entry.songs[0].name}` : "";
1373
- return /* @__PURE__ */ React2.createElement(
1374
- Box2,
1375
- {
1376
- key: entry.year,
1377
- paddingX: 1,
1378
- paddingY: 0,
1379
- marginY: 0,
1380
- borderStyle: "single",
1381
- borderColor: isSelected ? "cyan" : "gray"
1382
- },
1383
- /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, entry.year),
1384
- /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, " \u2502 "),
1385
- /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", flexGrow: 1 }, /* @__PURE__ */ React2.createElement(Text2, { bold: isSelected, color: isSelected ? "cyan" : void 0 }, entry.year, " \u5E74\u5EA6\u6B4C\u5355"), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, meta?.trackCount || entry.songs.length, " \u9996 ", preview ? `\xB7 ${preview}` : "")),
1386
- isSelected && /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, " \u2190")
1387
- );
1388
- })));
1389
- };
1390
- var SongList = ({ entry, selectedIndex, onSelect, onEnter, onBack, onQuit }) => {
1391
- useInput2((input, key) => {
1392
- if (input === "q" || input === "Q") {
1393
- onQuit();
1394
- return;
1395
- }
1396
- if (key.escape || input === "b" || input === "B") {
1397
- onBack();
1398
- return;
1399
- }
1400
- if (key.upArrow) {
1401
- onSelect(Math.max(0, selectedIndex - 1));
1402
- } else if (key.downArrow) {
1403
- onSelect(Math.min(entry.songs.length - 1, selectedIndex + 1));
1404
- } else if (key.return) {
1405
- onEnter();
1406
- }
1407
- });
1408
- return /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", paddingX: 2, paddingY: 1 }, /* @__PURE__ */ React2.createElement(Box2, { marginBottom: 1 }, /* @__PURE__ */ React2.createElement(Text2, { bold: true, color: "cyan" }, "\u{1F3B5} ", entry.year, " \u5E74\u5EA6\u6B4C\u5355"), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, " \xB7 ", entry.songs.length, " \u9996 \xB7 Esc \u8FD4\u56DE")), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true, marginBottom: 1 }, "\u2191\u2193 \u9009\u62E9 \xB7 Enter \u67E5\u770B\u8BE6\u60C5 \xB7 q \u9000\u51FA"), /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", borderStyle: "single", borderColor: "gray", paddingX: 0, paddingY: 0 }, entry.songs.map((song, index) => {
1409
- const isSelected = selectedIndex === index;
1410
- const num = String(index + 1).padStart(2, " ");
1411
- const artists = song.artists.join(", ");
1412
- const dur = formatDuration(song.duration);
1413
- return /* @__PURE__ */ React2.createElement(
1414
- Box2,
1415
- {
1416
- key: song.id,
1417
- paddingX: 1,
1418
- paddingY: 0,
1419
- marginY: 0,
1420
- borderStyle: "single",
1421
- borderColor: isSelected ? "cyan" : "gray"
1422
- },
1423
- /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, num),
1424
- /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, " \u2502 "),
1425
- /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", flexGrow: 1 }, /* @__PURE__ */ React2.createElement(Text2, { bold: isSelected, color: isSelected ? "cyan" : void 0 }, song.name), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, artists, " \xB7 ", dur)),
1426
- isSelected && /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, " \u2190")
1427
- );
1428
- })));
1429
- };
1430
- var SongDetail = ({ song, year, onBack, onQuit, onPrev, onNext, hasPrev, hasNext }) => {
1431
- const [copied, setCopied] = useState2(false);
1432
- const timerRef = useRef(null);
1433
- useInput2((input, key) => {
1434
- if (input === "q" || input === "Q") {
1435
- onQuit();
1436
- return;
1437
- }
1438
- if (key.escape || input === "b" || input === "B") {
1439
- onBack();
1440
- return;
1441
- }
1442
- if (key.return) {
1443
- copyToClipboard(song.name);
1444
- setCopied(true);
1445
- if (timerRef.current) clearTimeout(timerRef.current);
1446
- timerRef.current = setTimeout(() => setCopied(false), 1500);
1447
- return;
1448
- }
1449
- if (key.leftArrow && hasPrev) {
1450
- onPrev();
1451
- } else if (key.rightArrow && hasNext) {
1452
- onNext();
1254
+ function printSong(song, index) {
1255
+ console.log(`${String(index + 1).padStart(2, "0")} ${song.name}`);
1256
+ console.log(` ${song.artists.join(", ")} \xB7 ${formatDuration(song.duration)} \xB7 ${song.album}`);
1257
+ }
1258
+ function createSongsCommand() {
1259
+ return new Command5("songs").description(`\u5E74\u5EA6\u6B4C\u5355\uFF0C\u652F\u6301: ${availableYears.join(", ")}\uFF08--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E\uFF09`).option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").option("--year <year>", "\u8F93\u51FA\u6307\u5B9A\u5E74\u4EFD\u7684\u6B4C\u66F2\u5217\u8868").option("--copy <song-id>", "\u590D\u5236\u6307\u5B9A\u6B4C\u66F2\u540D\u79F0").action((opts) => {
1260
+ const year = opts.year ? Number(opts.year) : void 0;
1261
+ const entry = year === void 0 ? void 0 : allYears.find((item) => item.year === year);
1262
+ if (year !== void 0 && !entry) {
1263
+ const message = `\u6CA1\u6709 ${year} \u5E74\u7684\u6B4C\u5355`;
1264
+ if (opts.json) {
1265
+ console.error(JSON.stringify({ tool: "maidang", command: "songs", error: message }, null, 2));
1266
+ } else {
1267
+ console.error(message);
1268
+ }
1269
+ process.exit(1);
1453
1270
  }
1454
- });
1455
- return /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", paddingX: 2, paddingY: 1, flexShrink: 0 }, /* @__PURE__ */ React2.createElement(Box2, { marginBottom: 1 }, /* @__PURE__ */ React2.createElement(Text2, { bold: true, color: "cyan" }, "\u{1F3B5} ", year, " \u5E74\u5EA6\u6B4C\u5355"), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, " \xB7 Esc/q \u8FD4\u56DE \xB7 \u2190\u2192 \u5207\u6362")), /* @__PURE__ */ React2.createElement(Box2, { flexDirection: "column", borderStyle: "single", borderColor: "cyan", paddingX: 1, marginBottom: 1, flexShrink: 0 }, /* @__PURE__ */ React2.createElement(Text2, { bold: true, color: "white" }, song.name), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, song.artists.join(", ")), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, "\u4E13\u8F91: ", song.album), /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, "\u65F6\u957F: ", formatDuration(song.duration))), /* @__PURE__ */ React2.createElement(Box2, { marginTop: 1, flexShrink: 0 }, /* @__PURE__ */ React2.createElement(Text2, { dimColor: true }, "\u2190 ", hasPrev ? "\u4E0A\u4E00\u9996" : "\u65E0", "\u3000\u3000\u2192 ", hasNext ? "\u4E0B\u4E00\u9996" : "\u65E0", "\u3000\u3000Esc \u8FD4\u56DE\u3000\u3000Enter ", copied ? "\u2713 \u5DF2\u590D\u5236" : "\u590D\u5236\u6B4C\u540D")));
1456
- };
1457
- var SongsApp = ({ defaultYearIndex }) => {
1458
- const [selectedYearIndex, setSelectedYearIndex] = useState2(defaultYearIndex ?? 0);
1459
- const [selectedSongIndex, setSelectedSongIndex] = useState2(0);
1460
- const [view, setView] = useState2("YEAR_PICK");
1461
- const handleQuit = () => process.exit(0);
1462
- const currentEntry = ALL_YEARS[selectedYearIndex];
1463
- if (view === "SONG_DETAIL") {
1464
- const song = currentEntry.songs[selectedSongIndex];
1465
- if (!song) return null;
1466
- return /* @__PURE__ */ React2.createElement(
1467
- SongDetail,
1468
- {
1469
- song,
1470
- year: currentEntry.year,
1471
- onBack: () => setView("SONG_LIST"),
1472
- onQuit: handleQuit,
1473
- onPrev: () => setSelectedSongIndex((i) => Math.max(0, i - 1)),
1474
- onNext: () => setSelectedSongIndex((i) => Math.min(currentEntry.songs.length - 1, i + 1)),
1475
- hasPrev: selectedSongIndex > 0,
1476
- hasNext: selectedSongIndex < currentEntry.songs.length - 1
1271
+ if (opts.copy) {
1272
+ const song = allYears.flatMap((item) => item.songs).find((item) => item.id === opts.copy);
1273
+ if (!song) {
1274
+ console.error(`\u6CA1\u6709\u627E\u5230\u6B4C\u66F2 ${opts.copy}`);
1275
+ process.exit(1);
1477
1276
  }
1478
- );
1479
- }
1480
- if (view === "SONG_LIST") {
1481
- return /* @__PURE__ */ React2.createElement(
1482
- SongList,
1483
- {
1484
- entry: currentEntry,
1485
- selectedIndex: selectedSongIndex,
1486
- onSelect: setSelectedSongIndex,
1487
- onEnter: () => setView("SONG_DETAIL"),
1488
- onBack: () => {
1489
- setSelectedSongIndex(0);
1490
- setView("YEAR_PICK");
1491
- },
1492
- onQuit: handleQuit
1277
+ copyToClipboard(song.name);
1278
+ if (opts.json) {
1279
+ console.log(JSON.stringify({ tool: "maidang", command: "songs", copied: song.name, data: song }, null, 2));
1280
+ } else {
1281
+ console.log(`\u5DF2\u590D\u5236\uFF1A${song.name}`);
1493
1282
  }
1494
- );
1495
- }
1496
- return /* @__PURE__ */ React2.createElement(
1497
- YearPicker,
1498
- {
1499
- selectedIndex: selectedYearIndex,
1500
- onSelect: (i) => {
1501
- setSelectedYearIndex(i);
1502
- setSelectedSongIndex(0);
1503
- },
1504
- onConfirm: () => {
1505
- setSelectedSongIndex(0);
1506
- setView("SONG_LIST");
1507
- },
1508
- onQuit: handleQuit
1283
+ return;
1509
1284
  }
1510
- );
1511
- };
1512
- function createSongsCommand() {
1513
- 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`);
1514
- cmd.action((opts) => {
1515
1285
  if (opts.json) {
1516
- if (opts.year) {
1517
- const year = parseInt(opts.year, 10);
1518
- const entry = ALL_YEARS.find((e) => e.year === year);
1519
- if (!entry) {
1520
- console.error(`\u6CA1\u6709 ${year} \u5E74\u7684\u6B4C\u5355`);
1521
- process.exit(1);
1522
- }
1523
- const meta = ALL_META.find((m) => m.year === year);
1286
+ if (entry) {
1287
+ const meta = allMeta.find((item) => item.year === entry.year);
1524
1288
  console.log(JSON.stringify({ tool: "maidang", command: "songs", meta, data: entry.songs }, null, 2));
1525
1289
  } else {
1526
- console.log(JSON.stringify({ tool: "maidang", command: "songs", years: AVAILABLE_YEARS, meta: ALL_META, data: ALL_YEARS }, null, 2));
1290
+ console.log(JSON.stringify({ tool: "maidang", command: "songs", years: availableYears, meta: allMeta, data: allYears }, null, 2));
1527
1291
  }
1528
1292
  return;
1529
1293
  }
1530
- let defaultYearIndex;
1531
- if (opts.year) {
1532
- const year = parseInt(opts.year, 10);
1533
- defaultYearIndex = ALL_YEARS.findIndex((e) => e.year === year);
1534
- if (defaultYearIndex < 0) {
1535
- console.error(`\u6CA1\u6709 ${year} \u5E74\u7684\u6B4C\u5355`);
1536
- process.exit(1);
1537
- }
1294
+ if (entry) {
1295
+ console.log(`
1296
+ ${entry.year} \u5E74\u5EA6\u6B4C\u5355 \xB7 ${entry.songs.length} \u9996
1297
+ `);
1298
+ entry.songs.forEach(printSong);
1299
+ console.log("");
1300
+ return;
1301
+ }
1302
+ console.log("\n\u5E74\u5EA6\u6B4C\u5355\n");
1303
+ for (const item of allYears) {
1304
+ const meta = allMeta.find((candidate) => candidate.year === item.year);
1305
+ const preview = item.songs[0] ? ` \xB7 ${item.songs[0].name}` : "";
1306
+ console.log(`${item.year} ${meta?.trackCount || item.songs.length} \u9996${preview}`);
1538
1307
  }
1539
- render2(/* @__PURE__ */ React2.createElement(SongsApp, { defaultYearIndex }));
1308
+ console.log("\n\u67E5\u770B\u67D0\u5E74\uFF1Anpx maidang songs --year <year>\n");
1540
1309
  });
1541
- return cmd;
1542
1310
  }
1543
1311
 
1544
1312
  // src/commands/links.ts
@@ -1580,41 +1348,36 @@ function createLinksCommand() {
1580
1348
  // src/commands/projects.ts
1581
1349
  import { Command as Command7 } from "commander";
1582
1350
  function createProjectsCommand() {
1583
- 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) => {
1351
+ return new Command7("projects").description("\u9879\u76EE\u5217\u8868\uFF0C\u9ED8\u8BA4\u6BCF\u9875 10 \u6761\uFF08--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E\uFF09").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").option("--page <page>", "\u9875\u7801\uFF0C\u4ECE 1 \u5F00\u59CB", "1").option("--page-size <size>", "\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 10", "10").action(async (opts) => {
1584
1352
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1585
1353
  try {
1586
- const res = await fetch(`${apiUrl}/api/projects`);
1587
- if (!res.ok) throw new Error(await readApiMessage(res));
1588
- const projects = await readApiData(res);
1354
+ const response = await fetch(buildPaginationUrl(`${apiUrl}/api/projects`, opts));
1355
+ if (!response.ok) throw new Error(await readApiMessage(response));
1356
+ const data = await readApiData(response);
1589
1357
  if (opts.json) {
1590
- console.log(JSON.stringify({ tool: "maidang", command: "projects", data: projects }, null, 2));
1358
+ console.log(JSON.stringify({ tool: "maidang", command: "projects", data }, null, 2));
1591
1359
  return;
1592
1360
  }
1593
1361
  console.log("");
1594
1362
  console.log(" " + eyebrow("projects"));
1595
- console.log(" " + theme.ink("\u4E00\u4E9B\u5DF2\u7ECF\u843D\u5730\u7684\u4E1C\u897F"));
1363
+ console.log(" " + theme.ink(`\u7B2C ${data.pagination.page}/${data.pagination.totalPages || 1} \u9875 \xB7 \u5171 ${data.pagination.total} \u4E2A\u9879\u76EE`));
1596
1364
  console.log("");
1597
1365
  console.log(" " + hairline());
1598
1366
  console.log("");
1599
- projects.forEach((project, idx) => {
1600
- const num = theme.inkMuted(String(idx + 1).padStart(2, "0"));
1367
+ data.items.forEach((project, index) => {
1368
+ const num = theme.inkMuted(String((data.pagination.page - 1) * data.pagination.pageSize + index + 1).padStart(2, "0"));
1601
1369
  const cat = theme.inkMuted(`\xB7 ${project.category}`);
1602
1370
  console.log(` ${num} ${theme.inkBody(project.name)} ${cat}`);
1603
1371
  console.log(` ${theme.inkSoft(project.description)}`);
1604
- if (project.url) {
1605
- console.log(` ${theme.linkUnderline(project.url)}`);
1606
- }
1607
- if (idx < projects.length - 1) {
1608
- console.log("");
1609
- }
1372
+ if (project.url) console.log(` ${theme.linkUnderline(project.url)}`);
1373
+ if (index < data.items.length - 1) console.log("");
1610
1374
  });
1611
1375
  console.log("");
1612
- } catch (err) {
1613
- console.error(theme.err(`\u83B7\u53D6\u9879\u76EE\u5931\u8D25: ${err instanceof Error ? err.message : err}`));
1376
+ } catch (error) {
1377
+ console.error(theme.err(`\u83B7\u53D6\u9879\u76EE\u5931\u8D25: ${error instanceof Error ? error.message : error}`));
1614
1378
  process.exit(1);
1615
1379
  }
1616
1380
  });
1617
- return cmd;
1618
1381
  }
1619
1382
 
1620
1383
  // src/commands/tools.ts
@@ -1666,10 +1429,62 @@ function createToolsCommand() {
1666
1429
  return cmd;
1667
1430
  }
1668
1431
 
1669
- // src/commands/contact.tsx
1670
- import React3, { useRef as useRef2, useState as useState3 } from "react";
1671
- import { render as render3, Box as Box3, Text as Text3, useInput as useInput3 } from "ink";
1432
+ // src/commands/skills.ts
1672
1433
  import { Command as Command9 } from "commander";
1434
+ function createSkillsCommand() {
1435
+ return new Command9("skills").description("\u53EF\u5206\u4EAB\u7684 Agent Skills\uFF08--json \u8F93\u51FA\u7ED3\u6784\u5316\u6570\u636E\uFF09").option("--slug <slug>", "\u67E5\u8BE2\u4E00\u4E2A Skill \u7684\u5B8C\u6574\u5185\u5BB9").option("--json", "\u8F93\u51FA JSON \u683C\u5F0F").action(async (opts) => {
1436
+ const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
1437
+ try {
1438
+ if (opts.slug) {
1439
+ const response2 = await fetch(`${apiUrl}/api/skills/${encodeURIComponent(opts.slug)}`);
1440
+ if (!response2.ok) throw new Error(await readApiMessage(response2));
1441
+ const skill = await readApiData(response2);
1442
+ if (opts.json) {
1443
+ console.log(JSON.stringify({ tool: "maidang", command: "skills", slug: opts.slug, data: skill }, null, 2));
1444
+ return;
1445
+ }
1446
+ console.log("");
1447
+ console.log(" " + eyebrow(`skill / ${skill.category}`));
1448
+ console.log(" " + theme.ink(skill.name));
1449
+ console.log(" " + theme.inkSoft(skill.description));
1450
+ console.log("");
1451
+ console.log(" " + hairline());
1452
+ console.log("");
1453
+ console.log(" " + theme.inkMuted(`SKILL.md + ${skill.files.length} reference files`));
1454
+ for (const file of skill.files) console.log(" " + theme.inkMuted(`\u251C\u2500 ${file.path}`));
1455
+ console.log("");
1456
+ console.log(skill.content);
1457
+ return;
1458
+ }
1459
+ const response = await fetch(`${apiUrl}/api/skills`);
1460
+ if (!response.ok) throw new Error(await readApiMessage(response));
1461
+ const skills = await readApiData(response);
1462
+ if (opts.json) {
1463
+ console.log(JSON.stringify({ tool: "maidang", command: "skills", data: skills }, null, 2));
1464
+ return;
1465
+ }
1466
+ console.log("");
1467
+ console.log(" " + eyebrow("skills"));
1468
+ console.log(" " + theme.ink("\u53EF\u5206\u4EAB\u7684 Agent Skills"));
1469
+ console.log("");
1470
+ console.log(" " + hairline());
1471
+ console.log("");
1472
+ for (const [index, skill] of skills.entries()) {
1473
+ console.log(` ${theme.inkMuted(String(index + 1).padStart(2, "0"))} ${theme.inkBody(skill.name)} ${theme.inkMuted(`\xB7 ${skill.category}`)}`);
1474
+ console.log(` ${theme.inkSoft(skill.description)}`);
1475
+ console.log(` ${theme.inkMuted(`npx maidang skills --slug ${skill.slug}`)}`);
1476
+ if (index < skills.length - 1) console.log("");
1477
+ }
1478
+ console.log("");
1479
+ } catch (error) {
1480
+ console.error(theme.err(`\u83B7\u53D6 Skills \u5931\u8D25: ${error instanceof Error ? error.message : error}`));
1481
+ process.exit(1);
1482
+ }
1483
+ });
1484
+ }
1485
+
1486
+ // src/commands/contact.ts
1487
+ import { Command as Command10 } from "commander";
1673
1488
  import chalk2 from "chalk";
1674
1489
 
1675
1490
  // src/utils/contact-api.ts
@@ -1688,8 +1503,7 @@ async function sendContactMessage(input) {
1688
1503
  return readApiData(res);
1689
1504
  }
1690
1505
 
1691
- // src/commands/contact.tsx
1692
- var IDLE_HINT = "\u586B\u5199\u79F0\u547C / \u90AE\u7BB1 / \u7559\u8A00\uFF0CEnter \u53D1\u9001\uFF0CShift+Enter \u6362\u884C";
1506
+ // src/commands/contact.ts
1693
1507
  async function contactSync(message, options) {
1694
1508
  try {
1695
1509
  const result = await sendContactMessage({
@@ -1713,105 +1527,15 @@ async function contactSync(message, options) {
1713
1527
  } catch (error) {
1714
1528
  const messageText = error instanceof Error ? error.message : String(error);
1715
1529
  if (options?.json) {
1716
- console.error(JSON.stringify({
1717
- tool: "maidang",
1718
- command: "contact",
1719
- error: messageText
1720
- }, null, 2));
1530
+ console.error(JSON.stringify({ tool: "maidang", command: "contact", error: messageText }, null, 2));
1721
1531
  return;
1722
1532
  }
1723
1533
  console.error(chalk2.red(`Error: ${messageText}`));
1724
1534
  process.exit(1);
1725
1535
  }
1726
1536
  }
1727
- var ContactApp = () => {
1728
- const [input, setInput] = useState3("");
1729
- const [cursorPos, setCursorPos] = useState3(0);
1730
- const [submitState, setSubmitState] = useState3({ type: "idle" });
1731
- const sendingRef = useRef2(false);
1732
- const sending = submitState.type === "sending";
1733
- const visibleHint = (() => {
1734
- if (submitState.type === "success") {
1735
- return "\u5DF2\u53D1\u9001\uFF0CCtrl+C \u9000\u51FA";
1736
- }
1737
- if (submitState.type === "error") {
1738
- return "\u53D1\u9001\u5931\u8D25\uFF0C\u53EF\u7EE7\u7EED\u7F16\u8F91\u540E\u91CD\u8BD5";
1739
- }
1740
- return IDLE_HINT;
1741
- })();
1742
- const send = async () => {
1743
- const raw = input.trim();
1744
- if (!raw || sendingRef.current) {
1745
- return;
1746
- }
1747
- sendingRef.current = true;
1748
- setSubmitState({ type: "sending" });
1749
- try {
1750
- const result = await sendContactMessage({ message: raw });
1751
- setSubmitState({
1752
- type: "success",
1753
- message: result.message || "\u90AE\u4EF6\u5DF2\u53D1\u9001\u7ED9\u9EA6\u5F53\u3002"
1754
- });
1755
- } catch (error) {
1756
- const message = error instanceof Error ? error.message : String(error);
1757
- setSubmitState({ type: "error", message });
1758
- } finally {
1759
- sendingRef.current = false;
1760
- }
1761
- };
1762
- useInput3((char, key) => {
1763
- if (key.ctrl && char === "c") {
1764
- process.exit(0);
1765
- }
1766
- if (submitState.type === "success") {
1767
- return;
1768
- }
1769
- if (sending) {
1770
- return;
1771
- }
1772
- if (key.return) {
1773
- if (key.shift) {
1774
- const nextInput = `${input.slice(0, cursorPos)}
1775
- ${input.slice(cursorPos)}`;
1776
- setInput(nextInput);
1777
- setCursorPos(cursorPos + 1);
1778
- return;
1779
- }
1780
- if (input.trim()) {
1781
- void send();
1782
- }
1783
- return;
1784
- }
1785
- if (key.backspace || key.delete) {
1786
- if (cursorPos === 0) {
1787
- return;
1788
- }
1789
- setInput(`${input.slice(0, cursorPos - 1)}${input.slice(cursorPos)}`);
1790
- setCursorPos(cursorPos - 1);
1791
- return;
1792
- }
1793
- if (key.leftArrow) {
1794
- setCursorPos(Math.max(0, cursorPos - 1));
1795
- return;
1796
- }
1797
- if (key.rightArrow) {
1798
- setCursorPos(Math.min(input.length, cursorPos + 1));
1799
- return;
1800
- }
1801
- if (key.upArrow || key.downArrow || key.tab || key.escape) {
1802
- return;
1803
- }
1804
- if (!char) {
1805
- return;
1806
- }
1807
- setInput(`${input.slice(0, cursorPos)}${char}${input.slice(cursorPos)}`);
1808
- setCursorPos(cursorPos + char.length);
1809
- });
1810
- const displayValue = input.slice(0, cursorPos) + (submitState.type === "success" ? "" : chalk2.inverse(" ")) + input.slice(cursorPos);
1811
- 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)));
1812
- };
1813
1537
  function createContactCommand() {
1814
- 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) => {
1538
+ return new Command10("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").option("--name <name>", "\u7559\u8A00\u4EBA\u79F0\u547C").option("--email <email>", "\u7559\u8A00\u4EBA\u90AE\u7BB1").action(async (opts) => {
1815
1539
  const data = { email: "borisdunk@sina.com", note: "\u76F4\u63A5\u53D1\u9001\u539F\u6587\u7559\u8A00\uFF0C\u4E0D\u7ECF\u8FC7 chat \u6216\u5927\u6A21\u578B" };
1816
1540
  if (opts.json && !opts.message) {
1817
1541
  console.log(JSON.stringify({ tool: "maidang", command: "contact", data }, null, 2));
@@ -1825,13 +1549,20 @@ function createContactCommand() {
1825
1549
  });
1826
1550
  return;
1827
1551
  }
1828
- render3(/* @__PURE__ */ React3.createElement(ContactApp, null));
1552
+ if (opts.json) {
1553
+ console.log(JSON.stringify({ tool: "maidang", command: "contact", data }, null, 2));
1554
+ return;
1555
+ }
1556
+ console.log("");
1557
+ console.log("contact");
1558
+ console.log("\u7ED9\u9EA6\u5F53\u7559\u8A00\uFF1A");
1559
+ console.log(' npx maidang contact -m "\u4F60\u597D\uFF0C\u60F3\u548C\u4F60\u804A\u804A\u5408\u4F5C\u3002"');
1560
+ console.log("");
1829
1561
  });
1830
- return cmd;
1831
1562
  }
1832
1563
 
1833
1564
  // src/commands/whoami.ts
1834
- import { Command as Command10 } from "commander";
1565
+ import { Command as Command11 } from "commander";
1835
1566
 
1836
1567
  // src/constants/profile.ts
1837
1568
  var INTRO_TEXT = "Agent \u5F00\u53D1 / AI \u5DE5\u4F5C\u6D41 / \u5168\u6808 \xB7 \u5F00\u653E\u5408\u4F5C\uFF0C\u6B22\u8FCE\u627E\u6211\u804A\u804A";
@@ -1846,7 +1577,7 @@ function getStatus() {
1846
1577
  return { status: "working", label: "\u5DE5\u4F5C\u4E2D", description: "\u6B63\u5E38\u5DE5\u4F5C\u65F6\u6BB5" };
1847
1578
  }
1848
1579
  function createWhoAmICommand() {
1849
- 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) => {
1580
+ const cmd = new Command11("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) => {
1850
1581
  const status = getStatus();
1851
1582
  const whoami = {
1852
1583
  tagline: INTRO_TEXT,
@@ -1884,9 +1615,9 @@ function createWhoAmICommand() {
1884
1615
  }
1885
1616
 
1886
1617
  // src/commands/chat.tsx
1887
- import React4, { useState as useState4, useRef as useRef3, useEffect as useEffect3 } from "react";
1888
- import { render as render4, Box as Box4, Text as Text4, useInput as useInput4 } from "ink";
1889
- import { Command as Command11 } from "commander";
1618
+ import React, { useState, useRef, useEffect } from "react";
1619
+ import { render, Box, Text, useInput } from "ink";
1620
+ import { Command as Command12 } from "commander";
1890
1621
  import chalk3 from "chalk";
1891
1622
 
1892
1623
  // src/utils/chat-api.ts
@@ -2006,36 +1737,36 @@ async function chatSync(message, json = false, sessionId) {
2006
1737
  }
2007
1738
  var _id = 0;
2008
1739
  var uid = () => ++_id;
2009
- 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)));
2010
- 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)));
2011
- var ItemLoading = () => /* @__PURE__ */ React4.createElement(Box4, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React4.createElement(Text4, { dimColor: true }, "\u601D\u8003\u4E2D..."));
2012
- 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)));
2013
- var ItemContent = ({ content }) => /* @__PURE__ */ React4.createElement(Box4, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React4.createElement(Text4, { wrap: "wrap" }, content));
2014
- var ItemError = ({ content }) => /* @__PURE__ */ React4.createElement(Box4, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React4.createElement(Text4, { color: "red" }, content));
1740
+ var ItemUser = ({ content }) => /* @__PURE__ */ React.createElement(Box, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Box, { width: "100%", backgroundColor: "cyan", paddingX: 1, paddingY: 0 }, /* @__PURE__ */ React.createElement(Text, { color: "black", wrap: "wrap" }, content)));
1741
+ var ItemThinking = ({ content, expanded }) => /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "\u601D\u8003"), expanded && /* @__PURE__ */ React.createElement(Box, { width: "100%", borderStyle: "round", borderColor: "gray", paddingX: 1, paddingY: 0, marginTop: 0 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true, wrap: "wrap" }, content)));
1742
+ var ItemLoading = () => /* @__PURE__ */ React.createElement(Box, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true }, "\u601D\u8003\u4E2D..."));
1743
+ var ItemTool = ({ content }) => /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { color: "yellow" }, "\u26A1"), /* @__PURE__ */ React.createElement(Box, { width: "100%", borderStyle: "round", borderColor: "yellow", paddingX: 1, paddingY: 0, marginTop: 0 }, /* @__PURE__ */ React.createElement(Text, { color: "yellow", wrap: "wrap" }, content)));
1744
+ var ItemContent = ({ content }) => /* @__PURE__ */ React.createElement(Box, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { wrap: "wrap" }, content));
1745
+ var ItemError = ({ content }) => /* @__PURE__ */ React.createElement(Box, { width: "100%", marginBottom: 1 }, /* @__PURE__ */ React.createElement(Text, { color: "red" }, content));
2015
1746
  var DOUBLE_PRESS_WINDOW = 1e3;
2016
1747
  var ChatApp = ({ sessionId: initialSessionId }) => {
2017
- const [items, setItems] = useState4([]);
2018
- const [input, setInput] = useState4("");
2019
- const [cursorPos, setCursorPos] = useState4(0);
2020
- const [loading, setLoading] = useState4(false);
2021
- const [hint, setHint] = useState4("");
2022
- const [sessionId, setSessionId] = useState4(void 0);
2023
- const sessionIdRef = useRef3(void 0);
2024
- const [showThinking, setShowThinking] = useState4(false);
2025
- const lastEscRef = useRef3(0);
2026
- const lastCtrlCRef = useRef3(0);
2027
- const bottomRef = useRef3(null);
2028
- const showThinkingRef = useRef3(false);
2029
- useEffect3(() => {
1748
+ const [items, setItems] = useState([]);
1749
+ const [input, setInput] = useState("");
1750
+ const [cursorPos, setCursorPos] = useState(0);
1751
+ const [loading, setLoading] = useState(false);
1752
+ const [hint, setHint] = useState("");
1753
+ const [sessionId, setSessionId] = useState(void 0);
1754
+ const sessionIdRef = useRef(void 0);
1755
+ const [showThinking, setShowThinking] = useState(false);
1756
+ const lastEscRef = useRef(0);
1757
+ const lastCtrlCRef = useRef(0);
1758
+ const bottomRef = useRef(null);
1759
+ const showThinkingRef = useRef(false);
1760
+ useEffect(() => {
2030
1761
  showThinkingRef.current = showThinking;
2031
1762
  }, [showThinking]);
2032
- useEffect3(() => {
1763
+ useEffect(() => {
2033
1764
  if (initialSessionId) {
2034
1765
  setSessionId(initialSessionId);
2035
1766
  sessionIdRef.current = initialSessionId;
2036
1767
  }
2037
1768
  }, [initialSessionId]);
2038
- useEffect3(() => {
1769
+ useEffect(() => {
2039
1770
  if (hint) {
2040
1771
  const t = setTimeout(() => setHint(""), 1500);
2041
1772
  return () => clearTimeout(t);
@@ -2078,7 +1809,7 @@ var ChatApp = ({ sessionId: initialSessionId }) => {
2078
1809
  setLoading(false);
2079
1810
  }
2080
1811
  };
2081
- useInput4((char, key) => {
1812
+ useInput((char, key) => {
2082
1813
  if (key.ctrl && char === "o") {
2083
1814
  const hasThinking = items.some((i) => i.type === "thinking");
2084
1815
  if (hasThinking) {
@@ -2164,27 +1895,27 @@ var ChatApp = ({ sessionId: initialSessionId }) => {
2164
1895
  const cursorChar = input[cursorPos] ?? " ";
2165
1896
  const after = input.slice(cursorPos + 1);
2166
1897
  const fw = isFullWidth(cursorChar) ? 2 : 1;
2167
- 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 }, " "));
1898
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Text, { color: "cyan" }, "> "), /* @__PURE__ */ React.createElement(Text, null, before), /* @__PURE__ */ React.createElement(Text, { backgroundColor: "gray", color: "black" }, cursorChar, fw === 2 ? " " : ""), /* @__PURE__ */ React.createElement(Text, null, after), loading && /* @__PURE__ */ React.createElement(Text, { dimColor: true }, " "));
2168
1899
  };
2169
- return /* @__PURE__ */ React4.createElement(Box4, { flexDirection: "column", paddingX: 1, flexGrow: 1 }, /* @__PURE__ */ React4.createElement(Box4, { flexDirection: "column", flexGrow: 1 }, items.map((item) => {
1900
+ return /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", paddingX: 1, flexGrow: 1 }, /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", flexGrow: 1 }, items.map((item) => {
2170
1901
  switch (item.type) {
2171
1902
  case "user":
2172
- return /* @__PURE__ */ React4.createElement(ItemUser, { key: item.id, content: item.content });
1903
+ return /* @__PURE__ */ React.createElement(ItemUser, { key: item.id, content: item.content });
2173
1904
  case "thinking":
2174
- return /* @__PURE__ */ React4.createElement(ItemThinking, { key: item.id, content: item.content, expanded: showThinking });
1905
+ return /* @__PURE__ */ React.createElement(ItemThinking, { key: item.id, content: item.content, expanded: showThinking });
2175
1906
  case "loading":
2176
- return /* @__PURE__ */ React4.createElement(ItemLoading, { key: item.id });
1907
+ return /* @__PURE__ */ React.createElement(ItemLoading, { key: item.id });
2177
1908
  case "tool":
2178
- return /* @__PURE__ */ React4.createElement(ItemTool, { key: item.id, content: item.content });
1909
+ return /* @__PURE__ */ React.createElement(ItemTool, { key: item.id, content: item.content });
2179
1910
  case "content":
2180
- return /* @__PURE__ */ React4.createElement(ItemContent, { key: item.id, content: item.content });
1911
+ return /* @__PURE__ */ React.createElement(ItemContent, { key: item.id, content: item.content });
2181
1912
  case "error":
2182
- return /* @__PURE__ */ React4.createElement(ItemError, { key: item.id, content: item.content });
1913
+ return /* @__PURE__ */ React.createElement(ItemError, { key: item.id, content: item.content });
2183
1914
  }
2184
- })), /* @__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 }));
1915
+ })), /* @__PURE__ */ React.createElement(Box, { flexDirection: "column", flexShrink: 0 }, /* @__PURE__ */ React.createElement(Box, { borderStyle: "single", borderColor: "gray", paddingX: 1 }, renderInputLine()), /* @__PURE__ */ React.createElement(Box, { paddingTop: 1 }, /* @__PURE__ */ React.createElement(Text, { 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__ */ React.createElement(Box, { paddingTop: 0 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true, color: "yellow" }, hint)), !loading && items.some((i) => i.type === "thinking") && !showThinking && /* @__PURE__ */ React.createElement(Box, { paddingTop: 0 }, /* @__PURE__ */ React.createElement(Text, { dimColor: true, color: "cyan" }, "Ctrl+O \u67E5\u770B\u601D\u8003"))), /* @__PURE__ */ React.createElement(Box, { ref: bottomRef }));
2185
1916
  };
2186
1917
  function createChatCommand() {
2187
- const cmd = new Command11("chat").description("\u548C\u9EA6\u5F53\u5BF9\u8BDD\uFF08-m \u5355\u8F6E\u6D88\u606F\uFF0C--session-id \u7EED\u63A5\u5BF9\u8BDD\uFF09").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");
1918
+ const cmd = new Command12("chat").description("\u548C\u9EA6\u5F53\u5BF9\u8BDD\uFF08-m \u5355\u8F6E\u6D88\u606F\uFF0C--session-id \u7EED\u63A5\u5BF9\u8BDD\uFF09").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");
2188
1919
  cmd.action(async (opts) => {
2189
1920
  if (opts.json || opts.message) {
2190
1921
  if (!opts.message) {
@@ -2198,13 +1929,13 @@ function createChatCommand() {
2198
1929
  await chatSync(opts.message, !!opts.json, opts.sessionId);
2199
1930
  return;
2200
1931
  }
2201
- render4(/* @__PURE__ */ React4.createElement(ChatApp, { sessionId: opts.sessionId }));
1932
+ render(/* @__PURE__ */ React.createElement(ChatApp, { sessionId: opts.sessionId }));
2202
1933
  });
2203
1934
  return cmd;
2204
1935
  }
2205
1936
 
2206
1937
  // src/commands/manifest.ts
2207
- import { Command as Command12 } from "commander";
1938
+ import { Command as Command13 } from "commander";
2208
1939
 
2209
1940
  // src/utils/version.ts
2210
1941
  function getAgeVersion() {
@@ -2231,11 +1962,12 @@ async function fetchOrEmpty(url) {
2231
1962
  }
2232
1963
  }
2233
1964
  function createManifestCommand() {
2234
- 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) => {
1965
+ const cmd = new Command13("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) => {
2235
1966
  const apiUrl = process.env.MAIDANG_API_URL || DEFAULT_API_URL;
2236
- const [projects, tools, links] = await Promise.all([
1967
+ const [projects, tools, skills, links] = await Promise.all([
2237
1968
  fetchOrEmpty(`${apiUrl}/api/projects`),
2238
1969
  fetchOrEmpty(`${apiUrl}/api/tools`),
1970
+ fetchOrEmpty(`${apiUrl}/api/skills`),
2239
1971
  fetchOrEmpty(`${apiUrl}/api/links`)
2240
1972
  ]);
2241
1973
  const manifest = {
@@ -2255,6 +1987,7 @@ function createManifestCommand() {
2255
1987
  career: career_default.career,
2256
1988
  projects: projects ?? [],
2257
1989
  tools: tools ?? [],
1990
+ skills: skills ?? [],
2258
1991
  links: links ?? [],
2259
1992
  commands: [
2260
1993
  { name: "whoami", desc: "\u4E00\u53E5\u8BDD\u4ECB\u7ECD" },
@@ -2262,6 +1995,7 @@ function createManifestCommand() {
2262
1995
  { name: "projects", desc: "\u9879\u76EE" },
2263
1996
  { name: "posts", desc: "\u63A8\u6587" },
2264
1997
  { name: "tools", desc: "\u5DE5\u5177" },
1998
+ { name: "skills", desc: "Agent Skills" },
2265
1999
  { name: "songs", desc: "\u6B4C\u5355" },
2266
2000
  { name: "links", desc: "\u5916\u94FE" },
2267
2001
  { name: "cat", desc: "\u732B\u732B" },
@@ -2285,6 +2019,7 @@ function createManifestCommand() {
2285
2019
  printKV("career", `${manifest.career.experiences.length} \u6BB5\u7ECF\u5386`);
2286
2020
  printKV("projects", `${manifest.projects.length} \u4E2A\u9879\u76EE`);
2287
2021
  printKV("tools", `${manifest.tools.length} \u4E2A\u5DE5\u5177`);
2022
+ printKV("skills", `${manifest.skills.length} \u4E2A Skill`);
2288
2023
  printKV("links", `${manifest.links.length} \u4E2A\u5916\u94FE`);
2289
2024
  console.log("");
2290
2025
  console.log(" " + hairline());
@@ -2299,7 +2034,7 @@ function createManifestCommand() {
2299
2034
  }
2300
2035
 
2301
2036
  // src/index.ts
2302
- var program = new Command13();
2037
+ var program = new Command14();
2303
2038
  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");
2304
2039
  program.addCommand(createCareerCommand());
2305
2040
  program.addCommand(createCatCommand());
@@ -2308,6 +2043,7 @@ program.addCommand(createSongsCommand());
2308
2043
  program.addCommand(createLinksCommand());
2309
2044
  program.addCommand(createProjectsCommand());
2310
2045
  program.addCommand(createToolsCommand());
2046
+ program.addCommand(createSkillsCommand());
2311
2047
  program.addCommand(createContactCommand());
2312
2048
  program.addCommand(createWhoAmICommand());
2313
2049
  program.addCommand(createChatCommand());