sumulige-claude 1.5.1 → 1.5.2

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.
Files changed (219) hide show
  1. package/.claude/hooks/hook-registry.json +0 -15
  2. package/.claude/rules/coding-style.md +18 -7
  3. package/.claude/rules/hooks.md +15 -4
  4. package/.claude/rules/performance.md +15 -5
  5. package/.claude/rules/security.md +140 -4
  6. package/.claude/rules/testing.md +138 -9
  7. package/.claude/rules/web-design-standard.md +16 -5
  8. package/.claude/skills/algorithmic-art/metadata.yaml +28 -0
  9. package/.claude/skills/api-tester/SKILL.md +61 -0
  10. package/.claude/skills/api-tester/examples/basic.md +3 -0
  11. package/.claude/skills/api-tester/metadata.yaml +30 -0
  12. package/.claude/skills/api-tester/templates/default.md +3 -0
  13. package/.claude/skills/brand-guidelines/metadata.yaml +26 -0
  14. package/.claude/skills/canvas-design/metadata.yaml +27 -0
  15. package/.claude/skills/code-reviewer-123/SKILL.md +61 -0
  16. package/.claude/skills/code-reviewer-123/examples/basic.md +3 -0
  17. package/.claude/skills/code-reviewer-123/metadata.yaml +30 -0
  18. package/.claude/skills/code-reviewer-123/templates/default.md +3 -0
  19. package/.claude/skills/doc-coauthoring/metadata.yaml +27 -0
  20. package/.claude/skills/docx/metadata.yaml +30 -0
  21. package/.claude/skills/frontend-design/metadata.yaml +28 -0
  22. package/.claude/skills/internal-comms/metadata.yaml +28 -0
  23. package/.claude/skills/mcp-builder/metadata.yaml +26 -0
  24. package/.claude/skills/my-skill/SKILL.md +61 -0
  25. package/.claude/skills/my-skill/examples/basic.md +3 -0
  26. package/.claude/skills/my-skill/metadata.yaml +30 -0
  27. package/.claude/skills/my-skill/templates/default.md +3 -0
  28. package/.claude/skills/pdf/metadata.yaml +29 -0
  29. package/.claude/skills/pptx/metadata.yaml +29 -0
  30. package/.claude/skills/react-best-practices/metadata.yaml +26 -0
  31. package/.claude/skills/react-node-practices/SKILL.md +409 -0
  32. package/.claude/skills/react-node-practices/metadata.yaml +56 -0
  33. package/.claude/skills/skill-creator/metadata.yaml +25 -0
  34. package/.claude/skills/slack-gif-creator/metadata.yaml +28 -0
  35. package/.claude/skills/test-skill-name/SKILL.md +61 -0
  36. package/.claude/skills/test-skill-name/examples/basic.md +3 -0
  37. package/.claude/skills/test-skill-name/metadata.yaml +30 -0
  38. package/.claude/skills/test-skill-name/templates/default.md +3 -0
  39. package/.claude/skills/test-workflow/metadata.yaml +32 -0
  40. package/.claude/skills/theme-factory/metadata.yaml +26 -0
  41. package/.claude/skills/threejs-fundamentals/metadata.yaml +27 -0
  42. package/.claude/skills/web-artifacts-builder/metadata.yaml +30 -0
  43. package/.claude/skills/web-design-guidelines/metadata.yaml +26 -0
  44. package/.claude/skills/webapp-testing/metadata.yaml +26 -0
  45. package/.claude/skills/xlsx/metadata.yaml +29 -0
  46. package/LICENSE +21 -0
  47. package/cli.js +1 -1
  48. package/package.json +25 -3
  49. package/.claude/.kickoff-hint.txt +0 -52
  50. package/.claude/.sumulige-claude-version +0 -1
  51. package/.claude/.version +0 -1
  52. package/.claude/AGENTS.md +0 -42
  53. package/.claude/ANCHORS.md +0 -40
  54. package/.claude/CLAUDE.md +0 -138
  55. package/.claude/MEMORY.md +0 -69
  56. package/.claude/PROJECT_LOG.md +0 -101
  57. package/.claude/THINKING_CHAIN_GUIDE.md +0 -287
  58. package/.claude/USAGE.md +0 -175
  59. package/.claude/boris-optimizations.md +0 -167
  60. package/.claude/handoffs/INDEX.md +0 -21
  61. package/.claude/handoffs/LATEST.md +0 -76
  62. package/.claude/handoffs/handoff_2026-01-22T13-07-04-757Z.md +0 -76
  63. package/.claude/quality-gate.json +0 -82
  64. package/.claude/rag/skill-index.json +0 -135
  65. package/.claude/settings.json +0 -99
  66. package/.claude/settings.local.json +0 -175
  67. package/.claude/templates/PROJECT_KICKOFF.md +0 -89
  68. package/.claude/templates/PROJECT_PROPOSAL.md +0 -227
  69. package/.claude/templates/TASK_PLAN.md +0 -121
  70. package/.claude/templates/hooks/README.md +0 -302
  71. package/.claude/templates/hooks/hook.sh.template +0 -94
  72. package/.claude/templates/hooks/user-prompt-submit.cjs.template +0 -116
  73. package/.claude/templates/hooks/user-response-submit.cjs.template +0 -94
  74. package/.claude/templates/hooks/validate.js +0 -173
  75. package/.claude/templates/tasks/develop.md +0 -69
  76. package/.claude/templates/tasks/research.md +0 -64
  77. package/.claude/templates/tasks/test.md +0 -96
  78. package/.claude/thinking-routes/.last-sync +0 -1
  79. package/.claude/thinking-routes/QUICKREF.md +0 -98
  80. package/.claude/workflow/document-scanner.js +0 -426
  81. package/.claude/workflow/knowledge-engine.js +0 -941
  82. package/.claude/workflow/notebooklm/browser.js +0 -1028
  83. package/.claude/workflow/phases/phase1-research.js +0 -578
  84. package/.claude/workflow/phases/phase1-research.ts +0 -465
  85. package/.claude/workflow/phases/phase2-approve.js +0 -722
  86. package/.claude/workflow/phases/phase3-plan.js +0 -1200
  87. package/.claude/workflow/phases/phase4-develop.js +0 -894
  88. package/.claude/workflow/search-cache.js +0 -230
  89. package/.claude/workflow/templates/approval.md +0 -315
  90. package/.claude/workflow/templates/development.md +0 -377
  91. package/.claude/workflow/templates/planning.md +0 -328
  92. package/.claude/workflow/templates/research.md +0 -250
  93. package/.claude/workflow/types.js +0 -37
  94. package/.claude/workflow/web-search.js +0 -278
  95. package/.claude-plugin/marketplace.json +0 -71
  96. package/.github/workflows/sync-skills.yml +0 -74
  97. package/.versionrc +0 -25
  98. package/AGENTS.md +0 -580
  99. package/CHANGELOG.md +0 -481
  100. package/CLAUDE-template.md +0 -114
  101. package/DEV_TOOLS_GUIDE.md +0 -190
  102. package/PROJECT_STRUCTURE.md +0 -266
  103. package/Q&A.md +0 -325
  104. package/config/defaults.json +0 -34
  105. package/config/official-skills.json +0 -183
  106. package/config/quality-gate.json +0 -67
  107. package/config/skill-categories.json +0 -40
  108. package/config/version-manifest.json +0 -85
  109. package/demos/power-3d-scatter.html +0 -683
  110. package/development/cache/web-search/search_1193d605f8eb364651fc2f2041b58a31.json +0 -36
  111. package/development/cache/web-search/search_3798bf06960edc125f744a1abb5b72c5.json +0 -36
  112. package/development/cache/web-search/search_37c7d4843a53f0d83f1122a6f908a2a3.json +0 -36
  113. package/development/cache/web-search/search_44166fa0153709ee168485a22aa0ab40.json +0 -36
  114. package/development/cache/web-search/search_4deaebb1f77e86a8ca066dc5a49c59fd.json +0 -36
  115. package/development/cache/web-search/search_94da91789466070a7f545612e73c7372.json +0 -36
  116. package/development/cache/web-search/search_dd5de8491b8b803a3cb01339cd210fb0.json +0 -36
  117. package/development/knowledge-base/.index.clean.json +0 -1
  118. package/development/knowledge-base/.index.json +0 -486
  119. package/development/knowledge-base/test-best-practices.md +0 -29
  120. package/development/projects/proj_mkh1pazz_ixmt1/phase1/feasibility-report.md +0 -160
  121. package/development/projects/proj_mkh4jvnb_z7rwf/phase1/feasibility-report.md +0 -160
  122. package/development/projects/proj_mkh4jxkd_ewz5a/phase1/feasibility-report.md +0 -160
  123. package/development/projects/proj_mkh4k84n_ni73k/phase1/feasibility-report.md +0 -160
  124. package/development/projects/proj_mkh4wfyd_u9w88/phase1/feasibility-report.md +0 -160
  125. package/development/projects/proj_mkh4wsbo_iahvf/development/projects/proj_mkh4xbpg_4na5w/phase1/feasibility-report.md +0 -160
  126. package/development/projects/proj_mkh4wsbo_iahvf/phase1/feasibility-report.md +0 -160
  127. package/development/projects/proj_mkh4xulg_1ka8x/phase1/feasibility-report.md +0 -160
  128. package/development/projects/proj_mkh4xwhj_gch8j/phase1/feasibility-report.md +0 -160
  129. package/development/projects/proj_mkh4y2qk_9lm8z/phase1/feasibility-report.md +0 -160
  130. package/development/projects/proj_mkh4y2qk_9lm8z/phase2/requirements.md +0 -226
  131. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/PRD.md +0 -345
  132. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/TASK_PLAN.md +0 -284
  133. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/prototype/README.md +0 -14
  134. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/DEVELOPMENT_LOG.md +0 -35
  135. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/TASKS.md +0 -34
  136. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/.env.example +0 -5
  137. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/README.md +0 -60
  138. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/package.json +0 -25
  139. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/src/index.js +0 -70
  140. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/src/routes/index.js +0 -48
  141. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/tests/health.test.js +0 -20
  142. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/tests/jest.config.js +0 -21
  143. package/development/projects/proj_mkh7veqg_3lypc/phase1/feasibility-report.md +0 -160
  144. package/development/projects/proj_mkh7veqg_3lypc/phase2/requirements.md +0 -226
  145. package/development/projects/proj_mkh7veqg_3lypc/phase3/PRD.md +0 -345
  146. package/development/projects/proj_mkh7veqg_3lypc/phase3/TASK_PLAN.md +0 -284
  147. package/development/projects/proj_mkh7veqg_3lypc/phase3/prototype/README.md +0 -14
  148. package/development/projects/proj_mkh8k8fo_rmqn5/phase1/feasibility-report.md +0 -160
  149. package/development/projects/proj_mkh8xyhy_1vshq/phase1/feasibility-report.md +0 -178
  150. package/development/projects/proj_mkh8zddd_dhamf/phase1/feasibility-report.md +0 -377
  151. package/development/projects/proj_mkh8zddd_dhamf/phase2/requirements.md +0 -442
  152. package/development/projects/proj_mkh8zddd_dhamf/phase3/api-design.md +0 -800
  153. package/development/projects/proj_mkh8zddd_dhamf/phase3/architecture.md +0 -625
  154. package/development/projects/proj_mkh8zddd_dhamf/phase3/data-model.md +0 -830
  155. package/development/projects/proj_mkh8zddd_dhamf/phase3/risks.md +0 -957
  156. package/development/projects/proj_mkh8zddd_dhamf/phase3/wbs.md +0 -381
  157. package/development/todos/.state.json +0 -19
  158. package/development/todos/INDEX.md +0 -63
  159. package/development/todos/active/_README.md +0 -49
  160. package/development/todos/archived/_README.md +0 -11
  161. package/development/todos/backlog/_README.md +0 -11
  162. package/development/todos/backlog/mcp-integration.md +0 -35
  163. package/development/todos/completed/_README.md +0 -11
  164. package/development/todos/completed/boris-optimizations.md +0 -39
  165. package/development/todos/completed/develop/local-knowledge-index.md +0 -85
  166. package/development/todos/completed/develop/todo-system.md +0 -47
  167. package/development/todos/completed/develop/web-search-integration.md +0 -83
  168. package/development/todos/completed/test/phase1-e2e-test.md +0 -103
  169. package/docs/DEVELOPMENT.md +0 -461
  170. package/docs/MARKETPLACE.md +0 -352
  171. package/docs/RELEASE.md +0 -93
  172. package/jest.config.js +0 -63
  173. package/lib/commands.js +0 -3588
  174. package/lib/config-manager.js +0 -441
  175. package/lib/config-schema.js +0 -408
  176. package/lib/config-validator.js +0 -330
  177. package/lib/config.js +0 -122
  178. package/lib/errors.js +0 -305
  179. package/lib/incremental-sync.js +0 -274
  180. package/lib/marketplace.js +0 -487
  181. package/lib/migrations.js +0 -154
  182. package/lib/permission-audit.js +0 -255
  183. package/lib/quality-gate.js +0 -431
  184. package/lib/quality-rules.js +0 -373
  185. package/lib/utils.js +0 -150
  186. package/lib/version-check.js +0 -169
  187. package/lib/version-manifest.js +0 -171
  188. package/project-paradigm.md +0 -313
  189. package/prompts/how-to-find.md +0 -163
  190. package/prompts/linus-architect.md +0 -71
  191. package/prompts/software-architect.md +0 -173
  192. package/prompts/web-designer.md +0 -249
  193. package/scripts/fix-hooks.mjs +0 -97
  194. package/scripts/sync-external.mjs +0 -298
  195. package/scripts/sync-to-home.sh +0 -108
  196. package/scripts/update-registry.mjs +0 -325
  197. package/sources.yaml +0 -83
  198. package/tests/README.md +0 -263
  199. package/tests/commands.test.js +0 -1086
  200. package/tests/config-manager.test.js +0 -677
  201. package/tests/config-schema.test.js +0 -425
  202. package/tests/config-validator.test.js +0 -436
  203. package/tests/config.test.js +0 -100
  204. package/tests/errors.test.js +0 -477
  205. package/tests/manual/phase1-e2e.sh +0 -389
  206. package/tests/manual/phase2-test-cases.md +0 -311
  207. package/tests/manual/phase3-test-cases.md +0 -309
  208. package/tests/manual/phase4-test-cases.md +0 -414
  209. package/tests/manual/test-cases.md +0 -417
  210. package/tests/marketplace.test.js +0 -420
  211. package/tests/migrations.test.js +0 -187
  212. package/tests/quality-gate.test.js +0 -679
  213. package/tests/quality-rules.test.js +0 -619
  214. package/tests/sync-external.test.js +0 -214
  215. package/tests/update-registry.test.js +0 -251
  216. package/tests/utils.test.js +0 -171
  217. package/tests/version-check.test.js +0 -75
  218. package/tests/web-search.test.js +0 -392
  219. package/thinkinglens-silent.md +0 -138
