sumulige-claude 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/.kickoff-hint.txt +3 -2
- package/.claude/CLAUDE.md +138 -0
- package/.claude/README.md +234 -43
- package/.claude/boris-optimizations.md +167 -0
- package/.claude/commands/todos.md +6 -41
- package/.claude/hooks/code-formatter.cjs +2 -7
- package/.claude/hooks/conversation-logger.cjs +222 -0
- package/.claude/hooks/multi-session.cjs +3 -9
- package/.claude/hooks/project-kickoff.cjs +198 -20
- package/.claude/hooks/rag-skill-loader.cjs +0 -7
- package/.claude/hooks/session-restore.cjs +0 -0
- package/.claude/hooks/session-save.cjs +0 -0
- package/.claude/hooks/thinking-silent.cjs +3 -9
- package/.claude/hooks/todo-manager.cjs +142 -269
- package/.claude/hooks/verify-work.cjs +4 -10
- package/.claude/rag/skill-index.json +128 -8
- package/.claude/settings.json +115 -0
- package/.claude/skills/123-skill/SKILL.md +61 -0
- package/.claude/skills/123-skill/examples/basic.md +3 -0
- package/.claude/skills/123-skill/metadata.yaml +30 -0
- package/.claude/skills/123-skill/templates/default.md +3 -0
- package/.claude/skills/SKILLS.md +145 -0
- package/.claude/skills/code-reviewer-123/SKILL.md +61 -0
- package/.claude/skills/code-reviewer-123/examples/basic.md +3 -0
- package/.claude/skills/code-reviewer-123/metadata.yaml +30 -0
- package/.claude/skills/code-reviewer-123/templates/default.md +3 -0
- package/.claude/skills/examples/README.md +47 -0
- package/.claude/skills/examples/basic-task.md +67 -0
- package/.claude/skills/examples/bug-fix-workflow.md +92 -0
- package/.claude/skills/examples/feature-development.md +81 -0
- package/.claude/skills/manus-kickoff/SKILL.md +128 -0
- package/.claude/skills/manus-kickoff/examples/basic.md +84 -0
- package/.claude/skills/manus-kickoff/metadata.yaml +33 -0
- package/.claude/skills/manus-kickoff/templates/PROJECT_KICKOFF.md +89 -0
- package/.claude/skills/manus-kickoff/templates/PROJECT_PROPOSAL.md +227 -0
- package/.claude/skills/manus-kickoff/templates/TASK_PLAN.md +121 -0
- package/.claude/skills/my-skill/SKILL.md +61 -0
- package/.claude/skills/my-skill/examples/basic.md +3 -0
- package/.claude/skills/my-skill/metadata.yaml +30 -0
- package/.claude/skills/my-skill/templates/default.md +3 -0
- package/.claude/skills/template/metadata.yaml +30 -0
- package/.claude/skills/test-skill-name/SKILL.md +61 -0
- package/.claude/skills/test-skill-name/examples/basic.md +3 -0
- package/.claude/skills/test-skill-name/metadata.yaml +30 -0
- package/.claude/skills/test-skill-name/templates/default.md +3 -0
- package/.claude/templates/PROJECT_KICKOFF.md +89 -0
- package/.claude/templates/PROJECT_PROPOSAL.md +227 -0
- package/.claude/templates/TASK_PLAN.md +121 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/AGENTS.md +30 -6
- package/CHANGELOG.md +18 -0
- package/CLAUDE-template.md +114 -0
- package/README.md +16 -1
- package/config/official-skills.json +2 -2
- package/jest.config.js +3 -1
- package/lib/commands.js +1626 -1207
- package/lib/marketplace.js +1 -0
- package/package.json +1 -1
- package/project-paradigm.md +313 -0
- package/prompts/how-to-find.md +163 -0
- package/tests/commands.test.js +940 -17
- package/tests/config-schema.test.js +425 -0
- package/tests/marketplace.test.js +330 -214
- package/tests/sync-external.test.js +214 -0
- package/tests/update-registry.test.js +251 -0
- package/tests/utils.test.js +12 -8
- package/tests/web-search.test.js +392 -0
- package/thinkinglens-silent.md +138 -0
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config Schema 模块单元测试
|
|
3
|
+
* 测试 JSON Schema 定义和获取功能
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const schema = require('../lib/config-schema');
|
|
7
|
+
|
|
8
|
+
describe('Config Schema Module', () => {
|
|
9
|
+
describe('exports', () => {
|
|
10
|
+
it('should export CONFIG_SCHEMA', () => {
|
|
11
|
+
expect(schema.CONFIG_SCHEMA).toBeDefined();
|
|
12
|
+
expect(typeof schema.CONFIG_SCHEMA).toBe('object');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should export SETTINGS_SCHEMA', () => {
|
|
16
|
+
expect(schema.SETTINGS_SCHEMA).toBeDefined();
|
|
17
|
+
expect(typeof schema.SETTINGS_SCHEMA).toBe('object');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should export QUALITY_GATE_SCHEMA', () => {
|
|
21
|
+
expect(schema.QUALITY_GATE_SCHEMA).toBeDefined();
|
|
22
|
+
expect(typeof schema.QUALITY_GATE_SCHEMA).toBe('object');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should export getSchema function', () => {
|
|
26
|
+
expect(typeof schema.getSchema).toBe('function');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should export getAllSchemas function', () => {
|
|
30
|
+
expect(typeof schema.getAllSchemas).toBe('function');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('getSchema', () => {
|
|
35
|
+
it('should return CONFIG_SCHEMA for "config"', () => {
|
|
36
|
+
const result = schema.getSchema('config');
|
|
37
|
+
expect(result).toBe(schema.CONFIG_SCHEMA);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should return SETTINGS_SCHEMA for "settings"', () => {
|
|
41
|
+
const result = schema.getSchema('settings');
|
|
42
|
+
expect(result).toBe(schema.SETTINGS_SCHEMA);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should return QUALITY_GATE_SCHEMA for "quality-gate"', () => {
|
|
46
|
+
const result = schema.getSchema('quality-gate');
|
|
47
|
+
expect(result).toBe(schema.QUALITY_GATE_SCHEMA);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should return undefined for unknown schema name', () => {
|
|
51
|
+
const result = schema.getSchema('unknown');
|
|
52
|
+
expect(result).toBeUndefined();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should return undefined for empty string', () => {
|
|
56
|
+
const result = schema.getSchema('');
|
|
57
|
+
expect(result).toBeUndefined();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should return undefined for null', () => {
|
|
61
|
+
const result = schema.getSchema(null);
|
|
62
|
+
expect(result).toBeUndefined();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('getAllSchemas', () => {
|
|
67
|
+
it('should return all three schemas', () => {
|
|
68
|
+
const result = schema.getAllSchemas();
|
|
69
|
+
expect(Object.keys(result)).toHaveLength(3);
|
|
70
|
+
expect(result.config).toBeDefined();
|
|
71
|
+
expect(result.settings).toBeDefined();
|
|
72
|
+
expect(result['quality-gate']).toBeDefined();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should return the same schema objects as exported', () => {
|
|
76
|
+
const result = schema.getAllSchemas();
|
|
77
|
+
expect(result.config).toBe(schema.CONFIG_SCHEMA);
|
|
78
|
+
expect(result.settings).toBe(schema.SETTINGS_SCHEMA);
|
|
79
|
+
expect(result['quality-gate']).toBe(schema.QUALITY_GATE_SCHEMA);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('CONFIG_SCHEMA structure', () => {
|
|
84
|
+
it('should have correct $id', () => {
|
|
85
|
+
expect(schema.CONFIG_SCHEMA.$id).toBe('https://sumulige-claude.com/schemas/config.json');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('should use JSON Schema Draft 7', () => {
|
|
89
|
+
expect(schema.CONFIG_SCHEMA.$schema).toBe('http://json-schema.org/draft-07/schema#');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should have title', () => {
|
|
93
|
+
expect(schema.CONFIG_SCHEMA.title).toBe('Sumulige Claude Configuration');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should be object type', () => {
|
|
97
|
+
expect(schema.CONFIG_SCHEMA.type).toBe('object');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should require version field', () => {
|
|
101
|
+
expect(schema.CONFIG_SCHEMA.required).toContain('version');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('should have additionalProperties enabled', () => {
|
|
105
|
+
expect(schema.CONFIG_SCHEMA.additionalProperties).toBe(true);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('CONFIG_SCHEMA version validation', () => {
|
|
110
|
+
const versionSchema = schema.CONFIG_SCHEMA.properties.version;
|
|
111
|
+
|
|
112
|
+
it('should be string type', () => {
|
|
113
|
+
expect(versionSchema.type).toBe('string');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should have semantic version pattern', () => {
|
|
117
|
+
expect(versionSchema.pattern).toBeDefined();
|
|
118
|
+
const pattern = new RegExp(versionSchema.pattern);
|
|
119
|
+
|
|
120
|
+
// Valid versions
|
|
121
|
+
expect(pattern.test('1.0.0')).toBe(true);
|
|
122
|
+
expect(pattern.test('1.0.7')).toBe(true);
|
|
123
|
+
expect(pattern.test('2.3.4')).toBe(true);
|
|
124
|
+
expect(pattern.test('1.0.0-beta')).toBe(true);
|
|
125
|
+
expect(pattern.test('1.0.0-alpha.1')).toBe(true);
|
|
126
|
+
expect(pattern.test('1.0.0-rc.1')).toBe(true);
|
|
127
|
+
|
|
128
|
+
// Invalid versions
|
|
129
|
+
expect(pattern.test('1.0')).toBe(false);
|
|
130
|
+
expect(pattern.test('1')).toBe(false);
|
|
131
|
+
expect(pattern.test('v1.0.0')).toBe(false);
|
|
132
|
+
expect(pattern.test('1.0.0-beta_123')).toBe(false);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('CONFIG_SCHEMA model validation', () => {
|
|
137
|
+
const modelSchema = schema.CONFIG_SCHEMA.properties.model;
|
|
138
|
+
|
|
139
|
+
it('should be string type', () => {
|
|
140
|
+
expect(modelSchema.type).toBe('string');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('should have enum with valid Claude models', () => {
|
|
144
|
+
expect(modelSchema.enum).toBeDefined();
|
|
145
|
+
expect(modelSchema.enum).toContain('claude-opus-4.5');
|
|
146
|
+
expect(modelSchema.enum).toContain('claude-opus-4-20250514');
|
|
147
|
+
expect(modelSchema.enum).toContain('claude-opus-4-5-20251101');
|
|
148
|
+
expect(modelSchema.enum).toContain('claude-sonnet-4.5');
|
|
149
|
+
expect(modelSchema.enum).toContain('claude-sonnet-4-20250514');
|
|
150
|
+
expect(modelSchema.enum).toContain('claude-sonnet-4-5-20251101');
|
|
151
|
+
expect(modelSchema.enum).toContain('claude-haiku-4.5');
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe('CONFIG_SCHEMA agents validation', () => {
|
|
156
|
+
const agentsSchema = schema.CONFIG_SCHEMA.properties.agents;
|
|
157
|
+
|
|
158
|
+
it('should be object type', () => {
|
|
159
|
+
expect(agentsSchema.type).toBe('object');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('should validate agent name pattern', () => {
|
|
163
|
+
// The pattern is defined as a key in patternProperties
|
|
164
|
+
const patternKey = '^[a-z][a-z0-9-]*$';
|
|
165
|
+
expect(agentsSchema.patternProperties[patternKey]).toBeDefined();
|
|
166
|
+
|
|
167
|
+
const pattern = new RegExp(patternKey);
|
|
168
|
+
|
|
169
|
+
// Valid agent names
|
|
170
|
+
expect(pattern.test('conductor')).toBe(true);
|
|
171
|
+
expect(pattern.test('architect')).toBe(true);
|
|
172
|
+
expect(pattern.test('my-agent')).toBe(true);
|
|
173
|
+
expect(pattern.test('agent-123')).toBe(true);
|
|
174
|
+
expect(pattern.test('a')).toBe(true);
|
|
175
|
+
|
|
176
|
+
// Invalid agent names
|
|
177
|
+
expect(pattern.test('Agent')).toBe(false);
|
|
178
|
+
expect(pattern.test('123agent')).toBe(false);
|
|
179
|
+
expect(pattern.test('_agent')).toBe(false);
|
|
180
|
+
expect(pattern.test('agent_')).toBe(false);
|
|
181
|
+
expect(pattern.test('agent.name')).toBe(false);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('should require role field for agents', () => {
|
|
185
|
+
const agentSchema = agentsSchema.patternProperties['^[a-z][a-z0-9-]*$'];
|
|
186
|
+
expect(agentSchema.required).toContain('role');
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe('CONFIG_SCHEMA skills validation', () => {
|
|
191
|
+
const skillsSchema = schema.CONFIG_SCHEMA.properties.skills;
|
|
192
|
+
|
|
193
|
+
it('should be array type', () => {
|
|
194
|
+
expect(skillsSchema.type).toBe('array');
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('should validate skill repository format', () => {
|
|
198
|
+
const itemSchema = skillsSchema.items;
|
|
199
|
+
expect(itemSchema.pattern).toBeDefined();
|
|
200
|
+
const pattern = new RegExp(itemSchema.pattern);
|
|
201
|
+
|
|
202
|
+
// Valid formats
|
|
203
|
+
expect(pattern.test('anthropics/skills')).toBe(true);
|
|
204
|
+
expect(pattern.test('numman-ali/n-skills')).toBe(true);
|
|
205
|
+
expect(pattern.test('owner/repo.name')).toBe(true);
|
|
206
|
+
expect(pattern.test('Owner_123/repo-456')).toBe(true);
|
|
207
|
+
|
|
208
|
+
// Invalid formats
|
|
209
|
+
expect(pattern.test('owner')).toBe(false);
|
|
210
|
+
expect(pattern.test('owner/')).toBe(false);
|
|
211
|
+
expect(pattern.test('/repo')).toBe(false);
|
|
212
|
+
expect(pattern.test('owner/repo/extra')).toBe(false);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should require unique items', () => {
|
|
216
|
+
expect(skillsSchema.uniqueItems).toBe(true);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
describe('CONFIG_SCHEMA hooks validation', () => {
|
|
221
|
+
const hooksSchema = schema.CONFIG_SCHEMA.properties.hooks;
|
|
222
|
+
|
|
223
|
+
it('should be object type', () => {
|
|
224
|
+
expect(hooksSchema.type).toBe('object');
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('should have preTask array property', () => {
|
|
228
|
+
expect(hooksSchema.properties.preTask).toBeDefined();
|
|
229
|
+
expect(hooksSchema.properties.preTask.type).toBe('array');
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('should have postTask array property', () => {
|
|
233
|
+
expect(hooksSchema.properties.postTask).toBeDefined();
|
|
234
|
+
expect(hooksSchema.properties.postTask.type).toBe('array');
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
describe('CONFIG_SCHEMA thinkingLens validation', () => {
|
|
239
|
+
const tlSchema = schema.CONFIG_SCHEMA.properties.thinkingLens;
|
|
240
|
+
|
|
241
|
+
it('should be object type', () => {
|
|
242
|
+
expect(tlSchema.type).toBe('object');
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('should have enabled boolean property', () => {
|
|
246
|
+
expect(tlSchema.properties.enabled.type).toBe('boolean');
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('should have autoSync boolean property', () => {
|
|
250
|
+
expect(tlSchema.properties.autoSync.type).toBe('boolean');
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('should validate syncInterval range', () => {
|
|
254
|
+
const intervalSchema = tlSchema.properties.syncInterval;
|
|
255
|
+
expect(intervalSchema.type).toBe('integer');
|
|
256
|
+
expect(intervalSchema.minimum).toBe(1);
|
|
257
|
+
expect(intervalSchema.maximum).toBe(300);
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
describe('CONFIG_SCHEMA qualityGate validation', () => {
|
|
262
|
+
const qgSchema = schema.CONFIG_SCHEMA.properties.qualityGate;
|
|
263
|
+
|
|
264
|
+
it('should be object type', () => {
|
|
265
|
+
expect(qgSchema.type).toBe('object');
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('should have enabled boolean property', () => {
|
|
269
|
+
expect(qgSchema.properties.enabled.type).toBe('boolean');
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it('should validate severity enum', () => {
|
|
273
|
+
const severitySchema = qgSchema.properties.severity;
|
|
274
|
+
expect(severitySchema.enum).toEqual(['info', 'warn', 'error', 'critical']);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('should validate rules array structure', () => {
|
|
278
|
+
const rulesSchema = qgSchema.properties.rules;
|
|
279
|
+
expect(rulesSchema.type).toBe('array');
|
|
280
|
+
expect(rulesSchema.items.required).toContain('id');
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('should validate gates trigger points', () => {
|
|
284
|
+
const gatesSchema = qgSchema.properties.gates;
|
|
285
|
+
expect(gatesSchema.properties.preCommit).toBeDefined();
|
|
286
|
+
expect(gatesSchema.properties.prePush).toBeDefined();
|
|
287
|
+
expect(gatesSchema.properties.onToolUse).toBeDefined();
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('should validate reporting format enum', () => {
|
|
291
|
+
const reportingSchema = qgSchema.properties.reporting;
|
|
292
|
+
expect(reportingSchema.properties.format.enum).toEqual(['console', 'json', 'markdown', 'html']);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
describe('CONFIG_SCHEMA marketplace validation', () => {
|
|
297
|
+
const mpSchema = schema.CONFIG_SCHEMA.properties.marketplace;
|
|
298
|
+
|
|
299
|
+
it('should be object type', () => {
|
|
300
|
+
expect(mpSchema.type).toBe('object');
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('should have enabled boolean property', () => {
|
|
304
|
+
expect(mpSchema.properties.enabled.type).toBe('boolean');
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it('should have autoSync boolean property', () => {
|
|
308
|
+
expect(mpSchema.properties.autoSync.type).toBe('boolean');
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('should validate syncInterval range (1-1440 minutes)', () => {
|
|
312
|
+
const intervalSchema = mpSchema.properties.syncInterval;
|
|
313
|
+
expect(intervalSchema.type).toBe('integer');
|
|
314
|
+
expect(intervalSchema.minimum).toBe(1);
|
|
315
|
+
expect(intervalSchema.maximum).toBe(1440);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('should validate sources array', () => {
|
|
319
|
+
const sourcesSchema = mpSchema.properties.sources;
|
|
320
|
+
expect(sourcesSchema.type).toBe('array');
|
|
321
|
+
expect(sourcesSchema.items.format).toBe('uri');
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
describe('SETTINGS_SCHEMA structure', () => {
|
|
326
|
+
it('should have correct $id', () => {
|
|
327
|
+
expect(schema.SETTINGS_SCHEMA.$id).toBe('https://sumulige-claude.com/schemas/settings.json');
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('should use JSON Schema Draft 7', () => {
|
|
331
|
+
expect(schema.SETTINGS_SCHEMA.$schema).toBe('http://json-schema.org/draft-07/schema#');
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it('should have title', () => {
|
|
335
|
+
expect(schema.SETTINGS_SCHEMA.title).toBe('Project Settings');
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it('should be object type', () => {
|
|
339
|
+
expect(schema.SETTINGS_SCHEMA.type).toBe('object');
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
it('should validate hook event names', () => {
|
|
343
|
+
const patternProperties = schema.SETTINGS_SCHEMA.patternProperties;
|
|
344
|
+
const eventPattern = Object.keys(patternProperties)[0];
|
|
345
|
+
|
|
346
|
+
// The schema uses a single regex pattern for all events
|
|
347
|
+
expect(eventPattern).toBe('^(UserPromptSubmit|PreToolUse|PostToolUse|AgentStop|SessionEnd)$');
|
|
348
|
+
|
|
349
|
+
// Verify the pattern matches each event
|
|
350
|
+
const pattern = new RegExp(eventPattern);
|
|
351
|
+
expect(pattern.test('UserPromptSubmit')).toBe(true);
|
|
352
|
+
expect(pattern.test('PreToolUse')).toBe(true);
|
|
353
|
+
expect(pattern.test('PostToolUse')).toBe(true);
|
|
354
|
+
expect(pattern.test('AgentStop')).toBe(true);
|
|
355
|
+
expect(pattern.test('SessionEnd')).toBe(true);
|
|
356
|
+
|
|
357
|
+
// Verify it doesn't match invalid events
|
|
358
|
+
expect(pattern.test('InvalidEvent')).toBe(false);
|
|
359
|
+
expect(pattern.test('usereventsubmit')).toBe(false);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('should validate hook timeout range', () => {
|
|
363
|
+
// Get the first event pattern's items structure
|
|
364
|
+
const eventPattern = '^(UserPromptSubmit|PreToolUse|PostToolUse|AgentStop|SessionEnd)$';
|
|
365
|
+
const eventSchema = schema.SETTINGS_SCHEMA.patternProperties[eventPattern];
|
|
366
|
+
const hookItems = eventSchema.items.properties.hooks.items;
|
|
367
|
+
|
|
368
|
+
expect(hookItems.properties.timeout.minimum).toBe(100);
|
|
369
|
+
expect(hookItems.properties.timeout.maximum).toBe(60000);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('should validate hook type enum', () => {
|
|
373
|
+
const eventPattern = '^(UserPromptSubmit|PreToolUse|PostToolUse|AgentStop|SessionEnd)$';
|
|
374
|
+
const eventSchema = schema.SETTINGS_SCHEMA.patternProperties[eventPattern];
|
|
375
|
+
const hookItems = eventSchema.items.properties.hooks.items;
|
|
376
|
+
|
|
377
|
+
expect(hookItems.properties.type.enum).toContain('command');
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
describe('QUALITY_GATE_SCHEMA structure', () => {
|
|
382
|
+
it('should have correct $id', () => {
|
|
383
|
+
expect(schema.QUALITY_GATE_SCHEMA.$id).toBe('https://sumulige-claude.com/schemas/quality-gate.json');
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it('should use JSON Schema Draft 7', () => {
|
|
387
|
+
expect(schema.QUALITY_GATE_SCHEMA.$schema).toBe('http://json-schema.org/draft-07/schema#');
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
it('should have title', () => {
|
|
391
|
+
expect(schema.QUALITY_GATE_SCHEMA.title).toBe('Quality Gate Configuration');
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it('should be object type', () => {
|
|
395
|
+
expect(schema.QUALITY_GATE_SCHEMA.type).toBe('object');
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it('should validate severity enum with default', () => {
|
|
399
|
+
const severitySchema = schema.QUALITY_GATE_SCHEMA.properties.severity;
|
|
400
|
+
expect(severitySchema.enum).toEqual(['info', 'warn', 'error', 'critical']);
|
|
401
|
+
expect(severitySchema.default).toBe('warn');
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
it('should validate rules array structure', () => {
|
|
405
|
+
const rulesSchema = schema.QUALITY_GATE_SCHEMA.properties.rules;
|
|
406
|
+
expect(rulesSchema.type).toBe('array');
|
|
407
|
+
expect(rulesSchema.items.required).toEqual(['id']);
|
|
408
|
+
expect(rulesSchema.items.properties.enabled.default).toBe(true);
|
|
409
|
+
expect(rulesSchema.items.properties.severity.default).toBe('warn');
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it('should validate gates with defaults', () => {
|
|
413
|
+
const gatesSchema = schema.QUALITY_GATE_SCHEMA.properties.gates;
|
|
414
|
+
expect(gatesSchema.properties.preCommit.default).toBe(true);
|
|
415
|
+
expect(gatesSchema.properties.prePush.default).toBe(true);
|
|
416
|
+
expect(gatesSchema.properties.onToolUse.default).toBe(false);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it('should validate reporting format with default', () => {
|
|
420
|
+
const reportingSchema = schema.QUALITY_GATE_SCHEMA.properties.reporting;
|
|
421
|
+
expect(reportingSchema.properties.format.enum).toEqual(['console', 'json', 'markdown', 'html']);
|
|
422
|
+
expect(reportingSchema.properties.format.default).toBe('console');
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
});
|