mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 06:15:51 +00:00
feat: 添加服务层增强与零散改进
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
13
src/setup.ts
13
src/setup.ts
@@ -20,6 +20,7 @@ import {
|
||||
} from './bootstrap/state.js'
|
||||
import { getCommands } from './commands.js'
|
||||
import { initSessionMemory } from './services/SessionMemory/sessionMemory.js'
|
||||
import { initSkillLearning } from './services/skillLearning/runtimeObserver.js'
|
||||
import { asSessionId } from './types/ids.js'
|
||||
import { isAgentSwarmsEnabled } from './utils/agentSwarmsEnabled.js'
|
||||
import { checkAndRestoreTerminalBackup } from './utils/appleTerminalBackup.js'
|
||||
@@ -68,8 +69,7 @@ export async function setup(
|
||||
|
||||
// Check for Node.js version < 18
|
||||
const nodeVersion = process.version.match(/^v(\d+)\./)?.[1]
|
||||
if (!nodeVersion || parseInt(nodeVersion) < 18) {
|
||||
// biome-ignore lint/suspicious/noConsole:: intentional console output
|
||||
if (!nodeVersion || parseInt(nodeVersion, 10) < 18) {
|
||||
console.error(
|
||||
chalk.bold.red(
|
||||
'Error: Claude Code requires Node.js version 18 or higher.',
|
||||
@@ -117,14 +117,12 @@ export async function setup(
|
||||
if (isAgentSwarmsEnabled()) {
|
||||
const restoredIterm2Backup = await checkAndRestoreITerm2Backup()
|
||||
if (restoredIterm2Backup.status === 'restored') {
|
||||
// biome-ignore lint/suspicious/noConsole:: intentional console output
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'Detected an interrupted iTerm2 setup. Your original settings have been restored. You may need to restart iTerm2 for the changes to take effect.',
|
||||
),
|
||||
)
|
||||
} else if (restoredIterm2Backup.status === 'failed') {
|
||||
// biome-ignore lint/suspicious/noConsole:: intentional console output
|
||||
console.error(
|
||||
chalk.red(
|
||||
`Failed to restore iTerm2 settings. Please manually restore your original settings with: defaults import com.googlecode.iterm2 ${restoredIterm2Backup.backupPath}.`,
|
||||
@@ -137,14 +135,12 @@ export async function setup(
|
||||
try {
|
||||
const restoredTerminalBackup = await checkAndRestoreTerminalBackup()
|
||||
if (restoredTerminalBackup.status === 'restored') {
|
||||
// biome-ignore lint/suspicious/noConsole:: intentional console output
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'Detected an interrupted Terminal.app setup. Your original settings have been restored. You may need to restart Terminal.app for the changes to take effect.',
|
||||
),
|
||||
)
|
||||
} else if (restoredTerminalBackup.status === 'failed') {
|
||||
// biome-ignore lint/suspicious/noConsole:: intentional console output
|
||||
console.error(
|
||||
chalk.red(
|
||||
`Failed to restore Terminal.app settings. Please manually restore your original settings with: defaults import com.apple.Terminal ${restoredTerminalBackup.backupPath}.`,
|
||||
@@ -252,14 +248,12 @@ export async function setup(
|
||||
worktreeSession.worktreePath,
|
||||
)
|
||||
if (tmuxResult.created) {
|
||||
// biome-ignore lint/suspicious/noConsole:: intentional console output
|
||||
console.log(
|
||||
chalk.green(
|
||||
`Created tmux session: ${chalk.bold(tmuxSessionName)}\nTo attach: ${chalk.bold(`tmux attach -t ${tmuxSessionName}`)}`,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
// biome-ignore lint/suspicious/noConsole:: intentional console output
|
||||
console.error(
|
||||
chalk.yellow(
|
||||
`Warning: Failed to create tmux session: ${tmuxResult.error}`,
|
||||
@@ -292,6 +286,7 @@ export async function setup(
|
||||
// raced ahead and memoized an empty bundledSkills list.
|
||||
if (!isBareMode()) {
|
||||
initSessionMemory() // Synchronous - registers hook, gate check happens lazily
|
||||
initSkillLearning() // Synchronous - registers hook, gate check happens lazily
|
||||
if (feature('CONTEXT_COLLAPSE')) {
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
;(
|
||||
@@ -406,7 +401,6 @@ export async function setup(
|
||||
process.env.IS_SANDBOX !== '1' &&
|
||||
!isEnvTruthy(process.env.CLAUDE_CODE_BUBBLEWRAP)
|
||||
) {
|
||||
// biome-ignore lint/suspicious/noConsole:: intentional console output
|
||||
console.error(
|
||||
`--dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons`,
|
||||
)
|
||||
@@ -432,7 +426,6 @@ export async function setup(
|
||||
const isSandbox = process.env.IS_SANDBOX === '1'
|
||||
const isSandboxed = isDocker || isBubblewrap || isSandbox
|
||||
if (!isSandboxed || hasInternet) {
|
||||
// biome-ignore lint/suspicious/noConsole:: intentional console output
|
||||
console.error(
|
||||
`--dangerously-skip-permissions can only be used in Docker/sandbox containers with no internet access but got Docker: ${isDocker}, Bubblewrap: ${isBubblewrap}, IS_SANDBOX: ${isSandbox}, hasInternet: ${hasInternet}`,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user