mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 22:35: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,147 +1,178 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import setWith from 'lodash-es/setWith.js';
|
||||
import * as React from 'react';
|
||||
import { Box, Text, useTheme } from '../ink.js';
|
||||
import type { ValidationError } from '../utils/settings/validation.js';
|
||||
import { type TreeNode, treeify } from '../utils/treeify.js';
|
||||
import setWith from 'lodash-es/setWith.js'
|
||||
import * as React from 'react'
|
||||
import { Box, Text, useTheme } from '../ink.js'
|
||||
import type { ValidationError } from '../utils/settings/validation.js'
|
||||
import { type TreeNode, treeify } from '../utils/treeify.js'
|
||||
|
||||
/**
|
||||
* Builds a nested tree structure from dot-notation paths
|
||||
* Uses lodash setWith to avoid automatic array creation
|
||||
*/
|
||||
function buildNestedTree(errors: ValidationError[]): TreeNode {
|
||||
const tree: TreeNode = {};
|
||||
const tree: TreeNode = {}
|
||||
|
||||
errors.forEach(error => {
|
||||
if (!error.path) {
|
||||
// Root level error - use empty string as key
|
||||
tree[''] = error.message;
|
||||
return;
|
||||
tree[''] = error.message
|
||||
return
|
||||
}
|
||||
|
||||
// Try to enhance the path with meaningful values
|
||||
const pathParts = error.path.split('.');
|
||||
let modifiedPath = error.path;
|
||||
const pathParts = error.path.split('.')
|
||||
let modifiedPath = error.path
|
||||
|
||||
// If we have an invalid value, try to make the path more readable
|
||||
if (error.invalidValue !== null && error.invalidValue !== undefined && pathParts.length > 0) {
|
||||
const newPathParts: string[] = [];
|
||||
if (
|
||||
error.invalidValue !== null &&
|
||||
error.invalidValue !== undefined &&
|
||||
pathParts.length > 0
|
||||
) {
|
||||
const newPathParts: string[] = []
|
||||
|
||||
for (let i = 0; i < pathParts.length; i++) {
|
||||
const part = pathParts[i];
|
||||
if (!part) continue;
|
||||
const numericPart = parseInt(part, 10);
|
||||
const part = pathParts[i]
|
||||
if (!part) continue
|
||||
|
||||
const numericPart = parseInt(part, 10)
|
||||
|
||||
// If this is a numeric index and it's the last part where we have the invalid value
|
||||
if (!isNaN(numericPart) && i === pathParts.length - 1) {
|
||||
// Format the value for display
|
||||
let displayValue: string;
|
||||
let displayValue: string
|
||||
if (typeof error.invalidValue === 'string') {
|
||||
displayValue = `"${error.invalidValue}"`;
|
||||
displayValue = `"${error.invalidValue}"`
|
||||
} else if (error.invalidValue === null) {
|
||||
displayValue = 'null';
|
||||
displayValue = 'null'
|
||||
} else if (error.invalidValue === undefined) {
|
||||
displayValue = 'undefined';
|
||||
displayValue = 'undefined'
|
||||
} else {
|
||||
displayValue = String(error.invalidValue);
|
||||
displayValue = String(error.invalidValue)
|
||||
}
|
||||
newPathParts.push(displayValue);
|
||||
|
||||
newPathParts.push(displayValue)
|
||||
} else {
|
||||
// Keep other parts as-is
|
||||
newPathParts.push(part);
|
||||
newPathParts.push(part)
|
||||
}
|
||||
}
|
||||
modifiedPath = newPathParts.join('.');
|
||||
|
||||
modifiedPath = newPathParts.join('.')
|
||||
}
|
||||
setWith(tree, modifiedPath, error.message, Object);
|
||||
});
|
||||
return tree;
|
||||
|
||||
setWith(tree, modifiedPath, error.message, Object)
|
||||
})
|
||||
|
||||
return tree
|
||||
}
|
||||
|
||||
/**
|
||||
* Groups and displays validation errors using treeify with deduplication
|
||||
*/
|
||||
export function ValidationErrorsList(t0) {
|
||||
const $ = _c(9);
|
||||
const {
|
||||
errors
|
||||
} = t0;
|
||||
const [themeName] = useTheme();
|
||||
export function ValidationErrorsList({
|
||||
errors,
|
||||
}: {
|
||||
errors: ValidationError[]
|
||||
}): React.ReactNode {
|
||||
const [themeName] = useTheme()
|
||||
|
||||
if (errors.length === 0) {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
let T0;
|
||||
let t1;
|
||||
let t2;
|
||||
if ($[0] !== errors || $[1] !== themeName) {
|
||||
const errorsByFile = errors.reduce(_temp, {});
|
||||
const sortedFiles = Object.keys(errorsByFile).sort();
|
||||
T0 = Box;
|
||||
t1 = "column";
|
||||
t2 = sortedFiles.map(file_0 => {
|
||||
const fileErrors = errorsByFile[file_0] || [];
|
||||
fileErrors.sort(_temp2);
|
||||
const errorTree = buildNestedTree(fileErrors);
|
||||
const suggestionPairs = new Map();
|
||||
fileErrors.forEach(error_0 => {
|
||||
if (error_0.suggestion || error_0.docLink) {
|
||||
const key = `${error_0.suggestion || ""}|${error_0.docLink || ""}`;
|
||||
if (!suggestionPairs.has(key)) {
|
||||
suggestionPairs.set(key, {
|
||||
suggestion: error_0.suggestion,
|
||||
docLink: error_0.docLink
|
||||
});
|
||||
|
||||
// Group errors by file
|
||||
const errorsByFile = errors.reduce<Record<string, ValidationError[]>>(
|
||||
(acc, error) => {
|
||||
const file = error.file || '(file not specified)'
|
||||
if (!acc[file]) {
|
||||
acc[file] = []
|
||||
}
|
||||
acc[file]!.push(error)
|
||||
return acc
|
||||
},
|
||||
{},
|
||||
)
|
||||
|
||||
// Sort files alphabetically
|
||||
const sortedFiles = Object.keys(errorsByFile).sort()
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
{sortedFiles.map(file => {
|
||||
const fileErrors = errorsByFile[file] || []
|
||||
|
||||
// Sort errors by path
|
||||
fileErrors.sort((a, b) => {
|
||||
if (!a.path && b.path) return -1
|
||||
if (a.path && !b.path) return 1
|
||||
return (a.path || '').localeCompare(b.path || '')
|
||||
})
|
||||
|
||||
// Build nested tree structure from error paths
|
||||
const errorTree = buildNestedTree(fileErrors)
|
||||
|
||||
// Collect unique suggestion+docLink pairs
|
||||
const suggestionPairs = new Map<
|
||||
string,
|
||||
{ suggestion?: string; docLink?: string }
|
||||
>()
|
||||
|
||||
fileErrors.forEach(error => {
|
||||
if (error.suggestion || error.docLink) {
|
||||
// Create a key from suggestion+docLink combination
|
||||
const key = `${error.suggestion || ''}|${error.docLink || ''}`
|
||||
if (!suggestionPairs.has(key)) {
|
||||
suggestionPairs.set(key, {
|
||||
suggestion: error.suggestion,
|
||||
docLink: error.docLink,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
const treeOutput = treeify(errorTree, {
|
||||
showValues: true,
|
||||
themeName,
|
||||
treeCharColors: {
|
||||
treeChar: "inactive",
|
||||
key: "text",
|
||||
value: "inactive"
|
||||
}
|
||||
});
|
||||
return <Box key={file_0} flexDirection="column"><Text>{file_0}</Text><Box marginLeft={1}><Text dimColor={true}>{treeOutput}</Text></Box>{suggestionPairs.size > 0 && <Box flexDirection="column" marginTop={1}>{Array.from(suggestionPairs.values()).map(_temp3)}</Box>}</Box>;
|
||||
});
|
||||
$[0] = errors;
|
||||
$[1] = themeName;
|
||||
$[2] = T0;
|
||||
$[3] = t1;
|
||||
$[4] = t2;
|
||||
} else {
|
||||
T0 = $[2];
|
||||
t1 = $[3];
|
||||
t2 = $[4];
|
||||
}
|
||||
let t3;
|
||||
if ($[5] !== T0 || $[6] !== t1 || $[7] !== t2) {
|
||||
t3 = <T0 flexDirection={t1}>{t2}</T0>;
|
||||
$[5] = T0;
|
||||
$[6] = t1;
|
||||
$[7] = t2;
|
||||
$[8] = t3;
|
||||
} else {
|
||||
t3 = $[8];
|
||||
}
|
||||
return t3;
|
||||
}
|
||||
function _temp3(pair, index) {
|
||||
return <Box key={`suggestion-pair-${index}`} flexDirection="column" marginBottom={1}>{pair.suggestion && <Text dimColor={true} wrap="wrap">{pair.suggestion}</Text>}{pair.docLink && <Text dimColor={true} wrap="wrap">Learn more: {pair.docLink}</Text>}</Box>;
|
||||
}
|
||||
function _temp2(a, b) {
|
||||
if (!a.path && b.path) {
|
||||
return -1;
|
||||
}
|
||||
if (a.path && !b.path) {
|
||||
return 1;
|
||||
}
|
||||
return (a.path || "").localeCompare(b.path || "");
|
||||
}
|
||||
function _temp(acc, error) {
|
||||
const file = error.file || "(file not specified)";
|
||||
if (!acc[file]) {
|
||||
acc[file] = [];
|
||||
}
|
||||
acc[file].push(error);
|
||||
return acc;
|
||||
})
|
||||
|
||||
// Render the tree
|
||||
const treeOutput = treeify(errorTree, {
|
||||
showValues: true,
|
||||
themeName,
|
||||
treeCharColors: {
|
||||
treeChar: 'inactive',
|
||||
key: 'text',
|
||||
value: 'inactive',
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
<Box key={file} flexDirection="column">
|
||||
<Text>{file}</Text>
|
||||
<Box marginLeft={1}>
|
||||
<Text dimColor>{treeOutput}</Text>
|
||||
</Box>
|
||||
{/* Display unique suggestion+docLink pairs */}
|
||||
{suggestionPairs.size > 0 && (
|
||||
<Box flexDirection="column" marginTop={1}>
|
||||
{Array.from(suggestionPairs.values()).map((pair, index) => (
|
||||
<Box
|
||||
key={`suggestion-pair-${index}`}
|
||||
flexDirection="column"
|
||||
marginBottom={1}
|
||||
>
|
||||
{pair.suggestion && (
|
||||
<Text dimColor wrap="wrap">
|
||||
{pair.suggestion}
|
||||
</Text>
|
||||
)}
|
||||
{pair.docLink && (
|
||||
<Text dimColor wrap="wrap">
|
||||
Learn more: {pair.docLink}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
))}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
)
|
||||
})}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user