更新大量 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,16 +1,20 @@
import { c as _c } from "react/compiler-runtime";
import { feature } from 'bun:bundle';
import * as React from 'react';
import { useSyncExternalStore } from 'react';
import { Box, Text } from '../ink.js';
import { getFeatureValue_CACHED_MAY_BE_STALE } from '../services/analytics/growthbook.js';
import { calculateTokenWarningState, getEffectiveContextWindowSize, isAutoCompactEnabled } from '../services/compact/autoCompact.js';
import { useCompactWarningSuppression } from '../services/compact/compactWarningHook.js';
import { getUpgradeMessage } from '../utils/model/contextWindowUpgradeCheck.js';
import { feature } from 'bun:bundle'
import * as React from 'react'
import { useSyncExternalStore } from 'react'
import { Box, Text } from '../ink.js'
import { getFeatureValue_CACHED_MAY_BE_STALE } from '../services/analytics/growthbook.js'
import {
calculateTokenWarningState,
getEffectiveContextWindowSize,
isAutoCompactEnabled,
} from '../services/compact/autoCompact.js'
import { useCompactWarningSuppression } from '../services/compact/compactWarningHook.js'
import { getUpgradeMessage } from '../utils/model/contextWindowUpgradeCheck.js'
type Props = {
tokenUsage: number;
model: string;
};
tokenUsage: number
model: string
}
/**
* Live collapse progress: "x / y summarized". Sub-component so
@@ -18,161 +22,134 @@ type Props = {
* (hooks-in-conditionals would violate React rules). The parent only
* renders this when feature('CONTEXT_COLLAPSE') + isContextCollapseEnabled().
*/
function CollapseLabel(t0) {
const $ = _c(8);
const {
upgradeMessage
} = t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = require("../services/contextCollapse/index.js");
$[0] = t1;
} else {
t1 = $[0];
function CollapseLabel({
upgradeMessage,
}: {
upgradeMessage: string | null
}): React.ReactNode {
/* eslint-disable @typescript-eslint/no-require-imports */
const { getStats, subscribe } =
require('../services/contextCollapse/index.js') as typeof import('../services/contextCollapse/index.js')
/* eslint-enable @typescript-eslint/no-require-imports */
// Snapshot must be referentially stable across calls when the
// underlying counts haven't changed — returning a fresh object every
// time would infinite-loop useSyncExternalStore. Encode as a string.
const snapshot = useSyncExternalStore(subscribe, () => {
const s = getStats()
const idleWarn = s.health.emptySpawnWarningEmitted ? 1 : 0
return `${s.collapsedSpans}|${s.stagedSpans}|${s.health.totalErrors}|${s.health.totalEmptySpawns}|${idleWarn}`
})
const [collapsed, staged, errors, emptySpawns, idleWarn] = snapshot
.split('|')
.map(Number) as [number, number, number, number, number]
const total = collapsed + staged
// Show error indicator when ctx-agent is failing silently
if (errors > 0 || idleWarn) {
const problem =
errors > 0
? `collapse errors: ${errors}`
: `collapse idle (${emptySpawns} empty runs)`
return (
<Text color="warning" wrap="truncate">
{total > 0
? `${collapsed} / ${total} summarized \u00b7 ${problem}`
: problem}
</Text>
)
}
const {
getStats,
subscribe
} = t1 as typeof import('../services/contextCollapse/index.js');
let t2;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t2 = () => {
const s = getStats();
const idleWarn = s.health.emptySpawnWarningEmitted ? 1 : 0;
return `${s.collapsedSpans}|${s.stagedSpans}|${s.health.totalErrors}|${s.health.totalEmptySpawns}|${idleWarn}`;
};
$[1] = t2;
} else {
t2 = $[1];
}
const snapshot = useSyncExternalStore(subscribe, t2);
let t3;
if ($[2] !== snapshot) {
t3 = (snapshot as string).split("|").map(Number);
$[2] = snapshot;
$[3] = t3;
} else {
t3 = $[3];
}
const [collapsed, staged, errors, emptySpawns, idleWarn_0] = t3 as [number, number, number, number, number];
const total = collapsed + staged;
if (errors > 0 || idleWarn_0) {
const problem = errors > 0 ? `collapse errors: ${errors}` : `collapse idle (${emptySpawns} empty runs)`;
const t4 = total > 0 ? `${collapsed} / ${total} summarized \u00b7 ${problem}` : problem;
let t5;
if ($[4] !== t4) {
t5 = <Text color="warning" wrap="truncate">{t4}</Text>;
$[4] = t4;
$[5] = t5;
} else {
t5 = $[5];
}
return t5;
}
if (total === 0) {
return null;
}
const label = `${collapsed} / ${total} summarized`;
const t4 = upgradeMessage ? `${label} \u00b7 ${upgradeMessage}` : label;
let t5;
if ($[6] !== t4) {
t5 = <Text dimColor={true} wrap="truncate">{t4}</Text>;
$[6] = t4;
$[7] = t5;
} else {
t5 = $[7];
}
return t5;
if (total === 0) return null
const label = `${collapsed} / ${total} summarized`
return (
<Text dimColor wrap="truncate">
{upgradeMessage ? `${label} \u00b7 ${upgradeMessage}` : label}
</Text>
)
}
export function TokenWarning(t0) {
const $ = _c(13);
const {
tokenUsage,
model
} = t0;
let t1;
if ($[0] !== model || $[1] !== tokenUsage) {
t1 = calculateTokenWarningState(tokenUsage, model);
$[0] = model;
$[1] = tokenUsage;
$[2] = t1;
} else {
t1 = $[2];
}
const {
percentLeft,
isAboveWarningThreshold,
isAboveErrorThreshold
} = t1;
const suppressWarning = useCompactWarningSuppression();
export function TokenWarning({ tokenUsage, model }: Props): React.ReactNode {
const { percentLeft, isAboveWarningThreshold, isAboveErrorThreshold } =
calculateTokenWarningState(tokenUsage, model)
// Use reactive hook to check if warning should be suppressed
const suppressWarning = useCompactWarningSuppression()
if (!isAboveWarningThreshold || suppressWarning) {
return null;
return null
}
let t2;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t2 = isAutoCompactEnabled();
$[3] = t2;
} else {
t2 = $[3];
}
const showAutoCompactWarning = t2;
let t3;
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
t3 = getUpgradeMessage("warning");
$[4] = t3;
} else {
t3 = $[4];
}
const upgradeMessage = t3;
let displayPercentLeft = percentLeft;
let reactiveOnlyMode = false;
let collapseMode = false;
if (feature("REACTIVE_COMPACT")) {
if (getFeatureValue_CACHED_MAY_BE_STALE("tengu_cobalt_raccoon", false)) {
reactiveOnlyMode = true;
const showAutoCompactWarning = isAutoCompactEnabled()
const upgradeMessage = getUpgradeMessage('warning')
// Reactive-only or context-collapse mode: proactive autocompact never
// fires, so percentLeft's normal calculation (against the autocompact
// threshold) counts down to an event that won't happen. Recompute
// against the effective window so the percentage is honest.
//
// Each feature() block stands alone so the flag strings DCE from
// external builds independently.
let displayPercentLeft = percentLeft
let reactiveOnlyMode = false
let collapseMode = false
if (feature('REACTIVE_COMPACT')) {
if (getFeatureValue_CACHED_MAY_BE_STALE('tengu_cobalt_raccoon', false)) {
reactiveOnlyMode = true
}
}
if (feature("CONTEXT_COLLAPSE")) {
const {
isContextCollapseEnabled
} = require("../services/contextCollapse/index.js") as typeof import('../services/contextCollapse/index.js');
if (feature('CONTEXT_COLLAPSE')) {
/* eslint-disable @typescript-eslint/no-require-imports */
const { isContextCollapseEnabled } =
require('../services/contextCollapse/index.js') as typeof import('../services/contextCollapse/index.js')
/* eslint-enable @typescript-eslint/no-require-imports */
if (isContextCollapseEnabled()) {
collapseMode = true;
collapseMode = true
}
}
if (reactiveOnlyMode || collapseMode) {
const effectiveWindow = getEffectiveContextWindowSize(model);
let t4;
if ($[5] !== effectiveWindow || $[6] !== tokenUsage) {
t4 = Math.round((effectiveWindow - tokenUsage) / effectiveWindow * 100);
$[5] = effectiveWindow;
$[6] = tokenUsage;
$[7] = t4;
} else {
t4 = $[7];
}
displayPercentLeft = Math.max(0, t4);
const effectiveWindow = getEffectiveContextWindowSize(model)
displayPercentLeft = Math.max(
0,
Math.round(((effectiveWindow - tokenUsage) / effectiveWindow) * 100),
)
}
if (collapseMode && feature("CONTEXT_COLLAPSE")) {
let t4;
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
t4 = <Box flexDirection="row"><CollapseLabel upgradeMessage={upgradeMessage} /></Box>;
$[8] = t4;
} else {
t4 = $[8];
}
return t4;
// Collapse mode: delegate to the subscribing sub-component so the
// indicator updates live as the ctx-agent stages and commits fire, not
// just when the next API response re-renders TokenWarning.
if (collapseMode && feature('CONTEXT_COLLAPSE')) {
return (
<Box flexDirection="row">
<CollapseLabel upgradeMessage={upgradeMessage} />
</Box>
)
}
const autocompactLabel = reactiveOnlyMode ? `${100 - displayPercentLeft}% context used` : `${displayPercentLeft}% until auto-compact`;
let t4;
if ($[9] !== autocompactLabel || $[10] !== isAboveErrorThreshold || $[11] !== percentLeft) {
t4 = <Box flexDirection="row">{showAutoCompactWarning ? <Text dimColor={true} wrap="truncate">{upgradeMessage ? `${autocompactLabel} \u00b7 ${upgradeMessage}` : autocompactLabel}</Text> : <Text color={isAboveErrorThreshold ? "error" : "warning"} wrap="truncate">{upgradeMessage ? `Context low (${percentLeft}% remaining) \u00b7 ${upgradeMessage}` : `Context low (${percentLeft}% remaining) \u00b7 Run /compact to compact & continue`}</Text>}</Box>;
$[9] = autocompactLabel;
$[10] = isAboveErrorThreshold;
$[11] = percentLeft;
$[12] = t4;
} else {
t4 = $[12];
}
return t4;
const autocompactLabel = reactiveOnlyMode
? `${100 - displayPercentLeft}% context used`
: `${displayPercentLeft}% until auto-compact`
return (
<Box flexDirection="row">
{showAutoCompactWarning ? (
<Text dimColor wrap="truncate">
{upgradeMessage
? `${autocompactLabel} \u00b7 ${upgradeMessage}`
: autocompactLabel}
</Text>
) : (
<Text
color={isAboveErrorThreshold ? 'error' : 'warning'}
wrap="truncate"
>
{upgradeMessage
? `Context low (${percentLeft}% remaining) \u00b7 ${upgradeMessage}`
: `Context low (${percentLeft}% remaining) \u00b7 Run /compact to compact & continue`}
</Text>
)}
</Box>
)
}