mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-23 08:45:50 +00:00
feat: 添加本地 Memory/Vault 管理命令
- /local-memory: 本地记忆管理(store/entry CRUD、搜索、归档) - /local-vault: 本地密钥保险库管理(加解密、keychain 集成) - permissionValidation: vault 权限校验增强 Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
This commit is contained in:
107
src/commands/local-vault/LocalVaultView.tsx
Normal file
107
src/commands/local-vault/LocalVaultView.tsx
Normal file
@@ -0,0 +1,107 @@
|
||||
import React from 'react';
|
||||
import { Box, Text } from '@anthropic/ink';
|
||||
import type { Theme } from '@anthropic/ink';
|
||||
|
||||
export type LocalVaultViewProps =
|
||||
| { mode: 'list'; keys: string[] }
|
||||
| { mode: 'set-ok'; key: string }
|
||||
| { mode: 'get-masked'; key: string; masked: string }
|
||||
| { mode: 'get-revealed'; key: string; value: string }
|
||||
| { mode: 'not-found'; key: string }
|
||||
| { mode: 'deleted'; key: string }
|
||||
| { mode: 'error'; message: string };
|
||||
|
||||
export function LocalVaultView(props: LocalVaultViewProps): React.ReactNode {
|
||||
if (props.mode === 'list') {
|
||||
if (props.keys.length === 0) {
|
||||
return (
|
||||
<Box>
|
||||
<Text dimColor>No secrets stored. Use /local-vault set <key> <value> to add one.</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Box marginBottom={1}>
|
||||
<Text bold>Local Vault Keys ({props.keys.length})</Text>
|
||||
</Box>
|
||||
{props.keys.map(k => (
|
||||
<Box key={k}>
|
||||
<Text> </Text>
|
||||
<Text color={'success' as keyof Theme}>●</Text>
|
||||
<Text> {k}</Text>
|
||||
</Box>
|
||||
))}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (props.mode === 'set-ok') {
|
||||
return (
|
||||
<Box>
|
||||
<Text color={'success' as keyof Theme}>✓</Text>
|
||||
<Text> Secret stored: </Text>
|
||||
<Text bold>{props.key}</Text>
|
||||
<Text dimColor> = [REDACTED]</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (props.mode === 'get-masked') {
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Box>
|
||||
<Text bold>{props.key}</Text>
|
||||
<Text dimColor>: </Text>
|
||||
<Text>{props.masked}</Text>
|
||||
</Box>
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor>Use /local-vault get {props.key} --reveal to see the full value.</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (props.mode === 'get-revealed') {
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Box>
|
||||
<Text bold>{props.key}</Text>
|
||||
<Text dimColor>: </Text>
|
||||
<Text color={'warning' as keyof Theme}>{props.value}</Text>
|
||||
</Box>
|
||||
<Box marginTop={1}>
|
||||
<Text dimColor color={'warning' as keyof Theme}>
|
||||
⚠ Secret revealed in terminal — clear scrollback if this session is shared.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (props.mode === 'not-found') {
|
||||
return (
|
||||
<Box>
|
||||
<Text color={'error' as keyof Theme}>Key not found: </Text>
|
||||
<Text bold>{props.key}</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
if (props.mode === 'deleted') {
|
||||
return (
|
||||
<Box>
|
||||
<Text color={'success' as keyof Theme}>✓</Text>
|
||||
<Text> Deleted: </Text>
|
||||
<Text bold>{props.key}</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
// mode === 'error'
|
||||
return (
|
||||
<Box>
|
||||
<Text color={'error' as keyof Theme}>Error: {props.message}</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user