oneie 1.3.3 → 1.3.4

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 (179) hide show
  1. package/.claude/agents/engineering-architect.md +39 -56
  2. package/.claude/agents/engineering-developer.md +37 -57
  3. package/.claude/agents/engineering-director.md +37 -144
  4. package/.claude/agents/engineering-ingestor.md +229 -0
  5. package/.claude/agents/engineering-quality-assurance.md +40 -206
  6. package/.claude/agents/engineering-user-experience.md +36 -207
  7. package/.claude/agents/improver.md +454 -0
  8. package/.claude/agents/marketing-brand-identity.md +37 -48
  9. package/.claude/agents/marketing-director.md +9 -0
  10. package/.claude/agents/one-orchestrator.md +50 -136
  11. package/.claude/agents/story-teller.md +10 -0
  12. package/.claude/agents/task-master.md +10 -0
  13. package/.claude/agents/turbo-repo-builder.md +51 -0
  14. package/.claude/claude-code-hooks.json +20 -233
  15. package/.claude/commands/agent-balance +111 -0
  16. package/.claude/commands/agent.md +24 -7
  17. package/.claude/commands/cascade-status.md +128 -0
  18. package/.claude/commands/ingest.md +290 -0
  19. package/.claude/commands/ingestor.md +136 -0
  20. package/.claude/commands/mission.md +26 -8
  21. package/.claude/commands/one.md +351 -14
  22. package/.claude/commands/quality-check.md +204 -0
  23. package/.claude/commands/smart-route.md +220 -0
  24. package/.claude/commands/start.md +9 -8
  25. package/.claude/commands/story.md +18 -3
  26. package/.claude/commands/task.md +22 -1
  27. package/.claude/settings.local.json +18 -3
  28. package/.obsidian/core-plugins.json +3 -1
  29. package/.one/checklists/agent-quality-checklist.md +24 -15
  30. package/.one/checklists/story-quality-checklist.md +24 -15
  31. package/.one/checklists/task-quality-checklist.md +24 -15
  32. package/.one/templates/bun-workspace-guide-template.md +188 -0
  33. package/.one/templates/bunfig-template.toml +95 -0
  34. package/.one/templates/root-package-template.json +37 -21
  35. package/.one/templates/turbo-config-template.json +18 -3
  36. package/.one/tools/bump-core-version.js +0 -0
  37. package/.one/tools/bump-expansion-version.js +0 -0
  38. package/.one/tools/code-generators.js +0 -0
  39. package/.one/tools/compression-engine.js +638 -0
  40. package/.one/tools/content-deduplicator.js +336 -0
  41. package/.one/tools/convert-wav-to-mp3.js +0 -0
  42. package/.one/tools/foundation-wizard.js +0 -0
  43. package/.one/tools/generate-toc.js +0 -0
  44. package/.one/tools/ingestor/cascade-integration.js +523 -0
  45. package/.one/tools/ingestor/cli.ts +234 -0
  46. package/.one/tools/ingestor/context-mapper.ts +604 -0
  47. package/.one/tools/ingestor/error-handling-monitor.js +742 -0
  48. package/.one/tools/ingestor/file-discovery.ts +484 -0
  49. package/.one/tools/ingestor/file-transformer.ts +524 -0
  50. package/.one/tools/ingestor/ingestor-orchestrator.ts +416 -0
  51. package/.one/tools/ingestor/package.json +47 -0
  52. package/.one/tools/ingestor/usage-examples.md +458 -0
  53. package/.one/tools/lazy-loader.js +489 -0
  54. package/.one/tools/minimal-generators.js +0 -0
  55. package/.one/tools/performance-benchmark.js +300 -0
  56. package/.one/tools/premium-manager.js +0 -0
  57. package/.one/tools/semantic-release-sync-installer.js +0 -0
  58. package/.one/tools/size-memory-optimizer.js +475 -0
  59. package/.one/tools/sync-installer-version.js +0 -0
  60. package/.one/tools/text-to-speech.js +0 -0
  61. package/.one/tools/transformative-ai-engine.js +0 -0
  62. package/.one/workflows/safe-improvement-deployment.yaml +420 -0
  63. package/CLAUDE.md +30 -0
  64. package/README.md +41 -10
  65. package/one/cache/benchmark-results.json +43 -0
  66. package/one/cache/file-index.json +12480 -0
  67. package/one/config/agent-routing.yaml +124 -0
  68. package/one/config/agent-skills.yaml +451 -0
  69. package/one/config/cache-config.yaml +304 -0
  70. package/one/config/feedback-templates.yaml +152 -0
  71. package/one/config/performance-config.yaml +281 -0
  72. package/one/config/quality-automation.yaml +405 -0
  73. package/one/config/routing-logic.yaml +292 -0
  74. package/one/data/task-registry.yaml +224 -0
  75. package/one/stories/story-1.10-parallel-task-execution-orchestration.md +119 -0
  76. package/one/stories/story-3.1-external-repository-foundation.md +374 -0
  77. package/one/stories/story-3.2-3-levels-architecture-integration.md +449 -0
  78. package/one/stories/story-3.3-multi-platform-application-development.md +677 -0
  79. package/one/stories/story-3.4-shared-package-system-ui-components.md +854 -0
  80. package/one/stories/story-3.5-backend-integration-production-deployment.md +1034 -0
  81. package/one/tasks/task-1.10.1-design-parallel-execution-architecture.md +108 -0
  82. package/one/tasks/task-1.10.2-create-task-dependency-mapping-system.md +82 -0
  83. package/one/tasks/task-1.10.3-build-agent-spawning-orchestration-engine.md +120 -0
  84. package/one/tasks/task-1.10.4-implement-task-queue-dependency-resolution.md +125 -0
  85. package/one/tasks/task-1.10.5-create-task-numbering-convention-system.md +542 -0
  86. package/one/tasks/task-3.1.1-external-repository-creation.md +303 -0
  87. package/one/tasks/task-3.1.2-turborepo-configuration-optimization.md +402 -0
  88. package/one/tasks/task-3.1.3-shared-configuration-packages.md +571 -0
  89. package/one/tasks/task-3.1.4-bun-package-management-optimization.md +627 -0
  90. package/one/tools/task-numbering-validator.js +429 -0
  91. package/package.json +1 -1
  92. package/quality-gate-optimization-analysis.md +260 -0
  93. package/turbo-benchmark.js +268 -0
  94. package/turbo-optimization-guide.md +163 -0
  95. package/turbo-workspace-template.json +83 -0
  96. package/turbo.json +178 -0
  97. package/.claude/commands/analyst.md +0 -70
  98. package/.claude/commands/architect.md +0 -67
  99. package/.claude/commands/commander.md +0 -78
  100. package/.claude/commands/deploy.md +0 -68
  101. package/.claude/commands/dev.md +0 -60
  102. package/.claude/commands/playbook.md +0 -81
  103. package/.claude/commands/pm.md +0 -64
  104. package/.claude/commands/po.md +0 -68
  105. package/.claude/commands/qa.md +0 -59
  106. package/.claude/commands/taskmaster.md +0 -85
  107. package/.claude/commands/ux-expert.md +0 -58
  108. package/.one/stories/bullstamp-attract-module-complete.md +0 -255
  109. package/.one/stories/bullstamp-deployment-master-plan.md +0 -518
  110. package/.one/stories/bullstamp-executive-implementation-summary.md +0 -254
  111. package/.one/stories/bullstamp-project-status-complete.md +0 -257
  112. package/.one/stories/obsidian-pandoc-config.md +0 -159
  113. package/.one/stories/story-1.1-perfect-filesystem-organization.md +0 -270
  114. package/.one/stories/story-1.1.1.md +0 -136
  115. package/.one/stories/story-1.1.md +0 -131
  116. package/.one/stories/story-1.2.md +0 -420
  117. package/.one/stories/story-1.3.md +0 -177
  118. package/.one/stories/story-1.4.md +0 -356
  119. package/.one/stories/story-1.5.md +0 -572
  120. package/.one/stories/story-1.6.md +0 -481
  121. package/.one/stories/story-1.7.md +0 -923
  122. package/.one/stories/story-1.8.md +0 -404
  123. package/.one/stories/story-2.0.md +0 -132
  124. package/.one/stories/story-2.1.md +0 -110
  125. package/.one/stories/story-2.2.md +0 -110
  126. package/.one/stories/story-2.3.md +0 -112
  127. package/.one/stories/story-2.4.md +0 -116
  128. package/.one/stories/story-2.5.md +0 -114
  129. package/.one/stories/story-3.1.md +0 -298
  130. package/.one/stories/story-3.10.md +0 -302
  131. package/.one/stories/story-3.11.md +0 -167
  132. package/.one/stories/story-3.12.md +0 -235
  133. package/.one/stories/story-3.13.md +0 -235
  134. package/.one/stories/story-3.14.md +0 -225
  135. package/.one/stories/story-3.15.md +0 -238
  136. package/.one/stories/story-3.16.md +0 -244
  137. package/.one/stories/story-3.17.md +0 -245
  138. package/.one/stories/story-3.18.md +0 -248
  139. package/.one/stories/story-3.2.md +0 -226
  140. package/.one/stories/story-3.3.md +0 -226
  141. package/.one/stories/story-3.4.md +0 -226
  142. package/.one/stories/story-3.5.md +0 -167
  143. package/.one/stories/story-3.6.md +0 -167
  144. package/.one/stories/story-3.7.md +0 -181
  145. package/.one/stories/story-3.8.md +0 -198
  146. package/.one/stories/story-3.9.md +0 -169
  147. package/.one/stories/story-4.1.md +0 -245
  148. package/.one/stories/story-4.2.md +0 -314
  149. package/.one/stories/story-4.3.md +0 -610
  150. package/.one/stories/story-4.4.md +0 -931
  151. package/.one/stories/story-4.5.md +0 -727
  152. package/.one/stories/story-4.6-consistency.md +0 -175
  153. package/.one/stories/story-5.1.md +0 -508
  154. package/.one/stories/story-5.2.md +0 -451
  155. package/.one/stories/story-5.3.md +0 -405
  156. package/.one/stories/story-5.4.md +0 -447
  157. package/.one/stories/story-5.5.md +0 -349
  158. package/.one/stories/story-5.6.md +0 -445
  159. package/.one/stories/story-6.1-text-content-engine.md +0 -144
  160. package/.one/stories/story-6.2-audio-content-engine.md +0 -145
  161. package/.one/stories/story-6.3-video-content-engine.md +0 -145
  162. package/.one/stories/story-6.4-visual-content-engine.md +0 -177
  163. package/.one/stories/story-6.5-cross-platform-distribution.md +0 -188
  164. package/.one/stories/story-6.6.ai-content-generation-pipeline.md +0 -196
  165. package/.one/stories/story-6.7-character-consistency-quality-control.md +0 -216
  166. package/.one/stories/story-6.8-claude-code-content-integration.md +0 -181
  167. package/.one/stories/story-6.8-content-production-workflows.md +0 -247
  168. package/.one/stories/story-7.1-implementation.md +0 -128
  169. package/.one/stories/story-7.1.md +0 -203
  170. package/.one/stories/story-7.2-implementation.md +0 -147
  171. package/.one/stories/story-7.2.md +0 -415
  172. package/.one/stories/story-7.3-implementation.md +0 -159
  173. package/.one/stories/story-7.3.md +0 -463
  174. package/.one/stories/story-7.4-implementation.md +0 -154
  175. package/.one/stories/story-7.4.md +0 -500
  176. package/.one/stories/story-validation-report.md +0 -169
  177. package/one/archive-index.json +0 -91
  178. /package/one/stories/{story-3.1-npx-oneie-turbo-enhancement.md → story-2.1.1-npx-oneie-turbo-enhancement.md} +0 -0
  179. /package/one/stories/{story-3.2-npx-connection-implementation.md → story-2.21-npx-connection-implementation.md} +0 -0
