mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14:25:51 +00:00
- 合并 getOutputEfficiencySection + getSimpleToneAndStyleSection 为精简的 Communication style - 精简 auto memory 指令:删除 4 种类型的详细说明和示例,仅保留核心 description - 精简 Agent 工具:删除 forkExamples 和 currentExamples 大段示例 - 精简 Bash 工具:合并 sleep 相关指导 - 精简 EnterPlanMode/ExitPlanMode:删除详细 GOOD/BAD 示例 - gitStatus MAX_STATUS_CHARS 从 2000 降到 1000 - 同步更新 prompt engineering audit 测试断言 Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
61 lines
2.2 KiB
TypeScript
61 lines
2.2 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import { readFileSync } from 'fs'
|
|
import { join, dirname } from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const promptSource = readFileSync(join(__dirname, '..', 'prompt.ts'), 'utf-8')
|
|
|
|
describe('prompt.ts fork-related text verification', () => {
|
|
test('does not contain "omit `subagent_type`" guidance', () => {
|
|
expect(promptSource).not.toMatch(/omit.*subagent_type/)
|
|
})
|
|
|
|
test('contains `fork: true` in at least 3 locations (shared + whenToFork + forkExamples)', () => {
|
|
const matches = promptSource.match(/fork: true/g)
|
|
expect(matches).not.toBeNull()
|
|
expect(matches!.length).toBeGreaterThanOrEqual(3)
|
|
})
|
|
|
|
test('all forkEnabled references are ternary conditions, not negated', () => {
|
|
const lines = promptSource.split('\n')
|
|
for (const line of lines) {
|
|
if (
|
|
line.includes('forkEnabled') &&
|
|
!line.includes('const forkEnabled') &&
|
|
!line.includes('forkEnabled =')
|
|
) {
|
|
expect(line).not.toContain('!forkEnabled')
|
|
}
|
|
}
|
|
})
|
|
|
|
test('uses "non-fork" terminology instead of "fresh agent"', () => {
|
|
expect(promptSource).toContain('non-fork')
|
|
// "fresh agent" should not appear in fork-aware conditional text
|
|
const freshAgentMatches = promptSource.match(/fresh agent/g)
|
|
if (freshAgentMatches) {
|
|
// Only allowed in comments explaining behavior, not in prompt text
|
|
const linesWithFreshAgent = promptSource
|
|
.split('\n')
|
|
.filter(line => line.includes('fresh agent'))
|
|
.map(line => line.trim())
|
|
for (const line of linesWithFreshAgent) {
|
|
// "fresh agent" in the context of "starts fresh" (not fork-aware) is ok
|
|
// but "fresh agent" in forkEnabled conditional should not appear
|
|
expect(line).not.toMatch(/fresh agent.*subagent_type/)
|
|
}
|
|
}
|
|
})
|
|
|
|
test('background task condition does not include !forkEnabled', () => {
|
|
// The condition for showing background task instructions should not exclude fork
|
|
const bgCondition = promptSource.match(
|
|
/!isEnvTruthy.*isInProcessTeammate[\s\S]*?run_in_background/,
|
|
)
|
|
if (bgCondition) {
|
|
expect(bgCondition[0]).not.toContain('!forkEnabled')
|
|
}
|
|
})
|
|
})
|