mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
更新大量 tsx 原始文件; 已经迁移 login panel; 部分 (#121)
* style(B1-1): 格式化 ink/buddy/cli/context/screens/tasks/services/keybindings/state (43 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 修复了 Box.tsx 和 ScrollBox.tsx 中无效的 global.d.ts import。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-2): 格式化 commands (79 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-4): 格式化 components/PromptInput,FeedbackSurvey,tasks,agents,skills,design-system,wizard (73 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-5): 格式化 components其余 + hooks + tools (232 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-6): 格式化 main/entrypoints/utils/moreright (21 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: 更新 README,新增 Run.ps1/TODO.md,删除 V6.md - README.md: 大幅重写,更详细版本历史和配置示例 - Run.ps1: 新增 Windows 启动脚本 - TODO.md: 新增包完成清单 - V6.md: 删除(架构重构规划已不适用) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: 修复以前的问题 * fix: 修复 login 面板的问题 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,41 +1,43 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import React from 'react';
|
||||
import { removeSandboxViolationTags } from 'src/utils/sandbox/sandbox-ui-utils.js';
|
||||
import { KeyboardShortcutHint } from '../../components/design-system/KeyboardShortcutHint.js';
|
||||
import { MessageResponse } from '../../components/MessageResponse.js';
|
||||
import { OutputLine } from '../../components/shell/OutputLine.js';
|
||||
import { ShellTimeDisplay } from '../../components/shell/ShellTimeDisplay.js';
|
||||
import { Box, Text } from '../../ink.js';
|
||||
import type { Out as BashOut } from './BashTool.js';
|
||||
import React from 'react'
|
||||
import { removeSandboxViolationTags } from 'src/utils/sandbox/sandbox-ui-utils.js'
|
||||
import { KeyboardShortcutHint } from '../../components/design-system/KeyboardShortcutHint.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { OutputLine } from '../../components/shell/OutputLine.js'
|
||||
import { ShellTimeDisplay } from '../../components/shell/ShellTimeDisplay.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import type { Out as BashOut } from './BashTool.js'
|
||||
|
||||
type Props = {
|
||||
content: Omit<BashOut, 'interrupted'>;
|
||||
verbose: boolean;
|
||||
timeoutMs?: number;
|
||||
};
|
||||
content: Omit<BashOut, 'interrupted'>
|
||||
verbose: boolean
|
||||
timeoutMs?: number
|
||||
}
|
||||
|
||||
// Pattern to match "Shell cwd was reset to <path>" message
|
||||
// Use (?:^|\n) to match either start of string or after a newline
|
||||
const SHELL_CWD_RESET_PATTERN = /(?:^|\n)(Shell cwd was reset to .+)$/;
|
||||
const SHELL_CWD_RESET_PATTERN = /(?:^|\n)(Shell cwd was reset to .+)$/
|
||||
|
||||
/**
|
||||
* Extracts sandbox violations from stderr if present
|
||||
* Returns both the cleaned stderr and the violations content
|
||||
*/
|
||||
function extractSandboxViolations(stderr: string): {
|
||||
cleanedStderr: string;
|
||||
cleanedStderr: string
|
||||
} {
|
||||
const violationsMatch = stderr.match(/<sandbox_violations>([\s\S]*?)<\/sandbox_violations>/);
|
||||
const violationsMatch = stderr.match(
|
||||
/<sandbox_violations>([\s\S]*?)<\/sandbox_violations>/,
|
||||
)
|
||||
|
||||
if (!violationsMatch) {
|
||||
return {
|
||||
cleanedStderr: stderr
|
||||
};
|
||||
return { cleanedStderr: stderr }
|
||||
}
|
||||
|
||||
// Remove the sandbox violations section from stderr
|
||||
const cleanedStderr = removeSandboxViolationTags(stderr).trim();
|
||||
const cleanedStderr = removeSandboxViolationTags(stderr).trim()
|
||||
|
||||
return {
|
||||
cleanedStderr
|
||||
};
|
||||
cleanedStderr,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,148 +45,85 @@ function extractSandboxViolations(stderr: string): {
|
||||
* Returns the cleaned stderr and the warning message separately
|
||||
*/
|
||||
function extractCwdResetWarning(stderr: string): {
|
||||
cleanedStderr: string;
|
||||
cwdResetWarning: string | null;
|
||||
cleanedStderr: string
|
||||
cwdResetWarning: string | null
|
||||
} {
|
||||
const match = stderr.match(SHELL_CWD_RESET_PATTERN);
|
||||
const match = stderr.match(SHELL_CWD_RESET_PATTERN)
|
||||
if (!match) {
|
||||
return {
|
||||
cleanedStderr: stderr,
|
||||
cwdResetWarning: null
|
||||
};
|
||||
return { cleanedStderr: stderr, cwdResetWarning: null }
|
||||
}
|
||||
|
||||
// Extract the warning message from capture group 1
|
||||
const cwdResetWarning = match[1] ?? null;
|
||||
const cwdResetWarning = match[1] ?? null
|
||||
// Remove the warning from stderr (replace the full match)
|
||||
const cleanedStderr = stderr.replace(SHELL_CWD_RESET_PATTERN, '').trim();
|
||||
return {
|
||||
cleanedStderr,
|
||||
cwdResetWarning
|
||||
};
|
||||
const cleanedStderr = stderr.replace(SHELL_CWD_RESET_PATTERN, '').trim()
|
||||
|
||||
return { cleanedStderr, cwdResetWarning }
|
||||
}
|
||||
export default function BashToolResultMessage(t0) {
|
||||
const $ = _c(34);
|
||||
const {
|
||||
content: t1,
|
||||
verbose,
|
||||
timeoutMs
|
||||
} = t0;
|
||||
const {
|
||||
stdout: t2,
|
||||
stderr: t3,
|
||||
|
||||
export default function BashToolResultMessage({
|
||||
content: {
|
||||
stdout = '',
|
||||
stderr: stdErrWithViolations = '',
|
||||
isImage,
|
||||
returnCodeInterpretation,
|
||||
noOutputExpected,
|
||||
backgroundTaskId
|
||||
} = t1;
|
||||
const stdout = t2 === undefined ? "" : t2;
|
||||
const stdErrWithViolations = t3 === undefined ? "" : t3;
|
||||
let T0;
|
||||
let cwdResetWarning;
|
||||
let stderr;
|
||||
let t4;
|
||||
let t5;
|
||||
let t6;
|
||||
let t7;
|
||||
if ($[0] !== isImage || $[1] !== stdErrWithViolations || $[2] !== stdout || $[3] !== verbose) {
|
||||
t7 = Symbol.for("react.early_return_sentinel");
|
||||
bb0: {
|
||||
const {
|
||||
cleanedStderr: stderrWithoutViolations
|
||||
} = extractSandboxViolations(stdErrWithViolations);
|
||||
({
|
||||
cleanedStderr: stderr,
|
||||
cwdResetWarning
|
||||
} = extractCwdResetWarning(stderrWithoutViolations));
|
||||
if (isImage) {
|
||||
let t8;
|
||||
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t8 = <MessageResponse height={1}><Text dimColor={true}>[Image data detected and sent to Claude]</Text></MessageResponse>;
|
||||
$[11] = t8;
|
||||
} else {
|
||||
t8 = $[11];
|
||||
}
|
||||
t7 = t8;
|
||||
break bb0;
|
||||
}
|
||||
T0 = Box;
|
||||
t4 = "column";
|
||||
if ($[12] !== stdout || $[13] !== verbose) {
|
||||
t5 = stdout !== "" ? <OutputLine content={stdout} verbose={verbose} /> : null;
|
||||
$[12] = stdout;
|
||||
$[13] = verbose;
|
||||
$[14] = t5;
|
||||
} else {
|
||||
t5 = $[14];
|
||||
}
|
||||
t6 = stderr.trim() !== "" ? <OutputLine content={stderr} verbose={verbose} isError={true} /> : null;
|
||||
}
|
||||
$[0] = isImage;
|
||||
$[1] = stdErrWithViolations;
|
||||
$[2] = stdout;
|
||||
$[3] = verbose;
|
||||
$[4] = T0;
|
||||
$[5] = cwdResetWarning;
|
||||
$[6] = stderr;
|
||||
$[7] = t4;
|
||||
$[8] = t5;
|
||||
$[9] = t6;
|
||||
$[10] = t7;
|
||||
} else {
|
||||
T0 = $[4];
|
||||
cwdResetWarning = $[5];
|
||||
stderr = $[6];
|
||||
t4 = $[7];
|
||||
t5 = $[8];
|
||||
t6 = $[9];
|
||||
t7 = $[10];
|
||||
backgroundTaskId,
|
||||
},
|
||||
verbose,
|
||||
timeoutMs,
|
||||
}: Props): React.ReactNode {
|
||||
// Extract sandbox violations from stderr as it feels cleaner on the UI
|
||||
// We want the model to see the violations, so it can explain what went wrong, and the
|
||||
// user can access them in the violation logs
|
||||
const { cleanedStderr: stderrWithoutViolations } =
|
||||
extractSandboxViolations(stdErrWithViolations)
|
||||
|
||||
// Extract "Shell cwd was reset" warning to render it with warning color instead of error
|
||||
const { cleanedStderr: stderr, cwdResetWarning } = extractCwdResetWarning(
|
||||
stderrWithoutViolations,
|
||||
)
|
||||
|
||||
// If this is an image, we don't want to truncate it in the UI
|
||||
if (isImage) {
|
||||
return (
|
||||
<MessageResponse height={1}>
|
||||
<Text dimColor>[Image data detected and sent to Claude]</Text>
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
if (t7 !== Symbol.for("react.early_return_sentinel")) {
|
||||
return t7;
|
||||
}
|
||||
let t8;
|
||||
if ($[15] !== cwdResetWarning) {
|
||||
t8 = cwdResetWarning ? <MessageResponse><Text dimColor={true}>{cwdResetWarning}</Text></MessageResponse> : null;
|
||||
$[15] = cwdResetWarning;
|
||||
$[16] = t8;
|
||||
} else {
|
||||
t8 = $[16];
|
||||
}
|
||||
let t9;
|
||||
if ($[17] !== backgroundTaskId || $[18] !== cwdResetWarning || $[19] !== noOutputExpected || $[20] !== returnCodeInterpretation || $[21] !== stderr || $[22] !== stdout) {
|
||||
t9 = stdout === "" && stderr.trim() === "" && !cwdResetWarning ? <MessageResponse height={1}><Text dimColor={true}>{backgroundTaskId ? <>Running in the background{" "}<KeyboardShortcutHint shortcut={"\u2193"} action="manage" parens={true} /></> : returnCodeInterpretation || (noOutputExpected ? "Done" : "(No output)")}</Text></MessageResponse> : null;
|
||||
$[17] = backgroundTaskId;
|
||||
$[18] = cwdResetWarning;
|
||||
$[19] = noOutputExpected;
|
||||
$[20] = returnCodeInterpretation;
|
||||
$[21] = stderr;
|
||||
$[22] = stdout;
|
||||
$[23] = t9;
|
||||
} else {
|
||||
t9 = $[23];
|
||||
}
|
||||
let t10;
|
||||
if ($[24] !== timeoutMs) {
|
||||
t10 = timeoutMs && <MessageResponse><ShellTimeDisplay timeoutMs={timeoutMs} /></MessageResponse>;
|
||||
$[24] = timeoutMs;
|
||||
$[25] = t10;
|
||||
} else {
|
||||
t10 = $[25];
|
||||
}
|
||||
let t11;
|
||||
if ($[26] !== T0 || $[27] !== t10 || $[28] !== t4 || $[29] !== t5 || $[30] !== t6 || $[31] !== t8 || $[32] !== t9) {
|
||||
t11 = <T0 flexDirection={t4}>{t5}{t6}{t8}{t9}{t10}</T0>;
|
||||
$[26] = T0;
|
||||
$[27] = t10;
|
||||
$[28] = t4;
|
||||
$[29] = t5;
|
||||
$[30] = t6;
|
||||
$[31] = t8;
|
||||
$[32] = t9;
|
||||
$[33] = t11;
|
||||
} else {
|
||||
t11 = $[33];
|
||||
}
|
||||
return t11;
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
{stdout !== '' ? <OutputLine content={stdout} verbose={verbose} /> : null}
|
||||
{stderr.trim() !== '' ? (
|
||||
<OutputLine content={stderr} verbose={verbose} isError />
|
||||
) : null}
|
||||
{cwdResetWarning ? (
|
||||
<MessageResponse>
|
||||
<Text dimColor>{cwdResetWarning}</Text>
|
||||
</MessageResponse>
|
||||
) : null}
|
||||
{stdout === '' && stderr.trim() === '' && !cwdResetWarning ? (
|
||||
<MessageResponse height={1}>
|
||||
<Text dimColor>
|
||||
{backgroundTaskId ? (
|
||||
<>
|
||||
Running in the background{' '}
|
||||
<KeyboardShortcutHint shortcut="↓" action="manage" parens />
|
||||
</>
|
||||
) : (
|
||||
returnCodeInterpretation ||
|
||||
(noOutputExpected ? 'Done' : '(No output)')
|
||||
)}
|
||||
</Text>
|
||||
</MessageResponse>
|
||||
) : null}
|
||||
{timeoutMs && (
|
||||
<MessageResponse>
|
||||
<ShellTimeDisplay timeoutMs={timeoutMs} />
|
||||
</MessageResponse>
|
||||
)}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user