mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
主要变更: - Skill Learning 闭环系统 (9/9 AC) - Opus 4.7 模型层接入 + adaptive thinking - Prompt 工程优化 (64 审计测试) - Agent Teams 简化门控 (默认启用) - Windows Terminal 后端修复 (EncodedCommand/WT_SESSION) - TF-IDF 技能搜索精准化 (字段加权/CJK 优化) - Autonomy 系统 (/autonomy 命令) - ACP 协议完整实现 - mock.module 泄漏修复 (CI 全绿) - 152+ lint/type 修复
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, test } from 'bun:test'
|
|
import { readFile, rm } from 'node:fs/promises'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import {
|
|
resetStateForTests,
|
|
setCwdState,
|
|
setOriginalCwd,
|
|
} from '../../bootstrap/state'
|
|
import { getTaskListId } from '../../utils/tasks'
|
|
import { getTeamFilePath } from '../../utils/swarm/teamHelpers'
|
|
import { initializeAssistantTeam } from '../index'
|
|
|
|
let tempDir = ''
|
|
let previousConfigDir: string | undefined
|
|
|
|
beforeEach(() => {
|
|
previousConfigDir = process.env.CLAUDE_CONFIG_DIR
|
|
tempDir = join(
|
|
tmpdir(),
|
|
`assistant-team-${Date.now()}-${Math.random().toString(16).slice(2)}`,
|
|
)
|
|
process.env.CLAUDE_CONFIG_DIR = join(tempDir, 'config')
|
|
resetStateForTests()
|
|
setOriginalCwd(tempDir)
|
|
setCwdState(tempDir)
|
|
})
|
|
|
|
afterEach(async () => {
|
|
resetStateForTests()
|
|
if (previousConfigDir === undefined) {
|
|
delete process.env.CLAUDE_CONFIG_DIR
|
|
} else {
|
|
process.env.CLAUDE_CONFIG_DIR = previousConfigDir
|
|
}
|
|
await rm(tempDir, { recursive: true, force: true })
|
|
})
|
|
|
|
describe('initializeAssistantTeam', () => {
|
|
test('creates a session-scoped in-process team context and task list', async () => {
|
|
const context = await initializeAssistantTeam()
|
|
expect(context).toBeDefined()
|
|
const teamContext = context!
|
|
|
|
expect(teamContext.teamName).toStartWith('assistant-')
|
|
expect(teamContext.isLeader).toBe(true)
|
|
expect(teamContext.selfAgentName).toBe('team-lead')
|
|
expect(
|
|
teamContext.teammates[teamContext.leadAgentId]?.tmuxSessionName,
|
|
).toBe('in-process')
|
|
expect(getTaskListId()).toBe(teamContext.teamName)
|
|
|
|
const raw = await readFile(getTeamFilePath(teamContext.teamName), 'utf-8')
|
|
const teamFile = JSON.parse(raw)
|
|
expect(teamFile.leadAgentId).toBe(teamContext.leadAgentId)
|
|
expect(teamFile.members[0].backendType).toBe('in-process')
|
|
expect(teamFile.members[0].agentType).toBe('assistant')
|
|
})
|
|
})
|