Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(scripts): require own properties in schema validation
Zhao Dengfeng814dc26d1d86
diff --git a/scripts/__tests__/glossary-rules.test.mjs b/scripts/__tests__/glossary-rules.test.mjsindex 344668d597..bbba2b1728 100644--- a/scripts/__tests__/glossary-rules.test.mjs+++ b/scripts/__tests__/glossary-rules.test.mjs@@ -486,6 +486,11 @@ test('validateAgainstSchema: 校验 required / enum / pattern / oneOf', () => {};assert.deepEqual(validateAgainstSchema({ id: 'session', status: 'decided' }, schema), []);assert.match(validateAgainstSchema({ id: 'session' }, schema).join(), /缺少必填字段 "status"/);+ // required 只认实例自有字段,不能接受 Object.prototype 上的同名属性。+ assert.match(+ validateAgainstSchema({}, { type: 'object', required: ['toString'] }).join(),+ /缺少必填字段 "toString"/,+ );assert.match(validateAgainstSchema({ id: 'Session', status: 'decided' }, schema).join(), /不匹配/);assert.match(validateAgainstSchema({ id: 'a', status: 'decied' }, schema).join(), /取值必须是/);// 条件禁用少写 whenEn 时,两个 oneOf 分支都不匹配diff --git a/scripts/shared/json-schema-lite.mjs b/scripts/shared/json-schema-lite.mjsindex 9e022de329..2d13351631 100644--- a/scripts/shared/json-schema-lite.mjs+++ b/scripts/shared/json-schema-lite.mjs@@ -214,7 +214,7 @@ function validateNode(value, schema, root, path, errors) {if (typeOf(value) === 'object') {for (const key of schema.required ?? []) {- if (!(key in value)) errors.push(`${path}: 缺少必填字段 "${key}"`);+ if (!Object.hasOwn(value, key)) errors.push(`${path}: 缺少必填字段 "${key}"`);}const known = new Set(Object.keys(schema.properties ?? {}));for (const [key, child] of Object.entries(value)) {