更新大量 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:
claude-code-best
2026-04-04 23:24:27 +08:00
committed by GitHub
parent 02694918b5
commit 5b1a52b8e0
559 changed files with 103807 additions and 101817 deletions

View File

@@ -1,361 +1,472 @@
import chalk from 'chalk';
import figures from 'figures';
import * as React from 'react';
import { color, Text } from '../ink.js';
import type { MCPServerConnection } from '../services/mcp/types.js';
import { getAccountInformation, isClaudeAISubscriber } from './auth.js';
import { getLargeMemoryFiles, getMemoryFiles, MAX_MEMORY_CHARACTER_COUNT } from './claudemd.js';
import { getDoctorDiagnostic } from './doctorDiagnostic.js';
import { getAWSRegion, getDefaultVertexRegion, isEnvTruthy } from './envUtils.js';
import { getDisplayPath } from './file.js';
import { formatNumber } from './format.js';
import { getIdeClientName, type IDEExtensionInstallationStatus, isJetBrainsIde, toIDEDisplayName } from './ide.js';
import { getClaudeAiUserDefaultModelDescription, modelDisplayString } from './model/model.js';
import { getAPIProvider } from './model/providers.js';
import { getMTLSConfig } from './mtls.js';
import { checkInstall } from './nativeInstaller/index.js';
import { getProxyUrl } from './proxy.js';
import { SandboxManager } from './sandbox/sandbox-adapter.js';
import { getSettingsWithAllErrors } from './settings/allErrors.js';
import { getEnabledSettingSources, getSettingSourceDisplayNameCapitalized } from './settings/constants.js';
import { getManagedFileSettingsPresence, getPolicySettingsOrigin, getSettingsForSource } from './settings/settings.js';
import type { ThemeName } from './theme.js';
import chalk from 'chalk'
import figures from 'figures'
import * as React from 'react'
import { color, Text } from '../ink.js'
import type { MCPServerConnection } from '../services/mcp/types.js'
import { getAccountInformation, isClaudeAISubscriber } from './auth.js'
import {
getLargeMemoryFiles,
getMemoryFiles,
MAX_MEMORY_CHARACTER_COUNT,
} from './claudemd.js'
import { getDoctorDiagnostic } from './doctorDiagnostic.js'
import {
getAWSRegion,
getDefaultVertexRegion,
isEnvTruthy,
} from './envUtils.js'
import { getDisplayPath } from './file.js'
import { formatNumber } from './format.js'
import {
getIdeClientName,
type IDEExtensionInstallationStatus,
isJetBrainsIde,
toIDEDisplayName,
} from './ide.js'
import {
getClaudeAiUserDefaultModelDescription,
modelDisplayString,
} from './model/model.js'
import { getAPIProvider } from './model/providers.js'
import { getMTLSConfig } from './mtls.js'
import { checkInstall } from './nativeInstaller/index.js'
import { getProxyUrl } from './proxy.js'
import { SandboxManager } from './sandbox/sandbox-adapter.js'
import { getSettingsWithAllErrors } from './settings/allErrors.js'
import {
getEnabledSettingSources,
getSettingSourceDisplayNameCapitalized,
} from './settings/constants.js'
import {
getManagedFileSettingsPresence,
getPolicySettingsOrigin,
getSettingsForSource,
} from './settings/settings.js'
import type { ThemeName } from './theme.js'
export type Property = {
label?: string;
value: React.ReactNode | Array<string>;
};
export type Diagnostic = React.ReactNode;
export function buildSandboxProperties(): Property[] {
if ((process.env.USER_TYPE) !== 'ant') {
return [];
}
const isSandboxed = SandboxManager.isSandboxingEnabled();
return [{
label: 'Bash Sandbox',
value: isSandboxed ? 'Enabled' : 'Disabled'
}];
label?: string
value: React.ReactNode | Array<string>
}
export function buildIDEProperties(mcpClients: MCPServerConnection[], ideInstallationStatus: IDEExtensionInstallationStatus | null = null, theme: ThemeName): Property[] {
const ideClient = mcpClients?.find(client => client.name === 'ide');
export type Diagnostic = React.ReactNode
export function buildSandboxProperties(): Property[] {
if (process.env.USER_TYPE !== 'ant') {
return []
}
const isSandboxed = SandboxManager.isSandboxingEnabled()
return [
{
label: 'Bash Sandbox',
value: isSandboxed ? 'Enabled' : 'Disabled',
},
]
}
export function buildIDEProperties(
mcpClients: MCPServerConnection[],
ideInstallationStatus: IDEExtensionInstallationStatus | null = null,
theme: ThemeName,
): Property[] {
const ideClient = mcpClients?.find(client => client.name === 'ide')
if (ideInstallationStatus) {
const ideName = toIDEDisplayName(ideInstallationStatus.ideType);
const pluginOrExtension = isJetBrainsIde(ideInstallationStatus.ideType) ? 'plugin' : 'extension';
const ideName = toIDEDisplayName(ideInstallationStatus.ideType)
const pluginOrExtension = isJetBrainsIde(ideInstallationStatus.ideType)
? 'plugin'
: 'extension'
if (ideInstallationStatus.error) {
return [{
label: 'IDE',
value: <Text>
return [
{
label: 'IDE',
value: (
<Text>
{color('error', theme)(figures.cross)} Error installing {ideName}{' '}
{pluginOrExtension}: {ideInstallationStatus.error}
{'\n'}Please restart your IDE and try again.
</Text>
}];
),
},
]
}
if (ideInstallationStatus.installed) {
if (ideClient && ideClient.type === 'connected') {
if (ideInstallationStatus.installedVersion !== ideClient.serverInfo?.version) {
return [{
label: 'IDE',
value: `Connected to ${ideName} ${pluginOrExtension} version ${ideInstallationStatus.installedVersion} (server version: ${ideClient.serverInfo?.version})`
}];
if (
ideInstallationStatus.installedVersion !==
ideClient.serverInfo?.version
) {
return [
{
label: 'IDE',
value: `Connected to ${ideName} ${pluginOrExtension} version ${ideInstallationStatus.installedVersion} (server version: ${ideClient.serverInfo?.version})`,
},
]
} else {
return [{
label: 'IDE',
value: `Connected to ${ideName} ${pluginOrExtension} version ${ideInstallationStatus.installedVersion}`
}];
return [
{
label: 'IDE',
value: `Connected to ${ideName} ${pluginOrExtension} version ${ideInstallationStatus.installedVersion}`,
},
]
}
} else {
return [{
label: 'IDE',
value: `Installed ${ideName} ${pluginOrExtension}`
}];
return [
{
label: 'IDE',
value: `Installed ${ideName} ${pluginOrExtension}`,
},
]
}
}
} else if (ideClient) {
const ideName = getIdeClientName(ideClient) ?? 'IDE';
const ideName = getIdeClientName(ideClient) ?? 'IDE'
if (ideClient.type === 'connected') {
return [{
label: 'IDE',
value: `Connected to ${ideName} extension`
}];
return [
{
label: 'IDE',
value: `Connected to ${ideName} extension`,
},
]
} else {
return [{
label: 'IDE',
value: `${color('error', theme)(figures.cross)} Not connected to ${ideName}`
}];
return [
{
label: 'IDE',
value: `${color('error', theme)(figures.cross)} Not connected to ${ideName}`,
},
]
}
}
return [];
return []
}
export function buildMcpProperties(clients: MCPServerConnection[] = [], theme: ThemeName): Property[] {
const servers = clients.filter(client => client.name !== 'ide');
export function buildMcpProperties(
clients: MCPServerConnection[] = [],
theme: ThemeName,
): Property[] {
const servers = clients.filter(client => client.name !== 'ide')
if (!servers.length) {
return [];
return []
}
// Summary instead of a full server list — 20+ servers wrapped onto many
// rows, dominating the Status pane. Show counts by state + /mcp hint.
const byState = {
connected: 0,
pending: 0,
needsAuth: 0,
failed: 0
};
const byState = { connected: 0, pending: 0, needsAuth: 0, failed: 0 }
for (const s of servers) {
if (s.type === 'connected') byState.connected++;else if (s.type === 'pending') byState.pending++;else if (s.type === 'needs-auth') byState.needsAuth++;else byState.failed++;
if (s.type === 'connected') byState.connected++
else if (s.type === 'pending') byState.pending++
else if (s.type === 'needs-auth') byState.needsAuth++
else byState.failed++
}
const parts: string[] = [];
if (byState.connected) parts.push(color('success', theme)(`${byState.connected} connected`));
if (byState.needsAuth) parts.push(color('warning', theme)(`${byState.needsAuth} need auth`));
if (byState.pending) parts.push(color('inactive', theme)(`${byState.pending} pending`));
if (byState.failed) parts.push(color('error', theme)(`${byState.failed} failed`));
return [{
label: 'MCP servers',
value: `${parts.join(', ')} ${color('inactive', theme)('· /mcp')}`
}];
const parts: string[] = []
if (byState.connected)
parts.push(color('success', theme)(`${byState.connected} connected`))
if (byState.needsAuth)
parts.push(color('warning', theme)(`${byState.needsAuth} need auth`))
if (byState.pending)
parts.push(color('inactive', theme)(`${byState.pending} pending`))
if (byState.failed)
parts.push(color('error', theme)(`${byState.failed} failed`))
return [
{
label: 'MCP servers',
value: `${parts.join(', ')} ${color('inactive', theme)('· /mcp')}`,
},
]
}
export async function buildMemoryDiagnostics(): Promise<Diagnostic[]> {
const files = await getMemoryFiles();
const largeFiles = getLargeMemoryFiles(files);
const diagnostics: Diagnostic[] = [];
const files = await getMemoryFiles()
const largeFiles = getLargeMemoryFiles(files)
const diagnostics: Diagnostic[] = []
largeFiles.forEach(file => {
const displayPath = getDisplayPath(file.path);
diagnostics.push(`Large ${displayPath} will impact performance (${formatNumber(file.content.length)} chars > ${formatNumber(MAX_MEMORY_CHARACTER_COUNT)})`);
});
return diagnostics;
const displayPath = getDisplayPath(file.path)
diagnostics.push(
`Large ${displayPath} will impact performance (${formatNumber(file.content.length)} chars > ${formatNumber(MAX_MEMORY_CHARACTER_COUNT)})`,
)
})
return diagnostics
}
export function buildSettingSourcesProperties(): Property[] {
const enabledSources = getEnabledSettingSources();
const enabledSources = getEnabledSettingSources()
// Filter to only sources that actually have settings loaded
const sourcesWithSettings = enabledSources.filter(source => {
const settings = getSettingsForSource(source);
return settings !== null && Object.keys(settings).length > 0;
});
const settings = getSettingsForSource(source)
return settings !== null && Object.keys(settings).length > 0
})
// Map internal names to user-friendly names
// For policySettings, distinguish between remote and local (or skip if neither exists)
const sourceNames = sourcesWithSettings.map(source => {
if (source === 'policySettings') {
const origin = getPolicySettingsOrigin();
if (origin === null) {
return null; // Skip - no policy settings exist
}
switch (origin) {
case 'remote':
return 'Enterprise managed settings (remote)';
case 'plist':
return 'Enterprise managed settings (plist)';
case 'hklm':
return 'Enterprise managed settings (HKLM)';
case 'file':
{
const {
hasBase,
hasDropIns
} = getManagedFileSettingsPresence();
const sourceNames = sourcesWithSettings
.map(source => {
if (source === 'policySettings') {
const origin = getPolicySettingsOrigin()
if (origin === null) {
return null // Skip - no policy settings exist
}
switch (origin) {
case 'remote':
return 'Enterprise managed settings (remote)'
case 'plist':
return 'Enterprise managed settings (plist)'
case 'hklm':
return 'Enterprise managed settings (HKLM)'
case 'file': {
const { hasBase, hasDropIns } = getManagedFileSettingsPresence()
if (hasBase && hasDropIns) {
return 'Enterprise managed settings (file + drop-ins)';
return 'Enterprise managed settings (file + drop-ins)'
}
if (hasDropIns) {
return 'Enterprise managed settings (drop-ins)';
return 'Enterprise managed settings (drop-ins)'
}
return 'Enterprise managed settings (file)';
return 'Enterprise managed settings (file)'
}
case 'hkcu':
return 'Enterprise managed settings (HKCU)';
case 'hkcu':
return 'Enterprise managed settings (HKCU)'
}
}
}
return getSettingSourceDisplayNameCapitalized(source);
}).filter((name): name is string => name !== null);
return [{
label: 'Setting sources',
value: sourceNames
}];
return getSettingSourceDisplayNameCapitalized(source)
})
.filter((name): name is string => name !== null)
return [
{
label: 'Setting sources',
value: sourceNames,
},
]
}
export async function buildInstallationDiagnostics(): Promise<Diagnostic[]> {
const installWarnings = await checkInstall();
return installWarnings.map(warning => warning.message);
const installWarnings = await checkInstall()
return installWarnings.map(warning => warning.message)
}
export async function buildInstallationHealthDiagnostics(): Promise<Diagnostic[]> {
const diagnostic = await getDoctorDiagnostic();
const items: Diagnostic[] = [];
const {
errors: validationErrors
} = getSettingsWithAllErrors();
export async function buildInstallationHealthDiagnostics(): Promise<
Diagnostic[]
> {
const diagnostic = await getDoctorDiagnostic()
const items: Diagnostic[] = []
const { errors: validationErrors } = getSettingsWithAllErrors()
if (validationErrors.length > 0) {
const invalidFiles = Array.from(new Set(validationErrors.map(error => error.file)));
const fileList = invalidFiles.join(', ');
items.push(`Found invalid settings files: ${fileList}. They will be ignored.`);
const invalidFiles = Array.from(
new Set(validationErrors.map(error => error.file)),
)
const fileList = invalidFiles.join(', ')
items.push(
`Found invalid settings files: ${fileList}. They will be ignored.`,
)
}
// Add warnings from doctor diagnostic (includes leftover installations, config mismatches, etc.)
diagnostic.warnings.forEach(warning => {
items.push(warning.issue);
});
items.push(warning.issue)
})
if (diagnostic.hasUpdatePermissions === false) {
items.push('No write permissions for auto-updates (requires sudo)');
items.push('No write permissions for auto-updates (requires sudo)')
}
return items;
return items
}
export function buildAccountProperties(): Property[] {
const accountInfo = getAccountInformation();
const accountInfo = getAccountInformation()
if (!accountInfo) {
return [];
return []
}
const properties: Property[] = [];
const properties: Property[] = []
if (accountInfo.subscription) {
properties.push({
label: 'Login method',
value: `${accountInfo.subscription} Account`
});
value: `${accountInfo.subscription} Account`,
})
}
if (accountInfo.tokenSource) {
properties.push({
label: 'Auth token',
value: accountInfo.tokenSource
});
value: accountInfo.tokenSource,
})
}
if (accountInfo.apiKeySource) {
properties.push({
label: 'API key',
value: accountInfo.apiKeySource
});
value: accountInfo.apiKeySource,
})
}
// Hide sensitive account info in demo mode
if (accountInfo.organization && !process.env.IS_DEMO) {
properties.push({
label: 'Organization',
value: accountInfo.organization
});
value: accountInfo.organization,
})
}
if (accountInfo.email && !process.env.IS_DEMO) {
properties.push({
label: 'Email',
value: accountInfo.email
});
value: accountInfo.email,
})
}
return properties;
return properties
}
export function buildAPIProviderProperties(): Property[] {
const apiProvider = getAPIProvider();
const properties: Property[] = [];
const apiProvider = getAPIProvider()
const properties: Property[] = []
if (apiProvider !== 'firstParty') {
const providerLabel = {
bedrock: 'AWS Bedrock',
vertex: 'Google Vertex AI',
foundry: 'Microsoft Foundry'
}[apiProvider];
foundry: 'Microsoft Foundry',
}[apiProvider]
properties.push({
label: 'API provider',
value: providerLabel
});
value: providerLabel,
})
}
if (apiProvider === 'firstParty') {
const anthropicBaseUrl = process.env.ANTHROPIC_BASE_URL;
const anthropicBaseUrl = process.env.ANTHROPIC_BASE_URL
if (anthropicBaseUrl) {
properties.push({
label: 'Anthropic base URL',
value: anthropicBaseUrl
});
value: anthropicBaseUrl,
})
}
} else if (apiProvider === 'bedrock') {
const bedrockBaseUrl = process.env.BEDROCK_BASE_URL;
const bedrockBaseUrl = process.env.BEDROCK_BASE_URL
if (bedrockBaseUrl) {
properties.push({
label: 'Bedrock base URL',
value: bedrockBaseUrl
});
value: bedrockBaseUrl,
})
}
properties.push({
label: 'AWS region',
value: getAWSRegion()
});
value: getAWSRegion(),
})
if (isEnvTruthy(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)) {
properties.push({
value: 'AWS auth skipped'
});
value: 'AWS auth skipped',
})
}
} else if (apiProvider === 'vertex') {
const vertexBaseUrl = process.env.VERTEX_BASE_URL;
const vertexBaseUrl = process.env.VERTEX_BASE_URL
if (vertexBaseUrl) {
properties.push({
label: 'Vertex base URL',
value: vertexBaseUrl
});
value: vertexBaseUrl,
})
}
const gcpProject = process.env.ANTHROPIC_VERTEX_PROJECT_ID;
const gcpProject = process.env.ANTHROPIC_VERTEX_PROJECT_ID
if (gcpProject) {
properties.push({
label: 'GCP project',
value: gcpProject
});
value: gcpProject,
})
}
properties.push({
label: 'Default region',
value: getDefaultVertexRegion()
});
value: getDefaultVertexRegion(),
})
if (isEnvTruthy(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)) {
properties.push({
value: 'GCP auth skipped'
});
value: 'GCP auth skipped',
})
}
} else if (apiProvider === 'foundry') {
const foundryBaseUrl = process.env.ANTHROPIC_FOUNDRY_BASE_URL;
const foundryBaseUrl = process.env.ANTHROPIC_FOUNDRY_BASE_URL
if (foundryBaseUrl) {
properties.push({
label: 'Microsoft Foundry base URL',
value: foundryBaseUrl
});
value: foundryBaseUrl,
})
}
const foundryResource = process.env.ANTHROPIC_FOUNDRY_RESOURCE;
const foundryResource = process.env.ANTHROPIC_FOUNDRY_RESOURCE
if (foundryResource) {
properties.push({
label: 'Microsoft Foundry resource',
value: foundryResource
});
value: foundryResource,
})
}
if (isEnvTruthy(process.env.CLAUDE_CODE_SKIP_FOUNDRY_AUTH)) {
properties.push({
value: 'Microsoft Foundry auth skipped'
});
value: 'Microsoft Foundry auth skipped',
})
}
}
const proxyUrl = getProxyUrl();
const proxyUrl = getProxyUrl()
if (proxyUrl) {
properties.push({
label: 'Proxy',
value: proxyUrl
});
value: proxyUrl,
})
}
const mtlsConfig = getMTLSConfig();
const mtlsConfig = getMTLSConfig()
if (process.env.NODE_EXTRA_CA_CERTS) {
properties.push({
label: 'Additional CA cert(s)',
value: process.env.NODE_EXTRA_CA_CERTS
});
value: process.env.NODE_EXTRA_CA_CERTS,
})
}
if (mtlsConfig) {
if (mtlsConfig.cert && process.env.CLAUDE_CODE_CLIENT_CERT) {
properties.push({
label: 'mTLS client cert',
value: process.env.CLAUDE_CODE_CLIENT_CERT
});
value: process.env.CLAUDE_CODE_CLIENT_CERT,
})
}
if (mtlsConfig.key && process.env.CLAUDE_CODE_CLIENT_KEY) {
properties.push({
label: 'mTLS client key',
value: process.env.CLAUDE_CODE_CLIENT_KEY
});
value: process.env.CLAUDE_CODE_CLIENT_KEY,
})
}
}
return properties;
return properties
}
export function getModelDisplayLabel(mainLoopModel: string | null): string {
let modelLabel = modelDisplayString(mainLoopModel);
let modelLabel = modelDisplayString(mainLoopModel)
if (mainLoopModel === null && isClaudeAISubscriber()) {
const description = getClaudeAiUserDefaultModelDescription();
modelLabel = `${chalk.bold('Default')} ${description}`;
const description = getClaudeAiUserDefaultModelDescription()
modelLabel = `${chalk.bold('Default')} ${description}`
}
return modelLabel;
return modelLabel
}