oneie 3.5.0 → 3.6.0

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 (132) 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/one.md +375 -5
  6. package/.claude/commands/release.md +64 -3
  7. package/CLAUDE.md +55 -69
  8. package/dist/commands/init.d.ts +5 -6
  9. package/dist/commands/init.d.ts.map +1 -1
  10. package/dist/commands/init.js +101 -101
  11. package/dist/commands/init.js.map +1 -1
  12. package/dist/index.js +6 -5
  13. package/dist/index.js.map +1 -1
  14. package/dist/utils/installation-setup.d.ts +24 -1
  15. package/dist/utils/installation-setup.d.ts.map +1 -1
  16. package/dist/utils/installation-setup.js +85 -1
  17. package/dist/utils/installation-setup.js.map +1 -1
  18. package/dist/utils/launch-claude.d.ts +6 -0
  19. package/dist/utils/launch-claude.d.ts.map +1 -0
  20. package/dist/utils/launch-claude.js +51 -0
  21. package/dist/utils/launch-claude.js.map +1 -0
  22. package/dist/utils/validation.d.ts +48 -0
  23. package/dist/utils/validation.d.ts.map +1 -0
  24. package/dist/utils/validation.js +73 -0
  25. package/dist/utils/validation.js.map +1 -0
  26. package/folders.yaml +1 -1
  27. package/one/.obsidian/core-plugins.json +33 -0
  28. package/one/.obsidian/workspace.json +20 -20
  29. package/one/connections/workflow-onboarding.md +683 -0
  30. package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +354 -0
  31. package/one/events/CRITICAL-FIXES-COMPLETE.md +504 -0
  32. package/one/events/DEPLOYMENT.md +178 -0
  33. package/one/events/ECOMMERCE-DEMO-PLAN.md +225 -0
  34. package/one/events/ECOMMERCE-LIVE-DEMO.md +363 -0
  35. package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +735 -0
  36. package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +923 -0
  37. package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +223 -0
  38. package/one/events/HANDOFF.md +313 -0
  39. package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +503 -0
  40. package/one/events/IMPLEMENTATION_SUMMARY.md +529 -0
  41. package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +666 -0
  42. package/one/events/LANDING-PAGE-IMPLEMENTATION.md +642 -0
  43. package/one/events/LANDING-PAGE-QUICKSTART.md +407 -0
  44. package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +1627 -0
  45. package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +573 -0
  46. package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +398 -0
  47. package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +525 -0
  48. package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +455 -0
  49. package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +486 -0
  50. package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +203 -0
  51. package/one/events/SECURITY-AUDIT-FIXES.md +376 -0
  52. package/one/events/SECURITY-SCAN-COMPLETE.md +281 -0
  53. package/one/events/SHOP-BUILD-STATUS.md +114 -0
  54. package/one/events/SHOP-PREMIUM-UPDATE.md +149 -0
  55. package/one/events/SITE-WIDE-GRADIENT-FIX.md +299 -0
  56. package/one/events/STORE-PRODUCTION-READY-STATUS.md +359 -0
  57. package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +429 -0
  58. package/one/events/agent-director-enhancement-summary.md +386 -0
  59. package/one/events/agent-onboard-implementation-summary.md +457 -0
  60. package/one/events/clean-agent-ontology-cleanup-report.md +353 -0
  61. package/one/events/landing-page-generator.md +458 -0
  62. package/one/events/onboarding-implementation-complete.md +505 -0
  63. package/one/events/release.md +254 -0
  64. package/one/events/separate-implementation-status.md +537 -0
  65. package/one/knowledge/100-inference-quick-reference.md +431 -0
  66. package/one/knowledge/agent-onboard-usage.md +612 -0
  67. package/one/knowledge/cli-claude-handoff.md +718 -0
  68. package/one/knowledge/ontology-blog.yaml +31 -0
  69. package/one/knowledge/ontology-cheatsheet.md +591 -0
  70. package/one/knowledge/ontology-community.yaml +42 -0
  71. package/one/knowledge/ontology-core-universal.md +722 -0
  72. package/one/knowledge/ontology-core.yaml +50 -0
  73. package/one/knowledge/ontology-courses.yaml +53 -0
  74. package/one/knowledge/ontology-creator.md +376 -0
  75. package/one/knowledge/ontology-developer-guide.md +789 -0
  76. package/one/knowledge/ontology-education.md +920 -0
  77. package/one/knowledge/ontology-index.md +354 -0
  78. package/one/knowledge/ontology-migration-guide.md +811 -0
  79. package/one/knowledge/ontology-minimal.yaml +1 -1
  80. package/one/knowledge/ontology-portfolio.yaml +31 -0
  81. package/one/knowledge/ontology-quickstart.md +576 -0
  82. package/one/knowledge/ontology-shop.yaml +121 -0
  83. package/one/knowledge/ontology-tokens.yaml +32 -0
  84. package/one/knowledge/ontology-tutorial.md +434 -0
  85. package/one/knowledge/ontology-video-script.md +890 -0
  86. package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +467 -0
  87. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +408 -0
  88. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +369 -0
  89. package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +396 -0
  90. package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +468 -0
  91. package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +582 -0
  92. package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +449 -0
  93. package/one/things/docs/ecommerce/QUICK-START.md +368 -0
  94. package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +498 -0
  95. package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +237 -0
  96. package/one/things/docs/ecommerce/USAGE-EXAMPLE.astro +171 -0
  97. package/one/things/docs/ecommerce/demo.astro +309 -0
  98. package/one/things/plans/agent-director-100-inference-plans.md +410 -0
  99. package/one/things/plans/dual-website-strategy.md +612 -0
  100. package/one/things/plans/feature-based-sites.md +821 -0
  101. package/one/things/plans/multi-ontology-architecture.md +836 -0
  102. package/one/things/plans/onboarding.md +32 -0
  103. package/one/things/plans/separate.md +15 -17
  104. package/one/things/plans/start-new.md +738 -0
  105. package/package.json +2 -2
  106. package/one/things/claude/hooks/agent-hook-manager.js +0 -525
  107. package/one/things/claude/hooks/agent-load-balancer.js +0 -271
  108. package/one/things/claude/hooks/agent-request-interceptor.js +0 -70
  109. package/one/things/claude/hooks/cascade-feedback.js +0 -297
  110. package/one/things/claude/hooks/cascade-integration-hooks.js +0 -648
  111. package/one/things/claude/hooks/continuous-improvement-monitor.js +0 -510
  112. package/one/things/claude/hooks/file-organization-engine.js +0 -427
  113. package/one/things/claude/hooks/file-organization-monitor.js +0 -269
  114. package/one/things/claude/hooks/hook-config-manager.js +0 -202
  115. package/one/things/claude/hooks/hook-orchestrator.js +0 -662
  116. package/one/things/claude/hooks/hook-performance-report.js +0 -120
  117. package/one/things/claude/hooks/mcp-cascade-integration.js +0 -816
  118. package/one/things/claude/hooks/memory-optimizer.js +0 -510
  119. package/one/things/claude/hooks/ontology-compliance.js +0 -394
  120. package/one/things/claude/hooks/ontology-hook-manager.js +0 -316
  121. package/one/things/claude/hooks/ontology-validation-engine.js +0 -317
  122. package/one/things/claude/hooks/performance-monitoring-hook.js +0 -422
  123. package/one/things/claude/hooks/quality-scoring-engine.js +0 -834
  124. package/one/things/claude/hooks/simple-load-balancer.js +0 -238
  125. package/one/things/claude/hooks/startup-optimizer.js +0 -625
  126. package/one/things/claude/hooks/story-scoring-system.js +0 -445
  127. package/one/things/claude/hooks/story-validation-engine.js +0 -473
  128. package/one/things/claude/hooks/structure-synchronizer.js +0 -194
  129. package/one/things/claude/hooks/sub-agent-output-validator.js +0 -647
  130. package/one/things/claude/hooks/sub-agent-validation-hook.js +0 -343
  131. package/one/things/claude/hooks/trinity-validation-system.js +0 -392
  132. package/one/things/plans/organizations-to-groups.md +0 -705
