更新大量 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

@@ -1,4 +1,3 @@
import { c as _c } from "react/compiler-runtime";
/**
* CoordinatorTaskPanel — Steerable list of background agents.
*
@@ -7,18 +6,28 @@ import { c as _c } from "react/compiler-runtime";
* always; a timestamp shows until passed. Enter to view/steer, x to dismiss.
*/
import figures from 'figures';
import * as React from 'react';
import { BLACK_CIRCLE, PAUSE_ICON, PLAY_ICON } from '../constants/figures.js';
import { useTerminalSize } from '../hooks/useTerminalSize.js';
import { stringWidth } from '../ink/stringWidth.js';
import { Box, Text, wrapText } from '../ink.js';
import { type AppState, useAppState, useSetAppState } from '../state/AppState.js';
import { enterTeammateView, exitTeammateView } from '../state/teammateViewHelpers.js';
import { isPanelAgentTask, type LocalAgentTaskState } from '../tasks/LocalAgentTask/LocalAgentTask.js';
import { formatDuration, formatNumber } from '../utils/format.js';
import { evictTerminalTask } from '../utils/task/framework.js';
import { isTerminalStatus } from './tasks/taskStatusUtils.js';
import figures from 'figures'
import * as React from 'react'
import { BLACK_CIRCLE, PAUSE_ICON, PLAY_ICON } from '../constants/figures.js'
import { useTerminalSize } from '../hooks/useTerminalSize.js'
import { stringWidth } from '../ink/stringWidth.js'
import { Box, Text, wrapText } from '../ink.js'
import {
type AppState,
useAppState,
useSetAppState,
} from '../state/AppState.js'
import {
enterTeammateView,
exitTeammateView,
} from '../state/teammateViewHelpers.js'
import {
isPanelAgentTask,
type LocalAgentTaskState,
} from '../tasks/LocalAgentTask/LocalAgentTask.js'
import { formatDuration, formatNumber } from '../utils/format.js'
import { evictTerminalTask } from '../utils/task/framework.js'
import { isTerminalStatus } from './tasks/taskStatusUtils.js'
/**
* Which panel-managed tasks currently have a visible row.
@@ -28,51 +37,83 @@ import { isTerminalStatus } from './tasks/taskStatusUtils.js';
* the filter time-dependent. Shared by panel render, useCoordinatorTaskCount,
* and index resolvers so the math can't drift.
*/
export function getVisibleAgentTasks(tasks: AppState['tasks']): LocalAgentTaskState[] {
return Object.values(tasks).filter((t): t is LocalAgentTaskState => isPanelAgentTask(t) && t.evictAfter !== 0).sort((a, b) => a.startTime - b.startTime);
export function getVisibleAgentTasks(
tasks: AppState['tasks'],
): LocalAgentTaskState[] {
return Object.values(tasks)
.filter(
(t): t is LocalAgentTaskState =>
isPanelAgentTask(t) && t.evictAfter !== 0,
)
.sort((a, b) => a.startTime - b.startTime)
}
export function CoordinatorTaskPanel(): React.ReactNode {
const tasks = useAppState(s => s.tasks);
const viewingAgentTaskId = useAppState(s_0 => s_0.viewingAgentTaskId);
const agentNameRegistry = useAppState(s_1 => s_1.agentNameRegistry);
const coordinatorTaskIndex = useAppState(s_2 => s_2.coordinatorTaskIndex);
const tasksSelected = useAppState(s_3 => s_3.footerSelection === 'tasks');
const selectedIndex = tasksSelected ? coordinatorTaskIndex : undefined;
const setAppState = useSetAppState();
const visibleTasks = getVisibleAgentTasks(tasks);
const hasTasks = Object.values(tasks).some(isPanelAgentTask);
const tasks = useAppState(s => s.tasks)
const viewingAgentTaskId = useAppState(s => s.viewingAgentTaskId)
const agentNameRegistry = useAppState(s => s.agentNameRegistry)
const coordinatorTaskIndex = useAppState(s => s.coordinatorTaskIndex)
const tasksSelected = useAppState(s => s.footerSelection === 'tasks')
const selectedIndex = tasksSelected ? coordinatorTaskIndex : undefined
const setAppState = useSetAppState()
const visibleTasks = getVisibleAgentTasks(tasks)
const hasTasks = Object.values(tasks).some(isPanelAgentTask)
// 1s tick: re-render for elapsed time + evict tasks past their deadline.
// The eviction deletes from prev.tasks, which makes useCoordinatorTaskCount
// (and other consumers) see the updated count without their own tick.
const tasksRef = React.useRef(tasks);
tasksRef.current = tasks;
const [, setTick] = React.useState(0);
const tasksRef = React.useRef(tasks)
tasksRef.current = tasks
const [, setTick] = React.useState(0)
React.useEffect(() => {
if (!hasTasks) return;
const interval = setInterval((tasksRef_0, setAppState_0, setTick_0) => {
const now = Date.now();
for (const t of Object.values(tasksRef_0.current)) {
if (isPanelAgentTask(t) && (t.evictAfter ?? Infinity) <= now) {
evictTerminalTask(t.id, setAppState_0);
if (!hasTasks) return
const interval = setInterval(
(tasksRef, setAppState, setTick) => {
const now = Date.now()
for (const t of Object.values(tasksRef.current)) {
if (isPanelAgentTask(t) && (t.evictAfter ?? Infinity) <= now) {
evictTerminalTask(t.id, setAppState)
}
}
}
setTick_0((prev: number) => prev + 1);
}, 1000, tasksRef, setAppState, setTick);
return () => clearInterval(interval);
}, [hasTasks, setAppState]);
setTick((prev: number) => prev + 1)
},
1000,
tasksRef,
setAppState,
setTick,
)
return () => clearInterval(interval)
}, [hasTasks, setAppState])
const nameByAgentId = React.useMemo(() => {
const inv = new Map<string, string>();
for (const [n, id] of agentNameRegistry) inv.set(id, n);
return inv;
}, [agentNameRegistry]);
const inv = new Map<string, string>()
for (const [n, id] of agentNameRegistry) inv.set(id, n)
return inv
}, [agentNameRegistry])
if (visibleTasks.length === 0) {
return null;
return null
}
return <Box flexDirection="column" marginTop={1}>
<MainLine isSelected={selectedIndex === 0} isViewed={viewingAgentTaskId === undefined} onClick={() => exitTeammateView(setAppState)} />
{visibleTasks.map((task, i) => <AgentLine key={task.id} task={task} name={nameByAgentId.get(task.id)} isSelected={selectedIndex === i + 1} isViewed={viewingAgentTaskId === task.id} onClick={() => enterTeammateView(task.id, setAppState)} />)}
</Box>;
return (
<Box flexDirection="column" marginTop={1}>
<MainLine
isSelected={selectedIndex === 0}
isViewed={viewingAgentTaskId === undefined}
onClick={() => exitTeammateView(setAppState)}
/>
{visibleTasks.map((task, i) => (
<AgentLine
key={task.id}
task={task}
name={nameByAgentId.get(task.id)}
isSelected={selectedIndex === i + 1}
isViewed={viewingAgentTaskId === task.id}
onClick={() => enterTeammateView(task.id, setAppState)}
/>
))}
</Box>
)
}
/**
@@ -80,193 +121,137 @@ export function CoordinatorTaskPanel(): React.ReactNode {
* The panel's 1s tick evicts expired tasks from prev.tasks, so this count
* stays accurate without needing its own tick.
*/
export function useCoordinatorTaskCount() {
const tasks = useAppState(_temp);
let t0;
t0 = 0;
return t0;
export function useCoordinatorTaskCount(): number {
const tasks = useAppState(s => s.tasks)
return React.useMemo(() => {
if ("external" !== 'ant') return 0
const count = getVisibleAgentTasks(tasks).length
return count > 0 ? count + 1 : 0
}, [tasks])
}
function _temp(s) {
return s.tasks;
}
function MainLine(t0) {
const $ = _c(10);
const {
isSelected,
isViewed,
onClick
} = t0;
const [hover, setHover] = React.useState(false);
const prefix = isSelected || hover ? figures.pointer + " " : " ";
const bullet = isViewed ? BLACK_CIRCLE : figures.circle;
let t1;
let t2;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = () => setHover(true);
t2 = () => setHover(false);
$[0] = t1;
$[1] = t2;
} else {
t1 = $[0];
t2 = $[1];
}
const t3 = !isSelected && !isViewed && !hover;
let t4;
if ($[2] !== bullet || $[3] !== isViewed || $[4] !== prefix || $[5] !== t3) {
t4 = <Text dimColor={t3} bold={isViewed}>{prefix}{bullet} main</Text>;
$[2] = bullet;
$[3] = isViewed;
$[4] = prefix;
$[5] = t3;
$[6] = t4;
} else {
t4 = $[6];
}
let t5;
if ($[7] !== onClick || $[8] !== t4) {
t5 = <Box onClick={onClick} onMouseEnter={t1} onMouseLeave={t2}>{t4}</Box>;
$[7] = onClick;
$[8] = t4;
$[9] = t5;
} else {
t5 = $[9];
}
return t5;
function MainLine({
isSelected,
isViewed,
onClick,
}: {
isSelected?: boolean
isViewed?: boolean
onClick: () => void
}): React.ReactNode {
const [hover, setHover] = React.useState(false)
const prefix = isSelected || hover ? figures.pointer + ' ' : ' '
const bullet = isViewed ? BLACK_CIRCLE : figures.circle
return (
<Box
onClick={onClick}
onMouseEnter={() => setHover(true)}
onMouseLeave={() => setHover(false)}
>
<Text dimColor={!isSelected && !isViewed && !hover} bold={isViewed}>
{prefix}
{bullet} main
</Text>
</Box>
)
}
type AgentLineProps = {
task: LocalAgentTaskState;
name?: string;
isSelected?: boolean;
isViewed?: boolean;
onClick?: () => void;
};
function AgentLine(t0) {
const $ = _c(32);
const {
task,
name,
isSelected,
isViewed,
onClick
} = t0;
const {
columns
} = useTerminalSize();
const [hover, setHover] = React.useState(false);
const isRunning = !isTerminalStatus(task.status);
const pausedMs = task.totalPausedMs ?? 0;
const elapsedMs = Math.max(0, isRunning ? Date.now() - task.startTime - pausedMs : (task.endTime ?? task.startTime) - task.startTime - pausedMs);
let t1;
if ($[0] !== elapsedMs) {
t1 = formatDuration(elapsedMs);
$[0] = elapsedMs;
$[1] = t1;
} else {
t1 = $[1];
}
const elapsed = t1;
const tokenCount = task.progress?.tokenCount;
const lastActivity = task.progress?.lastActivity;
const arrow = lastActivity ? figures.arrowDown : figures.arrowUp;
let t2;
if ($[2] !== arrow || $[3] !== tokenCount) {
t2 = tokenCount !== undefined && tokenCount > 0 ? ` · ${arrow} ${formatNumber(tokenCount)} tokens` : "";
$[2] = arrow;
$[3] = tokenCount;
$[4] = t2;
} else {
t2 = $[4];
}
const tokenText = t2;
const queuedCount = task.pendingMessages.length;
const queuedText = queuedCount > 0 ? ` · ${queuedCount} queued` : "";
const displayDescription = task.progress?.summary || task.description;
const highlighted = isSelected || hover;
const prefix = highlighted ? figures.pointer + " " : " ";
const bullet = isViewed ? BLACK_CIRCLE : figures.circle;
const dim = !highlighted && !isViewed;
const sep = isRunning ? PLAY_ICON : PAUSE_ICON;
const namePart = name ? `${name}: ` : "";
const hintPart = isSelected && !isViewed ? ` · x to ${isRunning ? "stop" : "clear"}` : "";
const suffixPart = ` ${sep} ${elapsed}${tokenText}${queuedText}${hintPart}`;
const availableForDesc = columns - stringWidth(prefix) - stringWidth(`${bullet} `) - stringWidth(namePart) - stringWidth(suffixPart);
const t3 = Math.max(0, availableForDesc);
let t4;
if ($[5] !== displayDescription || $[6] !== t3) {
t4 = wrapText(displayDescription, t3, "truncate-end");
$[5] = displayDescription;
$[6] = t3;
$[7] = t4;
} else {
t4 = $[7];
}
const truncated = t4;
let t5;
if ($[8] !== name) {
t5 = name && <><Text dimColor={false} bold={true}>{name}</Text>{": "}</>;
$[8] = name;
$[9] = t5;
} else {
t5 = $[9];
}
let t6;
if ($[10] !== queuedCount || $[11] !== queuedText) {
t6 = queuedCount > 0 && <Text color="warning">{queuedText}</Text>;
$[10] = queuedCount;
$[11] = queuedText;
$[12] = t6;
} else {
t6 = $[12];
}
let t7;
if ($[13] !== hintPart) {
t7 = hintPart && <Text dimColor={true}>{hintPart}</Text>;
$[13] = hintPart;
$[14] = t7;
} else {
t7 = $[14];
}
let t8;
if ($[15] !== bullet || $[16] !== dim || $[17] !== elapsed || $[18] !== isViewed || $[19] !== prefix || $[20] !== sep || $[21] !== t5 || $[22] !== t6 || $[23] !== t7 || $[24] !== tokenText || $[25] !== truncated) {
t8 = <Text dimColor={dim} bold={isViewed}>{prefix}{bullet}{" "}{t5}{truncated} {sep} {elapsed}{tokenText}{t6}{t7}</Text>;
$[15] = bullet;
$[16] = dim;
$[17] = elapsed;
$[18] = isViewed;
$[19] = prefix;
$[20] = sep;
$[21] = t5;
$[22] = t6;
$[23] = t7;
$[24] = tokenText;
$[25] = truncated;
$[26] = t8;
} else {
t8 = $[26];
}
const line = t8;
if (!onClick) {
return line;
}
let t10;
let t9;
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
t9 = () => setHover(true);
t10 = () => setHover(false);
$[27] = t10;
$[28] = t9;
} else {
t10 = $[27];
t9 = $[28];
}
let t11;
if ($[29] !== line || $[30] !== onClick) {
t11 = <Box onClick={onClick} onMouseEnter={t9} onMouseLeave={t10}>{line}</Box>;
$[29] = line;
$[30] = onClick;
$[31] = t11;
} else {
t11 = $[31];
}
return t11;
task: LocalAgentTaskState
name?: string
isSelected?: boolean
isViewed?: boolean
onClick?: () => void
}
function AgentLine({
task,
name,
isSelected,
isViewed,
onClick,
}: AgentLineProps): React.ReactNode {
const { columns } = useTerminalSize()
const [hover, setHover] = React.useState(false)
const isRunning = !isTerminalStatus(task.status)
const pausedMs = task.totalPausedMs ?? 0
const elapsedMs = Math.max(
0,
isRunning
? Date.now() - task.startTime - pausedMs
: (task.endTime ?? task.startTime) - task.startTime - pausedMs,
)
const elapsed = formatDuration(elapsedMs)
const tokenCount = task.progress?.tokenCount
// Derive direction arrow from activity state, same logic as Spinner
const lastActivity = task.progress?.lastActivity
const arrow = lastActivity ? figures.arrowDown : figures.arrowUp
const tokenText =
tokenCount !== undefined && tokenCount > 0
? ` · ${arrow} ${formatNumber(tokenCount)} tokens`
: ''
const queuedCount = task.pendingMessages.length
const queuedText = queuedCount > 0 ? ` · ${queuedCount} queued` : ''
// Precedence: AI summary > static description (no tool-call activity noise)
const displayDescription = task.progress?.summary || task.description
const highlighted = isSelected || hover
const prefix = highlighted ? figures.pointer + ' ' : ' '
const bullet = isViewed ? BLACK_CIRCLE : figures.circle
const dim = !highlighted && !isViewed
const sep = isRunning ? PLAY_ICON : PAUSE_ICON
// Name is the steering handle — kept out of truncation and undimmed so it
// stays readable even when the row is inactive. Short by convention (the
// Agent tool prompt asks for "one or two words, lowercase").
const namePart = name ? `${name}: ` : ''
const hintPart =
isSelected && !isViewed ? ` · x to ${isRunning ? 'stop' : 'clear'}` : ''
const suffixPart = ` ${sep} ${elapsed}${tokenText}${queuedText}${hintPart}`
const availableForDesc =
columns -
stringWidth(prefix) -
stringWidth(`${bullet} `) -
stringWidth(namePart) -
stringWidth(suffixPart)
const truncated = wrapText(
displayDescription,
Math.max(0, availableForDesc),
'truncate-end',
)
const line = (
<Text dimColor={dim} bold={isViewed}>
{prefix}
{bullet}{' '}
{name && (
<>
<Text dimColor={false} bold>
{name}
</Text>
{': '}
</>
)}
{truncated} {sep} {elapsed}
{tokenText}
{queuedCount > 0 && <Text color="warning">{queuedText}</Text>}
{hintPart && <Text dimColor>{hintPart}</Text>}
</Text>
)
if (!onClick) return line
return (
<Box
onClick={onClick}
onMouseEnter={() => setHover(true)}
onMouseLeave={() => setHover(false)}
>
{line}
</Box>
)
}