feat: 大规模清理 claude 的类型问题及依赖

This commit is contained in:
claude-code-best
2026-03-31 22:21:35 +08:00
parent 2c759fe6fa
commit 4c0a655a1c
38 changed files with 1154 additions and 718 deletions

View File

@@ -263,7 +263,7 @@ function isBeingDebugged() {
}
// Exit if we detect node debugging or inspection
if ("external" !== 'ant' && isBeingDebugged()) {
if (("external" as string) !== 'ant' && isBeingDebugged()) {
// Use process.exit directly here since we're in the top-level code before imports
// and gracefulShutdown is not yet available
// eslint-disable-next-line custom-rules/no-top-level-side-effects
@@ -337,7 +337,7 @@ function runMigrations(): void {
if (feature('TRANSCRIPT_CLASSIFIER')) {
resetAutoModeOptInForDefaultOffer();
}
if ("external" === 'ant') {
if (("external" as string) === 'ant') {
migrateFennecToOpus();
}
saveGlobalConfig(prev => prev.migrationVersion === CURRENT_MIGRATION_VERSION ? prev : {
@@ -425,7 +425,7 @@ export function startDeferredPrefetches(): void {
}
// Event loop stall detector — logs when the main thread is blocked >500ms
if ("external" === 'ant') {
if (("external" as string) === 'ant') {
void import('./utils/eventLoopStallDetector.js').then(m => m.startEventLoopStallDetector());
}
}
@@ -1134,11 +1134,11 @@ async function run(): Promise<CommanderCommand> {
const disableSlashCommands = options.disableSlashCommands || false;
// Extract tasks mode options (ant-only)
const tasksOption = "external" === 'ant' && (options as {
const tasksOption = ("external" as string) === 'ant' && (options as {
tasks?: boolean | string;
}).tasks;
const taskListId = tasksOption ? typeof tasksOption === 'string' ? tasksOption : DEFAULT_TASKS_MODE_TASK_LIST_ID : undefined;
if ("external" === 'ant' && taskListId) {
if (("external" as string) === 'ant' && taskListId) {
process.env.CLAUDE_CODE_TASK_LIST_ID = taskListId;
}
@@ -1518,7 +1518,7 @@ async function run(): Promise<CommanderCommand> {
dynamicMcpConfig = {
...dynamicMcpConfig,
...allowed
};
} as Record<string, ScopedMcpServerConfig>;
}
}
@@ -1528,7 +1528,7 @@ async function run(): Promise<CommanderCommand> {
};
// Store the explicit CLI flag so teammates can inherit it
setChromeFlagOverride(chromeOpts.chrome);
const enableClaudeInChrome = shouldEnableClaudeInChrome(chromeOpts.chrome) && ("external" === 'ant' || isClaudeAISubscriber());
const enableClaudeInChrome = shouldEnableClaudeInChrome(chromeOpts.chrome) && (("external" as string) === 'ant' || isClaudeAISubscriber());
const autoEnableClaudeInChrome = !enableClaudeInChrome && shouldAutoEnableClaudeInChrome();
if (enableClaudeInChrome) {
const platform = getPlatform();
@@ -1760,7 +1760,7 @@ async function run(): Promise<CommanderCommand> {
} = initResult;
// Handle overly broad shell allow rules for ant users (Bash(*), PowerShell(*))
if ("external" === 'ant' && overlyBroadBashPermissions.length > 0) {
if (("external" as string) === 'ant' && overlyBroadBashPermissions.length > 0) {
for (const permission of overlyBroadBashPermissions) {
logForDebugging(`Ignoring overly broad shell permission ${permission.ruleDisplay} from ${permission.sourceDisplay}`);
}
@@ -2010,7 +2010,7 @@ async function run(): Promise<CommanderCommand> {
// - no env override (which short-circuits _CACHED_MAY_BE_STALE before disk)
// - flag absent from disk (== null also catches pre-#22279 poisoned null)
const explicitModel = options.model || process.env.ANTHROPIC_MODEL;
if ("external" === 'ant' && explicitModel && explicitModel !== 'default' && !hasGrowthBookEnvOverride('tengu_ant_model_override') && getGlobalConfig().cachedGrowthBookFeatures?.['tengu_ant_model_override'] == null) {
if (("external" as string) === 'ant' && explicitModel && explicitModel !== 'default' && !hasGrowthBookEnvOverride('tengu_ant_model_override') && getGlobalConfig().cachedGrowthBookFeatures?.['tengu_ant_model_override'] == null) {
await initializeGrowthBook();
}
@@ -2156,7 +2156,7 @@ async function run(): Promise<CommanderCommand> {
// Log agent memory loaded event for tmux teammates
if (customAgent.memory) {
logEvent('tengu_agent_memory_loaded', {
...("external" === 'ant' && {
...(("external" as string) === 'ant' && {
agent_type: customAgent.agentType as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
}),
scope: customAgent.memory as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
@@ -2220,7 +2220,7 @@ async function run(): Promise<CommanderCommand> {
getFpsMetrics = ctx.getFpsMetrics;
stats = ctx.stats;
// Install asciicast recorder before Ink mounts (ant-only, opt-in via CLAUDE_CODE_TERMINAL_RECORDING=1)
if ("external" === 'ant') {
if (("external" as string) === 'ant') {
installAsciicastRecorder();
}
const {
@@ -2301,7 +2301,7 @@ async function run(): Promise<CommanderCommand> {
// login state are fully loaded.
const orgValidation = await validateForceLoginOrg();
if (!orgValidation.valid) {
await exitWithError(root, orgValidation.message);
await exitWithError(root, (orgValidation as { valid: false; message: string }).message);
}
}
@@ -2613,7 +2613,7 @@ async function run(): Promise<CommanderCommand> {
// Validate org restriction for non-interactive sessions
const orgValidation = await validateForceLoginOrg();
if (!orgValidation.valid) {
process.stderr.write(orgValidation.message + '\n');
process.stderr.write((orgValidation as { valid: false; message: string }).message + '\n');
process.exit(1);
}
@@ -2816,7 +2816,7 @@ async function run(): Promise<CommanderCommand> {
if (!isBareMode()) {
startDeferredPrefetches();
void import('./utils/backgroundHousekeeping.js').then(m => m.startBackgroundHousekeeping());
if ("external" === 'ant') {
if (("external" as string) === 'ant') {
void import('./utils/sdkHeapDumpMonitor.js').then(m => m.startSdkMemoryMonitor());
}
}
@@ -3061,7 +3061,7 @@ async function run(): Promise<CommanderCommand> {
// - Runtime: uploader checks github.com/anthropics/* remote + gcloud auth.
// - Safety: CLAUDE_CODE_DISABLE_SESSION_DATA_UPLOAD=1 bypasses (tests set this).
// Import is dynamic + async to avoid adding startup latency.
const sessionUploaderPromise = "external" === 'ant' ? import('./utils/sessionDataUploader.js') : null;
const sessionUploaderPromise = ("external" as string) === 'ant' ? import('./utils/sessionDataUploader.js') : null;
// Defer session uploader resolution to the onTurnComplete callback to avoid
// adding a new top-level await in main.tsx (performance-critical path).
@@ -3492,7 +3492,7 @@ async function run(): Promise<CommanderCommand> {
debug: debug || debugToStderr,
commands: remoteCommands,
initialTools: [],
initialMessages: initialUserMessage ? [remoteInfoMessage, initialUserMessage] : [remoteInfoMessage],
initialMessages: (initialUserMessage ? [remoteInfoMessage, initialUserMessage] : [remoteInfoMessage]) as MessageType[],
mcpClients: [],
autoConnectIdeFlag: ide,
mainThreadAgentDefinition,
@@ -3578,7 +3578,7 @@ async function run(): Promise<CommanderCommand> {
}
}
}
if ("external" === 'ant') {
if (("external" as string) === 'ant') {
if (options.resume && typeof options.resume === 'string' && !maybeSessionId) {
// Check for ccshare URL (e.g. https://go/ccshare/boris-20260311-211036)
const {
@@ -3813,7 +3813,7 @@ async function run(): Promise<CommanderCommand> {
if (canUserConfigureAdvisor()) {
program.addOption(new Option('--advisor <model>', 'Enable the server-side advisor tool with the specified model (alias or full ID).').hideHelp());
}
if ("external" === 'ant') {
if (("external" as string) === 'ant') {
program.addOption(new Option('--delegate-permissions', '[ANT-ONLY] Alias for --permission-mode auto.').implies({
permissionMode: 'auto'
}));
@@ -4057,9 +4057,9 @@ async function run(): Promise<CommanderCommand> {
// which redirects to the main command with full TUI support.
if (feature('DIRECT_CONNECT')) {
program.command('open <cc-url>').description('Connect to a Claude Code server (internal — use cc:// URLs)').option('-p, --print [prompt]', 'Print mode (headless)').option('--output-format <format>', 'Output format: text, json, stream-json', 'text').action(async (ccUrl: string, opts: {
print?: string | boolean;
outputFormat: string;
}) => {
print?: string | true;
outputFormat?: string;
}, _command) => {
const {
parseConnectUrl
} = await import('./server/parseConnectUrl.js');
@@ -4367,7 +4367,7 @@ async function run(): Promise<CommanderCommand> {
});
// claude up — run the project's CLAUDE.md "# claude up" setup instructions.
if ("external" === 'ant') {
if (("external" as string) === 'ant') {
program.command('up').description('[ANT-ONLY] Initialize or upgrade the local dev environment using the "# claude up" section of the nearest CLAUDE.md').action(async () => {
const {
up
@@ -4378,7 +4378,7 @@ async function run(): Promise<CommanderCommand> {
// claude rollback (ant-only)
// Rolls back to previous releases
if ("external" === 'ant') {
if (("external" as string) === 'ant') {
program.command('rollback [target]').description('[ANT-ONLY] Roll back to a previous release\n\nExamples:\n claude rollback Go 1 version back from current\n claude rollback 3 Go 3 versions back from current\n claude rollback 2.0.73-dev.20251217.t190658 Roll back to a specific version').option('-l, --list', 'List recent published versions with ages').option('--dry-run', 'Show what would be installed without installing').option('--safe', 'Roll back to the server-pinned safe version (set by oncall during incidents)').action(async (target?: string, options?: {
list?: boolean;
dryRun?: boolean;
@@ -4402,7 +4402,7 @@ async function run(): Promise<CommanderCommand> {
});
// ant-only commands
if ("external" === 'ant') {
if (("external" as string) === 'ant') {
const validateLogId = (value: string) => {
const maybeSessionId = validateUuid(value);
if (maybeSessionId) return maybeSessionId;
@@ -4436,7 +4436,7 @@ Examples:
} = await import('./cli/handlers/ant.js');
await exportHandler(source, outputFile);
});
if ("external" === 'ant') {
if (("external" as string) === 'ant') {
const taskCmd = program.command('task').description('[ANT-ONLY] Manage task list tasks');
taskCmd.command('create <subject>').description('Create a new task').option('-d, --description <text>', 'Task description').option('-l, --list <id>', 'Task list ID (defaults to "tasklist")').action(async (subject: string, opts: {
description?: string;
@@ -4595,7 +4595,7 @@ async function logTenguInit({
assistantActivationPath: assistantActivationPath as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
}),
autoUpdatesChannel: (getInitialSettings().autoUpdatesChannel ?? 'latest') as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
...("external" === 'ant' ? (() => {
...(("external" as string) === 'ant' ? (() => {
const cwd = getCwd();
const gitRoot = findGitRoot(cwd);
const rp = gitRoot ? relative(gitRoot, cwd) || '.' : undefined;