@@ -1,662 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Advanced Hook Orchestration and Coordination System
5
- * Manages complex workflows, parallel execution, and hook dependencies
6
- */
7
-
8
- import fs from 'fs';
9
- import path from 'path';
10
- import { EventEmitter } from 'events';
11
- import AgentHookManager from './agent-hook-manager.js';
12
- import QualityScoringEngine from './quality-scoring-engine.js';
13
- import { PerformanceMonitor } from './performance-monitoring-hook.js';
14
-
15
- class HookOrchestrator extends EventEmitter {
16
- constructor() {
17
- super();
18
- this.agentHookManager = new AgentHookManager();
19
- this.qualityEngine = new QualityScoringEngine();
20
- this.performanceMonitor = new PerformanceMonitor();
21
-
22
- this.activeExecutions = new Map(); // executionId -> execution context
23
- this.executionQueue = [];
24
- this.maxConcurrentExecutions = 3;
25
- this.executionHistory = [];
26
- this.dependencies = new Map(); // hookType -> dependencies
27
-
28
- this.initializeDependencies();
29
- this.startExecutionProcessor();
30
- }
31
-
32
- initializeDependencies() {
33
- // Define hook execution dependencies
34
- this.dependencies.set('securityValidation', []);
35
- this.dependencies.set('storyValidation', ['securityValidation']);
36
- this.dependencies.set('qualityScoring', ['storyValidation']);
37
- this.dependencies.set('performanceMonitoring', []);
38
- this.dependencies.set('notifications', ['qualityScoring', 'performanceMonitoring']);
39
- }
40
-
41
- startExecutionProcessor() {
42
- // Process execution queue every 100ms
43
- setInterval(() => {
44
- this.processExecutionQueue();
45
- }, 100);
46
- }
47
-
48
- async orchestrateAgentWorkflow(agentName, workflowContext = {}) {
49
- const executionId = this.generateExecutionId();
50
- const startTime = Date.now();
51
-
52
- const execution = {
53
- id: executionId,
54
- agentName,
55
- context: workflowContext,
56
- status: 'pending',
57
- startTime,
58
- endTime: null,
59
- results: {},
60
- dependencies: new Map(),
61
- completedHooks: new Set(),
62
- failedHooks: new Set(),
63
- totalDuration: 0
64
- };
65
-
66
- this.activeExecutions.set(executionId, execution);
67
- this.emit('executionStarted', { executionId, agentName });
68
-
69
- try {
70
- // Get hook execution order based on dependencies
71
- const executionPlan = this.createExecutionPlan(agentName);
72
- execution.executionPlan = executionPlan;
73
-
74
- // Execute hooks according to plan
75
- const results = await this.executeWorkflowPlan(execution);
76
-
77
- execution.status = results.success ? 'completed' : 'failed';
78
- execution.endTime = Date.now();
79
- execution.totalDuration = execution.endTime - execution.startTime;
80
- execution.results = results;
81
-
82
- this.executionHistory.push({
83
- executionId,
84
- agentName,
85
- success: results.success,
86
- duration: execution.totalDuration,
87
- timestamp: new Date().toISOString()
88
- });
89
-
90
- this.emit('executionCompleted', { executionId, agentName, results });
91
- return results;
92
-
93
- } catch (error) {
94
- execution.status = 'error';
95
- execution.endTime = Date.now();
96
- execution.totalDuration = execution.endTime - execution.startTime;
97
- execution.error = error.message;
98
-
99
- this.emit('executionError', { executionId, agentName, error });
100
- throw error;
101
- } finally {
102
- this.activeExecutions.delete(executionId);
103
- }
104
- }
105
-
106
- createExecutionPlan(agentName) {
107
- const config = this.agentHookManager.getAgentConfiguration(agentName);
108
- const enabledHooks = Object.keys(config.hooks).filter(
109
- hookType => config.hooks[hookType].enabled
110
- );
111
-
112
- // Create dependency graph
113
- const dependencyGraph = new Map();
114
- const inDegree = new Map();
115
-
116
- // Initialize graph
117
- enabledHooks.forEach(hook => {
118
- dependencyGraph.set(hook, []);
119
- inDegree.set(hook, 0);
120
- });
121
-
122
- // Build dependency edges
123
- enabledHooks.forEach(hook => {
124
- const deps = this.dependencies.get(hook) || [];
125
- deps.forEach(dep => {
126
- if (enabledHooks.includes(dep)) {
127
- dependencyGraph.get(dep).push(hook);
128
- inDegree.set(hook, inDegree.get(hook) + 1);
129
- }
130
- });
131
- });
132
-
133
- // Topological sort to determine execution order
134
- const executionOrder = [];
135
- const queue = [];
136
-
137
- // Find hooks with no dependencies
138
- inDegree.forEach((degree, hook) => {
139
- if (degree === 0) {
140
- queue.push(hook);
141
- }
142
- });
143
-
144
- while (queue.length > 0) {
145
- const currentHook = queue.shift();
146
- executionOrder.push(currentHook);
147
-
148
- // Update dependent hooks
149
- dependencyGraph.get(currentHook).forEach(dependentHook => {
150
- inDegree.set(dependentHook, inDegree.get(dependentHook) - 1);
151
- if (inDegree.get(dependentHook) === 0) {
152
- queue.push(dependentHook);
153
- }
154
- });
155
- }
156
-
157
- // Check for circular dependencies
158
- if (executionOrder.length !== enabledHooks.length) {
159
- throw new Error(`Circular dependency detected in hooks for agent ${agentName}`);
160
- }
161
-
162
- return {
163
- hooks: executionOrder,
164
- parallelGroups: this.identifyParallelGroups(executionOrder, dependencyGraph),
165
- estimatedDuration: this.estimateExecutionDuration(agentName, executionOrder)
166
- };
167
- }
168
-
169
- identifyParallelGroups(executionOrder, dependencyGraph) {
170
- const parallelGroups = [];
171
- let currentGroup = [];
172
- const processed = new Set();
173
-
174
- for (const hook of executionOrder) {
175
- const deps = this.dependencies.get(hook) || [];
176
- const hasUnmetDependencies = deps.some(dep => !processed.has(dep));
177
-
178
- if (!hasUnmetDependencies && currentGroup.length === 0) {
179
- currentGroup.push(hook);
180
- } else if (!hasUnmetDependencies) {
181
- // Can run in parallel with current group
182
- currentGroup.push(hook);
183
- } else {
184
- // Start new group
185
- if (currentGroup.length > 0) {
186
- parallelGroups.push([...currentGroup]);
187
- currentGroup.forEach(h => processed.add(h));
188
- currentGroup = [];
189
- }
190
- currentGroup.push(hook);
191
- }
192
- }
193
-
194
- if (currentGroup.length > 0) {
195
- parallelGroups.push(currentGroup);
196
- }
197
-
198
- return parallelGroups;
199
- }
200
-
201
- estimateExecutionDuration(agentName, hooks) {
202
- const baseDurations = {
203
- 'securityValidation': 200,
204
- 'storyValidation': 1500,
205
- 'qualityScoring': 800,
206
- 'performanceMonitoring': 100,
207
- 'notifications': 300
208
- };
209
-
210
- let totalEstimate = 0;
211
- hooks.forEach(hook => {
212
- totalEstimate += baseDurations[hook] || 500;
213
- });
214
-
215
- return totalEstimate;
216
- }
217
-
218
- async executeWorkflowPlan(execution) {
219
- const { agentName, context, executionPlan } = execution;
220
- const results = {
221
- executionId: execution.id,
222
- agentName,
223
- success: true,
224
- hookResults: {},
225
- parallelGroupResults: [],
226
- totalDuration: 0,
227
- errors: []
228
- };
229
-
230
- const startTime = Date.now();
231
-
232
- try {
233
- // Execute hooks in parallel groups
234
- for (let i = 0; i < executionPlan.parallelGroups.length; i++) {
235
- const group = executionPlan.parallelGroups[i];
236
- const groupResults = await this.executeParallelGroup(agentName, group, context);
237
-
238
- results.parallelGroupResults.push({
239
- groupIndex: i,
240
- hooks: group,
241
- results: groupResults,
242
- success: groupResults.every(r => r.success)
243
- });
244
-
245
- // Update execution tracking
246
- group.forEach(hook => {
247
- const hookResult = groupResults.find(r => r.hookType === hook);
248
- if (hookResult) {
249
- results.hookResults[hook] = hookResult;
250
- if (hookResult.success) {
251
- execution.completedHooks.add(hook);
252
- } else {
253
- execution.failedHooks.add(hook);
254
- results.errors.push(`${hook}: ${hookResult.error || hookResult.message}`);
255
- }
256
- }
257
- });
258
-
259
- // Check if we should continue after failures
260
- const groupSuccess = results.parallelGroupResults[i].success;
261
- if (!groupSuccess) {
262
- const criticalFailures = groupResults.filter(r => !r.success && r.blocking);
263
- if (criticalFailures.length > 0) {
264
- results.success = false;
265
- this.emit('executionBlocked', {
266
- executionId: execution.id,
267
- agentName,
268
- blockingHooks: criticalFailures.map(f => f.hookType)
269
- });
270
- break;
271
- }
272
- }
273
- }
274
-
275
- results.totalDuration = Date.now() - startTime;
276
-
277
- // Update performance metrics
278
- this.performanceMonitor.recordAgentMetrics(agentName, {
279
- responseTime: results.totalDuration,
280
- error: !results.success,
281
- qualityScore: results.hookResults.qualityScoring?.score,
282
- delegated: context.delegated || false
283
- });
284
-
285
- return results;
286
-
287
- } catch (error) {
288
- results.success = false;
289
- results.error = error.message;
290
- results.totalDuration = Date.now() - startTime;
291
- results.errors.push(`Execution error: ${error.message}`);
292
-
293
- throw error;
294
- }
295
- }
296
-
297
- async executeParallelGroup(agentName, hooks, context) {
298
- const promises = hooks.map(async (hookType) => {
299
- const hookStartTime = Date.now();
300
-
301
- try {
302
- const result = await this.executeHook(agentName, hookType, context);
303
- return {
304
- hookType,
305
- success: true,
306
- result,
307
- duration: Date.now() - hookStartTime,
308
- blocking: result.blocking || false
309
- };
310
- } catch (error) {
311
- return {
312
- hookType,
313
- success: false,
314
- error: error.message,
315
- duration: Date.now() - hookStartTime,
316
- blocking: true
317
- };
318
- }
319
- });
320
-
321
- return await Promise.all(promises);
322
- }
323
-
324
- async executeHook(agentName, hookType, context) {
325
- const config = this.agentHookManager.getHookConfiguration(agentName, hookType);
326
-
327
- // Route to appropriate hook implementation
328
- switch (hookType) {
329
- case 'securityValidation':
330
- return await this.executeSecurityValidation(agentName, config, context);
331
- case 'storyValidation':
332
- return await this.executeStoryValidation(agentName, config, context);
333
- case 'qualityScoring':
334
- return await this.executeQualityScoring(agentName, config, context);
335
- case 'performanceMonitoring':
336
- return await this.executePerformanceMonitoring(agentName, config, context);
337
- case 'notifications':
338
- return await this.executeNotifications(agentName, config, context);
339
- default:
340
- throw new Error(`Unknown hook type: ${hookType}`);
341
- }
342
- }
343
-
344
- async executeSecurityValidation(agentName, config, context) {
345
- // Tool validation
346
- if (context.toolRequested) {
347
- const validation = this.agentHookManager.validateToolUsage(agentName, context.toolRequested);
348
- if (!validation.allowed) {
349
- return {
350
- success: false,
351
- message: validation.reason,
352
- blocking: true,
353
- allowedTools: validation.allowedTools
354
- };
355
- }
356
- }
357
-
358
- // Path validation
359
- if (context.filePath) {
360
- const sensitivePatterns = [
361
- /.*\/secrets\/.*/,
362
- /.*\.env.*/,
363
- /.*\/credentials\/.*/,
364
- /.*private.*key.*/
365
- ];
366
-
367
- const isSensitive = sensitivePatterns.some(pattern => pattern.test(context.filePath));
368
- if (isSensitive && !config.allowSensitiveFiles) {
369
- return {
370
- success: false,
371
- message: `Access to sensitive file blocked: ${context.filePath}`,
372
- blocking: true
373
- };
374
- }
375
- }
376
-
377
- return {
378
- success: true,
379
- message: 'Security validation passed',
380
- blocking: false
381
- };
382
- }
383
-
384
- async executeStoryValidation(agentName, config, context) {
385
- if (!context.storyContent) {
386
- return {
387
- success: true,
388
- message: 'No story content to validate',
389
- blocking: false
390
- };
391
- }
392
-
393
- // Simulate story validation with R.O.C.K.E.T. framework
394
- const score = this.calculateStoryScore(context.storyContent, agentName);
395
- const threshold = config.qualityThreshold || 7.0;
396
-
397
- return {
398
- success: score >= threshold,
399
- message: `Story validation ${score >= threshold ? 'passed' : 'failed'}: ${score}/${threshold}`,
400
- score,
401
- threshold,
402
- blocking: score < 5.0 // Block if critically poor
403
- };
404
- }
405
-
406
- async executeQualityScoring(agentName, config, context) {
407
- if (!context.content) {
408
- return {
409
- success: true,
410
- message: 'No content to score',
411
- score: 0,
412
- blocking: false
413
- };
414
- }
415
-
416
- try {
417
- const contentType = context.contentType || 'general';
418
- const scoreResult = await this.qualityEngine.scoreOutput(context.content, {
419
- agentType: agentName,
420
- contentType
421
- });
422
-
423
- const threshold = config.qualityThreshold || 7.0;
424
-
425
- return {
426
- success: scoreResult.adjustedScore >= threshold,
427
- message: `Quality score: ${scoreResult.adjustedScore.toFixed(1)}/${threshold}`,
428
- score: scoreResult.adjustedScore,
429
- threshold,
430
- qualityBand: scoreResult.qualityBand,
431
- blocking: scoreResult.adjustedScore < 5.0
432
- };
433
- } catch (error) {
434
- return {
435
- success: false,
436
- message: `Quality scoring failed: ${error.message}`,
437
- blocking: false
438
- };
439
- }
440
- }
441
-
442
- async executePerformanceMonitoring(agentName, config, context) {
443
- const responseTime = context.responseTime || Date.now() - (context.startTime || Date.now());
444
- const threshold = config.responseTimeThreshold || 2000;
445
-
446
- // Record metrics
447
- this.performanceMonitor.recordAgentMetrics(agentName, {
448
- responseTime,
449
- error: context.hasError || false,
450
- qualityScore: context.qualityScore,
451
- toolUsed: context.toolUsed,
452
- delegated: context.delegated
453
- });
454
-
455
- return {
456
- success: responseTime <= threshold,
457
- message: `Performance: ${responseTime}ms (threshold: ${threshold}ms)`,
458
- responseTime,
459
- threshold,
460
- blocking: false
461
- };
462
- }
463
-
464
- async executeNotifications(agentName, config, context) {
465
- const channels = config.channels || ['console'];
466
-
467
- if (context.notifications && context.notifications.length > 0) {
468
- for (const notification of context.notifications) {
469
- if (channels.includes('console')) {
470
- console.log(`[${agentName.toUpperCase()}] ${notification.message}`);
471
- }
472
-
473
- if (channels.includes('file')) {
474
- const logPath = path.join(__dirname, 'notifications.log');
475
- const timestamp = new Date().toISOString();
476
- const logEntry = `[${timestamp}] [${agentName}] ${notification.message}\n`;
477
- fs.appendFileSync(logPath, logEntry);
478
- }
479
- }
480
- }
481
-
482
- return {
483
- success: true,
484
- message: `Notifications sent via: ${channels.join(', ')}`,
485
- blocking: false
486
- };
487
- }
488
-
489
- calculateStoryScore(content, agentName) {
490
- let score = 7.0; // Base score
491
-
492
- // Check for user story format
493
- if (/\*\*As a\*\*.*\*\*I want\*\*.*\*\*so that\*\*/i.test(content)) {
494
- score += 1.0;
495
- } else {
496
- score -= 1.5;
497
- }
498
-
499
- // Check for acceptance criteria
500
- if (/acceptance criteria/i.test(content) && /\d+\./g.test(content)) {
501
- score += 0.5;
502
- } else {
503
- score -= 1.0;
504
- }
505
-
506
- // Check for tasks/subtasks
507
- if (/- \[ \]/g.test(content)) {
508
- score += 0.5;
509
- } else {
510
- score -= 0.5;
511
- }
512
-
513
- // Agent-specific scoring adjustments
514
- const agentConfig = this.agentHookManager.getAgentConfiguration(agentName);
515
- if (agentConfig.specialization === 'technical-leadership' && /architecture|technical/i.test(content)) {
516
- score += 0.5;
517
- }
518
-
519
- if (agentConfig.specialization === 'strategic-marketing' && /strategy|marketing|campaign/i.test(content)) {
520
- score += 0.5;
521
- }
522
-
523
- return Math.max(0, Math.min(10, score));
524
- }
525
-
526
- processExecutionQueue() {
527
- // Process queued executions if we have capacity
528
- while (this.executionQueue.length > 0 && this.activeExecutions.size < this.maxConcurrentExecutions) {
529
- const queuedExecution = this.executionQueue.shift();
530
- this.orchestrateAgentWorkflow(queuedExecution.agentName, queuedExecution.context)
531
- .then(queuedExecution.resolve)
532
- .catch(queuedExecution.reject);
533
- }
534
- }
535
-
536
- async queueExecution(agentName, context = {}) {
537
- return new Promise((resolve, reject) => {
538
- this.executionQueue.push({
539
- agentName,
540
- context,
541
- resolve,
542
- reject,
543
- queuedAt: Date.now()
544
- });
545
- });
546
- }
547
-
548
- generateExecutionId() {
549
- return `exec_${Date.now()}_${Math.random().toString(36).substring(7)}`;
550
- }
551
-
552
- getExecutionStatus(executionId) {
553
- const execution = this.activeExecutions.get(executionId);
554
- if (!execution) {
555
- return null;
556
- }
557
-
558
- return {
559
- id: execution.id,
560
- agentName: execution.agentName,
561
- status: execution.status,
562
- progress: {
563
- completed: execution.completedHooks.size,
564
- failed: execution.failedHooks.size,
565
- total: execution.executionPlan?.hooks.length || 0
566
- },
567
- duration: execution.endTime ?
568
- execution.totalDuration :
569
- Date.now() - execution.startTime
570
- };
571
- }
572
-
573
- getSystemMetrics() {
574
- return {
575
- activeExecutions: this.activeExecutions.size,
576
- queuedExecutions: this.executionQueue.length,
577
- maxConcurrentExecutions: this.maxConcurrentExecutions,
578
- totalExecutionsCompleted: this.executionHistory.length,
579
- averageExecutionTime: this.executionHistory.length > 0 ?
580
- this.executionHistory.reduce((sum, exec) => sum + exec.duration, 0) / this.executionHistory.length :
581
- 0,
582
- successRate: this.executionHistory.length > 0 ?
583
- this.executionHistory.filter(exec => exec.success).length / this.executionHistory.length :
584
- 0
585
- };
586
- }
587
-
588
- emergencyStop() {
589
- // Cancel all active executions
590
- this.activeExecutions.forEach((execution, executionId) => {
591
- execution.status = 'cancelled';
592
- execution.endTime = Date.now();
593
- execution.totalDuration = execution.endTime - execution.startTime;
594
- this.emit('executionCancelled', { executionId, agentName: execution.agentName });
595
- });
596
-
597
- this.activeExecutions.clear();
598
- this.executionQueue.length = 0;
599
-
600
- this.emit('emergencyStop', { timestamp: new Date().toISOString() });
601
- }
602
- }
603
-
604
- // CLI interface
605
- async function main() {
606
- const orchestrator = new HookOrchestrator();
607
- const command = process.argv[2];
608
-
609
- switch (command) {
610
- case 'execute':
611
- const agentName = process.argv[3];
612
- const contextStr = process.argv[4] || '{}';
613
-
614
- if (!agentName) {
615
- console.error('Agent name required');
616
- process.exit(1);
617
- }
618
-
619
- try {
620
- const context = JSON.parse(contextStr);
621
- const results = await orchestrator.orchestrateAgentWorkflow(agentName, context);
622
- console.log(JSON.stringify(results, null, 2));
623
- } catch (error) {
624
- console.error('Execution failed:', error.message);
625
- process.exit(1);
626
- }
627
- break;
628
-
629
- case 'status':
630
- const executionId = process.argv[3];
631
- if (executionId) {
632
- const status = orchestrator.getExecutionStatus(executionId);
633
- console.log(JSON.stringify(status, null, 2));
634
- } else {
635
- const metrics = orchestrator.getSystemMetrics();
636
- console.log(JSON.stringify(metrics, null, 2));
637
- }
638
- break;
639
-
640
- case 'metrics':
641
- const systemMetrics = orchestrator.getSystemMetrics();
642
- console.log(JSON.stringify(systemMetrics, null, 2));
643
- break;
644
-
645
- default:
646
- console.log('Usage: hook-orchestrator.js <command> [args...]');
647
- console.log('Commands:');
648
- console.log(' execute <agent-name> [context-json] - Execute workflow for agent');
649
- console.log(' status [execution-id] - Get execution status or system metrics');
650
- console.log(' metrics - Get system performance metrics');
651
- process.exit(1);
652
- }
653
- }
654
-
655
- if (import.meta.url === `file://${process.argv[1]}`) {
656
- main().catch(error => {
657
- console.error('Error:', error);
658
- process.exit(1);
659
- });
660
- }
661
-
662
- export default HookOrchestrator;