修复: 安全加固+DRY 收敛+文档同步+测试补齐

安全:
- ScriptNode 默认黑名单兜底(rm/del/format/shutdown/mkfs/dd)
- bind_directory 分段 .. 检测替代 contains 子串(对齐 tool_registry)
- ai_providers 白名单移除 api_key(防 update_field 旁路写明文)

DRY:
- useAiEvents 抽 cleanupTerminatedConversation 统一三分支收尾
- 新增 useStoreAction 工具,4 个 store 替换 38 处 try/catch 样板

文档:
- df-core → df-types 批量替换(ARCHITECTURE/PROGRESS/SQLite-CRUD)
- INDEX 补齐 9 漏列文档(单对话并行多轮/跑题试验/工程系统设计等)
- Agent架构说明 死链修复(../构想审查/)
- AI对话引擎工具清单改为数量+按风险分组(不再用固定数字)
- ARCH 状态标签 设计阶段 → Phase 2 验证

测试:
- df-relay 新增 registry_test: ConnRegistry 路由 + RelayState + 16 项单测
This commit is contained in:
lxy
2026-06-29 21:57:07 +08:00
parent dfed588b54
commit ff3f153d45
17 changed files with 761 additions and 563 deletions
+13 -20
View File
@@ -1,6 +1,7 @@
import { ideaApi } from '@/api'
import type { IdeaQuery } from '@/api/types'
import { t } from '@/i18n/i18n-helpers'
import { runWithCatch } from '@/composables/useStoreAction'
import { state } from './state'
/** 灵感 CRUD 子 store(共享全局 state) */
@@ -13,22 +14,18 @@ export function createIdeasStore() {
* - 不传 → 全量(created_at DESC,等价旧行为)。
*/
async function loadIdeas(query?: IdeaQuery) {
try {
await runWithCatch(state, t('ideas.err.loadFailed'), async () => {
state.ideas = await ideaApi.list(query)
} catch (e: any) {
state.error = e?.toString() ?? t('ideas.err.loadFailed')
}
})
}
async function createIdea(input: { title: string; description?: string; priority?: number; tags?: string; source?: string }) {
try {
const record = await ideaApi.create(input)
state.ideas.push(record)
return record
} catch (e: any) {
state.error = e?.toString() ?? t('ideas.err.createFailed')
return null
}
const record = await runWithCatch(state, t('ideas.err.createFailed'), async () => {
const r = await ideaApi.create(input)
state.ideas.push(r)
return r
})
return record ?? null
}
async function updateIdea(id: string, field: string, value: string) {
@@ -40,12 +37,10 @@ export function createIdeasStore() {
}
async function deleteIdea(id: string) {
try {
await runWithCatch(state, t('ideas.err.deleteFailed'), async () => {
await ideaApi.delete(id)
state.ideas = state.ideas.filter(i => i.id !== id)
} catch (e: any) {
state.error = e?.toString() ?? t('ideas.err.deleteFailed')
}
})
}
async function evaluateIdea(id: string) {
@@ -62,12 +57,10 @@ export function createIdeasStore() {
}
async function relateIdeas(subjectId: string, targetIds: string[]) {
try {
await runWithCatch(state, t('ideas.err.relateFailed'), async () => {
await ideaApi.relateIdeas(subjectId, targetIds)
await loadIdeas() // 后端已原子更新全部受影响灵感,刷新列表保持 store 一致
} catch (e: any) {
state.error = e?.toString() ?? t('ideas.err.relateFailed')
}
})
}
return {