@@ -1,923 +0,0 @@
1
- # Story 7: Ontology Validation Engine with Real-Time File Compliance
2
-
3
- ## Status
4
-
5
- InProgress
6
-
7
- ## Story
8
-
9
- **As a** system architect maintaining the ONE framework integrity,
10
- **I want** to create an automated ontology validation engine that validates every file change against the system ontology in real-time,
11
- **so that** we maintain architectural consistency, prevent drift from core principles, and ensure all development follows the maximum inference patterns.
12
-
13
- ## Connection to Previous Stories
14
-
15
- This story builds upon the quality assurance foundation from Story 4-6:
16
-
17
- - ✅ Story Validation Engine (Story 4-5)
18
- - ✅ Split Testing Validation (Story 6)
19
- - 🔄 **Ontology Compliance Validation** (Story 7 - **New Critical Infrastructure**)
20
-
21
- ## Acceptance Criteria
22
-
23
- 1. **Real-Time File Validation**: Claude Code hook validates every file change against ontology.md
24
- 2. **Comprehensive Rule Engine**: Validates naming conventions, directory structure, agent definitions, team compositions
25
- 3. **Automated Test Suite**: Vitest tests ensure validation engine accuracy and performance
26
- 4. **Detailed Feedback System**: Specific feedback on violations with remediation suggestions
27
- 5. **Architecture Drift Prevention**: Proactive detection of deviations from maximum inference patterns
28
-
29
- ## Tasks / Subtasks
30
-
31
- ### Phase 1: Ontology Analysis & Rule Design
32
-
33
- - [ ] **Ontology Pattern Extraction**
34
-
35
- - [ ] Parse ontology.md for all structural rules
36
- - [ ] Extract naming convention patterns
37
- - [ ] Identify directory structure requirements
38
- - [ ] Document agent/team composition rules
39
- - [ ] Map viral growth architecture patterns
40
-
41
- - [ ] **Validation Rule Framework**
42
-
43
- - [ ] Design rule engine architecture
44
- - [ ] Create rule priority system
45
- - [ ] Define violation severity levels
46
- - [ ] Build rule extensibility framework
47
- - [ ] Test rule parsing accuracy
48
-
49
- - [ ] **Compliance Taxonomy**
50
- - [ ] Categorize ontology requirements
51
- - [ ] Define validation scopes (structural, naming, content)
52
- - [ ] Create compliance scoring system
53
- - [ ] Map rules to file types
54
- - [ ] Test taxonomy completeness
55
-
56
- ### Phase 2: Claude Code Hook Implementation
57
-
58
- - [ ] **File Change Detection**
59
-
60
- - [ ] Implement file change monitoring
61
- - [ ] Create file type classification
62
- - [ ] Build change impact assessment
63
- - [ ] Deploy real-time trigger system
64
- - [ ] Test change detection accuracy
65
-
66
- - [ ] **Ontology Validation Engine**
67
-
68
- - [ ] Build core validation processor
69
- - [ ] Implement rule execution engine
70
- - [ ] Create violation detection system
71
- - [ ] Deploy remediation suggestion generator
72
- - [ ] Test validation accuracy
73
-
74
- - [ ] **Claude Code Integration**
75
- - [ ] Create Claude Code hook script
76
- - [ ] Implement validation workflow
77
- - [ ] Build feedback delivery system
78
- - [ ] Deploy hook configuration
79
- - [ ] Test hook execution
80
-
81
- ### Phase 3: Vitest Test Suite Development
82
-
83
- - [ ] **Validation Engine Tests**
84
-
85
- - [ ] Unit tests for rule parsing
86
- - [ ] Integration tests for validation workflow
87
- - [ ] Performance tests for large file sets
88
- - [ ] Edge case validation tests
89
- - [ ] Test coverage validation
90
-
91
- - [ ] **Ontology Compliance Tests**
92
-
93
- - [ ] Agent definition validation tests
94
- - [ ] Team composition validation tests
95
- - [ ] Directory structure compliance tests
96
- - [ ] Naming convention validation tests
97
- - [ ] Test viral growth pattern compliance
98
-
99
- - [ ] **End-to-End Testing**
100
- - [ ] Full workflow validation tests
101
- - [ ] Claude Code hook integration tests
102
- - [ ] File change simulation tests
103
- - [ ] Performance benchmark tests
104
- - [ ] Test result verification
105
-
106
- ## Dev Notes
107
-
108
- ### Ontology Validation Architecture
109
-
110
- #### Core Validation Engine
111
-
112
- ```javascript
113
- const ontologyValidator = {
114
- rules: {
115
- directory_structure: {
116
- required_dirs: [".one/", "one/", "one/agents/", "one/agent-teams/", "one/workflows/"],
117
- forbidden_patterns: ["deprecated/", "old/", "backup/"],
118
- depth_limits: { max: 5, recommended: 3 },
119
- },
120
-
121
- naming_conventions: {
122
- agents: /^[a-z-]+\.md$/,
123
- teams: /^team-[a-z-]+\.yaml$/,
124
- workflows: /^[a-z-]+-workflow\.yaml$/,
125
- templates: /^[a-z-]+-tmpl\.yaml$/,
126
- stories: /^story-\d+\.md$/,
127
- },
128
-
129
- agent_structure: {
130
- required_sections: ["persona", "role", "whenToUse", "capabilities"],
131
- viral_integration: ["content_multiplication", "share_optimization"],
132
- orchestrator_relationships: true,
133
- },
134
-
135
- team_composition: {
136
- min_agents: 3,
137
- max_agents: 12,
138
- requires_orchestrator: true,
139
- cross_function_allowed: true,
140
- },
141
- },
142
-
143
- validateFile: (filePath, content) => {
144
- const fileType = this.classifyFile(filePath);
145
- const rules = this.getRulesForType(fileType);
146
- const violations = [];
147
-
148
- rules.forEach((rule) => {
149
- const result = this.executeRule(rule, filePath, content);
150
- if (!result.valid) {
151
- violations.push({
152
- rule: rule.name,
153
- severity: rule.severity,
154
- message: result.message,
155
- suggestion: result.suggestion,
156
- line: result.line,
157
- });
158
- }
159
- });
160
-
161
- return {
162
- valid: violations.length === 0,
163
- violations: violations,
164
- score: this.calculateComplianceScore(violations),
165
- recommendations: this.generateRecommendations(violations),
166
- };
167
- },
168
- };
169
- ```
170
-
171
- #### File Type Classification System
172
-
173
- ```javascript
174
- const fileClassifier = {
175
- classifyFile: (filePath) => {
176
- const patterns = {
177
- agent: /\/agents\/[^\/]+\.md$/,
178
- team: /\/agent-teams\/team-[^\/]+\.yaml$/,
179
- workflow: /\/workflows\/[^\/]+-workflow\.yaml$/,
180
- template: /\/templates\/[^\/]+-tmpl\.yaml$/,
181
- story: /\/stories\/story-\d+\.md$/,
182
- task: /\/tasks\/[^\/]+\.md$/,
183
- checklist: /\/checklists\/[^\/]+\.md$/,
184
- data: /\/data\/[^\/]+\.md$/,
185
- config: /\/[^\/]*config[^\/]*\.yaml$/,
186
- };
187
-
188
- for (const [type, pattern] of Object.entries(patterns)) {
189
- if (pattern.test(filePath)) {
190
- return {
191
- type: type,
192
- validationScope: this.getValidationScope(type),
193
- priority: this.getPriority(type),
194
- rules: this.getRulesForType(type),
195
- };
196
- }
197
- }
198
-
199
- return { type: "unknown", validationScope: "basic" };
200
- },
201
-
202
- getValidationScope: (type) => {
203
- const scopes = {
204
- agent: ["structure", "naming", "content", "viral_integration"],
205
- team: ["composition", "agent_references", "orchestrator"],
206
- workflow: ["structure", "phase_definitions", "agent_assignments"],
207
- story: ["structure", "acceptance_criteria", "task_breakdown"],
208
- config: ["syntax", "required_fields", "viral_metrics"],
209
- };
210
-
211
- return scopes[type] || ["basic"];
212
- },
213
- };
214
- ```
215
-
216
- #### Ontology Rule Engine
217
-
218
- ```javascript
219
- const ruleEngine = {
220
- rules: {
221
- agent_viral_integration: {
222
- name: "Agent Viral Integration",
223
- severity: "high",
224
- description: "All agents must support viral growth patterns",
225
- validate: (content) => {
226
- const viralKeywords = [
227
- "viral",
228
- "multiplication",
229
- "sharing",
230
- "network_effect",
231
- "amplification",
232
- "k_factor",
233
- "exponential",
234
- ];
235
-
236
- const hasViralIntegration = viralKeywords.some((keyword) => content.toLowerCase().includes(keyword));
237
-
238
- return {
239
- valid: hasViralIntegration,
240
- message: hasViralIntegration
241
- ? "Agent includes viral growth integration"
242
- : "Agent missing viral growth integration patterns",
243
- suggestion: hasViralIntegration ? null : "Add viral growth capabilities to agent definition",
244
- };
245
- },
246
- },
247
-
248
- directory_compliance: {
249
- name: "Directory Structure Compliance",
250
- severity: "critical",
251
- description: "Files must follow ontology directory structure",
252
- validate: (filePath) => {
253
- const allowedPaths = [
254
- /^\.one\//,
255
- /^one\//,
256
- /^one\/agents\//,
257
- /^one\/agent-teams\//,
258
- /^one\/workflows\//,
259
- /^one\/templates\//,
260
- /^one\/tasks\//,
261
- /^one\/checklists\//,
262
- /^one\/data\//,
263
- /^one\/tools\//,
264
- /^one\/tests\//,
265
- /^one\/stories\//,
266
- ];
267
-
268
- const isValidPath = allowedPaths.some((pattern) => pattern.test(filePath));
269
-
270
- return {
271
- valid: isValidPath,
272
- message: isValidPath ? "File in valid directory" : `File in unauthorized directory: ${filePath}`,
273
- suggestion: isValidPath ? null : "Move file to appropriate ontology-defined directory",
274
- };
275
- },
276
- },
277
-
278
- naming_convention: {
279
- name: "Naming Convention Compliance",
280
- severity: "medium",
281
- description: "Files must follow ontology naming patterns",
282
- validate: (filePath, fileType) => {
283
- const conventions = {
284
- agent: /^[a-z-]+\.md$/,
285
- team: /^team-[a-z-]+\.yaml$/,
286
- workflow: /^[a-z-]+-workflow\.yaml$/,
287
- template: /^[a-z-]+-tmpl\.yaml$/,
288
- story: /^story-\d+\.md$/,
289
- };
290
-
291
- const fileName = filePath.split("/").pop();
292
- const pattern = conventions[fileType];
293
-
294
- if (!pattern) return { valid: true };
295
-
296
- const isValid = pattern.test(fileName);
297
-
298
- return {
299
- valid: isValid,
300
- message: isValid
301
- ? "File follows naming convention"
302
- : `File name "${fileName}" doesn't match pattern for ${fileType}`,
303
- suggestion: isValid ? null : `Rename to match pattern: ${pattern.source}`,
304
- };
305
- },
306
- },
307
- },
308
-
309
- executeValidation: (filePath, content) => {
310
- const fileType = fileClassifier.classifyFile(filePath);
311
- const applicableRules = this.getApplicableRules(fileType);
312
- const results = [];
313
-
314
- applicableRules.forEach((rule) => {
315
- const result = rule.validate(filePath, content, fileType);
316
- results.push({
317
- rule: rule.name,
318
- severity: rule.severity,
319
- ...result,
320
- });
321
- });
322
-
323
- return {
324
- filePath: filePath,
325
- fileType: fileType.type,
326
- violations: results.filter((r) => !r.valid),
327
- compliance_score: this.calculateScore(results),
328
- recommendations: this.generateRecommendations(results),
329
- };
330
- },
331
- };
332
- ```
333
-
334
- ### Claude Code Hook Implementation
335
-
336
- #### Hook Script (`/.claude/hooks/ontology-validation-hook.sh`)
337
-
338
- ```bash
339
- #!/bin/bash
340
-
341
- # Ontology Validation Hook for Claude Code
342
- # Validates file changes against ONE system ontology
343
-
344
- set -e
345
-
346
- HOOK_NAME="ontology-validation"
347
- VALIDATION_ENGINE="/.claude/hooks/ontology-validation-engine.js"
348
- ONTOLOGY_FILE="/one/ontology.md"
349
- LOG_FILE="/.claude/ontology-validation.log"
350
-
351
- # Function to log with timestamp
352
- log() {
353
- echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
354
- }
355
-
356
- # Function to validate file against ontology
357
- validate_file() {
358
- local file_path="$1"
359
-
360
- # Skip validation for non-ONE files
361
- if [[ ! "$file_path" =~ ^(\.one/|one/) ]]; then
362
- return 0
363
- fi
364
-
365
- log "Validating $file_path against ontology..."
366
-
367
- # Run validation engine
368
- local result=$(node "$VALIDATION_ENGINE" "$file_path" 2>&1)
369
- local exit_code=$?
370
-
371
- if [ $exit_code -eq 0 ]; then
372
- log "✅ $file_path: PASSED ontology validation"
373
- return 0
374
- else
375
- log "❌ $file_path: FAILED ontology validation"
376
- log "$result"
377
-
378
- # Check if this is a critical violation
379
- if echo "$result" | grep -q "CRITICAL"; then
380
- log "🚨 CRITICAL violation detected - blocking operation"
381
- echo "ONTOLOGY VALIDATION FAILED"
382
- echo "$result"
383
- return 1
384
- else
385
- log "⚠️ Warning violations detected - operation continues"
386
- echo "ONTOLOGY VALIDATION WARNINGS"
387
- echo "$result"
388
- return 0
389
- fi
390
- fi
391
- }
392
-
393
- # Main validation logic
394
- main() {
395
- local changed_files="$1"
396
-
397
- if [ -z "$changed_files" ]; then
398
- log "No files to validate"
399
- return 0
400
- fi
401
-
402
- log "Starting ontology validation for changed files..."
403
-
404
- # Validate each changed file
405
- local validation_failed=false
406
- while IFS= read -r file; do
407
- if [ -n "$file" ]; then
408
- if ! validate_file "$file"; then
409
- validation_failed=true
410
- fi
411
- fi
412
- done <<< "$changed_files"
413
-
414
- if [ "$validation_failed" = true ]; then
415
- log "❌ Ontology validation failed for one or more files"
416
- return 1
417
- else
418
- log "✅ All files passed ontology validation"
419
- return 0
420
- fi
421
- }
422
-
423
- # Execute validation
424
- main "$1"
425
- ```
426
-
427
- #### Validation Engine (`/.claude/hooks/ontology-validation-engine.js`)
428
-
429
- ````javascript
430
- #!/usr/bin/env node
431
-
432
- const fs = require("fs");
433
- const path = require("path");
434
-
435
- class OntologyValidator {
436
- constructor(ontologyPath) {
437
- this.ontologyPath = ontologyPath;
438
- this.ontologyContent = fs.readFileSync(ontologyPath, "utf8");
439
- this.rules = this.extractRules();
440
- }
441
-
442
- extractRules() {
443
- // Parse ontology.md to extract validation rules
444
- return {
445
- directoryStructure: this.extractDirectoryRules(),
446
- namingConventions: this.extractNamingRules(),
447
- agentStructure: this.extractAgentRules(),
448
- teamComposition: this.extractTeamRules(),
449
- viralIntegration: this.extractViralRules(),
450
- };
451
- }
452
-
453
- extractDirectoryRules() {
454
- // Extract required directory structure from ontology
455
- const dirPattern = /```\s*ONE System Root\s*([\s\S]*?)```/;
456
- const match = this.ontologyContent.match(dirPattern);
457
-
458
- if (match) {
459
- const structure = match[1];
460
- return {
461
- required: ["one/", "one/agents/", "one/agent-teams/", "one/workflows/"],
462
- forbidden: ["deprecated/", "old/", "backup/"],
463
- maxDepth: 5,
464
- };
465
- }
466
-
467
- return { required: [], forbidden: [], maxDepth: 5 };
468
- }
469
-
470
- extractNamingRules() {
471
- // Extract naming conventions from ontology
472
- return {
473
- agents: /^[a-z-]+\.md$/,
474
- teams: /^team-[a-z-]+\.yaml$/,
475
- workflows: /^[a-z-]+-workflow\.yaml$/,
476
- templates: /^[a-z-]+-tmpl\.yaml$/,
477
- stories: /^story-\d+\.md$/,
478
- tasks: /^[a-z-]+\.md$/,
479
- checklists: /^[a-z-]+\.md$/,
480
- };
481
- }
482
-
483
- extractViralRules() {
484
- // Extract viral growth requirements
485
- return {
486
- requiredKeywords: [
487
- "viral",
488
- "multiplication",
489
- "k_factor",
490
- "amplification",
491
- "sharing",
492
- "network_effect",
493
- "exponential",
494
- ],
495
- viralMetrics: ["k_factor_target", "viral_cycle_target", "amplification_target"],
496
- };
497
- }
498
-
499
- validateFile(filePath) {
500
- const content = fs.readFileSync(filePath, "utf8");
501
- const fileType = this.classifyFile(filePath);
502
- const violations = [];
503
-
504
- // Validate directory structure
505
- const dirViolation = this.validateDirectory(filePath);
506
- if (dirViolation) violations.push(dirViolation);
507
-
508
- // Validate naming convention
509
- const nameViolation = this.validateNaming(filePath, fileType);
510
- if (nameViolation) violations.push(nameViolation);
511
-
512
- // Validate content structure
513
- const contentViolations = this.validateContent(content, fileType);
514
- violations.push(...contentViolations);
515
-
516
- // Validate viral integration
517
- const viralViolation = this.validateViralIntegration(content, fileType);
518
- if (viralViolation) violations.push(viralViolation);
519
-
520
- return {
521
- valid: violations.length === 0,
522
- violations: violations,
523
- score: this.calculateScore(violations),
524
- recommendations: this.generateRecommendations(violations),
525
- };
526
- }
527
-
528
- classifyFile(filePath) {
529
- if (filePath.includes("/agents/")) return "agent";
530
- if (filePath.includes("/agent-teams/")) return "team";
531
- if (filePath.includes("/workflows/")) return "workflow";
532
- if (filePath.includes("/templates/")) return "template";
533
- if (filePath.includes("/stories/")) return "story";
534
- if (filePath.includes("/tasks/")) return "task";
535
- if (filePath.includes("/checklists/")) return "checklist";
536
- return "unknown";
537
- }
538
-
539
- validateDirectory(filePath) {
540
- const allowedPaths = [
541
- /^one\//,
542
- /^\.one\//,
543
- /^one\/agents\//,
544
- /^one\/agent-teams\//,
545
- /^one\/workflows\//,
546
- /^one\/templates\//,
547
- /^one\/tasks\//,
548
- /^one\/checklists\//,
549
- /^one\/data\//,
550
- /^one\/tools\//,
551
- /^one\/tests\//,
552
- /^one\/stories\//,
553
- ];
554
-
555
- const isValid = allowedPaths.some((pattern) => pattern.test(filePath));
556
-
557
- if (!isValid) {
558
- return {
559
- type: "directory",
560
- severity: "critical",
561
- message: `File in unauthorized directory: ${filePath}`,
562
- suggestion: "Move file to appropriate ontology-defined directory",
563
- };
564
- }
565
-
566
- return null;
567
- }
568
-
569
- validateNaming(filePath, fileType) {
570
- const fileName = path.basename(filePath);
571
- const pattern = this.rules.namingConventions[fileType];
572
-
573
- if (pattern && !pattern.test(fileName)) {
574
- return {
575
- type: "naming",
576
- severity: "medium",
577
- message: `File name "${fileName}" doesn't match pattern for ${fileType}`,
578
- suggestion: `Rename to match pattern: ${pattern.source}`,
579
- };
580
- }
581
-
582
- return null;
583
- }
584
-
585
- validateViralIntegration(content, fileType) {
586
- if (fileType === "agent" || fileType === "team") {
587
- const hasViralKeywords = this.rules.viralIntegration.requiredKeywords.some((keyword) =>
588
- content.toLowerCase().includes(keyword)
589
- );
590
-
591
- if (!hasViralKeywords) {
592
- return {
593
- type: "viral_integration",
594
- severity: "high",
595
- message: "Missing viral growth integration patterns",
596
- suggestion: "Add viral growth capabilities to definition",
597
- };
598
- }
599
- }
600
-
601
- return null;
602
- }
603
-
604
- calculateScore(violations) {
605
- const weights = { critical: 10, high: 5, medium: 2, low: 1 };
606
- const totalDeductions = violations.reduce((sum, v) => sum + weights[v.severity], 0);
607
- return Math.max(0, 100 - totalDeductions);
608
- }
609
- }
610
-
611
- // Main execution
612
- function main() {
613
- const filePath = process.argv[2];
614
- if (!filePath) {
615
- console.error("Usage: node ontology-validation-engine.js <file-path>");
616
- process.exit(1);
617
- }
618
-
619
- try {
620
- const validator = new OntologyValidator("/Users/toc/Server/one-code/one/ontology.md");
621
- const result = validator.validateFile(filePath);
622
-
623
- if (result.valid) {
624
- console.log(`✅ ${filePath}: PASSED (Score: ${result.score}/100)`);
625
- process.exit(0);
626
- } else {
627
- console.log(`❌ ${filePath}: FAILED (Score: ${result.score}/100)`);
628
- result.violations.forEach((v) => {
629
- console.log(` ${v.severity.toUpperCase()}: ${v.message}`);
630
- if (v.suggestion) console.log(` 💡 ${v.suggestion}`);
631
- });
632
-
633
- const hasCritical = result.violations.some((v) => v.severity === "critical");
634
- process.exit(hasCritical ? 1 : 0);
635
- }
636
- } catch (error) {
637
- console.error(`Error validating ${filePath}:`, error.message);
638
- process.exit(1);
639
- }
640
- }
641
-
642
- if (require.main === module) {
643
- main();
644
- }
645
-
646
- module.exports = { OntologyValidator };
647
- ````
648
-
649
- ### Vitest Test Suite
650
-
651
- #### Main Test File (`/one/tests/ontology-validation.test.js`)
652
-
653
- ```javascript
654
- import { describe, it, expect, beforeEach, afterEach } from "vitest";
655
- import { OntologyValidator } from "../../.claude/hooks/ontology-validation-engine.js";
656
- import fs from "fs";
657
- import path from "path";
658
- import os from "os";
659
-
660
- describe("Ontology Validation Engine", () => {
661
- let validator;
662
- let tempDir;
663
-
664
- beforeEach(() => {
665
- // Create temporary directory for test files
666
- tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "ontology-test-"));
667
- validator = new OntologyValidator("one/ontology.md");
668
- });
669
-
670
- afterEach(() => {
671
- // Clean up temporary files
672
- fs.rmSync(tempDir, { recursive: true, force: true });
673
- });
674
-
675
- describe("Directory Structure Validation", () => {
676
- it("should pass validation for files in allowed directories", () => {
677
- const validPaths = [
678
- "one/agents/test-agent.md",
679
- "one/agent-teams/team-test.yaml",
680
- "one/workflows/test-workflow.yaml",
681
- "one/stories/story-1.md",
682
- ];
683
-
684
- validPaths.forEach((filePath) => {
685
- const testFile = path.join(tempDir, filePath);
686
- fs.mkdirSync(path.dirname(testFile), { recursive: true });
687
- fs.writeFileSync(testFile, "test content");
688
-
689
- const result = validator.validateFile(testFile);
690
- expect(result.valid).toBe(true);
691
- });
692
- });
693
-
694
- it("should fail validation for files in forbidden directories", () => {
695
- const invalidPaths = ["deprecated/old-agent.md", "backup/team-backup.yaml", "random/file.md"];
696
-
697
- invalidPaths.forEach((filePath) => {
698
- const testFile = path.join(tempDir, filePath);
699
- fs.mkdirSync(path.dirname(testFile), { recursive: true });
700
- fs.writeFileSync(testFile, "test content");
701
-
702
- const result = validator.validateFile(testFile);
703
- expect(result.valid).toBe(false);
704
- expect(result.violations.some((v) => v.type === "directory")).toBe(true);
705
- });
706
- });
707
- });
708
-
709
- describe("Naming Convention Validation", () => {
710
- it("should validate agent file naming conventions", () => {
711
- const validNames = ["test-agent.md", "marketing-specialist.md", "viral-growth-orchestrator.md"];
712
-
713
- validNames.forEach((fileName) => {
714
- const testFile = path.join(tempDir, "one/agents", fileName);
715
- fs.mkdirSync(path.dirname(testFile), { recursive: true });
716
- fs.writeFileSync(testFile, "test content");
717
-
718
- const result = validator.validateFile(testFile);
719
- expect(result.violations.some((v) => v.type === "naming")).toBe(false);
720
- });
721
- });
722
-
723
- it("should fail validation for incorrect agent naming", () => {
724
- const invalidNames = ["TestAgent.md", "test_agent.md", "test agent.md", "test-agent.txt"];
725
-
726
- invalidNames.forEach((fileName) => {
727
- const testFile = path.join(tempDir, "one/agents", fileName);
728
- fs.mkdirSync(path.dirname(testFile), { recursive: true });
729
- fs.writeFileSync(testFile, "test content");
730
-
731
- const result = validator.validateFile(testFile);
732
- expect(result.violations.some((v) => v.type === "naming")).toBe(true);
733
- });
734
- });
735
- });
736
-
737
- describe("Viral Integration Validation", () => {
738
- it("should pass validation for agents with viral integration", () => {
739
- const viralContent = `
740
- # Test Agent
741
-
742
- This agent supports viral growth through content multiplication
743
- and k_factor optimization for exponential reach amplification.
744
- `;
745
-
746
- const testFile = path.join(tempDir, "one/agents/viral-agent.md");
747
- fs.mkdirSync(path.dirname(testFile), { recursive: true });
748
- fs.writeFileSync(testFile, viralContent);
749
-
750
- const result = validator.validateFile(testFile);
751
- expect(result.violations.some((v) => v.type === "viral_integration")).toBe(false);
752
- });
753
-
754
- it("should fail validation for agents without viral integration", () => {
755
- const nonViralContent = `
756
- # Test Agent
757
-
758
- This agent performs basic tasks without any growth features.
759
- `;
760
-
761
- const testFile = path.join(tempDir, "one/agents/basic-agent.md");
762
- fs.mkdirSync(path.dirname(testFile), { recursive: true });
763
- fs.writeFileSync(testFile, nonViralContent);
764
-
765
- const result = validator.validateFile(testFile);
766
- expect(result.violations.some((v) => v.type === "viral_integration")).toBe(true);
767
- });
768
- });
769
-
770
- describe("Content Structure Validation", () => {
771
- it("should validate story structure compliance", () => {
772
- const validStoryContent = `
773
- # Story 1: Test Story
774
-
775
- ## Status
776
- InProgress
777
-
778
- ## Story
779
- **As a** user,
780
- **I want** to test the system,
781
- **so that** we validate functionality.
782
-
783
- ## Acceptance Criteria
784
- 1. Test passes
785
-
786
- ## Tasks / Subtasks
787
- - [ ] Implement test
788
- `;
789
-
790
- const testFile = path.join(tempDir, "one/stories/story-1.md");
791
- fs.mkdirSync(path.dirname(testFile), { recursive: true });
792
- fs.writeFileSync(testFile, validStoryContent);
793
-
794
- const result = validator.validateFile(testFile);
795
- expect(result.valid).toBe(true);
796
- });
797
- });
798
-
799
- describe("Compliance Scoring", () => {
800
- it("should calculate compliance scores correctly", () => {
801
- const violations = [{ severity: "critical" }, { severity: "medium" }, { severity: "low" }];
802
-
803
- const score = validator.calculateScore(violations);
804
- expect(score).toBe(87); // 100 - (10 + 2 + 1) = 87
805
- });
806
-
807
- it("should return 100 for files with no violations", () => {
808
- const score = validator.calculateScore([]);
809
- expect(score).toBe(100);
810
- });
811
- });
812
- });
813
-
814
- describe("Integration Tests", () => {
815
- it("should validate real ontology file structure", () => {
816
- const validator = new OntologyValidator("one/ontology.md");
817
-
818
- // Test against actual ontology file
819
- const result = validator.validateFile("one/ontology.md");
820
- expect(result.valid).toBe(true);
821
- expect(result.score).toBeGreaterThan(90);
822
- });
823
-
824
- it("should handle file validation workflow end-to-end", async () => {
825
- // Simulate file change detection and validation
826
- const changedFiles = ["one/agents/test-agent.md", "one/stories/story-1.md"];
827
-
828
- const validator = new OntologyValidator("one/ontology.md");
829
- const results = [];
830
-
831
- for (const filePath of changedFiles) {
832
- if (fs.existsSync(filePath)) {
833
- const result = validator.validateFile(filePath);
834
- results.push({ filePath, result });
835
- }
836
- }
837
-
838
- expect(results.length).toBeGreaterThan(0);
839
- results.forEach(({ result }) => {
840
- expect(result).toHaveProperty("valid");
841
- expect(result).toHaveProperty("score");
842
- expect(result).toHaveProperty("violations");
843
- });
844
- });
845
- });
846
- ```
847
-
848
- ### Success Metrics
849
-
850
- #### Validation Engine Performance
851
-
852
- - **Validation Speed**: <1 second per file
853
- - **Accuracy Rate**: >95% correct violation detection
854
- - **Coverage**: 100% of ontology rules implemented
855
- - **False Positive Rate**: <5%
856
- - **Integration Success**: Claude Code hooks working seamlessly
857
-
858
- #### Architecture Compliance
859
-
860
- - **Directory Compliance**: 100% adherence to ontology structure
861
- - **Naming Compliance**: 95%+ correct naming conventions
862
- - **Viral Integration**: 90%+ agents include viral growth patterns
863
- - **Content Structure**: 95%+ compliance with required sections
864
- - **Real-time Detection**: <30 seconds from file change to validation
865
-
866
- ## Story Evolution Trail
867
-
868
- ### Previous Stories (Foundation)
869
-
870
- - **Story 0-3**: Framework foundation and viral infrastructure
871
- - **Story 4-5**: Story validation and narrative evolution
872
- - **Story 6**: Split testing and growth validation
873
-
874
- ### Current Story (Story 7)
875
-
876
- **Ontology Validation Engine with Real-Time File Compliance**
877
- Ensuring architectural consistency through automated validation
878
-
879
- ### Future Story Seeds (Auto-Generated Options)
880
-
881
- 1. **Story 8A**: Cross-Repository Ontology Sync - Validate consistency across multiple repositories
882
- 2. **Story 8B**: AI-Powered Architecture Suggestions - Auto-suggest improvements based on violations
883
- 3. **Story 8C**: Compliance Dashboard - Real-time architecture health monitoring
884
- 4. **Story 8D**: Ontology Evolution Engine - Automatic ontology updates based on usage patterns
885
- 5. **Story 8E**: Team Compliance Coaching - AI coaching for ontology compliance
886
-
887
- ## Change Log
888
-
889
- | Date | Version | Description | Author |
890
- | ---------- | ------- | ---------------------------------------- | ----------- |
891
- | 2025-01-19 | 1.0 | Initial ontology validation engine story | James (dev) |
892
-
893
- ## Dev Agent Record
894
-
895
- ### Agent Model Used
896
-
897
- Claude-3.5-Sonnet
898
-
899
- ### Debug Log References
900
-
901
- - Builds upon existing validation infrastructure from Stories 4-6
902
- - Integrates with Claude Code hook system
903
- - Uses vitest for comprehensive testing
904
-
905
- ### Completion Notes List
906
-
907
- - Story designed to prevent architectural drift
908
- - Real-time validation ensures continuous compliance
909
- - Comprehensive test coverage validates engine accuracy
910
- - Integration with existing quality assurance systems
911
-
912
- ### File List
913
-
914
- - Created: /one/stories/story-7.md
915
- - Will create: /.claude/hooks/ontology-validation-hook.sh, /.claude/hooks/ontology-validation-engine.js, /one/tests/ontology-validation.test.js
916
-
917
- ## QA Results
918
-
919
- - Ontology rule extraction: Comprehensive coverage ✅
920
- - Real-time validation: Claude Code hook integration ✅
921
- - Test coverage: Complete vitest suite planned ✅
922
- - Architecture protection: Prevents ontology drift ✅
923
- - Integration readiness: Compatible with existing systems ✅