snow-flow 2.0.2 → 2.0.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.
- package/{.claude/mcp-config.json → .mcp.json} +13 -12
- package/.releaserc.json +47 -0
- package/README.md +48 -1
- package/package.json +1 -1
- package/.claude/claude-settings.json +0 -15
- package/.claude/commands/analysis/README.md +0 -9
- package/.claude/commands/automation/README.md +0 -9
- package/.claude/commands/github/README.md +0 -11
- package/.claude/commands/helpers/standard-checkpoint-hooks.sh +0 -179
- package/.claude/commands/hooks/README.md +0 -11
- package/.claude/commands/monitoring/README.md +0 -9
- package/.claude/commands/optimization/README.md +0 -9
- package/.claude/commands/training/README.md +0 -9
- package/.claude/commands/workflows/README.md +0 -9
- package/.claude/config.json +0 -36
- package/.claude/helpers/github-setup.sh +0 -28
- package/.claude/helpers/quick-start.sh +0 -19
- package/.claude/helpers/setup-mcp.sh +0 -18
- package/.claude/settings.json +0 -114
- package/.claude/settings.local.json +0 -33
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -9
- package/.claude-flow/metrics/system-metrics.json +0 -15986
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/.roo/README.md +0 -402
- package/.roo/mcp-list.txt +0 -257
- package/.roo/mcp.json +0 -32
- package/.roo/workflows/basic-tdd.json +0 -32
- package/.roomodes +0 -201
- package/CLAUDE.md +0 -393
- package/bin/snow-flow.js +0 -3
- package/dist/cli.js.bak +0 -2052
- package/dist/config/snow-flow-config.d.ts +0 -1492
- package/dist/config/snow-flow-config.js +0 -938
- package/scripts/create-env.js +0 -91
- package/scripts/postinstall.js +0 -30
- package/scripts/register-mcp-servers.js +0 -210
- package/scripts/reset-mcp-servers.js +0 -246
- package/scripts/setup-mcp.js +0 -106
- package/scripts/update-version.js +0 -31
- package/src/agents/README.md +0 -192
- package/src/agents/base-agent.ts +0 -251
- package/src/agents/coordinator.ts +0 -971
- package/src/agents/index.ts +0 -18
- package/src/agents/queen-403-handler.ts +0 -230
- package/src/agents/queen-agent.ts +0 -1399
- package/src/agents/script-writer-agent.ts +0 -769
- package/src/agents/security-agent.ts +0 -726
- package/src/agents/widget-creator-agent.ts +0 -568
- package/src/api/error-handling.ts +0 -1758
- package/src/api/natural-language-mapper.ts +0 -630
- package/src/api/performance-optimizer.ts +0 -891
- package/src/api/transaction-manager.ts +0 -754
- package/src/cli/deploy-artifact.ts +0 -304
- package/src/cli/snow-flow-cli-integration.ts +0 -434
- package/src/cli.ts +0 -4455
- package/src/cli.ts.bak +0 -5616
- package/src/compliance/advanced-compliance-system.ts +0 -1268
- package/src/compliance/index.ts +0 -19
- package/src/config/snow-flow-config.ts +0 -1019
- package/src/documentation/index.ts +0 -16
- package/src/documentation/self-documenting-system.ts +0 -1421
- package/src/dynamic-version.ts +0 -44
- package/src/healing/index.ts +0 -20
- package/src/healing/self-healing-system.ts +0 -1435
- package/src/health/README.md +0 -161
- package/src/health/system-health.ts +0 -995
- package/src/index.ts +0 -60
- package/src/intelligence/acl-analyzer.ts +0 -377
- package/src/intelligence/auto-resolution-engine.ts +0 -643
- package/src/intelligence/gap-analysis-engine.ts +0 -488
- package/src/intelligence/manual-instructions-generator.ts +0 -744
- package/src/intelligence/mcp-coverage-analyzer.ts +0 -708
- package/src/intelligence/multi-pass-requirements-analyzer.ts +0 -603
- package/src/intelligence/performance-recommendations-engine.ts +0 -1223
- package/src/intelligence/requirements-analyzer.ts +0 -1148
- package/src/intelligence/task-analyzer.ts +0 -628
- package/src/managers/scope-manager.ts +0 -555
- package/src/mcp/advanced/servicenow-advanced-features-mcp.ts +0 -16110
- package/src/mcp/base-mcp-server.ts +0 -660
- package/src/mcp/http-transport-wrapper.ts +0 -426
- package/src/mcp/service-discovery-client.ts +0 -312
- package/src/mcp/servicenow-automation-mcp-refactored.ts +0 -678
- package/src/mcp/servicenow-automation-mcp.ts +0 -838
- package/src/mcp/servicenow-deployment-mcp-refactored.ts +0 -1292
- package/src/mcp/servicenow-deployment-mcp.ts +0 -7244
- package/src/mcp/servicenow-graph-memory-mcp-refactored.ts +0 -721
- package/src/mcp/servicenow-graph-memory-mcp.ts +0 -832
- package/src/mcp/servicenow-integration-mcp-refactored.ts +0 -655
- package/src/mcp/servicenow-integration-mcp.ts +0 -819
- package/src/mcp/servicenow-intelligent-mcp-refactored.ts +0 -977
- package/src/mcp/servicenow-intelligent-mcp.ts +0 -4638
- package/src/mcp/servicenow-mcp-server.ts +0 -728
- package/src/mcp/servicenow-memory-mcp.ts +0 -474
- package/src/mcp/servicenow-operations-mcp-refactored.ts +0 -1995
- package/src/mcp/servicenow-operations-mcp.ts +0 -3384
- package/src/mcp/servicenow-platform-development-mcp-refactored.ts +0 -611
- package/src/mcp/servicenow-platform-development-mcp.ts +0 -970
- package/src/mcp/servicenow-progressive-indexer.ts +0 -370
- package/src/mcp/servicenow-reporting-analytics-mcp-refactored.ts +0 -695
- package/src/mcp/servicenow-reporting-analytics-mcp.ts +0 -1123
- package/src/mcp/servicenow-security-compliance-mcp-refactored.ts +0 -642
- package/src/mcp/servicenow-security-compliance-mcp.ts +0 -1157
- package/src/mcp/servicenow-update-set-mcp-refactored.ts +0 -751
- package/src/mcp/servicenow-update-set-mcp.ts +0 -811
- package/src/mcp/shared/agent-context-provider.ts +0 -365
- package/src/mcp/shared/base-mcp-server.ts +0 -2463
- package/src/mcp/shared/mcp-memory-manager.ts +0 -540
- package/src/mcp/shared/mcp-resource-manager.ts +0 -367
- package/src/mcp/snow-flow-mcp.ts +0 -911
- package/src/mcp/start-all-mcp-servers.ts +0 -102
- package/src/mcp/start-servicenow-mcp.ts +0 -67
- package/src/monitoring/enhanced-monitoring-system.ts +0 -1345
- package/src/monitoring/performance-tracker.ts +0 -777
- package/src/optimization/cost-optimization-engine.ts +0 -1125
- package/src/optimization/index.ts +0 -10
- package/src/queen/README.md +0 -403
- package/src/queen/agent-factory.ts +0 -574
- package/src/queen/index.ts +0 -94
- package/src/queen/mcp-execution-bridge.ts +0 -681
- package/src/queen/neural-learning.ts +0 -319
- package/src/queen/parallel-agent-engine.ts +0 -848
- package/src/queen/queen-memory-system.ts +0 -490
- package/src/queen/queen-memory.ts +0 -456
- package/src/queen/servicenow-queen.ts +0 -1029
- package/src/queen/types.ts +0 -87
- package/src/rollback/smart-rollback-system.ts +0 -866
- package/src/schemas/deployment.schema.json +0 -58
- package/src/schemas/flow.schema.json +0 -79
- package/src/schemas/widget.schema.json +0 -72
- package/src/snow-flow-system.ts +0 -541
- package/src/sparc/sparc-help.ts +0 -49
- package/src/sparc/team-sparc.ts +0 -88
- package/src/strategies/global-scope-strategy.ts +0 -736
- package/src/templates/base/application.template.json +0 -45
- package/src/templates/base/business_rule.template.json +0 -33
- package/src/templates/base/script_include.template.json +0 -18
- package/src/templates/base/table.template.json +0 -64
- package/src/templates/base/widget.template.json +0 -25
- package/src/templates/patterns/composite.incident-management.template.json +0 -140
- package/src/templates/patterns/widget.dashboard.template.json +0 -238
- package/src/templates/patterns/widget.datatable.template.json +0 -292
- package/src/testing/integration-test-suite.ts +0 -1276
- package/src/types/index.ts +0 -183
- package/src/types/neo4j-driver.d.ts +0 -23
- package/src/types/servicenow.types.ts +0 -307
- package/src/types/snow-flow.types.ts +0 -186
- package/src/types/todo.types.ts +0 -70
- package/src/utils/action-type-cache.ts +0 -286
- package/src/utils/agent-detector.ts +0 -573
- package/src/utils/artifact-tracker.ts +0 -379
- package/src/utils/dependency-detector.ts +0 -233
- package/src/utils/deployment-metadata-handler.ts +0 -518
- package/src/utils/error-recovery.ts +0 -680
- package/src/utils/logger.ts +0 -60
- package/src/utils/mcp-auth-middleware.ts +0 -262
- package/src/utils/mcp-config-manager.ts +0 -270
- package/src/utils/mcp-server-manager.ts +0 -446
- package/src/utils/mcp-tool-registry.ts +0 -298
- package/src/utils/migrate-snow-flow.ts +0 -98
- package/src/utils/oauth-html-templates.ts +0 -188
- package/src/utils/scope-utils.ts +0 -443
- package/src/utils/servicenow-client.ts +0 -3321
- package/src/utils/servicenow-id-generator.ts +0 -181
- package/src/utils/snow-memory-manager.ts +0 -605
- package/src/utils/snow-oauth.ts +0 -797
- package/src/utils/template-engine.ts +0 -463
- package/src/utils/theme-manager.ts +0 -295
- package/src/utils/unified-auth-store.ts +0 -222
- package/src/utils/update-set-importer.ts +0 -422
- package/src/utils/update-set-xml-packager.ts +0 -371
- package/src/utils/widget-template-generator.ts +0 -1744
- package/src/version.ts +0 -1950
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snow-Flow CLI Integration
|
|
3
|
-
* Integrates the hive-mind system with the CLI commands
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { Command } from 'commander';
|
|
7
|
-
import { snowFlowSystem, SwarmOptions } from '../snow-flow-system';
|
|
8
|
-
import { snowFlowConfig } from '../config/snow-flow-config';
|
|
9
|
-
import { Logger } from '../utils/logger';
|
|
10
|
-
import chalk from 'chalk';
|
|
11
|
-
import ora from 'ora';
|
|
12
|
-
|
|
13
|
-
const logger = new Logger('SnowFlowCLI');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Initialize the swarm command with the integrated system
|
|
17
|
-
*/
|
|
18
|
-
export function createSwarmCommand(program: Command): void {
|
|
19
|
-
program
|
|
20
|
-
.command('swarm <objective>')
|
|
21
|
-
.description('🚀 Execute multi-agent swarm coordination with REVOLUTIONARY Parallel Agent Engine (v1.1.90) - automatically spawns specialized agent teams working simultaneously with 2-5x performance improvement')
|
|
22
|
-
.option('--strategy <strategy>', 'Swarm strategy', 'development')
|
|
23
|
-
.option('--mode <mode>', 'Coordination mode', 'hierarchical')
|
|
24
|
-
.option('--max-agents <number>', 'Maximum number of agents', '10')
|
|
25
|
-
.option('--parallel', 'Enable parallel execution (auto-detected by default in v1.1.90)')
|
|
26
|
-
.option('--monitor', 'Real-time monitoring')
|
|
27
|
-
.option('--no-auto-permissions', 'Disable automatic permission escalation')
|
|
28
|
-
.option('--no-smart-discovery', 'Disable smart artifact discovery')
|
|
29
|
-
.option('--no-live-testing', 'Disable live testing')
|
|
30
|
-
.option('--no-auto-deploy', 'Disable automatic deployment')
|
|
31
|
-
.option('--no-auto-rollback', 'Disable automatic rollback')
|
|
32
|
-
.option('--no-shared-memory', 'Disable shared memory')
|
|
33
|
-
.option('--no-progress-monitoring', 'Disable progress monitoring')
|
|
34
|
-
.action(async (objective: string, options: any) => {
|
|
35
|
-
const spinner = ora('Initializing Snow-Flow System...').start();
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
// Initialize system
|
|
39
|
-
await snowFlowSystem.initialize();
|
|
40
|
-
spinner.succeed('System initialized');
|
|
41
|
-
|
|
42
|
-
// Parse options
|
|
43
|
-
const swarmOptions: SwarmOptions = {
|
|
44
|
-
strategy: options.strategy,
|
|
45
|
-
mode: options.mode,
|
|
46
|
-
maxAgents: parseInt(options.maxAgents) || 10,
|
|
47
|
-
parallel: options.parallel,
|
|
48
|
-
monitor: options.monitor,
|
|
49
|
-
autoPermissions: options.autoPermissions,
|
|
50
|
-
smartDiscovery: options.smartDiscovery,
|
|
51
|
-
liveTesting: options.liveTesting,
|
|
52
|
-
autoDeploy: options.autoDeploy,
|
|
53
|
-
autoRollback: options.autoRollback,
|
|
54
|
-
sharedMemory: options.sharedMemory,
|
|
55
|
-
progressMonitoring: options.progressMonitoring
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
console.log(chalk.cyan('\n🐝 Starting Swarm Execution'));
|
|
59
|
-
console.log(chalk.yellow('🚀 NEW v1.1.93: Revolutionary Parallel Agent Spawning - 6+ specialized agents for 2.8x faster development!'));
|
|
60
|
-
console.log(chalk.gray('Objective:'), objective);
|
|
61
|
-
console.log(chalk.gray('Strategy:'), swarmOptions.strategy);
|
|
62
|
-
console.log(chalk.gray('Mode:'), swarmOptions.mode);
|
|
63
|
-
|
|
64
|
-
// Set up progress monitoring
|
|
65
|
-
if (swarmOptions.progressMonitoring) {
|
|
66
|
-
snowFlowSystem.on('swarm:progress', (data) => {
|
|
67
|
-
const { sessionId, progress } = data;
|
|
68
|
-
console.log(chalk.blue(`[${sessionId}]`), `Progress: ${progress.completed}/${progress.total} tasks`);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
snowFlowSystem.on('agent:spawned', (agent) => {
|
|
72
|
-
console.log(chalk.green('✅ Agent spawned:'), agent.type);
|
|
73
|
-
if (agent.specialization) {
|
|
74
|
-
console.log(chalk.blue(' 🎯 Specialization:'), agent.specialization);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
snowFlowSystem.on('agent:completed', (agent) => {
|
|
79
|
-
console.log(chalk.green('✅ Agent completed:'), agent.type);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
snowFlowSystem.on('parallel:detected', (data) => {
|
|
83
|
-
console.log(chalk.magenta('🚀 Parallel opportunities detected:'), data.opportunities.length);
|
|
84
|
-
data.opportunities.forEach((opp, index) => {
|
|
85
|
-
console.log(chalk.cyan(` ${index + 1}. ${opp.type}: ${opp.agentCount} agents, estimated ${opp.estimatedSpeedup}x speedup`));
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Execute swarm
|
|
91
|
-
const startTime = Date.now();
|
|
92
|
-
const result = await snowFlowSystem.executeSwarm(objective, swarmOptions);
|
|
93
|
-
const duration = Date.now() - startTime;
|
|
94
|
-
|
|
95
|
-
// Display results
|
|
96
|
-
console.log(chalk.green('\n✅ Swarm execution completed successfully!'));
|
|
97
|
-
console.log(chalk.gray('Session ID:'), result.sessionId);
|
|
98
|
-
console.log(chalk.gray('Duration:'), `${(duration / 1000).toFixed(2)}s`);
|
|
99
|
-
console.log(chalk.gray('Artifacts created:'), result.artifacts.length);
|
|
100
|
-
|
|
101
|
-
if (result.artifacts.length > 0) {
|
|
102
|
-
console.log(chalk.yellow('\n📦 Created Artifacts:'));
|
|
103
|
-
result.artifacts.forEach((artifact, index) => {
|
|
104
|
-
console.log(` ${index + 1}. ${artifact.type}: ${artifact.name} (${artifact.sys_id})`);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
console.log(chalk.cyan('\n📝 Summary:'));
|
|
109
|
-
console.log(result.summary);
|
|
110
|
-
|
|
111
|
-
// Show metrics if available
|
|
112
|
-
if (result.metrics && Object.keys(result.metrics).length > 0) {
|
|
113
|
-
console.log(chalk.yellow('\n📊 Performance Metrics:'));
|
|
114
|
-
console.log(JSON.stringify(result.metrics, null, 2));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
} catch (error) {
|
|
118
|
-
spinner.fail('Swarm execution failed');
|
|
119
|
-
logger.error('Swarm execution error:', error);
|
|
120
|
-
console.error(chalk.red('\n❌ Error:'), (error as Error).message);
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Create status command
|
|
128
|
-
*/
|
|
129
|
-
export function createStatusCommand(program: Command): void {
|
|
130
|
-
program
|
|
131
|
-
.command('status')
|
|
132
|
-
.description('Show comprehensive system status')
|
|
133
|
-
.action(async () => {
|
|
134
|
-
const spinner = ora('Checking system status...').start();
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
const status = await snowFlowSystem.getStatus();
|
|
138
|
-
spinner.stop();
|
|
139
|
-
|
|
140
|
-
// Display system status
|
|
141
|
-
console.log(chalk.bold('\n🔍 Snow-Flow System Status\n'));
|
|
142
|
-
|
|
143
|
-
const statusIcon = status.status === 'healthy' ? '✅' :
|
|
144
|
-
status.status === 'degraded' ? '⚠️' : '❌';
|
|
145
|
-
console.log(`${statusIcon} Overall Status: ${chalk.bold(status.status.toUpperCase())}`);
|
|
146
|
-
console.log(chalk.gray('Initialized:'), status.initialized ? 'Yes' : 'No');
|
|
147
|
-
|
|
148
|
-
if (status.components) {
|
|
149
|
-
console.log(chalk.yellow('\n📦 Component Health:'));
|
|
150
|
-
for (const [component, health] of Object.entries(status.components)) {
|
|
151
|
-
const icon = health.status === 'healthy' ? '✅' :
|
|
152
|
-
health.status === 'degraded' ? '⚠️' : '❌';
|
|
153
|
-
console.log(` ${icon} ${component}: ${health.status}`);
|
|
154
|
-
if (health.message) {
|
|
155
|
-
console.log(chalk.gray(` ${health.message}`));
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (status.activeSessions !== undefined) {
|
|
161
|
-
console.log(chalk.yellow('\n📊 Activity:'));
|
|
162
|
-
console.log(` - Active Sessions: ${status.activeSessions}`);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (status.metrics) {
|
|
166
|
-
console.log(chalk.yellow('\n📈 System Metrics:'));
|
|
167
|
-
console.log(` - Total Sessions: ${status.metrics.totalSessions}`);
|
|
168
|
-
console.log(` - Success Rate: ${status.metrics.successRate.toFixed(2)}%`);
|
|
169
|
-
console.log(` - Avg Execution Time: ${(status.metrics.averageExecutionTime / 1000).toFixed(2)}s`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
} catch (error) {
|
|
173
|
-
spinner.fail('Failed to get system status');
|
|
174
|
-
console.error(chalk.red('Error:'), (error as Error).message);
|
|
175
|
-
process.exit(1);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Create monitor command
|
|
182
|
-
*/
|
|
183
|
-
export function createMonitorCommand(program: Command): void {
|
|
184
|
-
program
|
|
185
|
-
.command('monitor')
|
|
186
|
-
.description('Real-time system monitoring dashboard')
|
|
187
|
-
.option('--interval <ms>', 'Update interval in milliseconds', '5000')
|
|
188
|
-
.action(async (options) => {
|
|
189
|
-
console.log(chalk.bold.cyan('\n📊 Snow-Flow Real-time Monitor\n'));
|
|
190
|
-
console.log(chalk.gray('Press Ctrl+C to exit'));
|
|
191
|
-
console.log(chalk.gray('=' . repeat(50)));
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
// Initialize system if needed
|
|
195
|
-
const status = snowFlowSystem.getStatus();
|
|
196
|
-
if (!(status as any).initialized) {
|
|
197
|
-
await snowFlowSystem.initialize();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Set up event listeners
|
|
201
|
-
snowFlowSystem.on('swarm:progress', (data) => {
|
|
202
|
-
console.log(chalk.blue(`\n[${new Date().toISOString()}] Swarm Progress`));
|
|
203
|
-
console.log(` Session: ${data.sessionId}`);
|
|
204
|
-
console.log(` Progress: ${data.progress.completed}/${data.progress.total}`);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
snowFlowSystem.on('agent:spawned', (agent) => {
|
|
208
|
-
console.log(chalk.green(`\n[${new Date().toISOString()}] Agent Spawned`));
|
|
209
|
-
console.log(` Type: ${agent.type}`);
|
|
210
|
-
console.log(` ID: ${agent.id}`);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
snowFlowSystem.on('performance:metric', (metric) => {
|
|
214
|
-
console.log(chalk.yellow(`\n[${new Date().toISOString()}] Performance Metric`));
|
|
215
|
-
console.log(` Operation: ${metric.operation}`);
|
|
216
|
-
console.log(` Duration: ${metric.duration}ms`);
|
|
217
|
-
console.log(` Success: ${metric.success}`);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
snowFlowSystem.on('health:alert', (alert) => {
|
|
221
|
-
console.log(chalk.red(`\n[${new Date().toISOString()}] Health Alert`));
|
|
222
|
-
console.log(` Type: ${alert.type}`);
|
|
223
|
-
console.log(` Severity: ${alert.severity}`);
|
|
224
|
-
console.log(` Message: ${alert.message}`);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// Periodic status update
|
|
228
|
-
const updateInterval = parseInt(options.interval) || 5000;
|
|
229
|
-
setInterval(async () => {
|
|
230
|
-
const status = await snowFlowSystem.getStatus();
|
|
231
|
-
const sessions = snowFlowSystem.listSessions({ status: 'active' });
|
|
232
|
-
|
|
233
|
-
console.log(chalk.dim(`\n[${new Date().toISOString()}] Status Update`));
|
|
234
|
-
console.log(chalk.dim(` System: ${status.status}`));
|
|
235
|
-
console.log(chalk.dim(` Active Sessions: ${sessions.length}`));
|
|
236
|
-
|
|
237
|
-
if (sessions.length > 0) {
|
|
238
|
-
sessions.forEach(session => {
|
|
239
|
-
console.log(chalk.dim(` - ${session.id}: ${session.completedTasks}/${session.totalTasks} tasks`));
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}, updateInterval);
|
|
243
|
-
|
|
244
|
-
// Keep process running
|
|
245
|
-
process.stdin.resume();
|
|
246
|
-
|
|
247
|
-
} catch (error) {
|
|
248
|
-
console.error(chalk.red('Monitor error:'), (error as Error).message);
|
|
249
|
-
process.exit(1);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Create memory management commands
|
|
256
|
-
*/
|
|
257
|
-
export function createMemoryCommands(program: Command): void {
|
|
258
|
-
const memory = program
|
|
259
|
-
.command('memory')
|
|
260
|
-
.description('Manage persistent memory system');
|
|
261
|
-
|
|
262
|
-
memory
|
|
263
|
-
.command('store <key> <value>')
|
|
264
|
-
.description('Store data in memory')
|
|
265
|
-
.option('--ttl <ms>', 'Time to live in milliseconds')
|
|
266
|
-
.action(async (key: string, value: string, options) => {
|
|
267
|
-
try {
|
|
268
|
-
await snowFlowSystem.initialize();
|
|
269
|
-
const memorySystem = snowFlowSystem.getMemory();
|
|
270
|
-
|
|
271
|
-
if (!memorySystem) {
|
|
272
|
-
throw new Error('Memory system not available');
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Parse value as JSON if possible
|
|
276
|
-
let parsedValue;
|
|
277
|
-
try {
|
|
278
|
-
parsedValue = JSON.parse(value);
|
|
279
|
-
} catch {
|
|
280
|
-
parsedValue = value;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
await memorySystem.store(key, parsedValue, options.ttl ? parseInt(options.ttl) : undefined);
|
|
284
|
-
console.log(chalk.green('✅ Data stored successfully'));
|
|
285
|
-
|
|
286
|
-
} catch (error) {
|
|
287
|
-
console.error(chalk.red('Error:'), (error as Error).message);
|
|
288
|
-
process.exit(1);
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
memory
|
|
293
|
-
.command('get <key>')
|
|
294
|
-
.description('Retrieve data from memory')
|
|
295
|
-
.action(async (key: string) => {
|
|
296
|
-
try {
|
|
297
|
-
await snowFlowSystem.initialize();
|
|
298
|
-
const memorySystem = snowFlowSystem.getMemory();
|
|
299
|
-
|
|
300
|
-
if (!memorySystem) {
|
|
301
|
-
throw new Error('Memory system not available');
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const value = await memorySystem.get(key);
|
|
305
|
-
|
|
306
|
-
if (value === null) {
|
|
307
|
-
console.log(chalk.yellow('Key not found or expired'));
|
|
308
|
-
} else {
|
|
309
|
-
console.log(chalk.green('Value:'));
|
|
310
|
-
console.log(JSON.stringify(value, null, 2));
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
} catch (error) {
|
|
314
|
-
console.error(chalk.red('Error:'), (error as Error).message);
|
|
315
|
-
process.exit(1);
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
memory
|
|
320
|
-
.command('stats')
|
|
321
|
-
.description('Show memory system statistics')
|
|
322
|
-
.action(async () => {
|
|
323
|
-
try {
|
|
324
|
-
await snowFlowSystem.initialize();
|
|
325
|
-
const memorySystem = snowFlowSystem.getMemory();
|
|
326
|
-
|
|
327
|
-
if (!memorySystem) {
|
|
328
|
-
throw new Error('Memory system not available');
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
const dbStats = await memorySystem.getDatabaseStats();
|
|
332
|
-
const cacheStats = await memorySystem.getCacheStats();
|
|
333
|
-
|
|
334
|
-
console.log(chalk.bold('\n💾 Memory System Statistics\n'));
|
|
335
|
-
|
|
336
|
-
console.log(chalk.yellow('Database:'));
|
|
337
|
-
console.log(` Size: ${(dbStats.size / 1024 / 1024).toFixed(2)} MB`);
|
|
338
|
-
console.log(` Tables: ${dbStats.tableCount}`);
|
|
339
|
-
console.log(` Row Counts:`);
|
|
340
|
-
for (const [table, count] of Object.entries(dbStats.rowCounts)) {
|
|
341
|
-
console.log(` - ${table}: ${count} rows`);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
console.log(chalk.yellow('\nCache:'));
|
|
345
|
-
console.log(` Size: ${cacheStats.size} entries`);
|
|
346
|
-
console.log(` Hits: ${cacheStats.hits}`);
|
|
347
|
-
console.log(` Misses: ${cacheStats.misses}`);
|
|
348
|
-
console.log(` Hit Rate: ${cacheStats.hits + cacheStats.misses > 0 ?
|
|
349
|
-
((cacheStats.hits / (cacheStats.hits + cacheStats.misses)) * 100).toFixed(2) : 0}%`);
|
|
350
|
-
console.log(` Evictions: ${cacheStats.evictions}`);
|
|
351
|
-
|
|
352
|
-
} catch (error) {
|
|
353
|
-
console.error(chalk.red('Error:'), (error as Error).message);
|
|
354
|
-
process.exit(1);
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Create configuration commands
|
|
361
|
-
*/
|
|
362
|
-
export function createConfigCommands(program: Command): void {
|
|
363
|
-
const config = program
|
|
364
|
-
.command('config')
|
|
365
|
-
.description('Configuration management');
|
|
366
|
-
|
|
367
|
-
config
|
|
368
|
-
.command('show')
|
|
369
|
-
.description('Show current configuration')
|
|
370
|
-
.action(() => {
|
|
371
|
-
const currentConfig = snowFlowConfig.get();
|
|
372
|
-
console.log(chalk.bold('\n⚙️ Snow-Flow Configuration\n'));
|
|
373
|
-
console.log(JSON.stringify(currentConfig, null, 2));
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
config
|
|
377
|
-
.command('get <path>')
|
|
378
|
-
.description('Get a specific configuration value')
|
|
379
|
-
.action((path: string) => {
|
|
380
|
-
const value = snowFlowConfig.getValue(path);
|
|
381
|
-
if (value === undefined) {
|
|
382
|
-
console.log(chalk.yellow('Configuration key not found'));
|
|
383
|
-
} else {
|
|
384
|
-
console.log(chalk.green('Value:'), JSON.stringify(value, null, 2));
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
config
|
|
389
|
-
.command('set <path> <value>')
|
|
390
|
-
.description('Set a configuration value')
|
|
391
|
-
.action((path: string, value: string) => {
|
|
392
|
-
try {
|
|
393
|
-
// Parse value as JSON if possible
|
|
394
|
-
let parsedValue;
|
|
395
|
-
try {
|
|
396
|
-
parsedValue = JSON.parse(value);
|
|
397
|
-
} catch {
|
|
398
|
-
parsedValue = value;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
snowFlowConfig.setValue(path, parsedValue);
|
|
402
|
-
console.log(chalk.green('✅ Configuration updated'));
|
|
403
|
-
|
|
404
|
-
} catch (error) {
|
|
405
|
-
console.error(chalk.red('Error:'), (error as Error).message);
|
|
406
|
-
process.exit(1);
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Integrate all commands with the main program
|
|
413
|
-
*/
|
|
414
|
-
export function integrateSnowFlowCommands(program: Command): void {
|
|
415
|
-
// Add all integrated commands
|
|
416
|
-
createSwarmCommand(program);
|
|
417
|
-
createStatusCommand(program);
|
|
418
|
-
createMonitorCommand(program);
|
|
419
|
-
createMemoryCommands(program);
|
|
420
|
-
createConfigCommands(program);
|
|
421
|
-
|
|
422
|
-
// Add shutdown handler
|
|
423
|
-
process.on('SIGINT', async () => {
|
|
424
|
-
console.log(chalk.yellow('\n\nShutting down Snow-Flow System...'));
|
|
425
|
-
try {
|
|
426
|
-
await snowFlowSystem.shutdown();
|
|
427
|
-
console.log(chalk.green('✅ Shutdown complete'));
|
|
428
|
-
process.exit(0);
|
|
429
|
-
} catch (error) {
|
|
430
|
-
console.error(chalk.red('Shutdown error:'), error);
|
|
431
|
-
process.exit(1);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
}
|