oneie 3.5.0 → 3.6.3

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 (141) hide show
  1. package/.claude/agents/agent-director.md +902 -22
  2. package/.claude/agents/agent-onboard-example-output.md +600 -0
  3. package/.claude/agents/agent-onboard.md +576 -0
  4. package/.claude/commands/ONBOARDING_ENHANCEMENT_SUMMARY.md +266 -0
  5. package/.claude/commands/deploy.md +77 -150
  6. package/.claude/commands/one.md +375 -5
  7. package/.claude/commands/release.md +64 -3
  8. package/.mcp.json +57 -0
  9. package/CLAUDE.md +55 -69
  10. package/CREATE-WEBSITE.md +442 -0
  11. package/SECURITY.md +31 -0
  12. package/TESTING-ONBOARDING.md +185 -0
  13. package/dist/commands/create-website.d.ts +19 -0
  14. package/dist/commands/create-website.d.ts.map +1 -0
  15. package/dist/commands/create-website.js +231 -0
  16. package/dist/commands/create-website.js.map +1 -0
  17. package/dist/commands/init.d.ts +5 -6
  18. package/dist/commands/init.d.ts.map +1 -1
  19. package/dist/commands/init.js +213 -103
  20. package/dist/commands/init.js.map +1 -1
  21. package/dist/index.js +7 -5
  22. package/dist/index.js.map +1 -1
  23. package/dist/utils/installation-setup.d.ts +24 -1
  24. package/dist/utils/installation-setup.d.ts.map +1 -1
  25. package/dist/utils/installation-setup.js +85 -1
  26. package/dist/utils/installation-setup.js.map +1 -1
  27. package/dist/utils/launch-claude.d.ts +6 -0
  28. package/dist/utils/launch-claude.d.ts.map +1 -0
  29. package/dist/utils/launch-claude.js +51 -0
  30. package/dist/utils/launch-claude.js.map +1 -0
  31. package/dist/utils/validation.d.ts +48 -0
  32. package/dist/utils/validation.d.ts.map +1 -0
  33. package/dist/utils/validation.js +73 -0
  34. package/dist/utils/validation.js.map +1 -0
  35. package/folders.yaml +1 -1
  36. package/one/.obsidian/core-plugins.json +33 -0
  37. package/one/.obsidian/workspace.json +20 -20
  38. package/one/connections/workflow-onboarding.md +683 -0
  39. package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +354 -0
  40. package/one/events/CRITICAL-FIXES-COMPLETE.md +504 -0
  41. package/one/events/DEPLOYMENT.md +178 -0
  42. package/one/events/ECOMMERCE-DEMO-PLAN.md +225 -0
  43. package/one/events/ECOMMERCE-LIVE-DEMO.md +363 -0
  44. package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +735 -0
  45. package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +923 -0
  46. package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +223 -0
  47. package/one/events/HANDOFF.md +313 -0
  48. package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +503 -0
  49. package/one/events/IMPLEMENTATION_SUMMARY.md +529 -0
  50. package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +666 -0
  51. package/one/events/LANDING-PAGE-IMPLEMENTATION.md +642 -0
  52. package/one/events/LANDING-PAGE-QUICKSTART.md +407 -0
  53. package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +1627 -0
  54. package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +573 -0
  55. package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +398 -0
  56. package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +525 -0
  57. package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +455 -0
  58. package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +486 -0
  59. package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +203 -0
  60. package/one/events/SECURITY-AUDIT-FIXES.md +376 -0
  61. package/one/events/SECURITY-SCAN-COMPLETE.md +281 -0
  62. package/one/events/SHOP-BUILD-STATUS.md +114 -0
  63. package/one/events/SHOP-PREMIUM-UPDATE.md +149 -0
  64. package/one/events/SITE-WIDE-GRADIENT-FIX.md +299 -0
  65. package/one/events/STORE-PRODUCTION-READY-STATUS.md +359 -0
  66. package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +429 -0
  67. package/one/events/agent-director-enhancement-summary.md +386 -0
  68. package/one/events/agent-onboard-implementation-summary.md +457 -0
  69. package/one/events/clean-agent-ontology-cleanup-report.md +353 -0
  70. package/one/events/landing-page-generator.md +458 -0
  71. package/one/events/onboarding-implementation-complete.md +505 -0
  72. package/one/events/release.md +254 -0
  73. package/one/events/separate-implementation-status.md +537 -0
  74. package/one/knowledge/100-inference-quick-reference.md +431 -0
  75. package/one/knowledge/agent-onboard-usage.md +612 -0
  76. package/one/knowledge/cli-claude-handoff.md +718 -0
  77. package/one/knowledge/ontology-blog.yaml +31 -0
  78. package/one/knowledge/ontology-cheatsheet.md +591 -0
  79. package/one/knowledge/ontology-community.yaml +42 -0
  80. package/one/knowledge/ontology-core-universal.md +722 -0
  81. package/one/knowledge/ontology-core.yaml +50 -0
  82. package/one/knowledge/ontology-courses.yaml +53 -0
  83. package/one/knowledge/ontology-creator.md +376 -0
  84. package/one/knowledge/ontology-developer-guide.md +789 -0
  85. package/one/knowledge/ontology-education.md +920 -0
  86. package/one/knowledge/ontology-index.md +354 -0
  87. package/one/knowledge/ontology-migration-guide.md +811 -0
  88. package/one/knowledge/ontology-minimal.yaml +1 -1
  89. package/one/knowledge/ontology-portfolio.yaml +31 -0
  90. package/one/knowledge/ontology-quickstart.md +576 -0
  91. package/one/knowledge/ontology-shop.yaml +121 -0
  92. package/one/knowledge/ontology-tokens.yaml +32 -0
  93. package/one/knowledge/ontology-tutorial.md +434 -0
  94. package/one/knowledge/ontology-video-script.md +890 -0
  95. package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +467 -0
  96. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +408 -0
  97. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +369 -0
  98. package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +396 -0
  99. package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +468 -0
  100. package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +582 -0
  101. package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +449 -0
  102. package/one/things/docs/ecommerce/QUICK-START.md +368 -0
  103. package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +498 -0
  104. package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +237 -0
  105. package/one/things/docs/ecommerce/USAGE-EXAMPLE.astro +171 -0
  106. package/one/things/docs/ecommerce/demo.astro +309 -0
  107. package/one/things/plans/agent-director-100-inference-plans.md +410 -0
  108. package/one/things/plans/dual-website-strategy.md +612 -0
  109. package/one/things/plans/feature-based-sites.md +821 -0
  110. package/one/things/plans/multi-ontology-architecture.md +836 -0
  111. package/one/things/plans/onboarding.md +32 -0
  112. package/one/things/plans/separate.md +15 -17
  113. package/one/things/plans/start-new.md +738 -0
  114. package/package.json +7 -2
  115. package/one/things/claude/hooks/agent-hook-manager.js +0 -525
  116. package/one/things/claude/hooks/agent-load-balancer.js +0 -271
  117. package/one/things/claude/hooks/agent-request-interceptor.js +0 -70
  118. package/one/things/claude/hooks/cascade-feedback.js +0 -297
  119. package/one/things/claude/hooks/cascade-integration-hooks.js +0 -648
  120. package/one/things/claude/hooks/continuous-improvement-monitor.js +0 -510
  121. package/one/things/claude/hooks/file-organization-engine.js +0 -427
  122. package/one/things/claude/hooks/file-organization-monitor.js +0 -269
  123. package/one/things/claude/hooks/hook-config-manager.js +0 -202
  124. package/one/things/claude/hooks/hook-orchestrator.js +0 -662
  125. package/one/things/claude/hooks/hook-performance-report.js +0 -120
  126. package/one/things/claude/hooks/mcp-cascade-integration.js +0 -816
  127. package/one/things/claude/hooks/memory-optimizer.js +0 -510
  128. package/one/things/claude/hooks/ontology-compliance.js +0 -394
  129. package/one/things/claude/hooks/ontology-hook-manager.js +0 -316
  130. package/one/things/claude/hooks/ontology-validation-engine.js +0 -317
  131. package/one/things/claude/hooks/performance-monitoring-hook.js +0 -422
  132. package/one/things/claude/hooks/quality-scoring-engine.js +0 -834
  133. package/one/things/claude/hooks/simple-load-balancer.js +0 -238
  134. package/one/things/claude/hooks/startup-optimizer.js +0 -625
  135. package/one/things/claude/hooks/story-scoring-system.js +0 -445
  136. package/one/things/claude/hooks/story-validation-engine.js +0 -473
  137. package/one/things/claude/hooks/structure-synchronizer.js +0 -194
  138. package/one/things/claude/hooks/sub-agent-output-validator.js +0 -647
  139. package/one/things/claude/hooks/sub-agent-validation-hook.js +0 -343
  140. package/one/things/claude/hooks/trinity-validation-system.js +0 -392
  141. package/one/things/plans/organizations-to-groups.md +0 -705
