Skip to content

Commit 7f58524

Browse files
committed
feat(knowledge): 摄影示例体系常量(具象化数据)
1 parent 50e39f9 commit 7f58524

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* knowledgeSample.test.ts — 摄影示例体系常量结构校验(v0.13.7 具象化)。
3+
*
4+
* @ai-context: 示例数据即 golden——节点层级/概念三问/模型三字段/决策四行
5+
* 必须完整,缺字段=示例残缺(具象化失败)。
6+
*/
7+
import { describe, expect, it } from "vitest";
8+
import { SAMPLE_SYSTEM } from "./knowledgeSample";
9+
10+
describe("SAMPLE_SYSTEM 结构完整性", () => {
11+
it("领域体系元数据完整", () => {
12+
expect(SAMPLE_SYSTEM.name).toBe("摄影");
13+
expect(SAMPLE_SYSTEM.kind).toBe("domain");
14+
});
15+
16+
it("问题树 7 节点且含层级(有父节点)", () => {
17+
expect(SAMPLE_SYSTEM.nodes.length).toBe(7);
18+
expect(SAMPLE_SYSTEM.nodes.some((n) => n.parentId != null)).toBe(true);
19+
expect(SAMPLE_SYSTEM.nodes.some((n) => n.type === "scenario")).toBe(true);
20+
});
21+
22+
it("概念 3 个且三问全填", () => {
23+
expect(SAMPLE_SYSTEM.concepts.length).toBe(3);
24+
for (const c of SAMPLE_SYSTEM.concepts) {
25+
expect(c.essence).toBeTruthy();
26+
expect(c.boundary).toBeTruthy();
27+
expect(c.relation).toBeTruthy();
28+
}
29+
});
30+
31+
it("模型 1 个且 claim/valid_when/invalid_when 全填", () => {
32+
expect(SAMPLE_SYSTEM.models.length).toBe(1);
33+
const m = SAMPLE_SYSTEM.models[0];
34+
expect(m.claim).toBeTruthy();
35+
expect(m.validWhen).toBeTruthy();
36+
expect(m.invalidWhen).toBeTruthy();
37+
});
38+
});

‎app/src/utils/knowledgeSample.ts‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* knowledgeSample.ts — 摄影示例体系常量(v0.13.7 具象化)。
3+
*
4+
* @ai-context: 示例≠预填(纪律裁决 2026-08-24)——示例是用户可见的完整
5+
* 参照物,复制后处于"待改造"状态。结构对应既有 command 入参,
6+
* 复制时逐条调 create/add 命令落库(零新命令)。
7+
*/
8+
import type { KnowledgeNodeType, SystemKind } from "../types/knowledge";
9+
10+
export interface SampleNode {
11+
type: KnowledgeNodeType;
12+
text: string;
13+
parentId: number | null;
14+
}
15+
export interface SampleConcept {
16+
name: string;
17+
essence: string;
18+
boundary: string;
19+
relation: string;
20+
}
21+
export interface SampleModel {
22+
name: string;
23+
disciplines: string[];
24+
claim: string;
25+
validWhen: string;
26+
invalidWhen: string;
27+
}
28+
29+
export const SAMPLE_SYSTEM = {
30+
name: "摄影",
31+
kind: "domain" as SystemKind,
32+
coreQuestion: "如何拍出有表达力、不灰蒙蒙的照片?",
33+
/** 问题树:7 节点(4 根 + 3 子;含 1 场景根)——parentId 索引指向 nodes 内下标 */
34+
nodes: [
35+
{ type: "question", text: "照片为什么发灰、不通透?", parentId: null }, // 0
36+
{ type: "question", text: "怎么判断一张照片曝光是否准确?", parentId: 0 }, // 1
37+
{ type: "question", text: "高光溢出了怎么办?", parentId: 0 }, // 2
38+
{ type: "question", text: "为什么拍人像背景虚化不了?", parentId: null }, // 3
39+
{ type: "question", text: "怎么让背景虚化(光圈优先)?", parentId: 3 }, // 4
40+
{ type: "question", text: "构图总是很平淡怎么办?", parentId: null }, // 5
41+
{ type: "scenario", text: "本周修好 10 张发灰的旅行照", parentId: null }, // 6
42+
] as SampleNode[],
43+
concepts: [
44+
{
45+
name: "曝光三角",
46+
essence: "光圈/快门/ISO 三者平衡光量的关系",
47+
boundary: "只影响明暗,不影响景深的是 ISO",
48+
relation: "感光元件对光的响应,是后期降噪的基础",
49+
},
50+
{
51+
name: "安全快门",
52+
essence: "1/焦距 的倒数,低于它手抖必糊",
53+
boundary: "有防抖/三脚架时失效",
54+
relation: "与曝光三角中快门联动",
55+
},
56+
{
57+
name: "三分构图",
58+
essence: "把主体放在画面 1/3 分割线上",
59+
boundary: "对称构图/居中构图时不用",
60+
relation: "与引导线结合更出效果",
61+
},
62+
] as SampleConcept[],
63+
models: [
64+
{
65+
name: "黄金时刻法则",
66+
disciplines: ["摄影"],
67+
claim: "日出日落前后 1 小时光质最佳",
68+
validWhen: "户外自然光",
69+
invalidWhen: "室内闪光灯/阴天正午想拍蓝调",
70+
},
71+
] as SampleModel[],
72+
};

0 commit comments

Comments
 (0)