Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

πŸ”– Checkpoint: Edit /workspaces/claude-code-flow/src/verification/simple-hooks.ts

rUv94c32a438f71
diff --git a/.claude/checkpoints/1754966678.json b/.claude/checkpoints/1754966678.json
new file mode 100644
index 0000000000..9e2223e5ca
--- /dev/null
+++ b/.claude/checkpoints/1754966678.json
@@ -0,0 +1 @@
+{"branch": "checkpoint/pre-edit-20250812-024438", "file": "/workspaces/claude-code-flow/docs/ci-cd/README.md", "timestamp": "2025-08-12T02:44:38Z", "type": "pre-edit", "original_branch": "alpha-89"}
diff --git a/.claude/checkpoints/1754966680.json b/.claude/checkpoints/1754966680.json
new file mode 100644
index 0000000000..3a12f58988
--- /dev/null
+++ b/.claude/checkpoints/1754966680.json
@@ -0,0 +1 @@
+{"tag": "checkpoint-20250812-024440", "file": "/workspaces/claude-code-flow/docs/ci-cd/README.md", "timestamp": "2025-08-12T02:44:40Z", "type": "post-edit", "branch": "alpha-89", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 244 ++++++++++++++++++-- .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/1754966668.json | 1 + .claude/checkpoints/1754966673.json | 1 + docs/ci-cd/README.md | 368 +++++++++++++++++++++++++++++++ 6 files changed, 604 insertions(+), 18 deletions(-) "}
diff --git a/src/verification/simple-hooks.ts b/src/verification/simple-hooks.ts
new file mode 100644
index 0000000000..6c507dbd61
--- /dev/null
+++ b/src/verification/simple-hooks.ts
@@ -0,0 +1,221 @@
+/**
+ * Simplified Verification Hooks
+ *
+ * A simplified version to avoid TypeScript compiler issues
+ */
+
+import { Logger } from '../core/logger.js';
+import { agenticHookManager } from '../services/agentic-flow-hooks/index.js';
+import type {
+ AgenticHookContext,
+ HookHandlerResult,
+ HookRegistration,
+ WorkflowHookPayload,
+} from '../services/agentic-flow-hooks/types.js';
+
+const logger = new Logger({
+ level: 'info',
+ format: 'text',
+ destination: 'console'
+}, { prefix: 'SimpleVerificationHooks' });
+
+// ===== Simple Types =====
+
+export interface SimpleVerificationConfig {
+ enabled: boolean;
+ logLevel: 'info' | 'debug' | 'warn' | 'error';
+}
+
+export interface SimpleVerificationResult {
+ success: boolean;
+ message: string;
+ details?: any;
+}
+
+// ===== Simple Verification Hook Manager =====
+
+export class SimpleVerificationHookManager {
+ private config: SimpleVerificationConfig;
+
+ constructor(config: Partial<SimpleVerificationConfig> = {}) {
+ this.config = {
+ enabled: true,
+ logLevel: 'info',
+ ...config
+ };
+
+ if (this.config.enabled) {
+ this.registerSimpleHooks();
+ }
+ }
+
+ private registerSimpleHooks(): void {
+ // Simple pre-task hook
+ const preTaskHook: HookRegistration = {
+ id: 'simple-verification-pre-task',
+ type: 'workflow-start',
+ priority: 100,
+ handler: async (payload: WorkflowHookPayload, context: AgenticHookContext): Promise<HookHandlerResult> => {
+ logger.info('πŸ” Pre-task verification starting...');
+
+ try {
+ const result = await this.runSimpleChecks(payload, context);
+
+ if (result.success) {
+ logger.info('βœ… Pre-task verification passed');
+ return {
+ continue: true,
+ metadata: {
+ verificationPassed: true,
+ message: result.message
+ }
+ };
+ } else {
+ logger.warn('⚠️ Pre-task verification failed:', result.message);
+ return {
+ continue: true, // Continue with warnings
+ metadata: {
+ verificationFailed: true,
+ message: result.message
+ }
+ };
+ }
+ } catch (error) {
+ logger.error('❌ Pre-task verification error:', error);
+ return {
+ continue: true,
+ metadata: {
+ verificationError: true,
+ error: (error as Error).message
+ }
+ };
+ }
+ }
+ };
+
+ // Simple post-task hook
+ const postTaskHook: HookRegistration = {
+ id: 'simple-verification-post-task',
+ type: 'workflow-complete',
+ priority: 90,
+ handler: async (payload: WorkflowHookPayload, context: AgenticHookContext): Promise<HookHandlerResult> => {
+ logger.info('πŸ” Post-task verification starting...');
+
+ try {
+ const result = await this.runSimpleValidation(payload, context);
+
+ logger.info(`βœ… Post-task verification completed: ${result.message}`);
+ return {
+ continue: true,
+ metadata: {
+ validationComplete: true,
+ success: result.success,
+ message: result.message
+ }
+ };
+ } catch (error) {
+ logger.error('❌ Post-task verification error:', error);
+ return {
+ continue: true,
+ metadata: {
+ validationError: true,
+ error: (error as Error).message
+ }
+ };
+ }
+ }
+ };
+
+ // Register hooks
+ agenticHookManager.register(preTaskHook);
+ agenticHookManager.register(postTaskHook);
+
+ logger.info('Simple verification hooks registered successfully');
+ }
+
+ private async runSimpleChecks(
+ payload: WorkflowHookPayload,
+ context: AgenticHookContext
+ ): Promise<SimpleVerificationResult> {
+ // Simple environment check
+ const nodeEnv = process.env.NODE_ENV;
+ if (!nodeEnv) {
+ return {
+ success: false,
+ message: 'NODE_ENV environment variable not set',
+ details: { missing: ['NODE_ENV'] }
+ };
+ }
+
+ // Simple memory check
+ const memUsage = process.memoryUsage();
+ const heapUsedMB = memUsage.heapUsed / 1024 / 1024;
+ if (heapUsedMB > 1000) { // More than 1GB
+ return {
+ success: false,
+ message: `High memory usage detected: ${heapUsedMB.toFixed(2)}MB`,
+ details: { memoryUsage: heapUsedMB }
+ };
+ }
+
+ return {
+ success: true,
+ message: 'All pre-task checks passed',
+ details: {
+ nodeEnv,
+ memoryUsage: heapUsedMB
+ }
+ };
+ }
+
+ private async runSimpleValidation(
+ payload: WorkflowHookPayload,
+ context: AgenticHookContext
+ ): Promise<SimpleVerificationResult> {
+ // Simple validation - check if workflow has state
+ if (!payload.state || Object.keys(payload.state).length === 0) {
+ return {
+ success: false,
+ message: 'Workflow completed with empty state',
+ details: { state: payload.state }
+ };
+ }
+
+ // Check for errors in metadata
+ if (payload.error) {
+ return {
+ success: false,
+ message: 'Workflow completed with errors',
+ details: { error: payload.error }
+ };
+ }
+
+ return {
+ success: true,
+ message: 'Post-task validation passed',
+ details: {
+ stateKeys: Object.keys(payload.state),
+ timestamp: Date.now()
+ }
+ };
+ }
+
+ public getStatus(): any {
+ return {
+ enabled: this.config.enabled,
+ hooksRegistered: this.config.enabled ? 2 : 0,
+ config: this.config
+ };
+ }
+
+ public updateConfig(newConfig: Partial<SimpleVerificationConfig>): void {
+ this.config = { ...this.config, ...newConfig };
+ logger.info('Simple verification configuration updated', this.config);
+ }
+}
+
+// Export singleton instance
+export const simpleVerificationHookManager = new SimpleVerificationHookManager();
+
+// Initialize
+logger.info('Simple verification hooks module initialized');
\ No newline at end of file