shenxiang-ai-cli 0.5.3 → 0.5.5

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.
Files changed (2) hide show
  1. package/dist/index.js +25 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2221,11 +2221,12 @@ ${truncated}
2221
2221
  // src/ui/banner.ts
2222
2222
  import boxen from "boxen";
2223
2223
  import chalk3 from "chalk";
2224
+ import stripAnsi from "strip-ansi";
2224
2225
  function showBanner() {
2225
2226
  console.clear();
2226
2227
  const p = chalk3.hex("#A78BFA");
2227
2228
  const w = chalk3.white;
2228
- const version = "v0.5.3";
2229
+ const version = "v0.5.5";
2229
2230
  const avatarLines = [
2230
2231
  ` ${p("\u2584\u2580\u2580\u2580\u2584")}`,
2231
2232
  ` ${p("\u2588")} ${w("\u2580")} ${w("\u2580")} ${p("\u2588")}`,
@@ -2235,7 +2236,7 @@ function showBanner() {
2235
2236
  ];
2236
2237
  const terminalWidth = process.stdout.columns || 80;
2237
2238
  const boxWidth = Math.max(60, Math.min(terminalWidth - 4, 120));
2238
- const leftColWidth = Math.floor(boxWidth * 0.45);
2239
+ const leftColWidth = Math.floor(boxWidth * 0.35);
2239
2240
  const rightColWidth = boxWidth - leftColWidth - 4;
2240
2241
  const leftContent = [
2241
2242
  "",
@@ -2247,22 +2248,40 @@ function showBanner() {
2247
2248
  ` ${chalk3.dim(process.cwd().length > leftColWidth - 2 ? "..." + process.cwd().slice(-(leftColWidth - 5)) : process.cwd())}`,
2248
2249
  ""
2249
2250
  ];
2251
+ const wrapText = (text, width) => {
2252
+ const words = text.split("");
2253
+ const lines2 = [];
2254
+ let currentLine = "";
2255
+ for (const char of words) {
2256
+ const charWidth = char.codePointAt(0) > 255 ? 2 : 1;
2257
+ const currentLineWidth = currentLine.split("").reduce((acc, c) => acc + (c.codePointAt(0) > 255 ? 2 : 1), 0);
2258
+ if (currentLineWidth + charWidth > width) {
2259
+ lines2.push(currentLine);
2260
+ currentLine = char;
2261
+ } else {
2262
+ currentLine += char;
2263
+ }
2264
+ }
2265
+ if (currentLine) lines2.push(currentLine);
2266
+ return lines2;
2267
+ };
2268
+ const quote = "\u5343\u4E07\u522B\u8DDF\u8BA4\u77E5\u4E0D\u540C\u9891\u7684\u4EBA\u4E89\u8BBA\uFF0C\u66F4\u522B\u548C\u4ED6\u4EEC\u8BA1\u8F83\uFF0C\u771F\u6B63\u7684\u806A\u660E\uFF0C\u662F\u61C2\u5F97\u7B5B\u9009\uFF0C\u800C\u4E0D\u662F\u8BD5\u56FE\u6539\u53D8";
2269
+ const wrappedQuote = wrapText(quote, rightColWidth - 2);
2250
2270
  const rightContent = [
2251
2271
  theme.brand("Tips for getting started"),
2252
2272
  `Run ${theme.code("/help")} for a list of commands`,
2253
2273
  "",
2254
- // Removed /init
2255
2274
  theme.brand("Recent activity"),
2256
2275
  "No recent activity",
2257
2276
  "",
2258
- "",
2277
+ ...wrappedQuote.map((l) => theme.dim(l)),
2259
2278
  ""
2260
2279
  ];
2261
2280
  const maxLines = Math.max(leftContent.length, rightContent.length);
2262
2281
  const lines = [];
2263
2282
  for (let i = 0; i < maxLines; i++) {
2264
2283
  const left = leftContent[i] || "";
2265
- const leftVisible = left.replace(/\u001b\[\d+m/g, "").length;
2284
+ const leftVisible = stripAnsi(left).length;
2266
2285
  const leftPadding = " ".repeat(Math.max(0, leftColWidth - leftVisible));
2267
2286
  const right = rightContent[i] || "";
2268
2287
  lines.push(`${left}${leftPadding} ${theme.dim("\u2502")} ${right}`);
@@ -2271,7 +2290,6 @@ function showBanner() {
2271
2290
  console.log(boxen(content, {
2272
2291
  padding: { top: 0, bottom: 0, left: 1, right: 1 },
2273
2292
  margin: 0,
2274
- // No margin since we clear screen and want full width likely
2275
2293
  borderStyle: "round",
2276
2294
  borderColor: "#A78BFA",
2277
2295
  title: chalk3.hex("#A78BFA")(" \u6C88\u7FD4\u7684AI\u7F16\u7A0B\u52A9\u7406 "),
@@ -3372,7 +3390,7 @@ function fmtTokens3(n) {
3372
3390
  var program = new Command();
3373
3391
  var config2 = getConfig();
3374
3392
  setLocale(config2.locale);
3375
- program.name("sxai").description(t("description")).version("0.5.3");
3393
+ program.name("sxai").description(t("description")).version("0.5.5");
3376
3394
  program.command("chat", { isDefault: true }).description("\u542F\u52A8\u4EA4\u4E92\u5F0FAI\u5BF9\u8BDD\uFF08\u9ED8\u8BA4\u547D\u4EE4\uFF09").option("-m, --model <model>", "\u6307\u5B9AAI\u6A21\u578B", config2.model).option("-y, --yolo", "\u81EA\u52A8\u6A21\u5F0F\uFF1A\u8DF3\u8FC7\u6240\u6709\u786E\u8BA4\uFF0C\u8BA9AI\u81EA\u4E3B\u6267\u884C").action(async (options) => {
3377
3395
  if (options.model && options.model !== config2.model) {
3378
3396
  setConfig("model", options.model);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shenxiang-ai-cli",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "沈翔的AI助手 - 终端里的AI全栈开发搭档",
5
5
  "type": "module",
6
6
  "bin": {