mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-19 23:05:51 +00:00
更新大量 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:
@@ -1,182 +1,183 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import * as React from 'react';
|
||||
import { useMainLoopModel } from '../../hooks/useMainLoopModel.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 type { LocalJSXCommandOnDone } from '../../types/command.js';
|
||||
import { type EffortValue, getDisplayedEffortLevel, getEffortEnvOverride, getEffortValueDescription, isEffortLevel, toPersistableEffort } from '../../utils/effort.js';
|
||||
import { updateSettingsForSource } from '../../utils/settings/settings.js';
|
||||
const COMMON_HELP_ARGS = ['help', '-h', '--help'];
|
||||
import * as React from 'react'
|
||||
import { useMainLoopModel } from '../../hooks/useMainLoopModel.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 type { LocalJSXCommandOnDone } from '../../types/command.js'
|
||||
import {
|
||||
type EffortValue,
|
||||
getDisplayedEffortLevel,
|
||||
getEffortEnvOverride,
|
||||
getEffortValueDescription,
|
||||
isEffortLevel,
|
||||
toPersistableEffort,
|
||||
} from '../../utils/effort.js'
|
||||
import { updateSettingsForSource } from '../../utils/settings/settings.js'
|
||||
|
||||
const COMMON_HELP_ARGS = ['help', '-h', '--help']
|
||||
|
||||
type EffortCommandResult = {
|
||||
message: string;
|
||||
effortUpdate?: {
|
||||
value: EffortValue | undefined;
|
||||
};
|
||||
};
|
||||
message: string
|
||||
effortUpdate?: { value: EffortValue | undefined }
|
||||
}
|
||||
|
||||
function setEffortValue(effortValue: EffortValue): EffortCommandResult {
|
||||
const persistable = toPersistableEffort(effortValue);
|
||||
const persistable = toPersistableEffort(effortValue)
|
||||
if (persistable !== undefined) {
|
||||
const result = updateSettingsForSource('userSettings', {
|
||||
effortLevel: persistable
|
||||
});
|
||||
effortLevel: persistable,
|
||||
})
|
||||
if (result.error) {
|
||||
return {
|
||||
message: `Failed to set effort level: ${result.error.message}`
|
||||
};
|
||||
message: `Failed to set effort level: ${result.error.message}`,
|
||||
}
|
||||
}
|
||||
}
|
||||
logEvent('tengu_effort_command', {
|
||||
effort: effortValue as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
|
||||
});
|
||||
effort:
|
||||
effortValue as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
|
||||
})
|
||||
|
||||
// Env var wins at resolveAppliedEffort time. Only flag it when it actually
|
||||
// conflicts — if env matches what the user just asked for, the outcome is
|
||||
// the same, so "Set effort to X" is true and the note is noise.
|
||||
const envOverride = getEffortEnvOverride();
|
||||
const envOverride = getEffortEnvOverride()
|
||||
if (envOverride !== undefined && envOverride !== effortValue) {
|
||||
const envRaw = process.env.CLAUDE_CODE_EFFORT_LEVEL;
|
||||
const envRaw = process.env.CLAUDE_CODE_EFFORT_LEVEL
|
||||
if (persistable === undefined) {
|
||||
return {
|
||||
message: `Not applied: CLAUDE_CODE_EFFORT_LEVEL=${envRaw} overrides effort this session, and ${effortValue} is session-only (nothing saved)`,
|
||||
effortUpdate: {
|
||||
value: effortValue
|
||||
}
|
||||
};
|
||||
effortUpdate: { value: effortValue },
|
||||
}
|
||||
}
|
||||
return {
|
||||
message: `CLAUDE_CODE_EFFORT_LEVEL=${envRaw} overrides this session — clear it and ${effortValue} takes over`,
|
||||
effortUpdate: {
|
||||
value: effortValue
|
||||
}
|
||||
};
|
||||
effortUpdate: { value: effortValue },
|
||||
}
|
||||
}
|
||||
const description = getEffortValueDescription(effortValue);
|
||||
const suffix = persistable !== undefined ? '' : ' (this session only)';
|
||||
|
||||
const description = getEffortValueDescription(effortValue)
|
||||
const suffix = persistable !== undefined ? '' : ' (this session only)'
|
||||
return {
|
||||
message: `Set effort level to ${effortValue}${suffix}: ${description}`,
|
||||
effortUpdate: {
|
||||
value: effortValue
|
||||
}
|
||||
};
|
||||
}
|
||||
export function showCurrentEffort(appStateEffort: EffortValue | undefined, model: string): EffortCommandResult {
|
||||
const envOverride = getEffortEnvOverride();
|
||||
const effectiveValue = envOverride === null ? undefined : envOverride ?? appStateEffort;
|
||||
if (effectiveValue === undefined) {
|
||||
const level = getDisplayedEffortLevel(model, appStateEffort);
|
||||
return {
|
||||
message: `Effort level: auto (currently ${level})`
|
||||
};
|
||||
effortUpdate: { value: effortValue },
|
||||
}
|
||||
const description = getEffortValueDescription(effectiveValue);
|
||||
return {
|
||||
message: `Current effort level: ${effectiveValue} (${description})`
|
||||
};
|
||||
}
|
||||
|
||||
export function showCurrentEffort(
|
||||
appStateEffort: EffortValue | undefined,
|
||||
model: string,
|
||||
): EffortCommandResult {
|
||||
const envOverride = getEffortEnvOverride()
|
||||
const effectiveValue =
|
||||
envOverride === null ? undefined : (envOverride ?? appStateEffort)
|
||||
if (effectiveValue === undefined) {
|
||||
const level = getDisplayedEffortLevel(model, appStateEffort)
|
||||
return { message: `Effort level: auto (currently ${level})` }
|
||||
}
|
||||
const description = getEffortValueDescription(effectiveValue)
|
||||
return {
|
||||
message: `Current effort level: ${effectiveValue} (${description})`,
|
||||
}
|
||||
}
|
||||
|
||||
function unsetEffortLevel(): EffortCommandResult {
|
||||
const result = updateSettingsForSource('userSettings', {
|
||||
effortLevel: undefined
|
||||
});
|
||||
effortLevel: undefined,
|
||||
})
|
||||
if (result.error) {
|
||||
return {
|
||||
message: `Failed to set effort level: ${result.error.message}`
|
||||
};
|
||||
message: `Failed to set effort level: ${result.error.message}`,
|
||||
}
|
||||
}
|
||||
logEvent('tengu_effort_command', {
|
||||
effort: 'auto' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
|
||||
});
|
||||
effort:
|
||||
'auto' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
|
||||
})
|
||||
// env=auto/unset (null) matches what /effort auto asks for, so only warn
|
||||
// when env is pinning a specific level that will keep overriding.
|
||||
const envOverride = getEffortEnvOverride();
|
||||
const envOverride = getEffortEnvOverride()
|
||||
if (envOverride !== undefined && envOverride !== null) {
|
||||
const envRaw = process.env.CLAUDE_CODE_EFFORT_LEVEL;
|
||||
const envRaw = process.env.CLAUDE_CODE_EFFORT_LEVEL
|
||||
return {
|
||||
message: `Cleared effort from settings, but CLAUDE_CODE_EFFORT_LEVEL=${envRaw} still controls this session`,
|
||||
effortUpdate: {
|
||||
value: undefined
|
||||
}
|
||||
};
|
||||
effortUpdate: { value: undefined },
|
||||
}
|
||||
}
|
||||
return {
|
||||
message: 'Effort level set to auto',
|
||||
effortUpdate: {
|
||||
value: undefined
|
||||
}
|
||||
};
|
||||
}
|
||||
export function executeEffort(args: string): EffortCommandResult {
|
||||
const normalized = args.toLowerCase();
|
||||
if (normalized === 'auto' || normalized === 'unset') {
|
||||
return unsetEffortLevel();
|
||||
effortUpdate: { value: undefined },
|
||||
}
|
||||
}
|
||||
|
||||
export function executeEffort(args: string): EffortCommandResult {
|
||||
const normalized = args.toLowerCase()
|
||||
if (normalized === 'auto' || normalized === 'unset') {
|
||||
return unsetEffortLevel()
|
||||
}
|
||||
|
||||
if (!isEffortLevel(normalized)) {
|
||||
return {
|
||||
message: `Invalid argument: ${args}. Valid options are: low, medium, high, max, auto`
|
||||
};
|
||||
message: `Invalid argument: ${args}. Valid options are: low, medium, high, max, auto`,
|
||||
}
|
||||
}
|
||||
return setEffortValue(normalized);
|
||||
|
||||
return setEffortValue(normalized)
|
||||
}
|
||||
function ShowCurrentEffort(t0) {
|
||||
const {
|
||||
onDone
|
||||
} = t0;
|
||||
const effortValue = useAppState(_temp);
|
||||
const model = useMainLoopModel();
|
||||
const {
|
||||
message
|
||||
} = showCurrentEffort(effortValue, model);
|
||||
onDone(message);
|
||||
return null;
|
||||
|
||||
function ShowCurrentEffort({
|
||||
onDone,
|
||||
}: {
|
||||
onDone: (result: string) => void
|
||||
}): React.ReactNode {
|
||||
const effortValue = useAppState(s => s.effortValue)
|
||||
const model = useMainLoopModel()
|
||||
const { message } = showCurrentEffort(effortValue, model)
|
||||
onDone(message)
|
||||
return null
|
||||
}
|
||||
function _temp(s) {
|
||||
return s.effortValue;
|
||||
|
||||
function ApplyEffortAndClose({
|
||||
result,
|
||||
onDone,
|
||||
}: {
|
||||
result: EffortCommandResult
|
||||
onDone: (result: string) => void
|
||||
}): React.ReactNode {
|
||||
const setAppState = useSetAppState()
|
||||
const { effortUpdate, message } = result
|
||||
React.useEffect(() => {
|
||||
if (effortUpdate) {
|
||||
setAppState(prev => ({
|
||||
...prev,
|
||||
effortValue: effortUpdate.value,
|
||||
}))
|
||||
}
|
||||
onDone(message)
|
||||
}, [setAppState, effortUpdate, message, onDone])
|
||||
return null
|
||||
}
|
||||
function ApplyEffortAndClose(t0) {
|
||||
const $ = _c(6);
|
||||
const {
|
||||
result,
|
||||
onDone
|
||||
} = t0;
|
||||
const setAppState = useSetAppState();
|
||||
const {
|
||||
effortUpdate,
|
||||
message
|
||||
} = result;
|
||||
let t1;
|
||||
let t2;
|
||||
if ($[0] !== effortUpdate || $[1] !== message || $[2] !== onDone || $[3] !== setAppState) {
|
||||
t1 = () => {
|
||||
if (effortUpdate) {
|
||||
setAppState(prev => ({
|
||||
...prev,
|
||||
effortValue: effortUpdate.value
|
||||
}));
|
||||
}
|
||||
onDone(message);
|
||||
};
|
||||
t2 = [setAppState, effortUpdate, message, onDone];
|
||||
$[0] = effortUpdate;
|
||||
$[1] = message;
|
||||
$[2] = onDone;
|
||||
$[3] = setAppState;
|
||||
$[4] = t1;
|
||||
$[5] = t2;
|
||||
} else {
|
||||
t1 = $[4];
|
||||
t2 = $[5];
|
||||
}
|
||||
React.useEffect(t1, t2);
|
||||
return null;
|
||||
}
|
||||
export async function call(onDone: LocalJSXCommandOnDone, _context: unknown, args?: string): Promise<React.ReactNode> {
|
||||
args = args?.trim() || '';
|
||||
|
||||
export async function call(
|
||||
onDone: LocalJSXCommandOnDone,
|
||||
_context: unknown,
|
||||
args?: string,
|
||||
): Promise<React.ReactNode> {
|
||||
args = args?.trim() || ''
|
||||
|
||||
if (COMMON_HELP_ARGS.includes(args)) {
|
||||
onDone('Usage: /effort [low|medium|high|max|auto]\n\nEffort levels:\n- low: Quick, straightforward implementation\n- medium: Balanced approach with standard testing\n- high: Comprehensive implementation with extensive testing\n- max: Maximum capability with deepest reasoning (Opus 4.6 only)\n- auto: Use the default effort level for your model');
|
||||
return;
|
||||
onDone(
|
||||
'Usage: /effort [low|medium|high|max|auto]\n\nEffort levels:\n- low: Quick, straightforward implementation\n- medium: Balanced approach with standard testing\n- high: Comprehensive implementation with extensive testing\n- max: Maximum capability with deepest reasoning (Opus 4.6 only)\n- auto: Use the default effort level for your model',
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (!args || args === 'current' || args === 'status') {
|
||||
return <ShowCurrentEffort onDone={onDone} />;
|
||||
return <ShowCurrentEffort onDone={onDone} />
|
||||
}
|
||||
const result = executeEffort(args);
|
||||
return <ApplyEffortAndClose result={result} onDone={onDone} />;
|
||||
|
||||
const result = executeEffort(args)
|
||||
return <ApplyEffortAndClose result={result} onDone={onDone} />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user