feat(dacli): define AntiPattern interface + ANTI_PATTERNS skeleton
This commit is contained in:
1 parent
04c758d15a
commit
5d7efca370
2 files changed
+67
No files matched your search
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 单一真值源: 反模式字典.
|
||||
* 由 TS 自动生成 dacli/docs/anti-patterns.md (单向).
|
||||
* installHelpHook 通过 enrichHelp() 注入到 --help.
|
||||
*/
|
||||
|
||||
export interface AntiPattern {
|
||||
/** 唯一 ID, 格式 AP-<command>-<n> */
|
||||
id: string
|
||||
/** 严重程度 */
|
||||
severity: 'P0' | 'P1' | 'P2'
|
||||
/** 反例 (1 行) */
|
||||
wrong: string
|
||||
/** 正例 (1-2 行) */
|
||||
right: string
|
||||
/** 根因 (1-2 句) */
|
||||
rationale: string
|
||||
/** 来源 (drift round / CLAUDE.md / decision number) */
|
||||
source: string
|
||||
/** 跨引用 (decisions 编号等) */
|
||||
crossRefs?: string[]
|
||||
}
|
||||
|
||||
export type CommandKey =
|
||||
| 'form create'
|
||||
| 'form update'
|
||||
| 'form info'
|
||||
| 'form delete'
|
||||
| 'menu create'
|
||||
| 'dict typeCreate'
|
||||
| 'workflow create'
|
||||
| 'dm create'
|
||||
| 'di create'
|
||||
| 'test run'
|
||||
| 'app context'
|
||||
|
||||
/** 中央反模式字典 (按命令分组) */
|
||||
export const ANTI_PATTERNS: Record<CommandKey, AntiPattern[]> = {
|
||||
'form create': [],
|
||||
'form update': [],
|
||||
'form info': [],
|
||||
'form delete': [],
|
||||
'menu create': [],
|
||||
'dict typeCreate': [],
|
||||
'workflow create': [],
|
||||
'dm create': [],
|
||||
'di create': [],
|
||||
'test run': [],
|
||||
'app context': [],
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import type { AntiPattern } from '../../src/commands/_anti_patterns'
|
||||
|
||||
describe('AntiPattern interface', () => {
|
||||
it('should accept all 6 required fields', () => {
|
||||
const p: AntiPattern = {
|
||||
id: 'AP-test-1',
|
||||
severity: 'P0',
|
||||
wrong: 'wrong way',
|
||||
right: 'right way',
|
||||
rationale: 'because AI defaults to wrong',
|
||||
source: 'drift/R17',
|
||||
}
|
||||
expect(p.id).toBe('AP-test-1')
|
||||
expect(p.severity).toBe('P0')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user