mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-23 00:35:51 +00:00
fix: 批量修正 external 字面量
This commit is contained in:
47
src/main.tsx
47
src/main.tsx
@@ -262,13 +262,10 @@ function isBeingDebugged() {
|
||||
}
|
||||
}
|
||||
|
||||
// Exit if we detect node debugging or inspection
|
||||
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
|
||||
process.exit(1);
|
||||
}
|
||||
// Anti-debugging check disabled for local development
|
||||
// if ((process.env.USER_TYPE) !== 'ant' && isBeingDebugged()) {
|
||||
// process.exit(1);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Per-session skill/plugin telemetry. Called from both the interactive path
|
||||
@@ -337,7 +334,7 @@ function runMigrations(): void {
|
||||
if (feature('TRANSCRIPT_CLASSIFIER')) {
|
||||
resetAutoModeOptInForDefaultOffer();
|
||||
}
|
||||
if (("external" as string) === 'ant') {
|
||||
if ((process.env.USER_TYPE) === 'ant') {
|
||||
migrateFennecToOpus();
|
||||
}
|
||||
saveGlobalConfig(prev => prev.migrationVersion === CURRENT_MIGRATION_VERSION ? prev : {
|
||||
@@ -425,7 +422,7 @@ export function startDeferredPrefetches(): void {
|
||||
}
|
||||
|
||||
// Event loop stall detector — logs when the main thread is blocked >500ms
|
||||
if (("external" as string) === 'ant') {
|
||||
if ((process.env.USER_TYPE) === 'ant') {
|
||||
void import('./utils/eventLoopStallDetector.js').then(m => m.startEventLoopStallDetector());
|
||||
}
|
||||
}
|
||||
@@ -1134,11 +1131,11 @@ async function run(): Promise<CommanderCommand> {
|
||||
const disableSlashCommands = options.disableSlashCommands || false;
|
||||
|
||||
// Extract tasks mode options (ant-only)
|
||||
const tasksOption = ("external" as string) === 'ant' && (options as {
|
||||
const tasksOption = (process.env.USER_TYPE) === 'ant' && (options as {
|
||||
tasks?: boolean | string;
|
||||
}).tasks;
|
||||
const taskListId = tasksOption ? typeof tasksOption === 'string' ? tasksOption : DEFAULT_TASKS_MODE_TASK_LIST_ID : undefined;
|
||||
if (("external" as string) === 'ant' && taskListId) {
|
||||
if ((process.env.USER_TYPE) === 'ant' && taskListId) {
|
||||
process.env.CLAUDE_CODE_TASK_LIST_ID = taskListId;
|
||||
}
|
||||
|
||||
@@ -1528,7 +1525,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" as string) === 'ant' || isClaudeAISubscriber());
|
||||
const enableClaudeInChrome = shouldEnableClaudeInChrome(chromeOpts.chrome) && ((process.env.USER_TYPE) === 'ant' || isClaudeAISubscriber());
|
||||
const autoEnableClaudeInChrome = !enableClaudeInChrome && shouldAutoEnableClaudeInChrome();
|
||||
if (enableClaudeInChrome) {
|
||||
const platform = getPlatform();
|
||||
@@ -1760,7 +1757,7 @@ async function run(): Promise<CommanderCommand> {
|
||||
} = initResult;
|
||||
|
||||
// Handle overly broad shell allow rules for ant users (Bash(*), PowerShell(*))
|
||||
if (("external" as string) === 'ant' && overlyBroadBashPermissions.length > 0) {
|
||||
if ((process.env.USER_TYPE) === 'ant' && overlyBroadBashPermissions.length > 0) {
|
||||
for (const permission of overlyBroadBashPermissions) {
|
||||
logForDebugging(`Ignoring overly broad shell permission ${permission.ruleDisplay} from ${permission.sourceDisplay}`);
|
||||
}
|
||||
@@ -2010,7 +2007,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" as string) === 'ant' && explicitModel && explicitModel !== 'default' && !hasGrowthBookEnvOverride('tengu_ant_model_override') && getGlobalConfig().cachedGrowthBookFeatures?.['tengu_ant_model_override'] == null) {
|
||||
if ((process.env.USER_TYPE) === 'ant' && explicitModel && explicitModel !== 'default' && !hasGrowthBookEnvOverride('tengu_ant_model_override') && getGlobalConfig().cachedGrowthBookFeatures?.['tengu_ant_model_override'] == null) {
|
||||
await initializeGrowthBook();
|
||||
}
|
||||
|
||||
@@ -2156,7 +2153,7 @@ async function run(): Promise<CommanderCommand> {
|
||||
// Log agent memory loaded event for tmux teammates
|
||||
if (customAgent.memory) {
|
||||
logEvent('tengu_agent_memory_loaded', {
|
||||
...(("external" as string) === 'ant' && {
|
||||
...((process.env.USER_TYPE) === '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 +2217,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" as string) === 'ant') {
|
||||
if ((process.env.USER_TYPE) === 'ant') {
|
||||
installAsciicastRecorder();
|
||||
}
|
||||
const {
|
||||
@@ -2816,7 +2813,7 @@ async function run(): Promise<CommanderCommand> {
|
||||
if (!isBareMode()) {
|
||||
startDeferredPrefetches();
|
||||
void import('./utils/backgroundHousekeeping.js').then(m => m.startBackgroundHousekeeping());
|
||||
if (("external" as string) === 'ant') {
|
||||
if ((process.env.USER_TYPE) === 'ant') {
|
||||
void import('./utils/sdkHeapDumpMonitor.js').then(m => m.startSdkMemoryMonitor());
|
||||
}
|
||||
}
|
||||
@@ -3061,7 +3058,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" as string) === 'ant' ? import('./utils/sessionDataUploader.js') : null;
|
||||
const sessionUploaderPromise = (process.env.USER_TYPE) === '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).
|
||||
@@ -3578,7 +3575,7 @@ async function run(): Promise<CommanderCommand> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (("external" as string) === 'ant') {
|
||||
if ((process.env.USER_TYPE) === 'ant') {
|
||||
if (options.resume && typeof options.resume === 'string' && !maybeSessionId) {
|
||||
// Check for ccshare URL (e.g. https://go/ccshare/boris-20260311-211036)
|
||||
const {
|
||||
@@ -3813,7 +3810,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" as string) === 'ant') {
|
||||
if ((process.env.USER_TYPE) === 'ant') {
|
||||
program.addOption(new Option('--delegate-permissions', '[ANT-ONLY] Alias for --permission-mode auto.').implies({
|
||||
permissionMode: 'auto'
|
||||
}));
|
||||
@@ -4367,7 +4364,7 @@ async function run(): Promise<CommanderCommand> {
|
||||
});
|
||||
|
||||
// claude up — run the project's CLAUDE.md "# claude up" setup instructions.
|
||||
if (("external" as string) === 'ant') {
|
||||
if ((process.env.USER_TYPE) === '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 +4375,7 @@ async function run(): Promise<CommanderCommand> {
|
||||
|
||||
// claude rollback (ant-only)
|
||||
// Rolls back to previous releases
|
||||
if (("external" as string) === 'ant') {
|
||||
if ((process.env.USER_TYPE) === '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 +4399,7 @@ async function run(): Promise<CommanderCommand> {
|
||||
});
|
||||
|
||||
// ant-only commands
|
||||
if (("external" as string) === 'ant') {
|
||||
if ((process.env.USER_TYPE) === 'ant') {
|
||||
const validateLogId = (value: string) => {
|
||||
const maybeSessionId = validateUuid(value);
|
||||
if (maybeSessionId) return maybeSessionId;
|
||||
@@ -4436,7 +4433,7 @@ Examples:
|
||||
} = await import('./cli/handlers/ant.js');
|
||||
await exportHandler(source, outputFile);
|
||||
});
|
||||
if (("external" as string) === 'ant') {
|
||||
if ((process.env.USER_TYPE) === '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 +4592,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" as string) === 'ant' ? (() => {
|
||||
...((process.env.USER_TYPE) === 'ant' ? (() => {
|
||||
const cwd = getCwd();
|
||||
const gitRoot = findGitRoot(cwd);
|
||||
const rp = gitRoot ? relative(gitRoot, cwd) || '.' : undefined;
|
||||
|
||||
Reference in New Issue
Block a user