@yivan-lab/pretty-please 1.3.0 → 1.3.1

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/bin/pls.tsx CHANGED
@@ -139,7 +139,7 @@ function executeCommand(command: string): Promise<{ exitCode: number; output: st
139
139
  ...wrappedLines.map((l) => console2.getDisplayWidth(l)),
140
140
  console2.getDisplayWidth('生成命令')
141
141
  )
142
- const boxWidth = Math.min(actualMaxWidth + 4, termWidth - 2)
142
+ const boxWidth = Math.max(console2.MIN_COMMAND_BOX_WIDTH, Math.min(actualMaxWidth + 4, termWidth - 2))
143
143
  console2.printSeparator('输出', boxWidth)
144
144
 
145
145
  // 使用 bash 并启用 pipefail,确保管道中任何命令失败都能正确返回非零退出码
@@ -1712,7 +1712,7 @@ async function executeRemoteCommand(
1712
1712
  ...wrappedLines.map((l) => console2.getDisplayWidth(l)),
1713
1713
  console2.getDisplayWidth('生成命令')
1714
1714
  )
1715
- const boxWidth = Math.min(actualMaxWidth + 4, termWidth - 2)
1715
+ const boxWidth = Math.max(console2.MIN_COMMAND_BOX_WIDTH, Math.min(actualMaxWidth + 4, termWidth - 2))
1716
1716
  console2.printSeparator(`远程输出 (${remoteName})`, boxWidth)
1717
1717
 
