claude-flow-novice 2.4.3 → 2.5.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-flow-novice",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "AI Agent Orchestration CLI",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"bin": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"readme"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
|
+
"postinstall": "node scripts/postinstall.js",
|
|
26
27
|
"build": "npm run clean && tsc && rollup -c",
|
|
27
28
|
"clean": "rimraf dist",
|
|
28
29
|
"lint": "eslint . --ext .ts",
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,94 +1,122 @@
|
|
|
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
|
-
|
|
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
|
+
}
|
|
8
23
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
24
|
+
// Check if running in development mode (not as installed dependency)
|
|
25
|
+
function isDevMode() {
|
|
26
|
+
try {
|
|
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
|
+
}
|
|
12
34
|
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
}
|
|
15
47
|
|
|
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
|
+
}
|
|
16
55
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
join(__dirname, '
|
|
28
|
-
join(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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);
|
|
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')
|
|
46
72
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// Copy file and show progress
|
|
69
|
-
const relativePath = relative(sourceDir, source);
|
|
70
|
-
const status = existsSync(target) ? '♻️ Overwriting' : '📄 Copying';
|
|
71
|
-
console.log(`${status}: ${relativePath}`);
|
|
72
|
-
|
|
73
|
-
copyFileSync(source, target);
|
|
74
|
-
fileCount++;
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
for (const config of syncConfigs) {
|
|
76
|
+
try {
|
|
77
|
+
// Create target directory if it doesn't exist
|
|
78
|
+
fs.mkdirSync(path.dirname(config.target), { recursive: true });
|
|
79
|
+
|
|
80
|
+
// Backup existing directory
|
|
81
|
+
await backupDirectory(config.source, config.target);
|
|
82
|
+
|
|
83
|
+
// Perform directory copy using cp command
|
|
84
|
+
const sourcePath = config.source;
|
|
85
|
+
const targetPath = config.target;
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
execSync(`cp -r "${sourcePath}" "${targetPath}"`, { stdio: 'ignore' });
|
|
89
|
+
log(`Synced ${path.basename(config.source)}/ to project`, 'info');
|
|
90
|
+
} catch (cpError) {
|
|
91
|
+
// Fallback to recursive copy for Windows
|
|
92
|
+
copyDirRecursive(sourcePath, targetPath);
|
|
93
|
+
log(`Synced ${path.basename(config.source)}/ to project`, 'info');
|
|
75
94
|
}
|
|
95
|
+
} catch (err) {
|
|
96
|
+
log(`Sync failed for ${path.basename(config.source)}: ${err.message}`, 'error');
|
|
76
97
|
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
77
100
|
|
|
78
|
-
|
|
79
|
-
|
|
101
|
+
// Fallback recursive copy for Windows
|
|
102
|
+
function copyDirRecursive(src, dest) {
|
|
103
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
104
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
80
105
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log('🎉 Installation complete! claude-flow-novice is ready to use.');
|
|
106
|
+
for (const entry of entries) {
|
|
107
|
+
const srcPath = path.join(src, entry.name);
|
|
108
|
+
const destPath = path.join(dest, entry.name);
|
|
85
109
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
110
|
+
if (entry.isDirectory()) {
|
|
111
|
+
copyDirRecursive(srcPath, destPath);
|
|
112
|
+
} else {
|
|
113
|
+
fs.copyFileSync(srcPath, destPath);
|
|
114
|
+
}
|
|
90
115
|
}
|
|
91
116
|
}
|
|
92
117
|
|
|
93
|
-
// Run
|
|
94
|
-
|
|
118
|
+
// Run sync
|
|
119
|
+
syncDirectories().catch(err => {
|
|
120
|
+
log(`Sync encountered an error: ${err.message}`, 'error');
|
|
121
|
+
process.exit(1);
|
|
122
|
+
});
|