refactor: align macro bootstrap with cli entry

This commit is contained in:
2026-04-03 13:59:27 +08:00
parent d7bb164a05
commit 4eb053eef5
2 changed files with 21 additions and 25 deletions

View File

@@ -1,16 +1,24 @@
import { feature } from 'bun:bundle';
const CLI_MACRO =
typeof MACRO !== 'undefined'
? MACRO
: {
VERSION: 'dev',
BUILD_TIME: '',
PACKAGE_URL: '@anthropic-ai/claude-code',
ISSUES_EXPLAINER:
'https://docs.anthropic.com/en/docs/claude-code/feedback',
FEEDBACK_CHANNEL: 'github',
};
// Define MACRO global for development (normally injected by bun build --define)
if (typeof MACRO === 'undefined') {
(globalThis as typeof globalThis & {
MACRO: {
VERSION: string
BUILD_TIME: string
PACKAGE_URL: string
ISSUES_EXPLAINER: string
FEEDBACK_CHANNEL: string
}
}).MACRO = {
VERSION: '2.1.88-dev',
BUILD_TIME: new Date().toISOString(),
PACKAGE_URL: 'claude-code-recover',
ISSUES_EXPLAINER:
'https://docs.anthropic.com/en/docs/claude-code/feedback',
FEEDBACK_CHANNEL: 'github',
};
}
// Bugfix for corepack auto-pinning, which adds yarnpkg to peoples' package.jsons
// eslint-disable-next-line custom-rules/no-top-level-side-effects
@@ -49,7 +57,7 @@ async function main(): Promise<void> {
if (args.length === 1 && (args[0] === '--version' || args[0] === '-v' || args[0] === '-V')) {
// MACRO.VERSION is inlined at build time
// biome-ignore lint/suspicious/noConsole:: intentional console output
console.log(`${CLI_MACRO.VERSION} (Claude Code)`);
console.log(`${MACRO.VERSION} (Claude Code)`);
return;
}

View File

@@ -65,18 +65,6 @@ import { computeInitialTeamContext } from './utils/swarm/reconnection.js';
import { initializeWarningHandler } from './utils/warningHandler.js';
import { isWorktreeModeEnabled } from './utils/worktreeModeEnabled.js';
const MAIN_MACRO =
typeof MACRO !== 'undefined'
? MACRO
: {
VERSION: 'dev',
BUILD_TIME: '',
PACKAGE_URL: '@anthropic-ai/claude-code',
ISSUES_EXPLAINER:
'https://docs.anthropic.com/en/docs/claude-code/feedback',
FEEDBACK_CHANNEL: 'github',
};
// Lazy require to avoid circular dependency: teammate.ts -> AppState.tsx -> ... -> main.tsx
/* eslint-disable @typescript-eslint/no-require-imports */
const getTeammateUtils = () => require('./utils/teammate.js') as typeof import('./utils/teammate.js');
@@ -3817,7 +3805,7 @@ async function run(): Promise<CommanderCommand> {
pendingHookMessages
}, renderAndRun);
}
}).version(`${MAIN_MACRO.VERSION} (Claude Code)`, '-v, --version', 'Output the version number');
}).version(`${MACRO.VERSION} (Claude Code)`, '-v, --version', 'Output the version number');
// Worktree flags
program.option('-w, --worktree [name]', 'Create a new git worktree for this session (optionally specify a name)');