Compare commits

..

6 Commits

Author SHA1 Message Date
claude-code-best
7e61e71c54 fix: 尝试禁用 UDS_INBOX 修复 nodejs 进入失败问题 2026-04-28 14:32:23 +08:00
claude-code-best
b8b48bf7ed fix: 修复 truncate 函数接收到 undefined/null 时崩溃的问题
BackgroundTask 组件渲染时传入的 task 属性(description、title、command 等)
可能为 undefined,导致 str.indexOf('\n') 抛出 TypeError。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-28 09:15:58 +08:00
claude-code-best
de9dbcdcbb chore: 1.10.8 2026-04-28 08:50:23 +08:00
claude-code-best
0a9e6c0313 fix: 先关闭 skill learning 2026-04-28 08:50:05 +08:00
claude-code-best
73130bded3 chore: 1.10.7 2026-04-28 08:47:45 +08:00
claude-code-best
1a1d57057e fix: 限制 skill-learning evidence 无限增长导致全局 skill 文件膨胀
evidence 数组和追加块缺少大小限制,导致 skill 文件(如
sdd-brainstorming)在短时间内膨胀至 21K+ 行/78 个 evidence 块。

三处修复:
- instinctParser: evidence 数组 cap 10 条, observationIds cap 20 条
- skillGenerator: 追加块每次最多 20 行, 文件总大小上限 50KB,
  生成 skill 的 evidence 段限制 20 行
- agentGenerator: 生成 agent 的 evidence 段限制 20 行

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-28 08:47:37 +08:00
6 changed files with 41 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "claude-code-best",
"version": "1.10.6",
"version": "1.10.9",
"description": "Reverse-engineered Anthropic Claude Code CLI — interactive AI coding assistant in the terminal",
"type": "module",
"author": "claude-code-best <claude-code-best@proton.me>",

View File

@@ -53,10 +53,10 @@ export const DEFAULT_BUILD_FEATURES = [
'CONTEXT_COLLAPSE', // 上下文折叠,自动压缩旧消息
'MONITOR_TOOL', // Monitor 工具,流式监控后台进程输出
'FORK_SUBAGENT', // Fork 子代理,在隔离上下文中并行执行任务
'UDS_INBOX', // inbox 数组只增不减(非 GB 级主因)
// 'UDS_INBOX', // inbox 数组只增不减(非 GB 级主因)
'KAIROS', // Kairos 定时任务系统核心
// 'COORDINATOR_MODE', // 已禁用AgentSummary 30s fork 循环GB 级泄露主因
'LAN_PIPES', // 依赖 UDS_INBOX已随 UDS_INBOX 恢复)
// 'LAN_PIPES', // 依赖 UDS_INBOX已随 UDS_INBOX 恢复)
'BG_SESSIONS', // 后台会话管理ps/logs/attach/kill
'TEMPLATES', // 模板任务new/list/reply 子命令)
// 'REVIEW_ARTIFACT', // 代码审查产物API 请求无响应,待排查 schema 兼容性)
@@ -68,7 +68,7 @@ export const DEFAULT_BUILD_FEATURES = [
'DIRECT_CONNECT', // 直连模式claude server / claude open
// Skill search & learning
'EXPERIMENTAL_SKILL_SEARCH', // 实验性技能搜索DiscoverSkills
'SKILL_LEARNING', // projectContext cache 无淘汰机制(非 GB 级主因)
// 'SKILL_LEARNING', // projectContext cache 无淘汰机制(非 GB 级主因)
// P3: poor mode
'POOR', // 穷鬼模式,跳过 extract_memories/prompt_suggestion 减少消耗
// Team Memory

View File

@@ -122,6 +122,7 @@ function buildAgentContent(params: {
'',
instincts
.flatMap(instinct => instinct.evidence.map(evidence => `- ${evidence}`))
.slice(0, 20)
.join('\n'),
'',
].join('\n')

View File

@@ -35,15 +35,18 @@ export function createInstinct(
})
}
const MAX_EVIDENCE_ENTRIES = 10
export function normalizeInstinct(instinct: StoredInstinct): StoredInstinct {
const uniqueEvidence = Array.from(new Set(instinct.evidence.filter(Boolean)))
return {
...instinct,
id: instinct.id || buildInstinctId(instinct.trigger, instinct.action),
confidence: clampConfidence(instinct.confidence),
evidence: Array.from(new Set(instinct.evidence.filter(Boolean))),
evidence: uniqueEvidence.slice(-MAX_EVIDENCE_ENTRIES),
evidenceOutcome: instinct.evidenceOutcome,
observationIds: instinct.observationIds
? Array.from(new Set(instinct.observationIds))
? Array.from(new Set(instinct.observationIds)).slice(-20)
: undefined,
}
}

View File

@@ -12,6 +12,9 @@ import {
import type { LearnedSkillDraft, SkillLearningScope } from './types.js'
export const DUPLICATE_SKILL_OVERLAP_THRESHOLD = 0.8
const MAX_EVIDENCE_LINES_PER_APPEND = 20
const MAX_EVIDENCE_LINES_IN_SKILL = 20
const MAX_SKILL_FILE_BYTES = 50_000
export type SkillGeneratorOptions = {
cwd?: string
@@ -101,20 +104,41 @@ export async function appendInstinctEvidenceToSkill(
const existing = await readFile(target.path, 'utf8').catch(
() => target.content,
)
// Skip if the file already exceeds the size cap
if (Buffer.byteLength(existing, 'utf8') >= MAX_SKILL_FILE_BYTES) {
return target.path
}
const allEvidence = instincts.flatMap(instinct =>
instinct.evidence.map(evidence => `- ${evidence}`),
)
const evidenceLines = allEvidence.slice(0, MAX_EVIDENCE_LINES_PER_APPEND)
if (evidenceLines.length < allEvidence.length) {
evidenceLines.push(
`- [... ${allEvidence.length - evidenceLines.length} more evidence entries omitted]`,
)
}
const now = new Date().toISOString()
const block = [
'',
`## Learned evidence (${now})`,
'',
...instincts.flatMap(instinct =>
instinct.evidence.map(evidence => `- ${evidence}`),
),
...evidenceLines,
'',
].join('\n')
const merged = existing.endsWith('\n')
? existing + block
: `${existing}\n${block}`
await writeFile(target.path, merged, 'utf8')
// Final guard: truncate if merged exceeds size cap
const finalContent =
Buffer.byteLength(merged, 'utf8') > MAX_SKILL_FILE_BYTES
? merged.slice(0, MAX_SKILL_FILE_BYTES)
: merged
await writeFile(target.path, finalContent, 'utf8')
clearSkillIndexCache()
return target.path
}
@@ -191,6 +215,7 @@ function buildSkillContent(params: {
'',
instincts
.flatMap(instinct => instinct.evidence.map(evidence => `- ${evidence}`))
.slice(0, MAX_EVIDENCE_LINES_IN_SKILL)
.join('\n'),
'',
]

View File

@@ -132,10 +132,11 @@ export function truncateToWidthNoEllipsis(
* @returns The truncated string with ellipsis if needed
*/
export function truncate(
str: string,
str: string | undefined | null,
maxWidth: number,
singleLine: boolean = false,
): string {
if (str == null) return ''
let result = str
// If singleLine is true, truncate at first newline