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,125 +1,154 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import chalk from 'chalk';
|
||||
import figures from 'figures';
|
||||
import React, { useEffect } from 'react';
|
||||
import { getAdditionalDirectoriesForClaudeMd, setAdditionalDirectoriesForClaudeMd } from '../../bootstrap/state.js';
|
||||
import type { LocalJSXCommandContext } from '../../commands.js';
|
||||
import { MessageResponse } from '../../components/MessageResponse.js';
|
||||
import { AddWorkspaceDirectory } from '../../components/permissions/rules/AddWorkspaceDirectory.js';
|
||||
import { Box, Text } from '../../ink.js';
|
||||
import type { LocalJSXCommandOnDone } from '../../types/command.js';
|
||||
import { applyPermissionUpdate, persistPermissionUpdate } from '../../utils/permissions/PermissionUpdate.js';
|
||||
import type { PermissionUpdateDestination } from '../../utils/permissions/PermissionUpdateSchema.js';
|
||||
import { SandboxManager } from '../../utils/sandbox/sandbox-adapter.js';
|
||||
import { addDirHelpMessage, validateDirectoryForWorkspace } from './validation.js';
|
||||
function AddDirError(t0) {
|
||||
const $ = _c(10);
|
||||
const {
|
||||
message,
|
||||
args,
|
||||
onDone
|
||||
} = t0;
|
||||
let t1;
|
||||
let t2;
|
||||
if ($[0] !== onDone) {
|
||||
t1 = () => {
|
||||
const timer = setTimeout(onDone, 0);
|
||||
return () => clearTimeout(timer);
|
||||
};
|
||||
t2 = [onDone];
|
||||
$[0] = onDone;
|
||||
$[1] = t1;
|
||||
$[2] = t2;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
t2 = $[2];
|
||||
}
|
||||
useEffect(t1, t2);
|
||||
let t3;
|
||||
if ($[3] !== args) {
|
||||
t3 = <Text dimColor={true}>{figures.pointer} /add-dir {args}</Text>;
|
||||
$[3] = args;
|
||||
$[4] = t3;
|
||||
} else {
|
||||
t3 = $[4];
|
||||
}
|
||||
let t4;
|
||||
if ($[5] !== message) {
|
||||
t4 = <MessageResponse><Text>{message}</Text></MessageResponse>;
|
||||
$[5] = message;
|
||||
$[6] = t4;
|
||||
} else {
|
||||
t4 = $[6];
|
||||
}
|
||||
let t5;
|
||||
if ($[7] !== t3 || $[8] !== t4) {
|
||||
t5 = <Box flexDirection="column">{t3}{t4}</Box>;
|
||||
$[7] = t3;
|
||||
$[8] = t4;
|
||||
$[9] = t5;
|
||||
} else {
|
||||
t5 = $[9];
|
||||
}
|
||||
return t5;
|
||||
import chalk from 'chalk'
|
||||
import figures from 'figures'
|
||||
import React, { useEffect } from 'react'
|
||||
import {
|
||||
getAdditionalDirectoriesForClaudeMd,
|
||||
setAdditionalDirectoriesForClaudeMd,
|
||||
} from '../../bootstrap/state.js'
|
||||
import type { LocalJSXCommandContext } from '../../commands.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { AddWorkspaceDirectory } from '../../components/permissions/rules/AddWorkspaceDirectory.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import type { LocalJSXCommandOnDone } from '../../types/command.js'
|
||||
import {
|
||||
applyPermissionUpdate,
|
||||
persistPermissionUpdate,
|
||||
} from '../../utils/permissions/PermissionUpdate.js'
|
||||
import type { PermissionUpdateDestination } from '../../utils/permissions/PermissionUpdateSchema.js'
|
||||
import { SandboxManager } from '../../utils/sandbox/sandbox-adapter.js'
|
||||
import {
|
||||
addDirHelpMessage,
|
||||
validateDirectoryForWorkspace,
|
||||
} from './validation.js'
|
||||
|
||||
function AddDirError({
|
||||
message,
|
||||
args,
|
||||
onDone,
|
||||
}: {
|
||||
message: string
|
||||
args: string
|
||||
onDone: () => void
|
||||
}): React.ReactNode {
|
||||
useEffect(() => {
|
||||
// We need to defer calling onDone to avoid the "return null" bug where
|
||||
// the component unmounts before React can render the error message.
|
||||
// Using setTimeout ensures the error displays before the command exits.
|
||||
const timer = setTimeout(onDone, 0)
|
||||
return () => clearTimeout(timer)
|
||||
}, [onDone])
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text dimColor>
|
||||
{figures.pointer} /add-dir {args}
|
||||
</Text>
|
||||
<MessageResponse>
|
||||
<Text>{message}</Text>
|
||||
</MessageResponse>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
export async function call(onDone: LocalJSXCommandOnDone, context: LocalJSXCommandContext, args?: string): Promise<React.ReactNode> {
|
||||
const directoryPath = (args ?? '').trim();
|
||||
const appState = context.getAppState();
|
||||
|
||||
export async function call(
|
||||
onDone: LocalJSXCommandOnDone,
|
||||
context: LocalJSXCommandContext,
|
||||
args?: string,
|
||||
): Promise<React.ReactNode> {
|
||||
const directoryPath = (args ?? '').trim()
|
||||
const appState = context.getAppState()
|
||||
|
||||
// Helper to handle adding a directory (shared by both with-path and no-path cases)
|
||||
const handleAddDirectory = async (path: string, remember = false) => {
|
||||
const destination: PermissionUpdateDestination = remember ? 'localSettings' : 'session';
|
||||
const destination: PermissionUpdateDestination = remember
|
||||
? 'localSettings'
|
||||
: 'session'
|
||||
|
||||
const permissionUpdate = {
|
||||
type: 'addDirectories' as const,
|
||||
directories: [path],
|
||||
destination
|
||||
};
|
||||
destination,
|
||||
}
|
||||
|
||||
// Apply to session context
|
||||
const latestAppState = context.getAppState();
|
||||
const updatedContext = applyPermissionUpdate(latestAppState.toolPermissionContext, permissionUpdate);
|
||||
const latestAppState = context.getAppState()
|
||||
const updatedContext = applyPermissionUpdate(
|
||||
latestAppState.toolPermissionContext,
|
||||
permissionUpdate,
|
||||
)
|
||||
context.setAppState(prev => ({
|
||||
...prev,
|
||||
toolPermissionContext: updatedContext
|
||||
}));
|
||||
toolPermissionContext: updatedContext,
|
||||
}))
|
||||
|
||||
// Update sandbox config so Bash commands can access the new directory.
|
||||
// Bootstrap state is the source of truth for session-only dirs; persisted
|
||||
// dirs are picked up via the settings subscription, but we refresh
|
||||
// eagerly here to avoid a race when the user acts immediately.
|
||||
const currentDirs = getAdditionalDirectoriesForClaudeMd();
|
||||
const currentDirs = getAdditionalDirectoriesForClaudeMd()
|
||||
if (!currentDirs.includes(path)) {
|
||||
setAdditionalDirectoriesForClaudeMd([...currentDirs, path]);
|
||||
setAdditionalDirectoriesForClaudeMd([...currentDirs, path])
|
||||
}
|
||||
SandboxManager.refreshConfig();
|
||||
let message: string;
|
||||
SandboxManager.refreshConfig()
|
||||
|
||||
let message: string
|
||||
|
||||
if (remember) {
|
||||
try {
|
||||
persistPermissionUpdate(permissionUpdate);
|
||||
message = `Added ${chalk.bold(path)} as a working directory and saved to local settings`;
|
||||
persistPermissionUpdate(permissionUpdate)
|
||||
message = `Added ${chalk.bold(path)} as a working directory and saved to local settings`
|
||||
} catch (error) {
|
||||
message = `Added ${chalk.bold(path)} as a working directory. Failed to save to local settings: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
||||
message = `Added ${chalk.bold(path)} as a working directory. Failed to save to local settings: ${error instanceof Error ? error.message : 'Unknown error'}`
|
||||
}
|
||||
} else {
|
||||
message = `Added ${chalk.bold(path)} as a working directory for this session`;
|
||||
message = `Added ${chalk.bold(path)} as a working directory for this session`
|
||||
}
|
||||
const messageWithHint = `${message} ${chalk.dim('· /permissions to manage')}`;
|
||||
onDone(messageWithHint);
|
||||
};
|
||||
|
||||
const messageWithHint = `${message} ${chalk.dim('· /permissions to manage')}`
|
||||
onDone(messageWithHint)
|
||||
}
|
||||
|
||||
// When no path is provided, show AddWorkspaceDirectory input form directly
|
||||
// and return to REPL after confirmation
|
||||
if (!directoryPath) {
|
||||
return <AddWorkspaceDirectory permissionContext={appState.toolPermissionContext} onAddDirectory={handleAddDirectory} onCancel={() => {
|
||||
onDone('Did not add a working directory.');
|
||||
}} />;
|
||||
return (
|
||||
<AddWorkspaceDirectory
|
||||
permissionContext={appState.toolPermissionContext}
|
||||
onAddDirectory={handleAddDirectory}
|
||||
onCancel={() => {
|
||||
onDone('Did not add a working directory.')
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
const result = await validateDirectoryForWorkspace(directoryPath, appState.toolPermissionContext);
|
||||
|
||||
const result = await validateDirectoryForWorkspace(
|
||||
directoryPath,
|
||||
appState.toolPermissionContext,
|
||||
)
|
||||
|
||||
if (result.resultType !== 'success') {
|
||||
const message = addDirHelpMessage(result);
|
||||
return <AddDirError message={message} args={args ?? ''} onDone={() => onDone(message)} />;
|
||||
const message = addDirHelpMessage(result)
|
||||
|
||||
return (
|
||||
<AddDirError
|
||||
message={message}
|
||||
args={args ?? ''}
|
||||
onDone={() => onDone(message)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return <AddWorkspaceDirectory directoryPath={result.absolutePath} permissionContext={appState.toolPermissionContext} onAddDirectory={handleAddDirectory} onCancel={() => {
|
||||
onDone(`Did not add ${chalk.bold(result.absolutePath)} as a working directory.`);
|
||||
}} />;
|
||||
|
||||
return (
|
||||
<AddWorkspaceDirectory
|
||||
directoryPath={result.absolutePath}
|
||||
permissionContext={appState.toolPermissionContext}
|
||||
onAddDirectory={handleAddDirectory}
|
||||
onCancel={() => {
|
||||
onDone(
|
||||
`Did not add ${chalk.bold(result.absolutePath)} as a working directory.`,
|
||||
)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user