multi-agents-cli 1.1.35 → 1.1.37
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 +92 -4
- package/package.json +1 -1
package/init.js
CHANGED
|
@@ -77,11 +77,51 @@ const isReInit = args[0] === 'init' && !args[1];
|
|
|
77
77
|
const projectArg = isGlobalCLI ? args[1] : null;
|
|
78
78
|
|
|
79
79
|
if (isReInit) {
|
|
80
|
+
let inGitRepo = false;
|
|
80
81
|
try {
|
|
81
82
|
const gitCommonDir = execSync('git rev-parse --git-common-dir', { encoding: 'utf8', stdio: 'pipe' }).trim();
|
|
82
83
|
const repoRoot = path.resolve(gitCommonDir, '..');
|
|
83
84
|
process.chdir(repoRoot);
|
|
84
|
-
|
|
85
|
+
inGitRepo = true;
|
|
86
|
+
} catch { /* not yet a git repo - stay in current directory */ }
|
|
87
|
+
|
|
88
|
+
if (!inGitRepo) {
|
|
89
|
+
const targetDir = process.cwd();
|
|
90
|
+
let gitOk = false;
|
|
91
|
+
try {
|
|
92
|
+
execSync('git init -b main', { cwd: targetDir, stdio: 'pipe' });
|
|
93
|
+
execSync('git commit --allow-empty -m "init: project created"', { cwd: targetDir, stdio: 'pipe' });
|
|
94
|
+
gitOk = true;
|
|
95
|
+
} catch {
|
|
96
|
+
try {
|
|
97
|
+
execSync('git init', { cwd: targetDir, stdio: 'pipe' });
|
|
98
|
+
execSync('git checkout -b main', { cwd: targetDir, stdio: 'pipe' });
|
|
99
|
+
execSync('git commit --allow-empty -m "init: project created"', { cwd: targetDir, stdio: 'pipe' });
|
|
100
|
+
gitOk = true;
|
|
101
|
+
} catch { /* both attempts failed */ }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (gitOk) {
|
|
105
|
+
try {
|
|
106
|
+
const commitCount = execSync('git rev-list --count HEAD', { cwd: targetDir, encoding: 'utf8', stdio: 'pipe' }).trim();
|
|
107
|
+
gitOk = parseInt(commitCount, 10) > 0;
|
|
108
|
+
} catch { gitOk = false; }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!gitOk) {
|
|
112
|
+
console.error(`
|
|
113
|
+
✖ Could not create the initial git commit.
|
|
114
|
+
|
|
115
|
+
This is usually caused by missing git identity configuration. Run:
|
|
116
|
+
|
|
117
|
+
git config --global user.name "Your Name"
|
|
118
|
+
git config --global user.email "you@example.com"
|
|
119
|
+
|
|
120
|
+
Then re-run: npm run init
|
|
121
|
+
`);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
85
125
|
}
|
|
86
126
|
|
|
87
127
|
if (isGlobalCLI) {
|
|
@@ -107,15 +147,40 @@ if (isGlobalCLI) {
|
|
|
107
147
|
'utf8'
|
|
108
148
|
);
|
|
109
149
|
|
|
150
|
+
let gitOk = false;
|
|
110
151
|
try {
|
|
111
152
|
execSync('git init -b main', { cwd: targetDir, stdio: 'pipe' });
|
|
112
153
|
execSync('git commit --allow-empty -m "init: project created"', { cwd: targetDir, stdio: 'pipe' });
|
|
154
|
+
gitOk = true;
|
|
113
155
|
} catch {
|
|
114
156
|
try {
|
|
115
157
|
execSync('git init', { cwd: targetDir, stdio: 'pipe' });
|
|
116
158
|
execSync('git checkout -b main', { cwd: targetDir, stdio: 'pipe' });
|
|
117
159
|
execSync('git commit --allow-empty -m "init: project created"', { cwd: targetDir, stdio: 'pipe' });
|
|
118
|
-
|
|
160
|
+
gitOk = true;
|
|
161
|
+
} catch { /* both attempts failed */ }
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Hard gate: verify a commit actually exists before proceeding
|
|
165
|
+
if (gitOk) {
|
|
166
|
+
try {
|
|
167
|
+
const commitCount = execSync('git rev-list --count HEAD', { cwd: targetDir, encoding: 'utf8', stdio: 'pipe' }).trim();
|
|
168
|
+
gitOk = parseInt(commitCount, 10) > 0;
|
|
169
|
+
} catch { gitOk = false; }
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!gitOk) {
|
|
173
|
+
console.error(`
|
|
174
|
+
✖ Could not create the initial git commit.
|
|
175
|
+
|
|
176
|
+
This is usually caused by missing git identity configuration. Run:
|
|
177
|
+
|
|
178
|
+
git config --global user.name "Your Name"
|
|
179
|
+
git config --global user.email "you@example.com"
|
|
180
|
+
|
|
181
|
+
Then re-run: multi-agents init ${path.basename(targetDir)}
|
|
182
|
+
`);
|
|
183
|
+
process.exit(1);
|
|
119
184
|
}
|
|
120
185
|
}
|
|
121
186
|
}
|
|
@@ -666,13 +731,36 @@ Before starting any task, verify:
|
|
|
666
731
|
|
|
667
732
|
// ── Auto-commit ───────────────────────────────────────────────────────────────
|
|
668
733
|
|
|
734
|
+
let configCommitOk = false;
|
|
669
735
|
try {
|
|
670
736
|
execSync('git add .', { cwd: ROOT, stdio: 'pipe' });
|
|
671
737
|
execSync('git commit -m "init: project configuration"', { cwd: ROOT, stdio: 'pipe' });
|
|
672
738
|
console.log(` ${green('✓')} Project configuration committed`);
|
|
739
|
+
configCommitOk = true;
|
|
673
740
|
} catch {
|
|
674
|
-
console.log(` ${yellow('!')} Could not auto-commit
|
|
675
|
-
|
|
741
|
+
console.log(` ${yellow('!')} Could not auto-commit.`);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
if (!configCommitOk) {
|
|
745
|
+
try {
|
|
746
|
+
const commitCount = execSync('git rev-list --count HEAD', { cwd: ROOT, encoding: 'utf8', stdio: 'pipe' }).trim();
|
|
747
|
+
configCommitOk = parseInt(commitCount, 10) > 0;
|
|
748
|
+
} catch { configCommitOk = false; }
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
if (!configCommitOk) {
|
|
752
|
+
console.error(`
|
|
753
|
+
✖ Project could not be committed to git.
|
|
754
|
+
|
|
755
|
+
This is usually caused by missing git identity configuration. Run:
|
|
756
|
+
|
|
757
|
+
git config --global user.name "Your Name"
|
|
758
|
+
git config --global user.email "you@example.com"
|
|
759
|
+
|
|
760
|
+
Then run: git add . && git commit -m "init: project configuration"
|
|
761
|
+
And re-run: npm run agent
|
|
762
|
+
`);
|
|
763
|
+
process.exit(1);
|
|
676
764
|
}
|
|
677
765
|
|
|
678
766
|
// ── Pre-commit hook ───────────────────────────────────────────────────────────
|
package/package.json
CHANGED