maidang 29.9.5 → 29.9.6

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
@@ -3067,370 +3067,138 @@ function stringWidth(string, options = {}) {
3067
3067
  return width;
3068
3068
  }
3069
3069
 
3070
- // ../../node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js
3071
- var ANSI_BACKGROUND_OFFSET = 10;
3072
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
3073
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
3074
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
3075
- var styles = {
3076
- modifier: {
3077
- reset: [0, 0],
3078
- // 21 isn't widely supported and 22 does the same thing
3079
- bold: [1, 22],
3080
- dim: [2, 22],
3081
- italic: [3, 23],
3082
- underline: [4, 24],
3083
- overline: [53, 55],
3084
- inverse: [7, 27],
3085
- hidden: [8, 28],
3086
- strikethrough: [9, 29]
3087
- },
3088
- color: {
3089
- black: [30, 39],
3090
- red: [31, 39],
3091
- green: [32, 39],
3092
- yellow: [33, 39],
3093
- blue: [34, 39],
3094
- magenta: [35, 39],
3095
- cyan: [36, 39],
3096
- white: [37, 39],
3097
- // Bright color
3098
- blackBright: [90, 39],
3099
- gray: [90, 39],
3100
- // Alias of `blackBright`
3101
- grey: [90, 39],
3102
- // Alias of `blackBright`
3103
- redBright: [91, 39],
3104
- greenBright: [92, 39],
3105
- yellowBright: [93, 39],
3106
- blueBright: [94, 39],
3107
- magentaBright: [95, 39],
3108
- cyanBright: [96, 39],
3109
- whiteBright: [97, 39]
3110
- },
3111
- bgColor: {
3112
- bgBlack: [40, 49],
3113
- bgRed: [41, 49],
3114
- bgGreen: [42, 49],
3115
- bgYellow: [43, 49],
3116
- bgBlue: [44, 49],
3117
- bgMagenta: [45, 49],
3118
- bgCyan: [46, 49],
3119
- bgWhite: [47, 49],
3120
- // Bright color
3121
- bgBlackBright: [100, 49],
3122
- bgGray: [100, 49],
3123
- // Alias of `bgBlackBright`
3124
- bgGrey: [100, 49],
3125
- // Alias of `bgBlackBright`
3126
- bgRedBright: [101, 49],
3127
- bgGreenBright: [102, 49],
3128
- bgYellowBright: [103, 49],
3129
- bgBlueBright: [104, 49],
3130
- bgMagentaBright: [105, 49],
3131
- bgCyanBright: [106, 49],
3132
- bgWhiteBright: [107, 49]
3133
- }
3070
+ // src/core/help.ts
3071
+ var SECTION_TITLES = {
3072
+ "Usage:": "\u7528\u6CD5:",
3073
+ "Arguments:": "\u53C2\u6570:",
3074
+ "Options:": "\u9009\u9879:",
3075
+ "Global Options:": "\u5168\u5C40\u9009\u9879:",
3076
+ "Commands:": "\u547D\u4EE4:"
3134
3077
  };
3135
- var modifierNames = Object.keys(styles.modifier);
3136
- var foregroundColorNames = Object.keys(styles.color);
3137
- var backgroundColorNames = Object.keys(styles.bgColor);
3138
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
3139
- function assembleStyles() {
3140
- const codes = /* @__PURE__ */ new Map();
3141
- for (const [groupName, group] of Object.entries(styles)) {
3142
- for (const [styleName, style] of Object.entries(group)) {
3143
- styles[styleName] = {
3144
- open: `\x1B[${style[0]}m`,
3145
- close: `\x1B[${style[1]}m`
3146
- };
3147
- group[styleName] = styles[styleName];
3148
- codes.set(style[0], style[1]);
3149
- }
3150
- Object.defineProperty(styles, groupName, {
3151
- value: group,
3152
- enumerable: false
3153
- });
3154
- }
3155
- Object.defineProperty(styles, "codes", {
3156
- value: codes,
3157
- enumerable: false
3158
- });
3159
- styles.color.close = "\x1B[39m";
3160
- styles.bgColor.close = "\x1B[49m";
3161
- styles.color.ansi = wrapAnsi16();
3162
- styles.color.ansi256 = wrapAnsi256();
3163
- styles.color.ansi16m = wrapAnsi16m();
3164
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
3165
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
3166
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
3167
- Object.defineProperties(styles, {
3168
- rgbToAnsi256: {
3169
- value(red, green, blue) {
3170
- if (red === green && green === blue) {
3171
- if (red < 8) {
3172
- return 16;
3173
- }
3174
- if (red > 248) {
3175
- return 231;
3176
- }
3177
- return Math.round((red - 8) / 247 * 24) + 232;
3178
- }
3179
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
3180
- },
3181
- enumerable: false
3182
- },
3183
- hexToRgb: {
3184
- value(hex) {
3185
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
3186
- if (!matches) {
3187
- return [0, 0, 0];
3188
- }
3189
- let [colorString] = matches;
3190
- if (colorString.length === 3) {
3191
- colorString = [...colorString].map((character) => character + character).join("");
3192
- }
3193
- const integer = Number.parseInt(colorString, 16);
3194
- return [
3195
- /* eslint-disable no-bitwise */
3196
- integer >> 16 & 255,
3197
- integer >> 8 & 255,
3198
- integer & 255
3199
- /* eslint-enable no-bitwise */
3200
- ];
3201
- },
3202
- enumerable: false
3203
- },
3204
- hexToAnsi256: {
3205
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
3206
- enumerable: false
3207
- },
3208
- ansi256ToAnsi: {
3209
- value(code) {
3210
- if (code < 8) {
3211
- return 30 + code;
3212
- }
3213
- if (code < 16) {
3214
- return 90 + (code - 8);
3215
- }
3216
- let red;
3217
- let green;
3218
- let blue;
3219
- if (code >= 232) {
3220
- red = ((code - 232) * 10 + 8) / 255;
3221
- green = red;
3222
- blue = red;
3223
- } else {
3224
- code -= 16;
3225
- const remainder = code % 36;
3226
- red = Math.floor(code / 36) / 5;
3227
- green = Math.floor(remainder / 6) / 5;
3228
- blue = remainder % 6 / 5;
3229
- }
3230
- const value = Math.max(red, green, blue) * 2;
3231
- if (value === 0) {
3232
- return 30;
3233
- }
3234
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
3235
- if (value === 2) {
3236
- result += 60;
3237
- }
3238
- return result;
3239
- },
3240
- enumerable: false
3241
- },
3242
- rgbToAnsi: {
3243
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
3244
- enumerable: false
3245
- },
3246
- hexToAnsi: {
3247
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
3248
- enumerable: false
3249
- }
3250
- });
3251
- return styles;
3252
- }
3253
- var ansiStyles = assembleStyles();
3254
- var ansi_styles_default = ansiStyles;
3255
-
3256
- // ../../node_modules/.pnpm/wrap-ansi@9.0.2/node_modules/wrap-ansi/index.js
3257
- var ESCAPES = /* @__PURE__ */ new Set([
3258
- "\x1B",
3259
- "\x9B"
3260
- ]);
3261
- var END_CODE = 39;
3262
- var ANSI_ESCAPE_BELL = "\x07";
3263
- var ANSI_CSI = "[";
3264
- var ANSI_OSC = "]";
3265
- var ANSI_SGR_TERMINATOR = "m";
3266
- var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
3267
- var wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
3268
- var wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
3269
- var wordLengths = (string) => string.split(" ").map((character) => stringWidth(character));
3270
- var wrapWord = (rows, word, columns) => {
3271
- const characters = [...word];
3272
- let isInsideEscape = false;
3273
- let isInsideLinkEscape = false;
3274
- let visible = stringWidth(stripAnsi(rows.at(-1)));
3275
- for (const [index, character] of characters.entries()) {
3276
- const characterLength = stringWidth(character);
3277
- if (visible + characterLength <= columns) {
3278
- rows[rows.length - 1] += character;
3279
- } else {
3280
- rows.push(character);
3281
- visible = 0;
3282
- }
3283
- if (ESCAPES.has(character)) {
3284
- isInsideEscape = true;
3285
- const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join("");
3286
- isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
3287
- }
3288
- if (isInsideEscape) {
3289
- if (isInsideLinkEscape) {
3290
- if (character === ANSI_ESCAPE_BELL) {
3291
- isInsideEscape = false;
3292
- isInsideLinkEscape = false;
3293
- }
3294
- } else if (character === ANSI_SGR_TERMINATOR) {
3295
- isInsideEscape = false;
3296
- }
3297
- continue;
3298
- }
3299
- visible += characterLength;
3300
- if (visible === columns && index < characters.length - 1) {
3301
- rows.push("");
3302
- visible = 0;
3303
- }
3304
- }
3305
- if (!visible && rows.at(-1).length > 0 && rows.length > 1) {
3306
- rows[rows.length - 2] += rows.pop();
3307
- }
3078
+ var COMMAND_SUMMARIES = {
3079
+ career: "\u5DE5\u4F5C\u7ECF\u5386",
3080
+ cat: "\u9EA6\u9EA6\u7684\u732B\u732B\u52A8\u6001",
3081
+ posts: "\u52A8\u6001\u5217\u8868",
3082
+ songs: "\u5E74\u5EA6\u6B4C\u5355",
3083
+ links: "\u793E\u4EA4\u4E0E\u5916\u94FE",
3084
+ projects: "\u9879\u76EE\u5217\u8868",
3085
+ tools: "\u6700\u8FD1\u5728\u7528\u7684\u597D\u7269",
3086
+ skills: "\u53EF\u5206\u4EAB\u7684 Agent Skills",
3087
+ contact: "\u7ED9\u9EA6\u5F53\u7559\u8A00",
3088
+ whoami: "\u4E00\u53E5\u8BDD\u4ECB\u7ECD\u6211",
3089
+ chat: "\u548C\u9EA6\u5F53\u5BF9\u8BDD",
3090
+ manifest: "\u4E00\u6B21\u6027\u8F93\u51FA\u516C\u5F00\u6570\u636E\uFF0C\u4F9B AI \u4F7F\u7528",
3091
+ news: "AI \u65E5\u62A5",
3092
+ changelog: "\u7AD9\u70B9\u66F4\u65B0\u65E5\u5FD7",
3093
+ upgrade: "\u5347\u7EA7 maidang"
3308
3094
  };
3309
- var stringVisibleTrimSpacesRight = (string) => {
3310
- const words = string.split(" ");
3311
- let last = words.length;
3312
- while (last > 0) {
3313
- if (stringWidth(words[last - 1]) > 0) {
3314
- break;
3095
+ var NARROW_HELP_WIDTH = 64;
3096
+ var ITEM_INDENT = 2;
3097
+ var DESCRIPTION_INDENT = 4;
3098
+ var OPENING_PUNCTUATION = /* @__PURE__ */ new Set(["\uFF08", "\u3010", "\u300A"]);
3099
+ var CLOSING_PUNCTUATION = /* @__PURE__ */ new Set(["\uFF0C", "\u3002", "\uFF1B", "\uFF1A", "\uFF01", "\uFF1F", "\u3001", "\uFF09", "\u3011", "\u300B"]);
3100
+ var ASCII_TOKEN_CHARACTER = /^[A-Za-z0-9_./:@+\-<>{}\[\]=]$/;
3101
+ function wrapTokens(text) {
3102
+ const raw = [];
3103
+ let ascii = "";
3104
+ const flushAscii = () => {
3105
+ if (!ascii) return;
3106
+ raw.push(ascii);
3107
+ ascii = "";
3108
+ };
3109
+ for (const character of Array.from(text)) {
3110
+ if (ASCII_TOKEN_CHARACTER.test(character)) {
3111
+ ascii += character;
3112
+ continue;
3315
3113
  }
3316
- last--;
3317
- }
3318
- if (last === words.length) {
3319
- return string;
3320
- }
3321
- return words.slice(0, last).join(" ") + words.slice(last).join("");
3322
- };
3323
- var exec = (string, columns, options = {}) => {
3324
- if (options.trim !== false && string.trim() === "") {
3325
- return "";
3326
- }
3327
- let returnValue = "";
3328
- let escapeCode;
3329
- let escapeUrl;
3330
- const lengths = wordLengths(string);
3331
- let rows = [""];
3332
- for (const [index, word] of string.split(" ").entries()) {
3333
- if (options.trim !== false) {
3334
- rows[rows.length - 1] = rows.at(-1).trimStart();
3335
- }
3336
- let rowLength = stringWidth(rows.at(-1));
3337
- if (index !== 0) {
3338
- if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
3339
- rows.push("");
3340
- rowLength = 0;
3341
- }
3342
- if (rowLength > 0 || options.trim === false) {
3343
- rows[rows.length - 1] += " ";
3344
- rowLength++;
3345
- }
3114
+ flushAscii();
3115
+ raw.push(character);
3116
+ }
3117
+ flushAscii();
3118
+ const tokens = [];
3119
+ let opening = "";
3120
+ for (const token of raw) {
3121
+ if (/^\s+$/.test(token)) {
3122
+ if (opening) tokens.push(opening);
3123
+ opening = "";
3124
+ tokens.push(" ");
3125
+ continue;
3346
3126
  }
3347
- if (options.hard && lengths[index] > columns) {
3348
- const remainingColumns = columns - rowLength;
3349
- const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
3350
- const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
3351
- if (breaksStartingNextLine < breaksStartingThisLine) {
3352
- rows.push("");
3353
- }
3354
- wrapWord(rows, word, columns);
3127
+ if (OPENING_PUNCTUATION.has(token)) {
3128
+ opening += token;
3355
3129
  continue;
3356
3130
  }
3357
- if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
3358
- if (options.wordWrap === false && rowLength < columns) {
3359
- wrapWord(rows, word, columns);
3131
+ const value = opening + token;
3132
+ opening = "";
3133
+ if (CLOSING_PUNCTUATION.has(token)) {
3134
+ const previous = tokens[tokens.length - 1];
3135
+ if (previous && previous !== " ") {
3136
+ tokens[tokens.length - 1] = previous + token;
3360
3137
  continue;
3361
3138
  }
3362
- rows.push("");
3363
3139
  }
3364
- if (rowLength + lengths[index] > columns && options.wordWrap === false) {
3365
- wrapWord(rows, word, columns);
3140
+ tokens.push(value);
3141
+ }
3142
+ if (opening) tokens.push(opening);
3143
+ return tokens;
3144
+ }
3145
+ function wrapLine(text, width) {
3146
+ const lines = [];
3147
+ let line = "";
3148
+ let pendingSpace = false;
3149
+ for (const token of wrapTokens(text)) {
3150
+ if (token === " ") {
3151
+ pendingSpace = line.length > 0;
3366
3152
  continue;
3367
3153
  }
3368
- rows[rows.length - 1] += word;
3369
- }
3370
- if (options.trim !== false) {
3371
- rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
3372
- }
3373
- const preString = rows.join("\n");
3374
- const pre = [...preString];
3375
- let preStringIndex = 0;
3376
- for (const [index, character] of pre.entries()) {
3377
- returnValue += character;
3378
- if (ESCAPES.has(character)) {
3379
- const { groups } = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} };
3380
- if (groups.code !== void 0) {
3381
- const code2 = Number.parseFloat(groups.code);
3382
- escapeCode = code2 === END_CODE ? void 0 : code2;
3383
- } else if (groups.uri !== void 0) {
3384
- escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
3385
- }
3386
- }
3387
- const code = ansi_styles_default.codes.get(Number(escapeCode));
3388
- if (pre[index + 1] === "\n") {
3389
- if (escapeUrl) {
3390
- returnValue += wrapAnsiHyperlink("");
3391
- }
3392
- if (escapeCode && code) {
3393
- returnValue += wrapAnsiCode(code);
3394
- }
3395
- } else if (character === "\n") {
3396
- if (escapeCode && code) {
3397
- returnValue += wrapAnsiCode(escapeCode);
3398
- }
3399
- if (escapeUrl) {
3400
- returnValue += wrapAnsiHyperlink(escapeUrl);
3401
- }
3154
+ const separator = pendingSpace && line ? " " : "";
3155
+ const candidate = line + separator + token;
3156
+ if (line && stringWidth(candidate) > width) {
3157
+ lines.push(line);
3158
+ line = token;
3159
+ } else {
3160
+ line = candidate;
3402
3161
  }
3403
- preStringIndex += character.length;
3162
+ pendingSpace = false;
3404
3163
  }
3405
- return returnValue;
3406
- };
3407
- function wrapAnsi(string, columns, options) {
3408
- return String(string).normalize().replaceAll("\r\n", "\n").split("\n").map((line) => exec(line, columns, options)).join("\n");
3164
+ lines.push(line);
3165
+ return lines;
3166
+ }
3167
+ function wrapDescription(text, width) {
3168
+ if (width <= 0) return text;
3169
+ return text.split(/\r?\n/).flatMap((line) => wrapLine(line, width)).join("\n");
3409
3170
  }
3410
-
3411
- // src/core/help.ts
3412
- var SECTION_TITLES = {
3413
- "Usage:": "\u7528\u6CD5:",
3414
- "Arguments:": "\u53C2\u6570:",
3415
- "Options:": "\u9009\u9879:",
3416
- "Global Options:": "\u5168\u5C40\u9009\u9879:",
3417
- "Commands:": "\u547D\u4EE4:"
3418
- };
3419
3171
  var ChineseHelp = class extends Help {
3420
- constructor() {
3421
- super(...arguments);
3422
- // 默认 40 列以下不折行,对 2 倍宽的中文太宽松,窄终端直接溢出
3423
- this.minWidthToWrap = 20;
3424
- }
3425
3172
  styleTitle(title) {
3426
3173
  return SECTION_TITLES[title] ?? title;
3427
3174
  }
3175
+ subcommandDescription(command) {
3176
+ return COMMAND_SUMMARIES[command.name()] ?? super.subcommandDescription(command);
3177
+ }
3428
3178
  displayWidth(str) {
3429
3179
  return stringWidth(str);
3430
3180
  }
3431
3181
  boxWrap(str, width) {
3432
- if (width < this.minWidthToWrap) return str;
3433
- return wrapAnsi(str, width, { hard: true, trim: true });
3182
+ return wrapDescription(str, width);
3183
+ }
3184
+ formatItem(term, termWidth, description, helper) {
3185
+ const helpWidth = this.helpWidth ?? 80;
3186
+ const itemIndent = " ".repeat(ITEM_INDENT);
3187
+ if (!description) return itemIndent + term;
3188
+ if (helpWidth <= NARROW_HELP_WIDTH) {
3189
+ const descriptionIndent = " ".repeat(DESCRIPTION_INDENT);
3190
+ const wrapped2 = helper.boxWrap(description, helpWidth - DESCRIPTION_INDENT);
3191
+ return `${itemIndent}${term}
3192
+ ${descriptionIndent}${wrapped2.replace(/\n/g, `
3193
+ ${descriptionIndent}`)}`;
3194
+ }
3195
+ const spacerWidth = 2;
3196
+ const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
3197
+ const descriptionWidth = helpWidth - ITEM_INDENT - termWidth - spacerWidth;
3198
+ const wrapped = helper.boxWrap(description, descriptionWidth);
3199
+ const continuationIndent = " ".repeat(ITEM_INDENT + termWidth + spacerWidth);
3200
+ return `${itemIndent}${paddedTerm}${" ".repeat(spacerWidth)}${wrapped.replace(/\n/g, `
3201
+ ${continuationIndent}`)}`;
3434
3202
  }
3435
3203
  };
3436
3204
  function envHelpWidth() {