mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14: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,75 +1,86 @@
|
||||
import { mkdir, writeFile } from 'fs/promises';
|
||||
import * as React from 'react';
|
||||
import type { CommandResultDisplay } from '../../commands.js';
|
||||
import { Dialog } from '../../components/design-system/Dialog.js';
|
||||
import { MemoryFileSelector } from '../../components/memory/MemoryFileSelector.js';
|
||||
import { getRelativeMemoryPath } from '../../components/memory/MemoryUpdateNotification.js';
|
||||
import { Box, Link, Text } from '../../ink.js';
|
||||
import type { LocalJSXCommandCall } from '../../types/command.js';
|
||||
import { clearMemoryFileCaches, getMemoryFiles } from '../../utils/claudemd.js';
|
||||
import { getClaudeConfigHomeDir } from '../../utils/envUtils.js';
|
||||
import { getErrnoCode } from '../../utils/errors.js';
|
||||
import { logError } from '../../utils/log.js';
|
||||
import { editFileInEditor } from '../../utils/promptEditor.js';
|
||||
import { mkdir, writeFile } from 'fs/promises'
|
||||
import * as React from 'react'
|
||||
import type { CommandResultDisplay } from '../../commands.js'
|
||||
import { Dialog } from '../../components/design-system/Dialog.js'
|
||||
import { MemoryFileSelector } from '../../components/memory/MemoryFileSelector.js'
|
||||
import { getRelativeMemoryPath } from '../../components/memory/MemoryUpdateNotification.js'
|
||||
import { Box, Link, Text } from '../../ink.js'
|
||||
import type { LocalJSXCommandCall } from '../../types/command.js'
|
||||
import { clearMemoryFileCaches, getMemoryFiles } from '../../utils/claudemd.js'
|
||||
import { getClaudeConfigHomeDir } from '../../utils/envUtils.js'
|
||||
import { getErrnoCode } from '../../utils/errors.js'
|
||||
import { logError } from '../../utils/log.js'
|
||||
import { editFileInEditor } from '../../utils/promptEditor.js'
|
||||
|
||||
function MemoryCommand({
|
||||
onDone
|
||||
onDone,
|
||||
}: {
|
||||
onDone: (result?: string, options?: {
|
||||
display?: CommandResultDisplay;
|
||||
}) => void;
|
||||
onDone: (
|
||||
result?: string,
|
||||
options?: { display?: CommandResultDisplay },
|
||||
) => void
|
||||
}): React.ReactNode {
|
||||
const handleSelectMemoryFile = async (memoryPath: string) => {
|
||||
try {
|
||||
// Create claude directory if it doesn't exist (idempotent with recursive)
|
||||
if (memoryPath.includes(getClaudeConfigHomeDir())) {
|
||||
await mkdir(getClaudeConfigHomeDir(), {
|
||||
recursive: true
|
||||
});
|
||||
await mkdir(getClaudeConfigHomeDir(), { recursive: true })
|
||||
}
|
||||
|
||||
// Create file if it doesn't exist (wx flag fails if file exists,
|
||||
// which we catch to preserve existing content)
|
||||
try {
|
||||
await writeFile(memoryPath, '', {
|
||||
encoding: 'utf8',
|
||||
flag: 'wx'
|
||||
});
|
||||
await writeFile(memoryPath, '', { encoding: 'utf8', flag: 'wx' })
|
||||
} catch (e: unknown) {
|
||||
if (getErrnoCode(e) !== 'EEXIST') {
|
||||
throw e;
|
||||
throw e
|
||||
}
|
||||
}
|
||||
await editFileInEditor(memoryPath);
|
||||
|
||||
await editFileInEditor(memoryPath)
|
||||
|
||||
// Determine which environment variable controls the editor
|
||||
let editorSource = 'default';
|
||||
let editorValue = '';
|
||||
let editorSource = 'default'
|
||||
let editorValue = ''
|
||||
if (process.env.VISUAL) {
|
||||
editorSource = '$VISUAL';
|
||||
editorValue = process.env.VISUAL;
|
||||
editorSource = '$VISUAL'
|
||||
editorValue = process.env.VISUAL
|
||||
} else if (process.env.EDITOR) {
|
||||
editorSource = '$EDITOR';
|
||||
editorValue = process.env.EDITOR;
|
||||
editorSource = '$EDITOR'
|
||||
editorValue = process.env.EDITOR
|
||||
}
|
||||
const editorInfo = editorSource !== 'default' ? `Using ${editorSource}="${editorValue}".` : '';
|
||||
const editorHint = editorInfo ? `> ${editorInfo} To change editor, set $EDITOR or $VISUAL environment variable.` : `> To use a different editor, set the $EDITOR or $VISUAL environment variable.`;
|
||||
onDone(`Opened memory file at ${getRelativeMemoryPath(memoryPath)}\n\n${editorHint}`, {
|
||||
display: 'system'
|
||||
});
|
||||
|
||||
const editorInfo =
|
||||
editorSource !== 'default'
|
||||
? `Using ${editorSource}="${editorValue}".`
|
||||
: ''
|
||||
|
||||
const editorHint = editorInfo
|
||||
? `> ${editorInfo} To change editor, set $EDITOR or $VISUAL environment variable.`
|
||||
: `> To use a different editor, set the $EDITOR or $VISUAL environment variable.`
|
||||
|
||||
onDone(
|
||||
`Opened memory file at ${getRelativeMemoryPath(memoryPath)}\n\n${editorHint}`,
|
||||
{ display: 'system' },
|
||||
)
|
||||
} catch (error) {
|
||||
logError(error);
|
||||
onDone(`Error opening memory file: ${error}`);
|
||||
logError(error)
|
||||
onDone(`Error opening memory file: ${error}`)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
onDone('Cancelled memory editing', {
|
||||
display: 'system'
|
||||
});
|
||||
};
|
||||
return <Dialog title="Memory" onCancel={handleCancel} color="remember">
|
||||
onDone('Cancelled memory editing', { display: 'system' })
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog title="Memory" onCancel={handleCancel} color="remember">
|
||||
<Box flexDirection="column">
|
||||
<React.Suspense fallback={null}>
|
||||
<MemoryFileSelector onSelect={handleSelectMemoryFile} onCancel={handleCancel} />
|
||||
<MemoryFileSelector
|
||||
onSelect={handleSelectMemoryFile}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
</React.Suspense>
|
||||
|
||||
<Box marginTop={1}>
|
||||
@@ -78,12 +89,14 @@ function MemoryCommand({
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
</Dialog>;
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
||||
export const call: LocalJSXCommandCall = async onDone => {
|
||||
// Clear + prime before rendering — Suspense handles the unprimed case,
|
||||
// but awaiting here avoids a fallback flash on initial open.
|
||||
clearMemoryFileCaches();
|
||||
await getMemoryFiles();
|
||||
return <MemoryCommand onDone={onDone} />;
|
||||
};
|
||||
clearMemoryFileCaches()
|
||||
await getMemoryFiles()
|
||||
return <MemoryCommand onDone={onDone} />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user