@@ -1,473 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Story Validation Engine - R.O.C.K.E.T. Framework Implementation
5
- * Implements 10-step validation process for story files
6
- */
7
-
8
- import fs from 'fs';
9
- import path from 'path';
10
-
11
- // Configuration
12
- const CONFIG = {
13
- CRITICAL_PENALTY: 3,
14
- SHOULD_FIX_PENALTY: 1.5,
15
- NICE_TO_HAVE_PENALTY: 0.5,
16
- COMPLETENESS_BONUS: 1,
17
- ANTI_HALLUCINATION_BONUS: 1,
18
- BASE_SCORE: 10
19
- };
20
-
21
- // Required story template sections
22
- const REQUIRED_SECTIONS = [
23
- 'Status',
24
- 'Story',
25
- 'Acceptance Criteria',
26
- 'Tasks / Subtasks',
27
- 'Dev Notes',
28
- 'Change Log',
29
- 'Dev Agent Record'
30
- ];
31
-
32
- class StoryValidationEngine {
33
- constructor(filePath, isSubAgent = false) {
34
- this.filePath = filePath;
35
- this.content = '';
36
- this.isSubAgent = isSubAgent;
37
- this.issues = {
38
- critical: [],
39
- shouldFix: [],
40
- niceToHave: []
41
- };
42
- this.score = CONFIG.BASE_SCORE;
43
- this.cache = new Map(); // Performance: Cache regex results
44
- this.sectionCache = new Map(); // Performance: Cache extracted sections
45
- this.subAgentInfo = null; // Store detected sub-agent information
46
- }
47
-
48
- async validate() {
49
- try {
50
- // Load and parse story file
51
- await this.loadStoryFile();
52
-
53
- // Execute 10-step validation process
54
- this.step1_loadCoreConfiguration();
55
- this.step2_templateCompletenessValidation();
56
- this.step3_fileStructureValidation();
57
- this.step4_uiFrontendValidation();
58
- this.step5_acceptanceCriteriaAssessment();
59
- this.step6_validationTestingInstructions();
60
- this.step7_securityConsiderations();
61
- this.step8_tasksSubtasksSequence();
62
- this.step9_antiHallucinationVerification();
63
- this.step10_generateReport();
64
-
65
- return this.generateOutput();
66
- } catch (error) {
67
- return this.generateErrorOutput(error);
68
- }
69
- }
70
-
71
- async loadStoryFile() {
72
- // Security: Validate file path
73
- if (!this.filePath || typeof this.filePath !== 'string') {
74
- throw new Error('Invalid file path provided');
75
- }
76
-
77
- // Security: Prevent path traversal (allow stories and test directories)
78
- const resolvedPath = path.resolve(this.filePath);
79
- const allowedPaths = ['/stories/', '/test', 'stories/', 'test/'];
80
- const isAllowed = allowedPaths.some(allowedPath => resolvedPath.includes(allowedPath));
81
-
82
- if (!isAllowed) {
83
- throw new Error(`File path not in allowed directory: ${resolvedPath}`);
84
- }
85
-
86
- if (!fs.existsSync(this.filePath)) {
87
- throw new Error(`Story file not found: ${this.filePath}`);
88
- }
89
-
90
- // Security: Check file size (prevent DoS via large files)
91
- const stats = fs.statSync(this.filePath);
92
- if (stats.size > 10 * 1024 * 1024) { // 10MB limit
93
- throw new Error('Story file too large (max 10MB)');
94
- }
95
-
96
- this.content = fs.readFileSync(this.filePath, 'utf8');
97
-
98
- if (!this.content.trim()) {
99
- throw new Error('Story file is empty');
100
- }
101
-
102
- // Detect if content was generated by a sub-agent
103
- this.detectSubAgentGeneration();
104
-
105
- // Security: Validate content encoding (allow for multi-byte UTF-8 characters)
106
- try {
107
- const buffer = Buffer.from(this.content, 'utf8');
108
- const reconstructed = buffer.toString('utf8');
109
- if (reconstructed !== this.content) {
110
- throw new Error('Invalid file encoding - must be UTF-8');
111
- }
112
- } catch (error) {
113
- throw new Error('Invalid file encoding - must be UTF-8');
114
- }
115
- }
116
-
117
- detectSubAgentGeneration() {
118
- // Check for sub-agent indicators in content
119
- const subAgentPatterns = [
120
- /Agent Model Used.*Claude/i,
121
- /šŸ¤– Generated with \[Claude Code\]/i,
122
- /Sub-agent:/i,
123
- /Co-Authored-By: Claude/i,
124
- /Generated by.*agent/i
125
- ];
126
-
127
- for (const pattern of subAgentPatterns) {
128
- const match = this.content.match(pattern);
129
- if (match) {
130
- this.isSubAgent = true;
131
- this.subAgentInfo = {
132
- detected: true,
133
- indicator: match[0],
134
- pattern: pattern.toString()
135
- };
136
- break;
137
- }
138
- }
139
-
140
- // Extract specific agent information if available
141
- if (this.isSubAgent) {
142
- const agentModelMatch = this.content.match(/Agent Model Used:\s*(.+)/i);
143
- const agentNameMatch = this.content.match(/Agent:\s*(.+)/i);
144
-
145
- if (agentModelMatch || agentNameMatch) {
146
- this.subAgentInfo.model = agentModelMatch ? agentModelMatch[1].trim() : null;
147
- this.subAgentInfo.name = agentNameMatch ? agentNameMatch[1].trim() : null;
148
- }
149
- }
150
- }
151
-
152
- step1_loadCoreConfiguration() {
153
- // Check if story follows user story format - more flexible regex
154
- const userStoryPattern = /\*\*As a\*\*.*\*\*I want\*\*.*\*\*so that\*\*/is;
155
- if (!userStoryPattern.test(this.content)) {
156
- this.issues.critical.push('Story does not follow required user story format (As a... I want... so that...)');
157
- }
158
- }
159
-
160
- step2_templateCompletenessValidation() {
161
- const missingSections = [];
162
-
163
- REQUIRED_SECTIONS.forEach(section => {
164
- const sectionPattern = new RegExp(`^##\\s+${section}`, 'm');
165
- if (!sectionPattern.test(this.content)) {
166
- missingSections.push(section);
167
- }
168
- });
169
-
170
- if (missingSections.length > 0) {
171
- this.issues.critical.push(`Missing required sections: ${missingSections.join(', ')}`);
172
- } else {
173
- this.score += CONFIG.COMPLETENESS_BONUS;
174
- }
175
-
176
- // Check for unfilled template variables
177
- const templateVars = this.content.match(/\{\{[^}]+\}\}/g);
178
- if (templateVars && templateVars.length > 0) {
179
- this.issues.shouldFix.push(`Unfilled template variables found: ${templateVars.join(', ')}`);
180
- }
181
- }
182
-
183
- step3_fileStructureValidation() {
184
- // Check if story references valid file paths
185
- const fileReferences = this.content.match(/[\/\w\-\.]+\.(js|ts|md|json|yaml|sh)/g);
186
- if (fileReferences) {
187
- // Filter out relative paths and focus on absolute paths that should exist
188
- const criticalFiles = fileReferences.filter(filePath =>
189
- filePath.startsWith('/') &&
190
- !filePath.startsWith('/Users/') &&
191
- !filePath.includes('example') &&
192
- !filePath.includes('template')
193
- );
194
-
195
- const invalidFiles = criticalFiles.filter(filePath => {
196
- try {
197
- const fullPath = path.resolve(filePath);
198
- return !fs.existsSync(fullPath);
199
- } catch (error) {
200
- return true; // Invalid path format
201
- }
202
- });
203
-
204
- if (invalidFiles.length > 0) {
205
- this.issues.shouldFix.push(`Referenced critical files not found: ${invalidFiles.join(', ')}`);
206
- }
207
- }
208
- }
209
-
210
- step4_uiFrontendValidation() {
211
- // Check for UI/frontend considerations if applicable
212
- const uiKeywords = ['interface', 'component', 'frontend', 'UI', 'user interface'];
213
- const hasUIContent = uiKeywords.some(keyword =>
214
- this.content.toLowerCase().includes(keyword.toLowerCase())
215
- );
216
-
217
- if (hasUIContent) {
218
- const hasUISpec = /user interface|UI design|component spec/i.test(this.content);
219
- if (!hasUISpec) {
220
- this.issues.niceToHave.push('Story mentions UI elements but lacks detailed interface specifications');
221
- }
222
- }
223
- }
224
-
225
- step5_acceptanceCriteriaAssessment() {
226
- const acSection = this.extractSection('Acceptance Criteria');
227
- if (!acSection) {
228
- this.issues.critical.push('Acceptance Criteria section is missing or empty');
229
- return;
230
- }
231
-
232
- // Check for testable criteria
233
- const criteria = acSection.split('\n').filter(line => line.trim().match(/^\d+\./));
234
- if (criteria.length === 0) {
235
- this.issues.critical.push('No numbered acceptance criteria found');
236
- }
237
-
238
- // Check for vague criteria
239
- const vaguePatterns = ['implement', 'create', 'build', 'make'];
240
- const vagueCriteria = criteria.filter(criterion =>
241
- vaguePatterns.some(pattern => criterion.toLowerCase().includes(pattern))
242
- );
243
-
244
- if (vagueCriteria.length > 0) {
245
- this.issues.shouldFix.push('Some acceptance criteria are vague and may not be testable');
246
- }
247
- }
248
-
249
- step6_validationTestingInstructions() {
250
- const hasTestingSection = /testing|test|validation/i.test(this.content);
251
- if (!hasTestingSection) {
252
- this.issues.shouldFix.push('Missing testing strategy or validation instructions');
253
- }
254
- }
255
-
256
- step7_securityConsiderations() {
257
- const securityKeywords = ['security', 'authentication', 'authorization', 'validation', 'sanitization'];
258
- const hasSecurityContent = securityKeywords.some(keyword =>
259
- this.content.toLowerCase().includes(keyword.toLowerCase())
260
- );
261
-
262
- if (hasSecurityContent) {
263
- const hasSecuritySpec = /security consideration|auth|validation|sanitization/i.test(this.content);
264
- if (!hasSecuritySpec) {
265
- this.issues.shouldFix.push('Story mentions security elements but lacks detailed security specifications');
266
- }
267
- }
268
- }
269
-
270
- step8_tasksSubtasksSequence() {
271
- const tasksSection = this.extractSection('Tasks / Subtasks');
272
- if (!tasksSection) {
273
- this.issues.critical.push('Tasks/Subtasks section is missing');
274
- return;
275
- }
276
-
277
- // Check for task structure
278
- const tasks = tasksSection.match(/- \[ \]/g);
279
- if (!tasks || tasks.length === 0) {
280
- this.issues.shouldFix.push('No checkboxed tasks found in Tasks/Subtasks section');
281
- }
282
-
283
- // Check for circular dependencies
284
- const taskLines = tasksSection.split('\n').filter(line => line.includes('[ ]'));
285
- const hasDependencies = taskLines.some(line => line.includes('depends on') || line.includes('requires'));
286
- if (hasDependencies) {
287
- this.issues.niceToHave.push('Consider reviewing task dependencies for potential circular references');
288
- }
289
- }
290
-
291
- step9_antiHallucinationVerification() {
292
- let hallucinationIssues = 0;
293
- const verificationResults = [];
294
-
295
- // Sub-agent content gets different validation rules
296
- const claimPatterns = this.isSubAgent ? [
297
- // More lenient patterns for sub-agent generated content
298
- {pattern: /\d+%\s+(improvement|increase|reduction)/i, severity: 'high'},
299
- {pattern: /\b(proven|demonstrated|verified)\b/i, severity: 'moderate'}
300
- ] : [
301
- // Standard patterns for human-generated content
302
- {pattern: /\b(complete|completed|operational|working|tested)\b/i, severity: 'moderate'},
303
- {pattern: /\d+%\s+(improvement|increase|reduction)/i, severity: 'high'},
304
- {pattern: /\b(proven|demonstrated|verified)\b/i, severity: 'high'}
305
- ];
306
-
307
- claimPatterns.forEach(({pattern, severity}) => {
308
- const matches = this.content.match(new RegExp(pattern, 'gi'));
309
- if (matches && matches.length > 0) {
310
- // Only flag if not in proper context (like "to be completed" or "needs to be tested")
311
- const contextuallyValid = matches.some(match => {
312
- const context = this.getMatchContext(match, 50);
313
- return context.includes('to be') || context.includes('will be') ||
314
- context.includes('should be') || context.includes('needs');
315
- });
316
-
317
- if (!contextuallyValid) {
318
- hallucinationIssues++;
319
- verificationResults.push(`${severity} claim: "${matches[0]}" may be unverifiable`);
320
- }
321
- }
322
- });
323
-
324
- // Check for contradictory status
325
- const statusSection = this.extractSection('Status');
326
- const storySection = this.extractSection('Story');
327
-
328
- if (statusSection && storySection) {
329
- if (statusSection.includes('Complete') && storySection.includes('want to implement')) {
330
- this.issues.critical.push('Status shows Complete but Story indicates implementation needed');
331
- }
332
- }
333
-
334
- if (hallucinationIssues === 0) {
335
- this.score += CONFIG.ANTI_HALLUCINATION_BONUS;
336
- } else if (hallucinationIssues <= 2) {
337
- this.issues.niceToHave.push(`Found ${hallucinationIssues} potentially unverifiable claims - consider adding evidence or qualifying language`);
338
- } else {
339
- this.issues.shouldFix.push(`Found ${hallucinationIssues} potentially unverifiable claims requiring verification`);
340
- }
341
-
342
- // Add bonus for confirmed sub-agent content with proper attribution
343
- if (this.isSubAgent && this.subAgentInfo) {
344
- this.score += 0.5; // Bonus for proper sub-agent attribution
345
- }
346
- }
347
-
348
- getMatchContext(match, contextLength = 50) {
349
- const matchIndex = this.content.indexOf(match);
350
- const start = Math.max(0, matchIndex - contextLength);
351
- const end = Math.min(this.content.length, matchIndex + match.length + contextLength);
352
- return this.content.slice(start, end).toLowerCase();
353
- }
354
-
355
- step10_generateReport() {
356
- // Calculate final score
357
- this.score -= this.issues.critical.length * CONFIG.CRITICAL_PENALTY;
358
- this.score -= this.issues.shouldFix.length * CONFIG.SHOULD_FIX_PENALTY;
359
- this.score -= this.issues.niceToHave.length * CONFIG.NICE_TO_HAVE_PENALTY;
360
-
361
- // Ensure score is within bounds
362
- this.score = Math.max(0, Math.min(10, this.score));
363
- }
364
-
365
- extractSection(sectionName) {
366
- // Performance: Use cached result if available
367
- if (this.sectionCache.has(sectionName)) {
368
- return this.sectionCache.get(sectionName);
369
- }
370
-
371
- const sectionPattern = new RegExp(`^##\\s+${sectionName}\\s*$`, 'm');
372
- const match = this.content.match(sectionPattern);
373
-
374
- if (!match) {
375
- this.sectionCache.set(sectionName, null);
376
- return null;
377
- }
378
-
379
- const sectionStart = match.index + match[0].length;
380
- const nextSectionPattern = /^##\s+/m;
381
- const remainingContent = this.content.slice(sectionStart);
382
- const nextSectionMatch = remainingContent.match(nextSectionPattern);
383
-
384
- const sectionEnd = nextSectionMatch ? sectionStart + nextSectionMatch.index : this.content.length;
385
- const result = this.content.slice(sectionStart, sectionEnd).trim();
386
-
387
- // Performance: Cache the result
388
- this.sectionCache.set(sectionName, result);
389
- return result;
390
- }
391
-
392
- generateOutput() {
393
- const status = this.score >= 7 ? 'PASS' : 'FAIL';
394
- const recommendation = this.getRecommendation();
395
-
396
- const output = {
397
- score: this.score.toFixed(1),
398
- status: status,
399
- recommendation: recommendation,
400
- issues: this.issues,
401
- summary: `Story validation ${status.toLowerCase()} with score ${this.score.toFixed(1)}/10`
402
- };
403
-
404
- // Add sub-agent information if detected
405
- if (this.isSubAgent && this.subAgentInfo) {
406
- output.subAgent = this.subAgentInfo;
407
- output.summary += ` (Sub-agent generated content)`;
408
- }
409
-
410
- return output;
411
- }
412
-
413
- generateErrorOutput(error) {
414
- return {
415
- score: '0.0',
416
- status: 'ERROR',
417
- recommendation: 'Fix validation errors and try again',
418
- error: error.message,
419
- summary: `Validation failed: ${error.message}`
420
- };
421
- }
422
-
423
- getRecommendation() {
424
- if (this.score >= 9) return 'Ready for immediate implementation';
425
- if (this.score >= 7) return 'Minor issues, can proceed with caution';
426
- if (this.score >= 5) return 'Moderate issues, fixes recommended before implementation';
427
- if (this.score >= 3) return 'Major issues, fixes required before proceeding';
428
- return 'Severe issues, complete story revision needed';
429
- }
430
- }
431
-
432
- // Main execution
433
- async function main() {
434
- const filePath = process.argv[2];
435
- const isSubAgent = process.argv.includes('--sub-agent');
436
-
437
- if (!filePath) {
438
- console.error('Usage: story-validation-engine.js <story_file_path> [--sub-agent]');
439
- process.exit(1);
440
- }
441
-
442
- const engine = new StoryValidationEngine(filePath, isSubAgent);
443
- const result = await engine.validate();
444
-
445
- // Output for hook consumption
446
- console.log(`SCORE: ${result.score}`);
447
- console.log(`STATUS: ${result.status}`);
448
- console.log(`RECOMMENDATION: ${result.recommendation}`);
449
-
450
- if (result.issues) {
451
- if (result.issues.critical.length > 0) {
452
- console.log(`CRITICAL: ${result.issues.critical.join('; ')}`);
453
- }
454
- if (result.issues.shouldFix.length > 0) {
455
- console.log(`SHOULD_FIX: ${result.issues.shouldFix.join('; ')}`);
456
- }
457
- if (result.issues.niceToHave.length > 0) {
458
- console.log(`NICE_TO_HAVE: ${result.issues.niceToHave.join('; ')}`);
459
- }
460
- }
461
-
462
- process.exit(result.status === 'PASS' ? 0 : 1);
463
- }
464
-
465
- // Check if this is the main module (ES module equivalent of require.main === module)
466
- if (import.meta.url === `file://${process.argv[1]}`) {
467
- main().catch(error => {
468
- console.error('VALIDATION_ERROR:', error.message);
469
- process.exit(1);
470
- });
471
- }
472
-
473
- export default StoryValidationEngine;
@@ -1,194 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Structure Synchronizer Hook
5
- * Maintains harmonized organization across .claude, .one, and one/ directories
6
- * Part of Mission-1: Elegant File Harmonization
7
- */
8
-
9
- import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'fs';
10
- import { dirname, basename, extname, join } from 'path';
11
- import { execSync } from 'child_process';
12
-
13
- const TRINITY_ROOTS = {
14
- claude: '.claude',
15
- platform: '.one',
16
- user: 'one'
17
- };
18
-
19
- const DIRECTORY_MAPPING = {
20
- agents: ['agents'],
21
- workflows: ['workflows'],
22
- templates: ['templates'],
23
- tasks: ['tasks'],
24
- checklists: ['checklists'],
25
- tools: ['tools'],
26
- data: ['data'],
27
- playbooks: ['playbooks'],
28
- stories: ['stories'],
29
- teams: ['teams'],
30
- missions: ['missions'],
31
- guides: ['guides'],
32
- prompts: ['prompts'],
33
- research: ['research'],
34
- tests: ['tests'],
35
- docs: ['docs'],
36
- architecture: ['architecture'],
37
- brand: ['brand'],
38
- assets: ['assets']
39
- };
40
-
41
- /**
42
- * Validates file placement according to trinity architecture
43
- */
44
- function validateFilePlacement(filePath) {
45
- const normalized = filePath.replace(/^\.\//, '');
46
- const segments = normalized.split('/');
47
-
48
- // Determine which trinity this belongs to
49
- const trinity = segments[0];
50
- const directory = segments[1];
51
- const filename = segments[segments.length - 1];
52
-
53
- console.log(`šŸ” Validating: ${filePath}`);
54
- console.log(`šŸ“ Trinity: ${trinity}, Directory: ${directory}, File: ${filename}`);
55
-
56
- // Validate trinity structure
57
- if (!Object.values(TRINITY_ROOTS).includes(trinity)) {
58
- return {
59
- valid: false,
60
- reason: `File not in trinity structure (${trinity})`,
61
- suggestion: `Move to appropriate trinity: ${Object.values(TRINITY_ROOTS).join(', ')}`
62
- };
63
- }
64
-
65
- // Validate directory mapping
66
- if (directory && !DIRECTORY_MAPPING[directory]) {
67
- return {
68
- valid: false,
69
- reason: `Directory '${directory}' not in harmonized structure`,
70
- suggestion: `Use one of: ${Object.keys(DIRECTORY_MAPPING).join(', ')}`
71
- };
72
- }
73
-
74
- return { valid: true, trinity, directory, filename };
75
- }
76
-
77
- /**
78
- * Ensures beautiful naming conventions
79
- */
80
- function validateNaming(filename) {
81
- const rules = [
82
- {
83
- test: /^[a-z0-9-]+(\.[a-z0-9]+)*\.(md|yaml|js|json|css|html)$/i,
84
- message: 'Use kebab-case with valid extensions'
85
- },
86
- {
87
- test: /^(?!.*--).*$/,
88
- message: 'Avoid double dashes'
89
- },
90
- {
91
- test: /^(?!-|.*-$).*$/,
92
- message: 'No leading or trailing dashes'
93
- }
94
- ];
95
-
96
- for (const rule of rules) {
97
- if (!rule.test.test(filename)) {
98
- return {
99
- valid: false,
100
- reason: rule.message,
101
- suggestion: `Rename '${filename}' to follow naming conventions`
102
- };
103
- }
104
- }
105
-
106
- return { valid: true };
107
- }
108
-
109
- /**
110
- * Checks if directories exist across trinity, creates if needed
111
- */
112
- function ensureDirectoryHarmony(directory) {
113
- const paths = Object.values(TRINITY_ROOTS).map(root =>
114
- join(process.cwd(), root, directory)
115
- );
116
-
117
- paths.forEach(path => {
118
- if (!existsSync(path)) {
119
- console.log(`šŸ“ Creating missing directory: ${path}`);
120
- mkdirSync(path, { recursive: true });
121
- }
122
- });
123
- }
124
-
125
- /**
126
- * Main hook execution
127
- */
128
- function main() {
129
- const changedFiles = process.env.CHANGED_FILES?.split('\n').filter(Boolean) || [];
130
-
131
- if (changedFiles.length === 0) {
132
- console.log('ā„¹ļø No files to validate');
133
- return;
134
- }
135
-
136
- console.log('šŸ”„ Structure Synchronizer Hook Activated');
137
- console.log(`šŸ“Š Validating ${changedFiles.length} files`);
138
-
139
- let errors = [];
140
- let warnings = [];
141
-
142
- changedFiles.forEach(filePath => {
143
- // Validate file placement
144
- const placement = validateFilePlacement(filePath);
145
- if (!placement.valid) {
146
- errors.push(`āŒ ${filePath}: ${placement.reason}`);
147
- if (placement.suggestion) {
148
- warnings.push(`šŸ’” ${placement.suggestion}`);
149
- }
150
- return;
151
- }
152
-
153
- // Validate naming
154
- const naming = validateNaming(placement.filename);
155
- if (!naming.valid) {
156
- errors.push(`āŒ ${filePath}: ${naming.reason}`);
157
- if (naming.suggestion) {
158
- warnings.push(`šŸ’” ${naming.suggestion}`);
159
- }
160
- return;
161
- }
162
-
163
- // Ensure directory harmony
164
- if (placement.directory) {
165
- ensureDirectoryHarmony(placement.directory);
166
- }
167
-
168
- console.log(`āœ… ${filePath}: Harmonized`);
169
- });
170
-
171
- // Report results
172
- if (errors.length > 0) {
173
- console.log('\n🚨 Structure Validation Errors:');
174
- errors.forEach(error => console.log(error));
175
-
176
- if (warnings.length > 0) {
177
- console.log('\nšŸ’” Suggestions:');
178
- warnings.forEach(warning => console.log(warning));
179
- }
180
-
181
- console.log('\nšŸ“– See one/docs/harmonized-structure-design.md for guidance');
182
- process.exit(1);
183
- } else {
184
- console.log('\nšŸŽÆ All files perfectly harmonized!');
185
- console.log('šŸ“ Trinity structure maintained with elegance');
186
- }
187
- }
188
-
189
- // Execute if called directly
190
- if (import.meta.url === `file://${process.argv[1]}`) {
191
- main();
192
- }
193
-
194
- export { validateFilePlacement, validateNaming, ensureDirectoryHarmony };