mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 22:05:50 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -69,7 +69,7 @@ function convertPluginHooksToMatchers(
|
||||
continue
|
||||
}
|
||||
|
||||
for (const matcher of (matchers ?? [])) {
|
||||
for (const matcher of matchers ?? []) {
|
||||
if (matcher.hooks.length > 0) {
|
||||
pluginMatchers[hookEvent].push({
|
||||
matcher: matcher.matcher,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import type {
|
||||
McpbManifestAny as McpbManifest,
|
||||
} from '@anthropic-ai/mcpb'
|
||||
import type { McpbManifestAny as McpbManifest } from '@anthropic-ai/mcpb'
|
||||
type McpbUserConfigurationOption = any
|
||||
import axios from 'axios'
|
||||
import { createHash } from 'crypto'
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { performBackgroundPluginInstallations } from '../../services/plugins/PluginInstallationManager.js'
|
||||
import type { AppState } from '../../state/AppState.js'
|
||||
import { checkHasTrustDialogAccepted } from '../config.js'
|
||||
import { logForDebugging } from '../debug.js'
|
||||
import {
|
||||
clearMarketplacesCache,
|
||||
registerSeedMarketplaces,
|
||||
} from './marketplaceManager.js'
|
||||
import { clearPluginCache } from './pluginLoader.js'
|
||||
import { performBackgroundPluginInstallations } from '../../services/plugins/PluginInstallationManager.js';
|
||||
import type { AppState } from '../../state/AppState.js';
|
||||
import { checkHasTrustDialogAccepted } from '../config.js';
|
||||
import { logForDebugging } from '../debug.js';
|
||||
import { clearMarketplacesCache, registerSeedMarketplaces } from './marketplaceManager.js';
|
||||
import { clearPluginCache } from './pluginLoader.js';
|
||||
|
||||
type SetAppState = (f: (prevState: AppState) => AppState) => void
|
||||
type SetAppState = (f: (prevState: AppState) => AppState) => void;
|
||||
|
||||
/**
|
||||
* Perform plugin startup checks and initiate background installations
|
||||
@@ -25,21 +22,17 @@ type SetAppState = (f: (prevState: AppState) => AppState) => void
|
||||
*
|
||||
* @param setAppState Function to update app state with installation progress
|
||||
*/
|
||||
export async function performStartupChecks(
|
||||
setAppState: SetAppState,
|
||||
): Promise<void> {
|
||||
logForDebugging('performStartupChecks called')
|
||||
export async function performStartupChecks(setAppState: SetAppState): Promise<void> {
|
||||
logForDebugging('performStartupChecks called');
|
||||
|
||||
// Check if the current directory has been trusted
|
||||
if (!checkHasTrustDialogAccepted()) {
|
||||
logForDebugging(
|
||||
'Trust not accepted for current directory - skipping plugin installations',
|
||||
)
|
||||
return
|
||||
logForDebugging('Trust not accepted for current directory - skipping plugin installations');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
logForDebugging('Starting background plugin installations')
|
||||
logForDebugging('Starting background plugin installations');
|
||||
|
||||
// Register seed marketplaces (CLAUDE_CODE_PLUGIN_SEED_DIR) before diffing.
|
||||
// Idempotent; no-op if seed not configured. Without this, background install
|
||||
@@ -48,30 +41,28 @@ export async function performStartupChecks(
|
||||
// If registration changed state, clear caches so earlier plugin-load passes
|
||||
// (e.g. getAllMcpConfigs during REPL init) don't keep stale "marketplace
|
||||
// not found" results.
|
||||
const seedChanged = await registerSeedMarketplaces()
|
||||
const seedChanged = await registerSeedMarketplaces();
|
||||
if (seedChanged) {
|
||||
clearMarketplacesCache()
|
||||
clearPluginCache('performStartupChecks: seed marketplaces changed')
|
||||
clearMarketplacesCache();
|
||||
clearPluginCache('performStartupChecks: seed marketplaces changed');
|
||||
// Set needsRefresh so useManagePlugins notifies the user to run
|
||||
// /reload-plugins. Without this signal, the initial plugin-load
|
||||
// (which raced and cached "marketplace not found") would persist
|
||||
// until the user manually reloads.
|
||||
setAppState(prev => {
|
||||
if (prev.plugins.needsRefresh) return prev
|
||||
if (prev.plugins.needsRefresh) return prev;
|
||||
return {
|
||||
...prev,
|
||||
plugins: { ...prev.plugins, needsRefresh: true },
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// Start background installations without waiting
|
||||
// This will update AppState as installations progress
|
||||
await performBackgroundPluginInstallations(setAppState)
|
||||
await performBackgroundPluginInstallations(setAppState);
|
||||
} catch (error) {
|
||||
// Even if something fails here, don't block startup
|
||||
logForDebugging(
|
||||
`Error initiating background plugin installations: ${error}`,
|
||||
)
|
||||
logForDebugging(`Error initiating background plugin installations: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,7 +408,11 @@ export async function installResolvedPlugin({
|
||||
allowedCrossMarketplaces,
|
||||
)
|
||||
if (!resolution.ok) {
|
||||
return { ok: false, reason: 'resolution-failed', resolution: resolution as ResolutionResult & { ok: false } }
|
||||
return {
|
||||
ok: false,
|
||||
reason: 'resolution-failed',
|
||||
resolution: resolution as ResolutionResult & { ok: false },
|
||||
}
|
||||
}
|
||||
|
||||
// ── Policy guard for transitive dependencies ──
|
||||
|
||||
@@ -1862,12 +1862,16 @@ function mergeHooksSettings(
|
||||
|
||||
const merged = { ...base }
|
||||
|
||||
for (const [event, matchers] of Object.entries(additional) as [string, HookMatcher[]][]) {
|
||||
for (const [event, matchers] of Object.entries(additional) as [
|
||||
string,
|
||||
HookMatcher[],
|
||||
][]) {
|
||||
if (!merged[event as keyof HooksSettings]) {
|
||||
merged[event as keyof HooksSettings] = matchers
|
||||
} else {
|
||||
// Merge matchers for this event
|
||||
const existing = ((merged[event as keyof HooksSettings] as unknown) ?? []) as HookMatcher[]
|
||||
const existing = ((merged[event as keyof HooksSettings] as unknown) ??
|
||||
[]) as HookMatcher[]
|
||||
merged[event as keyof HooksSettings] = [...existing, ...matchers]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,9 +164,17 @@ export async function refreshActivePlugins(
|
||||
if (!p.hooksConfig) return sum
|
||||
return (
|
||||
sum +
|
||||
(Object.values(p.hooksConfig) as Array<Array<{ hooks: unknown[] }> | undefined>).reduce(
|
||||
(
|
||||
Object.values(p.hooksConfig) as Array<
|
||||
Array<{ hooks: unknown[] }> | undefined
|
||||
>
|
||||
).reduce(
|
||||
(s, matchers) =>
|
||||
s + (matchers?.reduce((h: number, m: { hooks: { length: number } }) => h + m.hooks.length, 0) ?? 0),
|
||||
s +
|
||||
(matchers?.reduce(
|
||||
(h: number, m: { hooks: { length: number } }) => h + m.hooks.length,
|
||||
0,
|
||||
) ?? 0),
|
||||
0,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user