mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 05:45:51 +00:00
* 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>
179 lines
5.1 KiB
TypeScript
179 lines
5.1 KiB
TypeScript
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 = {}
|
|
|
|
errors.forEach(error => {
|
|
if (!error.path) {
|
|
// Root level error - use empty string as key
|
|
tree[''] = error.message
|
|
return
|
|
}
|
|
|
|
// Try to enhance the path with meaningful values
|
|
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[] = []
|
|
|
|
for (let i = 0; i < pathParts.length; i++) {
|
|
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
|
|
if (typeof error.invalidValue === 'string') {
|
|
displayValue = `"${error.invalidValue}"`
|
|
} else if (error.invalidValue === null) {
|
|
displayValue = 'null'
|
|
} else if (error.invalidValue === undefined) {
|
|
displayValue = 'undefined'
|
|
} else {
|
|
displayValue = String(error.invalidValue)
|
|
}
|
|
|
|
newPathParts.push(displayValue)
|
|
} else {
|
|
// Keep other parts as-is
|
|
newPathParts.push(part)
|
|
}
|
|
}
|
|
|
|
modifiedPath = newPathParts.join('.')
|
|
}
|
|
|
|
setWith(tree, modifiedPath, error.message, Object)
|
|
})
|
|
|
|
return tree
|
|
}
|
|
|
|
/**
|
|
* Groups and displays validation errors using treeify with deduplication
|
|
*/
|
|
export function ValidationErrorsList({
|
|
errors,
|
|
}: {
|
|
errors: ValidationError[]
|
|
}): React.ReactNode {
|
|
const [themeName] = useTheme()
|
|
|
|
if (errors.length === 0) {
|
|
return null
|
|
}
|
|
|
|
// 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,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
// 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>
|
|
)
|
|
}
|