multi-agents-cli 1.0.26 → 1.0.28
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/init.js +28 -19
- package/package.json +1 -1
package/init.js
CHANGED
|
@@ -80,33 +80,41 @@ const red = (s) => `${c.red}${s}${c.reset}`;
|
|
|
80
80
|
|
|
81
81
|
// ── CLI argument handling ─────────────────────────────────────────────────────
|
|
82
82
|
|
|
83
|
-
const args
|
|
83
|
+
const args = process.argv.slice(2);
|
|
84
84
|
const isGlobalCLI = args[0] === 'init' && args[1];
|
|
85
|
+
const isReInit = args[0] === 'init' && !args[1];
|
|
85
86
|
const projectArg = isGlobalCLI ? args[1] : null;
|
|
86
87
|
|
|
88
|
+
if (isReInit) {
|
|
89
|
+
// Re-init from inside project or worktree - self-relocate to repo root
|
|
90
|
+
try {
|
|
91
|
+
const { execSync } = require('child_process');
|
|
92
|
+
const repoRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
|
|
93
|
+
process.chdir(repoRoot);
|
|
94
|
+
} catch { /* stay in current directory */ }
|
|
95
|
+
}
|
|
96
|
+
|
|
87
97
|
if (isGlobalCLI) {
|
|
88
98
|
const targetDir = path.resolve(process.cwd(), projectArg);
|
|
89
99
|
|
|
90
100
|
if (fs.existsSync(targetDir)) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
fs.mkdirSync(targetDir, { recursive: true });
|
|
97
|
-
process.chdir(targetDir);
|
|
101
|
+
process.chdir(targetDir);
|
|
102
|
+
} else {
|
|
103
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
104
|
+
process.chdir(targetDir);
|
|
98
105
|
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
execSync('git init -b main', { cwd: targetDir, stdio: 'pipe' });
|
|
102
|
-
execSync('git commit --allow-empty -m "init: project created"', { cwd: targetDir, stdio: 'pipe' });
|
|
103
|
-
} catch {
|
|
104
|
-
// Fallback for older git versions that don't support -b flag
|
|
106
|
+
// Initialize git
|
|
105
107
|
try {
|
|
106
|
-
execSync('git init', { cwd: targetDir, stdio: 'pipe' });
|
|
107
|
-
execSync('git checkout -b main', { cwd: targetDir, stdio: 'pipe' });
|
|
108
|
+
execSync('git init -b main', { cwd: targetDir, stdio: 'pipe' });
|
|
108
109
|
execSync('git commit --allow-empty -m "init: project created"', { cwd: targetDir, stdio: 'pipe' });
|
|
109
|
-
} catch {
|
|
110
|
+
} catch {
|
|
111
|
+
// Fallback for older git versions that don't support -b flag
|
|
112
|
+
try {
|
|
113
|
+
execSync('git init', { cwd: targetDir, stdio: 'pipe' });
|
|
114
|
+
execSync('git checkout -b main', { cwd: targetDir, stdio: 'pipe' });
|
|
115
|
+
execSync('git commit --allow-empty -m "init: project created"', { cwd: targetDir, stdio: 'pipe' });
|
|
116
|
+
} catch { /* continue */ }
|
|
117
|
+
}
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
|
|
@@ -1139,8 +1147,9 @@ If a dependency is not met:
|
|
|
1139
1147
|
prompts: '^2.4.2',
|
|
1140
1148
|
},
|
|
1141
1149
|
scripts: {
|
|
1142
|
-
|
|
1143
|
-
|
|
1150
|
+
init: 'multi-agents init',
|
|
1151
|
+
agent: 'node .workflow/agent.js',
|
|
1152
|
+
complete: 'node .workflow/complete.js',
|
|
1144
1153
|
},
|
|
1145
1154
|
};
|
|
1146
1155
|
fs.writeFileSync(path.join(ROOT, 'package.json'), JSON.stringify(userPackage, null, 2), 'utf8');
|
package/package.json
CHANGED