@@ -1,330 +0,0 @@
1
- /**
2
- * Configuration Validator
3
- *
4
- * AJV-based configuration validation with detailed error reporting.
5
- * Provides structured error messages, severity levels, and auto-fix suggestions.
6
- *
7
- * @module lib/config-validator
8
- */
9
-
10
- const fs = require('fs');
11
- const path = require('path');
12
- const { CONFIG_SCHEMA, SETTINGS_SCHEMA, QUALITY_GATE_SCHEMA } = require('./config-schema');
13
- const { ConfigError, parseAJVErrors } = require('./errors');
14
-
15
- // Try to load AJV, provide fallback if not available
16
- let Ajv = null;
17
- let addFormats = null;
18
-
19
- try {
20
- Ajv = require('ajv');
21
- addFormats = require('ajv-formats');
22
- } catch {
23
- // AJV not installed - will use basic validation
24
- }
25
-
26
- /**
27
- * Configuration Validator class
28
- */
29
- class ConfigValidator {
30
- /**
31
- * @param {Object} options - Validator options
32
- * @param {boolean} options.strict - Strict mode (default: false)
33
- * @param {boolean} options.allErrors - Collect all errors (default: true)
34
- * @param {boolean} options.coerceTypes - Coerce types (default: true)
35
- * @param {boolean} options.useDefaults - Use default values (default: false)
36
- */
37
- constructor(options = {}) {
38
- this.strict = options.strict !== false;
39
- this.allErrors = options.allErrors !== false;
40
- this.coerceTypes = options.coerceTypes !== false;
41
- this.useDefaults = options.useDefaults || false;
42
-
43
- // Initialize AJV if available
44
- if (Ajv) {
45
- this.ajv = new Ajv({
46
- allErrors: this.allErrors,
47
- verbose: true,
48
- coerceTypes: this.coerceTypes,
49
- useDefaults: this.useDefaults,
50
- allowUnionTypes: true,
51
- strict: false,
52
- removeAdditional: false // Keep additional properties
53
- });
54
-
55
- // Add formats if available
56
- if (addFormats) {
57
- addFormats(this.ajv);
58
- }
59
-
60
- // Compile schemas
61
- this.configValidate = this.ajv.compile(CONFIG_SCHEMA);
62
- this.settingsValidate = this.ajv.compile(SETTINGS_SCHEMA);
63
- this.qualityGateValidate = this.ajv.compile(QUALITY_GATE_SCHEMA);
64
- } else {
65
- // Fallback: basic validation without AJV
66
- this.configValidate = null;
67
- this.settingsValidate = null;
68
- this.qualityGateValidate = null;
69
- }
70
- }
71
-
72
- /**
73
- * Validate configuration object
74
- * @param {Object} config - Configuration to validate
75
- * @param {string} schemaName - Schema name ('config' | 'settings' | 'quality-gate')
76
- * @returns {Object} Validation result
77
- */
78
- validate(config, schemaName = 'config') {
79
- // If AJV not available, do basic validation
80
- if (!this.ajv) {
81
- return this._basicValidate(config, schemaName);
82
- }
83
-
84
- const validate = this._getValidator(schemaName);
85
-
86
- if (!validate) {
87
- return {
88
- valid: false,
89
- errors: [{
90
- path: 'schema',
91
- message: `Unknown schema: ${schemaName}`,
92
- severity: 'critical',
93
- fix: `Use valid schema name: config, settings, quality-gate`
94
- }],
95
- warnings: [],
96
- fixes: []
97
- };
98
- }
99
-
100
- const valid = validate(config);
101
-
102
- if (valid) {
103
- return { valid: true, errors: [], warnings: [], fixes: [] };
104
- }
105
-
106
- // Process AJV errors
107
- const result = {
108
- valid: false,
109
- errors: [],
110
- warnings: [],
111
- fixes: []
112
- };
113
-
114
- const processedErrors = parseAJVErrors(validate.errors);
115
-
116
- for (const error of processedErrors) {
117
- if (error.severity === 'warn' || error.severity === 'info') {
118
- result.warnings.push(error);
119
- } else {
120
- result.errors.push(error);
121
- }
122
- if (error.fix) {
123
- result.fixes.push(error.fix);
124
- }
125
- }
126
-
127
- return result;
128
- }
129
-
130
- /**
131
- * Validate configuration file
132
- * @param {string} configPath - Path to config file
133
- * @param {string} schemaName - Schema name to use
134
- * @returns {Object} Validation result
135
- */
136
- validateFile(configPath, schemaName = null) {
137
- // Auto-detect schema from filename if not provided
138
- if (!schemaName) {
139
- const filename = path.basename(configPath);
140
- if (filename === 'config.json') {
141
- schemaName = 'config';
142
- } else if (filename === 'settings.json' || filename === 'settings.local.json') {
143
- schemaName = 'settings';
144
- } else if (filename === 'quality-gate.json') {
145
- schemaName = 'quality-gate';
146
- } else {
147
- schemaName = 'config';
148
- }
149
- }
150
-
151
- if (!fs.existsSync(configPath)) {
152
- return {
153
- valid: false,
154
- errors: [{
155
- path: configPath,
156
- message: 'Configuration file not found',
157
- severity: 'critical',
158
- fix: `Create config at: ${configPath}`
159
- }],
160
- warnings: [],
161
- fixes: []
162
- };
163
- }
164
-
165
- try {
166
- const content = fs.readFileSync(configPath, 'utf-8');
167
- const config = JSON.parse(content);
168
- return this.validate(config, schemaName);
169
- } catch (e) {
170
- if (e instanceof SyntaxError) {
171
- return {
172
- valid: false,
173
- errors: [{
174
- path: configPath,
175
- message: `JSON parse error: ${e.message}`,
176
- severity: 'critical',
177
- fix: this._suggestJsonFix(e, configPath)
178
- }],
179
- warnings: [],
180
- fixes: []
181
- };
182
- }
183
- throw e;
184
- }
185
- }
186
-
187
- /**
188
- * Validate with error throwing
189
- * @param {Object} config - Configuration to validate
190
- * @param {string} schemaName - Schema name
191
- * @throws {ConfigError} If validation fails
192
- */
193
- validateOrThrow(config, schemaName = 'config') {
194
- const result = this.validate(config, schemaName);
195
- if (!result.valid) {
196
- throw new ConfigError(
197
- 'Configuration validation failed',
198
- result.errors,
199
- result.fixes
200
- );
201
- }
202
- return config;
203
- }
204
-
205
- /**
206
- * Get validator for schema name
207
- * @param {string} schemaName - Schema name
208
- * @returns {Function|null} Validator function
209
- */
210
- _getValidator(schemaName) {
211
- const validators = {
212
- config: this.configValidate,
213
- settings: this.settingsValidate,
214
- 'quality-gate': this.qualityGateValidate
215
- };
216
- return validators[schemaName] || null;
217
- }
218
-
219
- /**
220
- * Basic validation without AJV
221
- * @param {Object} config - Configuration to validate
222
- * @param {string} schemaName - Schema name
223
- * @returns {Object} Validation result
224
- */
225
- _basicValidate(config, schemaName) {
226
- const result = {
227
- valid: true,
228
- errors: [],
229
- warnings: [],
230
- fixes: []
231
- };
232
-
233
- // Basic type check
234
- if (!config || typeof config !== 'object') {
235
- result.valid = false;
236
- result.errors.push({
237
- path: 'root',
238
- message: 'Configuration must be an object',
239
- severity: 'critical',
240
- fix: 'Ensure config is valid JSON object'
241
- });
242
- return result;
243
- }
244
-
245
- // Schema-specific basic validation
246
- if (schemaName === 'config') {
247
- if (!config.version) {
248
- result.valid = false;
249
- result.errors.push({
250
- path: 'version',
251
- message: 'Missing required field: version',
252
- severity: 'critical',
253
- fix: 'Add "version": "1.0.0" to config'
254
- });
255
- } else if (typeof config.version === 'string' &&
256
- !/^\d+\.\d+\.\d+/.test(config.version)) {
257
- result.valid = false;
258
- result.errors.push({
259
- path: 'version',
260
- message: 'Invalid version format',
261
- severity: 'error',
262
- expected: 'X.Y.Z',
263
- actual: config.version,
264
- fix: 'Use semantic version format (e.g., 1.0.0)'
265
- });
266
- }
267
- }
268
-
269
- return result;
270
- }
271
-
272
- /**
273
- * Suggest fix for JSON parsing errors
274
- * @param {Error} error - JSON parse error
275
- * @param {string} filePath - Path to file
276
- * @returns {string} Fix suggestion
277
- */
278
- _suggestJsonFix(error, filePath) {
279
- const match = error.message.match(/position (\d+)/);
280
- if (match) {
281
- const pos = parseInt(match[1]);
282
- try {
283
- const content = fs.readFileSync(filePath, 'utf-8');
284
- const line = content.substring(0, pos).split('\n').length;
285
- const col = pos - content.lastIndexOf('\n', pos - 1);
286
- return `Check line ${line}, column ${col} for syntax errors (missing comma, quote, bracket, etc.)`;
287
- } catch {
288
- return `Check around position ${pos} for syntax errors`;
289
- }
290
- }
291
- return 'Verify JSON syntax (commas, quotes, brackets are properly closed)';
292
- }
293
-
294
- /**
295
- * Check if AJV is available
296
- * @returns {boolean}
297
- */
298
- static isAJVAvailable() {
299
- return Ajv !== null;
300
- }
301
- }
302
-
303
- /**
304
- * Create a default validator instance
305
- */
306
- const defaultValidator = new ConfigValidator();
307
-
308
- /**
309
- * Convenience functions using default validator
310
- */
311
- function validate(config, schemaName) {
312
- return defaultValidator.validate(config, schemaName);
313
- }
314
-
315
- function validateFile(configPath, schemaName) {
316
- return defaultValidator.validateFile(configPath, schemaName);
317
- }
318
-
319
- function validateOrThrow(config, schemaName) {
320
- return defaultValidator.validateOrThrow(config, schemaName);
321
- }
322
-
323
- module.exports = {
324
- ConfigValidator,
325
- defaultValidator,
326
- validate,
327
- validateFile,
328
- validateOrThrow,
329
- isAJVAvailable: ConfigValidator.isAJVAvailable
330
- };
package/lib/config.js DELETED
@@ -1,122 +0,0 @@
1
- /**
2
- * Config - Configuration management
3
- *
4
- * Loads default config and merges with user config from ~/.claude/config.json
5
- *
6
- * v2.0: Supports new ConfigManager with validation, backup, and rollback.
7
- * Enable with SMC_USE_NEW_CONFIG=1 environment variable.
8
- */
9
-
10
- const fs = require('fs');
11
- const path = require('path');
12
- const defaults = require('../config/defaults.json');
13
-
14
- const CONFIG_DIR = path.join(process.env.HOME, '.claude');
15
- const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
16
-
17
- // Try to load new ConfigManager (v2.0)
18
- let ConfigManager = null;
19
- let newManager = null;
20
-
21
- try {
22
- ({ ConfigManager } = require('./config-manager'));
23
- } catch {
24
- // New system not available, use legacy
25
- }
26
-
27
- /**
28
- * Check if new config system should be used
29
- */
30
- function useNewSystem() {
31
- return process.env.SMC_USE_NEW_CONFIG === '1' ||
32
- process.env.SMC_CONFIG_V2 === '1' ||
33
- process.env.SMC_STRICT_CONFIG === '1';
34
- }
35
-
36
- /**
37
- * Deep merge two objects
38
- */
39
- function deepMerge(target, source) {
40
- const result = { ...target };
41
- for (const key in source) {
42
- if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
43
- result[key] = deepMerge(target[key] || {}, source[key]);
44
- } else {
45
- result[key] = source[key];
46
- }
47
- }
48
- return result;
49
- }
50
-
51
- /**
52
- * Load configuration (defaults + user overrides)
53
- * @returns {Object} Merged configuration
54
- */
55
- exports.loadConfig = function() {
56
- // Use new system if enabled and available
57
- if (useNewSystem() && ConfigManager) {
58
- if (!newManager) {
59
- newManager = new ConfigManager();
60
- }
61
- try {
62
- return newManager.load({ expandEnv: true });
63
- } catch (e) {
64
- console.warn(`[Config] ${e.message}`);
65
- if (process.env.SMC_STRICT_CONFIG === '1') {
66
- throw e;
67
- }
68
- // Fall back to legacy on validation error
69
- console.warn('[Config] Falling back to legacy config system');
70
- }
71
- }
72
-
73
- // Legacy implementation
74
- if (fs.existsSync(CONFIG_FILE)) {
75
- try {
76
- const userConfig = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'));
77
- // Deep merge: user config overrides defaults
78
- return deepMerge(defaults, userConfig);
79
- } catch (e) {
80
- console.warn('Warning: Failed to parse user config, using defaults');
81
- return defaults;
82
- }
83
- }
84
- return defaults;
85
- };
86
-
87
- /**
88
- * Save configuration to file
89
- * @param {Object} config - Configuration to save
90
- * @param {Object} options - Save options
91
- */
92
- exports.saveConfig = function(config, options = {}) {
93
- // Use new system if enabled and available
94
- if (useNewSystem() && ConfigManager) {
95
- if (!newManager) {
96
- newManager = new ConfigManager();
97
- }
98
- return newManager.save(config, options);
99
- }
100
-
101
- // Legacy implementation
102
- exports.ensureDir(CONFIG_DIR);
103
- fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
104
- return { success: true };
105
- };
106
-
107
- /**
108
- * Ensure a directory exists
109
- */
110
- exports.ensureDir = function(dir) {
111
- if (!fs.existsSync(dir)) {
112
- fs.mkdirSync(dir, { recursive: true });
113
- }
114
- };
115
-
116
- // Export constants
117
- exports.CONFIG_DIR = CONFIG_DIR;
118
- exports.CONFIG_FILE = CONFIG_FILE;
119
- exports.DEFAULTS = defaults;
120
-
121
- // Calculate derived paths
122
- exports.SKILLS_DIR = path.join(CONFIG_DIR, 'skills');