* 完善所有用到的type对象,并添加中文注释

* 补充遗失的type
This commit is contained in:
xiaoFjun-eng
2026-05-19 09:05:04 +08:00
committed by GitHub
parent c499bfb4ed
commit ea399f1862
68 changed files with 986 additions and 208 deletions

View File

@@ -1,4 +1,22 @@
// Auto-generated stub — replace with real implementation
export type LspServerConfig = any
export type ScopedLspServerConfig = any
export type LspServerState = any
import type { z } from 'zod/v4'
import { LspServerConfigSchema } from '../../utils/plugins/schemas.js'
/** 插件 manifest / `.lsp.json` 中的单条 LSP 服务器配置(由 Zod schema 推导)。 */
export type LspServerConfig = z.infer<ReturnType<typeof LspServerConfigSchema>>
/**
* 插件动态注册时附带的作用域与来源插件名。
* 与全局 user/project 配置区分,避免多插件同名冲突。
*/
export type ScopedLspServerConfig = LspServerConfig & {
scope: 'dynamic' // 运行时由插件挂载的作用域标记
source: string // 来源插件名(用于 `plugin:name:server` 前缀等)
}
/** LSP 子进程生命周期状态(由 `LSPServerInstance` 维护)。 */
export type LspServerState =
| 'stopped' // 未启动或已完全退出
| 'starting' // 正在拉起进程/握手
| 'running' // 已初始化并可服务请求
| 'stopping' // 正在优雅关闭
| 'error' // 启动失败或运行期崩溃后的错误态

View File

@@ -440,8 +440,8 @@ const externalTips: Tip[] = [
},
{
id: 'desktop-shortcut',
content: async (ctx: TipContext) => {
const blue = color('suggestion', ctx.theme)
content: async (ctx?) => {
const blue = color('suggestion', ctx?.theme ?? 'dark')
return `Continue your session in Claude Code Desktop with ${blue('/desktop')}`
},
cooldownSessions: 15,
@@ -486,24 +486,24 @@ const externalTips: Tip[] = [
},
{
id: 'frontend-design-plugin',
content: async (ctx: TipContext) => {
const blue = color('suggestion', ctx.theme)
content: async (ctx?) => {
const blue = color('suggestion', ctx?.theme ?? 'dark')
return `Working with HTML/CSS? Install the frontend-design plugin:\n${blue(`/plugin install frontend-design@${OFFICIAL_MARKETPLACE_NAME}`)}`
},
cooldownSessions: 3,
isRelevant: async (context: TipContext) =>
isRelevant: async (context?) =>
isMarketplacePluginRelevant('frontend-design', context, {
filePath: /\.(html|css|htm)$/i,
}),
},
{
id: 'vercel-plugin',
content: async (ctx: TipContext) => {
const blue = color('suggestion', ctx.theme)
content: async (ctx?) => {
const blue = color('suggestion', ctx?.theme ?? 'dark')
return `Working with Vercel? Install the vercel plugin:\n${blue(`/plugin install vercel@${OFFICIAL_MARKETPLACE_NAME}`)}`
},
cooldownSessions: 3,
isRelevant: async (context: TipContext) =>
isRelevant: async (context?) =>
isMarketplacePluginRelevant('vercel', context, {
filePath: /(?:^|[/\\])vercel\.json$/i,
cli: ['vercel'],
@@ -511,8 +511,8 @@ const externalTips: Tip[] = [
},
{
id: 'effort-high-nudge',
content: async (ctx: TipContext) => {
const blue = color('suggestion', ctx.theme)
content: async (ctx?) => {
const blue = color('suggestion', ctx?.theme ?? 'dark')
const cmd = blue('/effort high')
const variant = getFeatureValue_CACHED_MAY_BE_STALE<
'off' | 'copy_a' | 'copy_b'
@@ -541,8 +541,8 @@ const externalTips: Tip[] = [
},
{
id: 'subagent-fanout-nudge',
content: async (ctx: TipContext) => {
const blue = color('suggestion', ctx.theme)
content: async (ctx?) => {
const blue = color('suggestion', ctx?.theme ?? 'dark')
const variant = getFeatureValue_CACHED_MAY_BE_STALE<
'off' | 'copy_a' | 'copy_b'
>('tengu_tern_alloy', 'off')
@@ -563,8 +563,8 @@ const externalTips: Tip[] = [
},
{
id: 'loop-command-nudge',
content: async (ctx: TipContext) => {
const blue = color('suggestion', ctx.theme)
content: async (ctx?) => {
const blue = color('suggestion', ctx?.theme ?? 'dark')
const variant = getFeatureValue_CACHED_MAY_BE_STALE<
'off' | 'copy_a' | 'copy_b'
>('tengu_timber_lark', 'off')
@@ -586,8 +586,8 @@ const externalTips: Tip[] = [
},
{
id: 'guest-passes',
content: async (ctx: TipContext) => {
const claude = color('claude', ctx.theme)
content: async (ctx?) => {
const claude = color('claude', ctx?.theme ?? 'dark')
const reward = getCachedReferrerReward()
return reward
? `Share Claude Code and earn ${claude(formatCreditAmount(reward))} of extra usage · ${claude('/passes')}`
@@ -605,8 +605,8 @@ const externalTips: Tip[] = [
},
{
id: 'overage-credit',
content: async (ctx: TipContext) => {
const claude = color('claude', ctx.theme)
content: async (ctx?) => {
const claude = color('claude', ctx?.theme ?? 'dark')
const info = getCachedOverageCreditGrant()
const amount = info ? formatGrantAmount(info) : null
if (!amount) return ''
@@ -674,7 +674,9 @@ export async function getRelevantTips(context?: TipContext): Promise<Tip[]> {
// Otherwise, filter built-in tips as before and combine with custom
const tips = [...externalTips, ...internalOnlyTips]
const isRelevant = await Promise.all(tips.map(_ => _.isRelevant(context)))
const isRelevant = await Promise.all(
tips.map(_ => _.isRelevant?.(context) ?? Promise.resolve(true)),
)
const filtered = tips
.filter((_, index) => isRelevant[index])
.filter(_ => getSessionsSinceLastShown(_.id) >= _.cooldownSessions)

View File

@@ -1,3 +1,17 @@
// Auto-generated stub — replace with real implementation
export type Tip = any
export type TipContext = any
import type { ThemeName } from '@anthropic/ink'
import type { FileStateCache } from '../../utils/fileStateCache.js'
/** Spinner 提示评估时可用的会话上下文(字段可按调用场景部分提供)。 */
export type TipContext = {
theme?: ThemeName // 当前终端主题名,用于 `color()` 等着色
readFileState?: FileStateCache // 近期已读文件 LRU用于文件类相关性判断
bashTools?: Set<string> // 本会话出现过的 bash 子命令集合
}
/** 内置或用户自定义的 Spinner 提示条目。 */
export type Tip = {
id: string // 稳定 id用于冷却与历史去重
content: (ctx?: TipContext) => Promise<string> // 异步生成 Spinner 旁提示文案
cooldownSessions: number // 至少间隔多少会话后才可再次展示
isRelevant?: (ctx?: TipContext) => Promise<boolean> // 可选:当前是否应展示该条
}