更新大量 tsx 原始文件; 已经迁移 login panel; 部分 (#121)

* style(B1-1): 格式化 ink/buddy/cli/context/screens/tasks/services/keybindings/state (43 files)

纯格式化:移除分号、React Compiler import、import 多行展开。
修复了 Box.tsx 和 ScrollBox.tsx 中无效的 global.d.ts import。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* style(B1-2): 格式化 commands (79 files)

纯格式化:移除分号、React Compiler import、import 多行展开。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files)

纯格式化:移除分号、React Compiler import、import 多行展开。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* style(B1-4): 格式化 components/PromptInput,FeedbackSurvey,tasks,agents,skills,design-system,wizard (73 files)

纯格式化:移除分号、React Compiler import、import 多行展开。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* style(B1-5): 格式化 components其余 + hooks + tools (232 files)

纯格式化:移除分号、React Compiler import、import 多行展开。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* style(B1-6): 格式化 main/entrypoints/utils/moreright (21 files)

纯格式化:移除分号、React Compiler import、import 多行展开。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: 更新 README,新增 Run.ps1/TODO.md,删除 V6.md

- README.md: 大幅重写,更详细版本历史和配置示例
- Run.ps1: 新增 Windows 启动脚本
- TODO.md: 新增包完成清单
- V6.md: 删除(架构重构规划已不适用)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: 修复以前的问题

* fix: 修复 login 面板的问题

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-04 23:24:27 +08:00
committed by GitHub
parent 02694918b5
commit 5b1a52b8e0
559 changed files with 103807 additions and 101817 deletions

View File