1718
1718
  try {
package/dist/bin/pls.js CHANGED
@@ -83,7 +83,7 @@ function executeCommand(command) {
83
83
  wrappedLines.push(...console2.wrapText(line, maxContentWidth));
84
84
  }
85
85
  const actualMaxWidth = Math.max(...wrappedLines.map((l) => console2.getDisplayWidth(l)), console2.getDisplayWidth('生成命令'));
86
- const boxWidth = Math.min(actualMaxWidth + 4, termWidth - 2);
86
+ const boxWidth = Math.max(console2.MIN_COMMAND_BOX_WIDTH, Math.min(actualMaxWidth + 4, termWidth - 2));
87
87
  console2.printSeparator('输出', boxWidth);
88
88
  // 使用 bash 并启用 pipefail,确保管道中任何命令失败都能正确返回非零退出码
89
89
  const child = exec(`set -o pipefail; ${command}`, { shell: '/bin/bash' });
@@ -1452,7 +1452,7 @@ async function executeRemoteCommand(remoteName, command) {
1452
1452
  wrappedLines.push(...console2.wrapText(line, maxContentWidth));
1453
1453
  }
1454
1454
  const actualMaxWidth = Math.max(...wrappedLines.map((l) => console2.getDisplayWidth(l)), console2.getDisplayWidth('生成命令'));
1455
- const boxWidth = Math.min(actualMaxWidth + 4, termWidth - 2);
1455
+ const boxWidth = Math.max(console2.MIN_COMMAND_BOX_WIDTH, Math.min(actualMaxWidth + 4, termWidth - 2));
1456
1456
  console2.printSeparator(`远程输出 (${remoteName})`, boxWidth);
1457
1457
  try {
1458
1458
  const result = await sshExec(remoteName, actualCommand, {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yivan-lab/pretty-please",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "AI 驱动的命令行工具,将自然语言转换为可执行的 Shell 命令",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Box, Text } from 'ink';
3
3
  import { getCurrentTheme } from '../ui/theme.js';
4
- import { getDisplayWidth, wrapText } from '../utils/console.js';
4
+ import { getDisplayWidth, wrapText, MIN_COMMAND_BOX_WIDTH } from '../utils/console.js';
5
5
  /**
6
6
  * CommandBox 组件 - 显示带边框和标题的命令框
7
7
  */
@@ -20,7 +20,7 @@ export const CommandBox = ({ command, title = '生成命令' }) => {
20
20
  }
21
21
  // 计算实际使用的宽度
22
22
  const actualMaxWidth = Math.max(...wrappedLines.map((l) => getDisplayWidth(l)), titleWidth);
23
- const boxWidth = Math.min(actualMaxWidth + 4, termWidth - 2);
23
+ const boxWidth = Math.max(MIN_COMMAND_BOX_WIDTH, Math.min(actualMaxWidth + 4, termWidth - 2));
24
24
  // 顶部边框:┌─ 生成命令 ─────┐
25
25
  const topPadding = boxWidth - titleWidth - 5;
26
26
  const topBorder = '┌─ ' + title + ' ' + '─'.repeat(Math.max(0, topPadding)) + '┐';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * 原生控制台输出工具函数
3
+ * 用于不需要 Ink 的场景,避免清屏和性能问题
4
+ */
5
+ export declare const MIN_COMMAND_BOX_WIDTH = 20;
1
6
  /**
2
7
  * 计算字符串的显示宽度(中文占2个宽度)
3
8
  */
@@ -4,6 +4,8 @@ import { getCurrentTheme } from '../ui/theme.js';
4
4
  * 原生控制台输出工具函数
5
5
  * 用于不需要 Ink 的场景,避免清屏和性能问题
6
6
  */
7
+ // 命令框最小宽度(统一配置)
8
+ export const MIN_COMMAND_BOX_WIDTH = 20;
7
9
  // 获取当前主题颜色
8
10
  function getColors() {
9
11
  const theme = getCurrentTheme();
@@ -102,7 +104,7 @@ export function drawCommandBox(command, title = '生成命令') {
102
104
  }
103
105
  // 计算实际使用的宽度
104
106
  const actualMaxWidth = Math.max(...wrappedLines.map((l) => getDisplayWidth(l)), titleWidth);
105
- const boxWidth = Math.min(actualMaxWidth + 4, termWidth - 2);
107
+ const boxWidth = Math.max(MIN_COMMAND_BOX_WIDTH, Math.min(actualMaxWidth + 4, termWidth - 2));
106
108
  const topPadding = boxWidth - titleWidth - 5;
107
109
  const topBorder = '┌─ ' + title + ' ' + '─'.repeat(Math.max(0, topPadding)) + '┐';
108
110
  const bottomBorder = '└' + '─'.repeat(boxWidth - 2) + '┘';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yivan-lab/pretty-please",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "AI 驱动的命令行工具,将自然语言转换为可执行的 Shell 命令",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
2
  import { Box, Text } from 'ink'
3
3
  import { getCurrentTheme } from '../ui/theme.js'
4
- import { getDisplayWidth, wrapText } from '../utils/console.js'
4
+ import { getDisplayWidth, wrapText, MIN_COMMAND_BOX_WIDTH } from '../utils/console.js'
5
5
 
6
6
  interface CommandBoxProps {
7
7
  command: string
@@ -33,7 +33,7 @@ export const CommandBox: React.FC<CommandBoxProps> = ({ command, title = '生成
33
33
  ...wrappedLines.map((l) => getDisplayWidth(l)),
34
34
  titleWidth
35
35
  )
36
- const boxWidth = Math.min(actualMaxWidth + 4, termWidth - 2)
36
+ const boxWidth = Math.max(MIN_COMMAND_BOX_WIDTH, Math.min(actualMaxWidth + 4, termWidth - 2))
37
37
 
38
38
  // 顶部边框:┌─ 生成命令 ─────┐
39
39
  const topPadding = boxWidth - titleWidth - 5
@@ -6,6 +6,9 @@ import { getCurrentTheme } from '../ui/theme.js'
6
6
  * 用于不需要 Ink 的场景,避免清屏和性能问题
7
7
  */
8
8
 
9
+ // 命令框最小宽度(统一配置)
10
+ export const MIN_COMMAND_BOX_WIDTH = 20
11
+
9
12
  // 获取当前主题颜色
10
13
  function getColors() {
11
14
  const theme = getCurrentTheme()
@@ -115,7 +118,7 @@ export function drawCommandBox(command: string, title: string = '生成命令'):
115
118
  ...wrappedLines.map((l) => getDisplayWidth(l)),
116
119
  titleWidth
117
120
  )
118
- const boxWidth = Math.min(actualMaxWidth + 4, termWidth - 2)
121
+ const boxWidth = Math.max(MIN_COMMAND_BOX_WIDTH, Math.min(actualMaxWidth + 4, termWidth - 2))
119
122
 
120
123
  const topPadding = boxWidth - titleWidth - 5
121
124
  const topBorder = '┌─ ' + title + ' ' + '─'.repeat(Math.max(0, topPadding)) + '┐'