snow-flow 8.1.1 ā 8.1.2
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/dist/cli.js
CHANGED
|
@@ -205,9 +205,11 @@ program
|
|
|
205
205
|
cliLogger.info('š VERBOSE MODE: Enabled');
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
// Only show header in verbose mode
|
|
209
|
+
if (options.verbose) {
|
|
210
|
+
cliLogger.info(`\nš Snow-Flow v${version_js_1.VERSION}`);
|
|
211
|
+
console.log(chalk_1.default.blue(`š ${objective}`));
|
|
212
|
+
}
|
|
211
213
|
// Only show detailed config in verbose mode
|
|
212
214
|
if (options.verbose) {
|
|
213
215
|
cliLogger.info(`āļø Strategy: ${options.strategy} | Mode: ${options.mode} | Max Agents: ${options.maxAgents}`);
|
|
@@ -257,43 +259,6 @@ program
|
|
|
257
259
|
cliLogger.info(` š„ Self-Healing: ${autonomousHealingActive ? 'ā
ACTIVE' : 'ā Disabled'}`);
|
|
258
260
|
cliLogger.info('');
|
|
259
261
|
}
|
|
260
|
-
else {
|
|
261
|
-
// In non-verbose mode, only show critical info
|
|
262
|
-
if (options.autoDeploy) {
|
|
263
|
-
console.log(chalk_1.default.green(`ā
ServiceNow integration active - will create real artifacts`));
|
|
264
|
-
}
|
|
265
|
-
// Calculate autonomous systems for non-verbose mode (same logic as verbose)
|
|
266
|
-
const noAutonomousAll = options.autonomousAll === false;
|
|
267
|
-
const forceAutonomousAll = options.autonomousAll === true;
|
|
268
|
-
const autonomousDocActive = noAutonomousAll ? false :
|
|
269
|
-
forceAutonomousAll ? true :
|
|
270
|
-
options.autonomousDocumentation !== false;
|
|
271
|
-
const autonomousCostActive = noAutonomousAll ? false :
|
|
272
|
-
forceAutonomousAll ? true :
|
|
273
|
-
options.autonomousCostOptimization !== false;
|
|
274
|
-
const autonomousComplianceActive = noAutonomousAll ? false :
|
|
275
|
-
forceAutonomousAll ? true :
|
|
276
|
-
options.autonomousCompliance !== false;
|
|
277
|
-
const autonomousHealingActive = noAutonomousAll ? false :
|
|
278
|
-
forceAutonomousAll ? true :
|
|
279
|
-
options.autonomousHealing !== false;
|
|
280
|
-
// Show active autonomous systems
|
|
281
|
-
const activeSystems = [];
|
|
282
|
-
if (autonomousDocActive)
|
|
283
|
-
activeSystems.push('š Documentation');
|
|
284
|
-
if (autonomousCostActive)
|
|
285
|
-
activeSystems.push('š° Cost Optimization');
|
|
286
|
-
if (autonomousComplianceActive)
|
|
287
|
-
activeSystems.push('š Compliance');
|
|
288
|
-
if (autonomousHealingActive)
|
|
289
|
-
activeSystems.push('š„ Self-Healing');
|
|
290
|
-
if (activeSystems.length > 0) {
|
|
291
|
-
cliLogger.info(`š¤ Autonomous Systems: ${activeSystems.join(', ')}`);
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
cliLogger.info(`š¤ Autonomous Systems: ā All Disabled`);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
262
|
// Snow-Flow uses Claude Code directly - no provider-agnostic layer needed
|
|
298
263
|
// Analyze the objective using intelligent agent detection
|
|
299
264
|
const taskAnalysis = analyzeObjective(objective, parseInt(options.maxAgents));
|
|
@@ -341,10 +306,6 @@ program
|
|
|
341
306
|
cliLogger.info('š” Run "snow-flow auth login" to enable live ServiceNow integration');
|
|
342
307
|
}
|
|
343
308
|
}
|
|
344
|
-
else if (!isAuthenticated) {
|
|
345
|
-
// In non-verbose mode, only warn if not authenticated
|
|
346
|
-
console.log(chalk_1.default.yellow('ā ļø Not authenticated - run ') + chalk_1.default.cyan('snow-flow auth login') + chalk_1.default.yellow(' first'));
|
|
347
|
-
}
|
|
348
309
|
// Initialize Queen Agent memory system
|
|
349
310
|
if (options.verbose) {
|
|
350
311
|
cliLogger.info('\nš¾ Initializing swarm memory system...');
|
|
@@ -377,9 +338,6 @@ program
|
|
|
377
338
|
cliLogger.info(` - Coordinate through shared memory (session: ${sessionId})`);
|
|
378
339
|
cliLogger.info(` - Monitor progress and adapt strategy`);
|
|
379
340
|
}
|
|
380
|
-
else {
|
|
381
|
-
cliLogger.info('\nš Launching OpenCode orchestration...');
|
|
382
|
-
}
|
|
383
341
|
// Check if intelligent features are enabled
|
|
384
342
|
const hasIntelligentFeatures = options.autoPermissions || options.smartDiscovery ||
|
|
385
343
|
options.liveTesting || options.autoDeploy || options.autoRollback ||
|
|
@@ -418,12 +376,11 @@ program
|
|
|
418
376
|
cliLogger.info('\nš Live ServiceNow integration: ā Disabled');
|
|
419
377
|
}
|
|
420
378
|
}
|
|
421
|
-
console.log(chalk_1.default.blue('\nš Starting OpenCode with 235+ ServiceNow tools via MCP...'));
|
|
422
379
|
// Try to execute OpenCode directly with the objective
|
|
423
380
|
const success = await executeOpenCode(objective);
|
|
424
381
|
if (success) {
|
|
425
|
-
cliLogger.info('ā
OpenCode launched successfully!');
|
|
426
382
|
if (options.verbose) {
|
|
383
|
+
cliLogger.info('ā
OpenCode launched successfully!');
|
|
427
384
|
cliLogger.info('š¤ OpenCode is now executing your objective');
|
|
428
385
|
cliLogger.info(`š¾ Monitor progress with session ID: ${sessionId}`);
|
|
429
386
|
if (isAuthenticated && options.autoDeploy) {
|
|
@@ -466,7 +423,6 @@ program
|
|
|
466
423
|
});
|
|
467
424
|
// Helper function to execute OpenCode directly with the objective
|
|
468
425
|
async function executeOpenCode(objective) {
|
|
469
|
-
cliLogger.info('š¤ Preparing OpenCode for ServiceNow development...');
|
|
470
426
|
try {
|
|
471
427
|
// Check if OpenCode CLI is available
|
|
472
428
|
const { execSync } = require('child_process');
|
|
@@ -498,9 +454,6 @@ async function executeOpenCode(objective) {
|
|
|
498
454
|
cliLogger.info(' - Default model (DEFAULT_LLM_PROVIDER, DEFAULT_ANTHROPIC_MODEL, etc.)');
|
|
499
455
|
return false;
|
|
500
456
|
}
|
|
501
|
-
cliLogger.info('ā
OpenCode configuration found');
|
|
502
|
-
cliLogger.info('š§ Starting OpenCode with ServiceNow MCP servers...');
|
|
503
|
-
console.log(chalk_1.default.green('ā
235+ ServiceNow tools available via MCP'));
|
|
504
457
|
// Debug output if enabled
|
|
505
458
|
if (process.env.SNOW_FLOW_DEBUG === 'true' || process.env.VERBOSE === 'true') {
|
|
506
459
|
cliLogger.info(`š Working Directory: ${process.cwd()}`);
|
|
@@ -512,18 +465,9 @@ async function executeOpenCode(objective) {
|
|
|
512
465
|
const { writeFileSync, unlinkSync } = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
513
466
|
const tmpFile = (0, path_1.join)(tmpdir(), `snow-flow-objective-${Date.now()}.txt`);
|
|
514
467
|
writeFileSync(tmpFile, objective, 'utf8');
|
|
515
|
-
cliLogger.info('š Launching OpenCode with your objective...');
|
|
516
|
-
cliLogger.info('š OpenCode interface opening...\n');
|
|
517
|
-
cliLogger.info(chalk_1.default.blue(`š” Objective: ${objective}\n`));
|
|
518
468
|
// Get default model from .env if available
|
|
519
469
|
const defaultModel = process.env.DEFAULT_MODEL;
|
|
520
470
|
const defaultProvider = process.env.DEFAULT_LLM_PROVIDER;
|
|
521
|
-
if (defaultModel) {
|
|
522
|
-
cliLogger.info(chalk_1.default.green(`š¤ Using default model: ${defaultModel}`));
|
|
523
|
-
}
|
|
524
|
-
if (defaultProvider) {
|
|
525
|
-
cliLogger.info(chalk_1.default.blue(`š§ Provider: ${defaultProvider}\n`));
|
|
526
|
-
}
|
|
527
471
|
// Start OpenCode with the objective and default model
|
|
528
472
|
// OpenCode will be started interactively
|
|
529
473
|
let opencodeCommand = `opencode < "${tmpFile}"`;
|
|
@@ -551,14 +495,7 @@ async function executeOpenCode(objective) {
|
|
|
551
495
|
catch (e) {
|
|
552
496
|
// Ignore cleanup errors
|
|
553
497
|
}
|
|
554
|
-
|
|
555
|
-
cliLogger.info('\nā
OpenCode session completed successfully!');
|
|
556
|
-
resolve(true);
|
|
557
|
-
}
|
|
558
|
-
else {
|
|
559
|
-
cliLogger.warn(`\nā ļø OpenCode session ended with code: ${code}`);
|
|
560
|
-
resolve(false);
|
|
561
|
-
}
|
|
498
|
+
resolve(code === 0);
|
|
562
499
|
});
|
|
563
500
|
opencodeProcess.on('error', (error) => {
|
|
564
501
|
// Clean up temp file
|
|
@@ -1794,7 +1731,41 @@ async function checkAndInstallOpenCode() {
|
|
|
1794
1731
|
console.log(chalk_1.default.blue('\nš§ Setting up OpenCode configuration...'));
|
|
1795
1732
|
try {
|
|
1796
1733
|
// Copy example config to .opencode/config.json for automatic detection
|
|
1797
|
-
|
|
1734
|
+
let configContent = await fs_1.promises.readFile(exampleConfigPath, 'utf-8');
|
|
1735
|
+
// Ensure the config content has the correct cwd (in case it still has a placeholder)
|
|
1736
|
+
// This is a safety check - the placeholder should already be replaced by copyOpenCodeConfig
|
|
1737
|
+
if (configContent.includes('"/path/to/your/snow-flow/installation"')) {
|
|
1738
|
+
console.log(chalk_1.default.yellow('ā ļø Config still contains placeholder, attempting to fix...'));
|
|
1739
|
+
// Determine the snow-flow installation directory
|
|
1740
|
+
let snowFlowRoot;
|
|
1741
|
+
const isGlobalInstall = __dirname.includes('node_modules/snow-flow') ||
|
|
1742
|
+
__dirname.includes('node_modules/.pnpm') ||
|
|
1743
|
+
__dirname.includes('npm/snow-flow');
|
|
1744
|
+
if (isGlobalInstall) {
|
|
1745
|
+
const parts = __dirname.split(/node_modules[\/\\]/);
|
|
1746
|
+
snowFlowRoot = parts[0] + 'node_modules/snow-flow';
|
|
1747
|
+
}
|
|
1748
|
+
else {
|
|
1749
|
+
let currentDir = __dirname;
|
|
1750
|
+
while (currentDir !== '/') {
|
|
1751
|
+
try {
|
|
1752
|
+
const packageJsonPath = (0, path_1.join)(currentDir, 'package.json');
|
|
1753
|
+
const packageJson = JSON.parse(await fs_1.promises.readFile(packageJsonPath, 'utf-8'));
|
|
1754
|
+
if (packageJson.name === 'snow-flow') {
|
|
1755
|
+
snowFlowRoot = currentDir;
|
|
1756
|
+
break;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
catch {
|
|
1760
|
+
// Continue searching up
|
|
1761
|
+
}
|
|
1762
|
+
currentDir = (0, path_1.dirname)(currentDir);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
if (snowFlowRoot) {
|
|
1766
|
+
configContent = configContent.replace('"/path/to/your/snow-flow/installation"', `"${snowFlowRoot.replace(/\\/g, '/')}"`);
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1798
1769
|
await fs_1.promises.writeFile(opencodeConfigPath, configContent);
|
|
1799
1770
|
console.log(chalk_1.default.green('ā
OpenCode configuration created at .opencode/config.json'));
|
|
1800
1771
|
console.log(chalk_1.default.blue('š” OpenCode will automatically detect this configuration'));
|
|
@@ -1869,8 +1840,42 @@ async function createReadmeFiles(targetDir, force = false) {
|
|
|
1869
1840
|
// Helper functions
|
|
1870
1841
|
async function copyOpenCodeConfig(targetDir, force = false) {
|
|
1871
1842
|
try {
|
|
1843
|
+
// Determine the snow-flow installation directory
|
|
1844
|
+
let snowFlowRoot;
|
|
1845
|
+
// Check if we're in a global npm installation
|
|
1846
|
+
const isGlobalInstall = __dirname.includes('node_modules/snow-flow') ||
|
|
1847
|
+
__dirname.includes('node_modules/.pnpm') ||
|
|
1848
|
+
__dirname.includes('npm/snow-flow');
|
|
1849
|
+
if (isGlobalInstall) {
|
|
1850
|
+
// For global installs, find the snow-flow package root
|
|
1851
|
+
const parts = __dirname.split(/node_modules[\/\\]/);
|
|
1852
|
+
snowFlowRoot = parts[0] + 'node_modules/snow-flow';
|
|
1853
|
+
}
|
|
1854
|
+
else {
|
|
1855
|
+
// For local development or local install
|
|
1856
|
+
// Find the snow-flow project root by looking for the parent directory with package.json
|
|
1857
|
+
let currentDir = __dirname;
|
|
1858
|
+
while (currentDir !== '/') {
|
|
1859
|
+
try {
|
|
1860
|
+
const packageJsonPath = (0, path_1.join)(currentDir, 'package.json');
|
|
1861
|
+
const packageJson = JSON.parse(await fs_1.promises.readFile(packageJsonPath, 'utf-8'));
|
|
1862
|
+
if (packageJson.name === 'snow-flow') {
|
|
1863
|
+
snowFlowRoot = currentDir;
|
|
1864
|
+
break;
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
catch {
|
|
1868
|
+
// Continue searching up
|
|
1869
|
+
}
|
|
1870
|
+
currentDir = (0, path_1.dirname)(currentDir);
|
|
1871
|
+
}
|
|
1872
|
+
if (!snowFlowRoot) {
|
|
1873
|
+
throw new Error('Could not find snow-flow project root');
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1872
1876
|
// Try to find the opencode-config.example.json
|
|
1873
1877
|
const sourceFiles = [
|
|
1878
|
+
(0, path_1.join)(snowFlowRoot, 'opencode-config.example.json'),
|
|
1874
1879
|
(0, path_1.join)(__dirname, '..', 'opencode-config.example.json'),
|
|
1875
1880
|
(0, path_1.join)(__dirname, 'opencode-config.example.json'),
|
|
1876
1881
|
(0, path_1.join)(__dirname, '..', '..', '..', 'opencode-config.example.json'),
|
|
@@ -1894,6 +1899,8 @@ async function copyOpenCodeConfig(targetDir, force = false) {
|
|
|
1894
1899
|
console.log('ā ļø Could not find opencode-config.example.json source file');
|
|
1895
1900
|
return;
|
|
1896
1901
|
}
|
|
1902
|
+
// Replace placeholders with actual snow-flow installation path
|
|
1903
|
+
configContent = configContent.replace('"/path/to/your/snow-flow/installation"', `"${snowFlowRoot.replace(/\\/g, '/')}"`);
|
|
1897
1904
|
const targetPath = (0, path_1.join)(targetDir, 'opencode-config.example.json');
|
|
1898
1905
|
try {
|
|
1899
1906
|
await fs_1.promises.access(targetPath);
|
|
@@ -1909,7 +1916,7 @@ async function copyOpenCodeConfig(targetDir, force = false) {
|
|
|
1909
1916
|
// File doesn't exist, continue with creation
|
|
1910
1917
|
}
|
|
1911
1918
|
await fs_1.promises.writeFile(targetPath, configContent);
|
|
1912
|
-
console.log('ā
Created opencode-config.example.json');
|
|
1919
|
+
console.log('ā
Created opencode-config.example.json with correct snow-flow path');
|
|
1913
1920
|
}
|
|
1914
1921
|
catch (error) {
|
|
1915
1922
|
console.error('ā Error copying opencode-config.example.json:', error);
|