claude-flow-novice 2.4.3 → 2.5.1
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/README-NPM.md +366 -0
- package/README.md +26 -9
- package/package.json +3 -1
- package/readme/additional-commands.md +38 -0
- package/readme/logs-features.md +30 -0
- package/readme/logs-hooks.md +12 -1
- package/scripts/postinstall.js +143 -77
- package/scripts/toggle-cost-savings.cjs +1 -1
- package/scripts/validate-agent-hooks.js +1 -1
- package/src/cli/hybrid-routing/spawn-workers.js +1 -1
- package/.claude/agents/SPARSE_LANGUAGE_FINDINGS.md +0 -991
package/scripts/postinstall.js
CHANGED
|
@@ -1,94 +1,160 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const { execSync } = require('node:child_process');
|
|
5
|
+
|
|
6
|
+
// Logging utility
|
|
7
|
+
function log(message, type = 'info') {
|
|
8
|
+
const colors = {
|
|
9
|
+
info: '\x1b[36m', // Cyan
|
|
10
|
+
warn: '\x1b[33m', // Yellow
|
|
11
|
+
error: '\x1b[31m' // Red
|
|
12
|
+
};
|
|
13
|
+
console.log(`${colors[type]}[Claude Flow] ${message}\x1b[0m`);
|
|
14
|
+
}
|
|
2
15
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { dirname, join, relative } from 'path';
|
|
11
|
-
import { fileURLToPath } from 'url';
|
|
12
|
-
|
|
13
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
-
const __dirname = dirname(__filename);
|
|
15
|
-
|
|
16
|
+
// Generate timestamped backup filename
|
|
17
|
+
function getBackupFilename(basePath) {
|
|
18
|
+
const timestamp = new Date().toISOString()
|
|
19
|
+
.replace(/:/g, '-')
|
|
20
|
+
.replace(/\./g, '_');
|
|
21
|
+
return `${basePath}_backup_${timestamp}`;
|
|
22
|
+
}
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* Shows progress for each file copied
|
|
20
|
-
*/
|
|
21
|
-
function copyClaudeDirectory() {
|
|
24
|
+
// Check if running in development mode (not as installed dependency)
|
|
25
|
+
function isDevMode() {
|
|
22
26
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
const sourceDir = possibleSources.find(dir => existsSync(dir));
|
|
33
|
-
const targetDir = join(projectRoot, '.claude');
|
|
34
|
-
|
|
35
|
-
console.log('🚀 claude-flow-novice post-install: Setting up .claude directory...');
|
|
36
|
-
console.log('📂 Source:', sourceDir);
|
|
37
|
-
console.log('📁 Target:', targetDir);
|
|
38
|
-
console.log('');
|
|
39
|
-
|
|
40
|
-
// Check if source directory was found
|
|
41
|
-
if (!sourceDir) {
|
|
42
|
-
console.error('❌ Source .claude directory not found. Tried:');
|
|
43
|
-
possibleSources.forEach(dir => console.error(` - ${dir}`));
|
|
44
|
-
console.log(' This indicates a broken npm package installation.');
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
27
|
+
const packageJson = require(path.resolve(process.cwd(), 'package.json'));
|
|
28
|
+
// We're in dev mode if the package name matches (developing the package itself)
|
|
29
|
+
return packageJson.name === 'claude-flow-novice';
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
47
34
|
|
|
48
|
-
|
|
35
|
+
// Perform backup before sync
|
|
36
|
+
async function backupDirectory(sourcePath, targetPath) {
|
|
37
|
+
if (fs.existsSync(targetPath)) {
|
|
38
|
+
const backupPath = getBackupFilename(targetPath);
|
|
39
|
+
try {
|
|
40
|
+
fs.renameSync(targetPath, backupPath);
|
|
41
|
+
log(`Created backup: ${backupPath}`, 'info');
|
|
42
|
+
} catch (err) {
|
|
43
|
+
log(`Failed to create backup: ${err.message}`, 'warn');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
// Sync directories
|
|
49
|
+
async function syncDirectories() {
|
|
50
|
+
// Skip if we're in development mode (developing the package itself)
|
|
51
|
+
if (isDevMode()) {
|
|
52
|
+
log('Development mode detected - skipping auto-sync', 'info');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
log('Auto-syncing agents, commands, and hooks to your project...', 'info');
|
|
57
|
+
|
|
58
|
+
const projectRoot = process.cwd();
|
|
59
|
+
|
|
60
|
+
const syncConfigs = [
|
|
61
|
+
{
|
|
62
|
+
source: path.join(__dirname, '..', '.claude', 'agents'),
|
|
63
|
+
target: path.join(projectRoot, '.claude', 'agents')
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
source: path.join(__dirname, '..', '.claude', 'commands'),
|
|
67
|
+
target: path.join(projectRoot, '.claude', 'commands')
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
source: path.join(__dirname, '..', 'config', 'hooks'),
|
|
71
|
+
target: path.join(projectRoot, 'config', 'hooks')
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
// Sync individual reference files from .claude root
|
|
76
|
+
const referenceFiles = [
|
|
77
|
+
'cfn-loop-rules.md',
|
|
78
|
+
'cfn-mode-patterns.md',
|
|
79
|
+
'coordinator-feedback-pattern.md',
|
|
80
|
+
'coordinator-patterns.md',
|
|
81
|
+
'redis-agent-dependencies.md',
|
|
82
|
+
'spawn-pattern-examples.md'
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
const claudeRoot = path.join(__dirname, '..', '.claude');
|
|
86
|
+
const targetClaudeRoot = path.join(projectRoot, '.claude');
|
|
87
|
+
|
|
88
|
+
// Ensure target .claude directory exists
|
|
89
|
+
fs.mkdirSync(targetClaudeRoot, { recursive: true });
|
|
90
|
+
|
|
91
|
+
for (const filename of referenceFiles) {
|
|
92
|
+
try {
|
|
93
|
+
const sourceFile = path.join(claudeRoot, filename);
|
|
94
|
+
const targetFile = path.join(targetClaudeRoot, filename);
|
|
95
|
+
|
|
96
|
+
if (fs.existsSync(sourceFile)) {
|
|
97
|
+
// Backup existing file if it exists
|
|
98
|
+
if (fs.existsSync(targetFile)) {
|
|
99
|
+
const backupFile = getBackupFilename(targetFile);
|
|
100
|
+
fs.renameSync(targetFile, backupFile);
|
|
101
|
+
log(`Backed up existing ${filename}`, 'info');
|
|
60
102
|
}
|
|
61
103
|
|
|
62
|
-
// Copy
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
104
|
+
// Copy reference file
|
|
105
|
+
fs.copyFileSync(sourceFile, targetFile);
|
|
106
|
+
log(`Synced ${filename} to project`, 'info');
|
|
107
|
+
}
|
|
108
|
+
} catch (err) {
|
|
109
|
+
log(`Failed to sync ${filename}: ${err.message}`, 'error');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (const config of syncConfigs) {
|
|
114
|
+
try {
|
|
115
|
+
// Create target directory if it doesn't exist
|
|
116
|
+
fs.mkdirSync(path.dirname(config.target), { recursive: true });
|
|
117
|
+
|
|
118
|
+
// Backup existing directory
|
|
119
|
+
await backupDirectory(config.source, config.target);
|
|
120
|
+
|
|
121
|
+
// Perform directory copy using cp command
|
|
122
|
+
const sourcePath = config.source;
|
|
123
|
+
const targetPath = config.target;
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
execSync(`cp -r "${sourcePath}" "${targetPath}"`, { stdio: 'ignore' });
|
|
127
|
+
log(`Synced ${path.basename(config.source)}/ to project`, 'info');
|
|
128
|
+
} catch (cpError) {
|
|
129
|
+
// Fallback to recursive copy for Windows
|
|
130
|
+
copyDirRecursive(sourcePath, targetPath);
|
|
131
|
+
log(`Synced ${path.basename(config.source)}/ to project`, 'info');
|
|
75
132
|
}
|
|
133
|
+
} catch (err) {
|
|
134
|
+
log(`Sync failed for ${path.basename(config.source)}: ${err.message}`, 'error');
|
|
76
135
|
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
77
138
|
|
|
78
|
-
|
|
79
|
-
|
|
139
|
+
// Fallback recursive copy for Windows
|
|
140
|
+
function copyDirRecursive(src, dest) {
|
|
141
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
142
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
80
143
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log('🎉 Installation complete! claude-flow-novice is ready to use.');
|
|
144
|
+
for (const entry of entries) {
|
|
145
|
+
const srcPath = path.join(src, entry.name);
|
|
146
|
+
const destPath = path.join(dest, entry.name);
|
|
85
147
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
148
|
+
if (entry.isDirectory()) {
|
|
149
|
+
copyDirRecursive(srcPath, destPath);
|
|
150
|
+
} else {
|
|
151
|
+
fs.copyFileSync(srcPath, destPath);
|
|
152
|
+
}
|
|
90
153
|
}
|
|
91
154
|
}
|
|
92
155
|
|
|
93
|
-
// Run
|
|
94
|
-
|
|
156
|
+
// Run sync
|
|
157
|
+
syncDirectories().catch(err => {
|
|
158
|
+
log(`Sync encountered an error: ${err.message}`, 'error');
|
|
159
|
+
process.exit(1);
|
|
160
|
+
});
|