feat: 为 project 级 skill 添加黄色 [local] 标签区分显示

在斜杠命令列表和 SkillsMenu 中,对 projectSettings/localSettings
来源的 skill 显示黄色 [local] 标签,方便区分项目级和用户级技能。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-06 14:11:01 +08:00
parent ca630488c6
commit dd2bd12626
3 changed files with 37 additions and 2 deletions

View File

@@ -163,7 +163,11 @@ const SuggestionItemRow = memo(function SuggestionItemRow({
<Text color={textColor} dimColor={shouldDim}> <Text color={textColor} dimColor={shouldDim}>
{paddedDisplayText} {paddedDisplayText}
</Text> </Text>
{tagText ? <Text dimColor>{tagText}</Text> : null} {tagText ? (
<Text color={item.tag === 'local' ? 'yellow' : undefined} dimColor={item.tag !== 'local'}>
{tagText}
</Text>
) : null}
<Text <Text
color={isSelected ? 'suggestion' : undefined} color={isSelected ? 'suggestion' : undefined}
dimColor={!isSelected} dimColor={!isSelected}

View File

@@ -139,6 +139,22 @@ export function SkillsMenu({ onExit, commands }: Props): React.ReactNode {
) )
} }
const getScopeTag = (
source: SkillSource,
): { label: string; color: string } | undefined => {
switch (source) {
case 'projectSettings':
case 'localSettings':
return { label: 'local', color: 'yellow' }
case 'userSettings':
return { label: 'global', color: 'cyan' }
case 'policySettings':
return { label: 'managed', color: 'magenta' }
default:
return undefined
}
}
const renderSkill = (skill: SkillCommand) => { const renderSkill = (skill: SkillCommand) => {
const estimatedTokens = estimateSkillFrontmatterTokens(skill) const estimatedTokens = estimateSkillFrontmatterTokens(skill)
const tokenDisplay = `~${formatTokens(estimatedTokens)}` const tokenDisplay = `~${formatTokens(estimatedTokens)}`
@@ -146,10 +162,14 @@ export function SkillsMenu({ onExit, commands }: Props): React.ReactNode {
skill.source === 'plugin' skill.source === 'plugin'
? skill.pluginInfo?.pluginManifest.name ? skill.pluginInfo?.pluginManifest.name
: undefined : undefined
const scopeTag = getScopeTag(skill.source as SkillSource)
return ( return (
<Box key={`${skill.name}-${skill.source}`}> <Box key={`${skill.name}-${skill.source}`}>
<Text>{getCommandName(skill)}</Text> <Text>{getCommandName(skill)}</Text>
{scopeTag && (
<Text color={scopeTag.color}> [{scopeTag.label}]</Text>
)}
<Text dimColor> <Text dimColor>
{pluginName ? ` · ${pluginName}` : ''} · {tokenDisplay} description {pluginName ? ` · ${pluginName}` : ''} · {tokenDisplay} description
tokens tokens
@@ -187,7 +207,9 @@ export function SkillsMenu({ onExit, commands }: Props): React.ReactNode {
> >
<Box flexDirection="column" gap={1}> <Box flexDirection="column" gap={1}>
{renderSkillGroup('projectSettings')} {renderSkillGroup('projectSettings')}
{renderSkillGroup('localSettings')}
{renderSkillGroup('userSettings')} {renderSkillGroup('userSettings')}
{renderSkillGroup('flagSettings')}
{renderSkillGroup('policySettings')} {renderSkillGroup('policySettings')}
{renderSkillGroup('plugin')} {renderSkillGroup('plugin')}
{renderSkillGroup('mcp')} {renderSkillGroup('mcp')}

View File

@@ -271,6 +271,15 @@ function createCommandSuggestionItem(
const aliasText = matchedAlias ? ` (${matchedAlias})` : '' const aliasText = matchedAlias ? ` (${matchedAlias})` : ''
const isWorkflow = cmd.type === 'prompt' && cmd.kind === 'workflow' const isWorkflow = cmd.type === 'prompt' && cmd.kind === 'workflow'
// Show "local" tag for project-scoped prompt commands
const scopeTag =
cmd.type === 'prompt' &&
!isWorkflow &&
(cmd.source === 'projectSettings' || cmd.source === 'localSettings')
? 'local'
: undefined
const fullDescription = const fullDescription =
(isWorkflow ? cmd.description : formatDescriptionWithSource(cmd)) + (isWorkflow ? cmd.description : formatDescriptionWithSource(cmd)) +
(cmd.type === 'prompt' && cmd.argNames?.length (cmd.type === 'prompt' && cmd.argNames?.length
@@ -280,7 +289,7 @@ function createCommandSuggestionItem(
return { return {
id: getCommandId(cmd), id: getCommandId(cmd),
displayText: `/${commandName}${aliasText}`, displayText: `/${commandName}${aliasText}`,
tag: isWorkflow ? 'workflow' : undefined, tag: isWorkflow ? 'workflow' : scopeTag,
description: fullDescription, description: fullDescription,
metadata: cmd, metadata: cmd,
} }