mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
fix: 修复 builtin channel 的 ChannelsNotice 误报
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
|||||||
getAllowedChannels,
|
getAllowedChannels,
|
||||||
getHasDevChannels,
|
getHasDevChannels,
|
||||||
} from '../../bootstrap/state.js'
|
} from '../../bootstrap/state.js'
|
||||||
|
import { getBuiltinPlugins } from '../../plugins/builtinPlugins.js'
|
||||||
import { Box, Text } from '@anthropic/ink'
|
import { Box, Text } from '@anthropic/ink'
|
||||||
import { getMcpConfigsByScope } from '../../services/mcp/config.js'
|
import { getMcpConfigsByScope } from '../../services/mcp/config.js'
|
||||||
import { loadInstalledPluginsV2 } from '../../utils/plugins/installedPluginsManager.js'
|
import { loadInstalledPluginsV2 } from '../../utils/plugins/installedPluginsManager.js'
|
||||||
@@ -75,25 +76,39 @@ function formatEntry(c: ChannelEntry): string {
|
|||||||
|
|
||||||
type Unmatched = { entry: ChannelEntry; why: string }
|
type Unmatched = { entry: ChannelEntry; why: string }
|
||||||
|
|
||||||
function findUnmatched(
|
type FindUnmatchedDeps = {
|
||||||
|
configuredServerNames?: ReadonlySet<string>
|
||||||
|
installedPluginIds?: ReadonlySet<string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findUnmatched(
|
||||||
entries: readonly ChannelEntry[],
|
entries: readonly ChannelEntry[],
|
||||||
|
deps?: FindUnmatchedDeps,
|
||||||
): Unmatched[] {
|
): Unmatched[] {
|
||||||
// Server-kind: build one Set from all scopes up front. getMcpConfigsByScope
|
// Server-kind: build one Set from all scopes up front. getMcpConfigsByScope
|
||||||
// is not cached (project scope walks the dir tree); getMcpConfigByName would
|
// is not cached (project scope walks the dir tree); getMcpConfigByName would
|
||||||
// redo that walk per entry.
|
// redo that walk per entry.
|
||||||
const scopes = ['enterprise', 'user', 'project', 'local'] as const
|
const configured = deps?.configuredServerNames ?? (() => {
|
||||||
const configured = new Set<string>()
|
const scopes = ['enterprise', 'user', 'project', 'local'] as const
|
||||||
for (const scope of scopes) {
|
const names = new Set<string>()
|
||||||
for (const name of Object.keys(getMcpConfigsByScope(scope).servers)) {
|
for (const scope of scopes) {
|
||||||
configured.add(name)
|
for (const name of Object.keys(getMcpConfigsByScope(scope).servers)) {
|
||||||
|
names.add(name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return names
|
||||||
|
})()
|
||||||
|
|
||||||
// Plugin-kind installed check: installed_plugins.json keys are
|
// Plugin-kind installed check: installed_plugins.json keys are
|
||||||
// `name@marketplace`. loadInstalledPluginsV2 is cached.
|
// `name@marketplace`. loadInstalledPluginsV2 is cached.
|
||||||
const installedPluginIds = new Set(
|
const installedPluginIds = deps?.installedPluginIds ?? (() => {
|
||||||
Object.keys(loadInstalledPluginsV2().plugins),
|
const ids = new Set(Object.keys(loadInstalledPluginsV2().plugins))
|
||||||
)
|
const builtinPlugins = getBuiltinPlugins()
|
||||||
|
for (const plugin of [...builtinPlugins.enabled, ...builtinPlugins.disabled]) {
|
||||||
|
ids.add(plugin.source)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
})()
|
||||||
|
|
||||||
const out: Unmatched[] = []
|
const out: Unmatched[] = []
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
|
|||||||
17
src/components/LogoV2/__tests__/ChannelsNotice.test.ts
Normal file
17
src/components/LogoV2/__tests__/ChannelsNotice.test.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { describe, expect, test } from 'bun:test'
|
||||||
|
|
||||||
|
import { findUnmatched } from '../ChannelsNotice.js'
|
||||||
|
|
||||||
|
describe('findUnmatched', () => {
|
||||||
|
test('does not flag builtin weixin as plugin not installed', () => {
|
||||||
|
expect(
|
||||||
|
findUnmatched(
|
||||||
|
[{ kind: 'plugin', name: 'weixin', marketplace: 'builtin' }],
|
||||||
|
{
|
||||||
|
configuredServerNames: new Set(),
|
||||||
|
installedPluginIds: new Set(['weixin@builtin']),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
).toEqual([])
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user