@@ -4,27 +4,31 @@
* Must be rendered inside KeybindingSetup to have access to the keybinding context.
* This component renders nothing - it just registers the keybinding handlers.
*/
import { feature } from 'bun:bundle';
import { useCallback } from 'react';
import instances from '../ink/instances.js';
import { useKeybinding } from '../keybindings/useKeybinding.js';
import type { Screen } from '../screens/REPL.js';
import { getFeatureValue_CACHED_MAY_BE_STALE } from '../services/analytics/growthbook.js';
import { type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS, logEvent } from '../services/analytics/index.js';
import { useAppState, useSetAppState } from '../state/AppState.js';
import { count } from '../utils/array.js';
import { getTerminalPanel } from '../utils/terminalPanel.js';
import { feature } from 'bun:bundle'
import { useCallback } from 'react'
import instances from '../ink/instances.js'
import { useKeybinding } from '../keybindings/useKeybinding.js'
import type { Screen } from '../screens/REPL.js'
import { getFeatureValue_CACHED_MAY_BE_STALE } from '../services/analytics/growthbook.js'
import {
type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
logEvent,
} from '../services/analytics/index.js'
import { useAppState, useSetAppState } from '../state/AppState.js'
import { count } from '../utils/array.js'
import { getTerminalPanel } from '../utils/terminalPanel.js'
type Props = {
screen: Screen;
setScreen: React.Dispatch<React.SetStateAction<Screen>>;
showAllInTranscript: boolean;
setShowAllInTranscript: React.Dispatch<React.SetStateAction<boolean>>;
messageCount: number;
onEnterTranscript?: () => void;
onExitTranscript?: () => void;
virtualScrollActive?: boolean;
searchBarOpen?: boolean;
};
screen: Screen
setScreen: React.Dispatch<React.SetStateAction<Screen>>
showAllInTranscript: boolean
setShowAllInTranscript: React.Dispatch<React.SetStateAction<boolean>>
messageCount: number
onEnterTranscript?: () => void
onExitTranscript?: () => void
virtualScrollActive?: boolean
searchBarOpen?: boolean
}
/**
* Registers global keybinding handlers for:
@@ -42,56 +46,55 @@ export function GlobalKeybindingHandlers({
onEnterTranscript,
onExitTranscript,
virtualScrollActive,
searchBarOpen = false
searchBarOpen = false,
}: Props): null {
const expandedView = useAppState(s => s.expandedView);
const setAppState = useSetAppState();
const expandedView = useAppState(s => s.expandedView)
const setAppState = useSetAppState()
// Toggle todo list (ctrl+t) - cycles through views
const handleToggleTodos = useCallback(() => {
logEvent('tengu_toggle_todos', {
is_expanded: expandedView === 'tasks'
});
is_expanded: expandedView === 'tasks',
})
setAppState(prev => {
const {
getAllInProcessTeammateTasks
} =
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('../tasks/InProcessTeammateTask/InProcessTeammateTask.js') as typeof import('../tasks/InProcessTeammateTask/InProcessTeammateTask.js');
const hasTeammates = count(getAllInProcessTeammateTasks(prev.tasks), t => t.status === 'running') > 0;
const { getAllInProcessTeammateTasks } =
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('../tasks/InProcessTeammateTask/InProcessTeammateTask.js') as typeof import('../tasks/InProcessTeammateTask/InProcessTeammateTask.js')
const hasTeammates =
count(
getAllInProcessTeammateTasks(prev.tasks),
t => t.status === 'running',
) > 0
if (hasTeammates) {
// Both exist: none → tasks → teammates → none
switch (prev.expandedView) {
case 'none':
return {
...prev,
expandedView: 'tasks' as const
};
return { ...prev, expandedView: 'tasks' as const }
case 'tasks':
return {
...prev,
expandedView: 'teammates' as const
};
return { ...prev, expandedView: 'teammates' as const }
case 'teammates':
return {
...prev,
expandedView: 'none' as const
};
return { ...prev, expandedView: 'none' as const }
}
}
// Only tasks: none ↔ tasks
return {
...prev,
expandedView: prev.expandedView === 'tasks' ? 'none' as const : 'tasks' as const
};
});
}, [expandedView, setAppState]);
expandedView:
prev.expandedView === 'tasks'
? ('none' as const)
: ('tasks' as const),
}
})
}, [expandedView, setAppState])
// Toggle transcript mode (ctrl+o). Two-way prompt ↔ transcript.
// Brief view has its own dedicated toggle on ctrl+shift+b.
const isBriefOnly = feature('KAIROS') || feature('KAIROS_BRIEF') ?
// biome-ignore lint/correctness/useHookAtTopLevel: feature() is a compile-time constant
useAppState(s_0 => s_0.isBriefOnly) : false;
const isBriefOnly =
feature('KAIROS') || feature('KAIROS_BRIEF')
? // biome-ignore lint/correctness/useHookAtTopLevel: feature() is a compile-time constant
useAppState(s => s.isBriefOnly)
: false
const handleToggleTranscript = useCallback(() => {
if (feature('KAIROS') || feature('KAIROS_BRIEF')) {
// Escape hatch: GB kill-switch while defaultView=chat was persisted
@@ -100,58 +103,71 @@ export function GlobalKeybindingHandlers({
// Only needed in the prompt screen — transcript mode already ignores
// isBriefOnly (Messages.tsx filter is gated on !isTranscriptMode).
/* eslint-disable @typescript-eslint/no-require-imports */
const {
isBriefEnabled
} = require('../tools/BriefTool/BriefTool.js') as typeof import('../tools/BriefTool/BriefTool.js');
const { isBriefEnabled } =
require('../tools/BriefTool/BriefTool.js') as typeof import('../tools/BriefTool/BriefTool.js')
/* eslint-enable @typescript-eslint/no-require-imports */
if (!isBriefEnabled() && isBriefOnly && screen !== 'transcript') {
setAppState(prev_0 => {
if (!prev_0.isBriefOnly) return prev_0;
return {
...prev_0,
isBriefOnly: false
};
});
return;
setAppState(prev => {
if (!prev.isBriefOnly) return prev
return { ...prev, isBriefOnly: false }
})
return
}
}
const isEnteringTranscript = screen !== 'transcript';
const isEnteringTranscript = screen !== 'transcript'
logEvent('tengu_toggle_transcript', {
is_entering: isEnteringTranscript,
show_all: showAllInTranscript,
message_count: messageCount
});
setScreen(s_1 => s_1 === 'transcript' ? 'prompt' : 'transcript');
setShowAllInTranscript(false);
message_count: messageCount,
})
setScreen(s => (s === 'transcript' ? 'prompt' : 'transcript'))
setShowAllInTranscript(false)
if (isEnteringTranscript && onEnterTranscript) {
onEnterTranscript();
onEnterTranscript()
}
if (!isEnteringTranscript && onExitTranscript) {
onExitTranscript();
onExitTranscript()
}
}, [screen, setScreen, isBriefOnly, showAllInTranscript, setShowAllInTranscript, messageCount, setAppState, onEnterTranscript, onExitTranscript]);
}, [
screen,
setScreen,
isBriefOnly,
showAllInTranscript,
setShowAllInTranscript,
messageCount,
setAppState,
onEnterTranscript,
onExitTranscript,
])
// Toggle showing all messages in transcript mode (ctrl+e)
const handleToggleShowAll = useCallback(() => {
logEvent('tengu_transcript_toggle_show_all', {
is_expanding: !showAllInTranscript,
message_count: messageCount
});
setShowAllInTranscript(prev_1 => !prev_1);
}, [showAllInTranscript, setShowAllInTranscript, messageCount]);
message_count: messageCount,
})
setShowAllInTranscript(prev => !prev)
}, [showAllInTranscript, setShowAllInTranscript, messageCount])
// Exit transcript mode (ctrl+c or escape)
const handleExitTranscript = useCallback(() => {
logEvent('tengu_transcript_exit', {
show_all: showAllInTranscript,
message_count: messageCount
});
setScreen('prompt');
setShowAllInTranscript(false);
message_count: messageCount,
})
setScreen('prompt')
setShowAllInTranscript(false)
if (onExitTranscript) {
onExitTranscript();
onExitTranscript()
}
}, [setScreen, showAllInTranscript, setShowAllInTranscript, messageCount, onExitTranscript]);
}, [
setScreen,
showAllInTranscript,
setShowAllInTranscript,
messageCount,
onExitTranscript,
])
// Toggle brief-only view (ctrl+shift+b). Pure display filter toggle —
// does not touch opt-in state. Asymmetric gate (mirrors /brief): OFF
@@ -160,81 +176,80 @@ export function GlobalKeybindingHandlers({
const handleToggleBrief = useCallback(() => {
if (feature('KAIROS') || feature('KAIROS_BRIEF')) {
/* eslint-disable @typescript-eslint/no-require-imports */
const {
isBriefEnabled: isBriefEnabled_0
} = require('../tools/BriefTool/BriefTool.js') as typeof import('../tools/BriefTool/BriefTool.js');
const { isBriefEnabled } =
require('../tools/BriefTool/BriefTool.js') as typeof import('../tools/BriefTool/BriefTool.js')
/* eslint-enable @typescript-eslint/no-require-imports */
if (!isBriefEnabled_0() && !isBriefOnly) return;
const next = !isBriefOnly;
if (!isBriefEnabled() && !isBriefOnly) return
const next = !isBriefOnly
logEvent('tengu_brief_mode_toggled', {
enabled: next,
gated: false,
source: 'keybinding' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
});
setAppState(prev_2 => {
if (prev_2.isBriefOnly === next) return prev_2;
return {
...prev_2,
isBriefOnly: next
};
});
source:
'keybinding' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
})
setAppState(prev => {
if (prev.isBriefOnly === next) return prev
return { ...prev, isBriefOnly: next }
})
}
}, [isBriefOnly, setAppState]);
}, [isBriefOnly, setAppState])
// Register keybinding handlers
useKeybinding('app:toggleTodos', handleToggleTodos, {
context: 'Global'
});
context: 'Global',
})
useKeybinding('app:toggleTranscript', handleToggleTranscript, {
context: 'Global'
});
context: 'Global',
})
if (feature('KAIROS') || feature('KAIROS_BRIEF')) {
// biome-ignore lint/correctness/useHookAtTopLevel: feature() is a compile-time constant
useKeybinding('app:toggleBrief', handleToggleBrief, {
context: 'Global'
});
context: 'Global',
})
}
// Register teammate keybinding
useKeybinding('app:toggleTeammatePreview', () => {
setAppState(prev_3 => ({
...prev_3,
showTeammateMessagePreview: !prev_3.showTeammateMessagePreview
}));
}, {
context: 'Global'
});
useKeybinding(
'app:toggleTeammatePreview',
() => {
setAppState(prev => ({
...prev,
showTeammateMessagePreview: !prev.showTeammateMessagePreview,
}))
},
{
context: 'Global',
},
)
// Toggle built-in terminal panel (meta+j).
// toggle() blocks in spawnSync until the user detaches from tmux.
const handleToggleTerminal = useCallback(() => {
if (feature('TERMINAL_PANEL')) {
if (!getFeatureValue_CACHED_MAY_BE_STALE('tengu_terminal_panel', false)) {
return;
return
}
getTerminalPanel().toggle();
getTerminalPanel().toggle()
}
}, []);
}, [])
useKeybinding('app:toggleTerminal', handleToggleTerminal, {
context: 'Global'
});
context: 'Global',
})
// Clear screen and force full redraw (ctrl+l). Recovery path when the
// terminal was cleared externally (macOS Cmd+K) and Ink's diff engine
// thinks unchanged cells don't need repainting.
const handleRedraw = useCallback(() => {
instances.get(process.stdout)?.forceRedraw();
}, []);
useKeybinding('app:redraw', handleRedraw, {
context: 'Global'
});
instances.get(process.stdout)?.forceRedraw()
}, [])
useKeybinding('app:redraw', handleRedraw, { context: 'Global' })
// Transcript-specific bindings (only active when in transcript mode)
const isInTranscript = screen === 'transcript';
const isInTranscript = screen === 'transcript'
useKeybinding('transcript:toggleShowAll', handleToggleShowAll, {
context: 'Transcript',
isActive: isInTranscript && !virtualScrollActive
});
isActive: isInTranscript && !virtualScrollActive,
})
useKeybinding('transcript:exit', handleExitTranscript, {
context: 'Transcript',
// Bar-open is a mode (owns keystrokes). Navigating (highlights
@@ -242,7 +257,8 @@ export function GlobalKeybindingHandlers({
// directly, same as less q. useSearchInput doesn't stopPropagation,
// so without this gate its onCancel AND this handler would both
// fire on one Esc (child registers first, fires first, bubbles).
isActive: isInTranscript && !searchBarOpen
});
return null;
isActive: isInTranscript && !searchBarOpen,
})
return null
}