multi-agents-cli 1.1.44 → 1.1.46

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.
@@ -152,30 +152,75 @@ const wipeAgent = ({ scope, agent, branch, worktreePath }) => {
152
152
  const scopeContents = fs.readdirSync(scopeDir).filter(f => f !== 'CLAUDE.md');
153
153
  if (scopeContents.length > 0) {
154
154
  try {
155
- // Delete each entry individually - preserve CLAUDE.md
156
155
  for (const entry of scopeContents) {
157
156
  fs.rmSync(require('path').join(scopeDir, entry), { recursive: true, force: true });
158
157
  }
159
- // Restore CLAUDE.md from CLI templates if missing
160
- const claudePath = require('path').join(scopeDir, 'CLAUDE.md');
161
- if (!fs.existsSync(claudePath)) {
158
+ } catch {}
159
+ }
160
+ }
161
+ // Always ensure scope CLAUDE.md exists - restore from CLI templates if missing or folder gone
162
+ try {
163
+ const claudePath = require('path').join(scopeDir, 'CLAUDE.md');
164
+ if (!fs.existsSync(claudePath)) {
165
+ const globalPkg = require('child_process').execSync('npm root -g', { stdio: 'pipe', encoding: 'utf8' }).trim();
166
+ const tmplPath = require('path').join(globalPkg, 'multi-agents-cli', 'core', 'templates', scope, 'CLAUDE.md');
167
+ if (fs.existsSync(tmplPath)) {
168
+ fs.mkdirSync(scopeDir, { recursive: true });
169
+ fs.copyFileSync(tmplPath, claudePath);
170
+ // Substitute @config values from .config.json (primary) or git history (secondary)
171
+ try {
172
+ let restored = fs.readFileSync(claudePath, 'utf8');
173
+ const scopeCfg = config[scope] || {};
174
+ const configMap = {
175
+ PROJECT_NAME: config.projectName,
176
+ FRAMEWORK: scopeCfg.framework,
177
+ FRAMEWORK_VERSION: scopeCfg.frameworkVersion,
178
+ LANGUAGE: scopeCfg.language,
179
+ UI_LIBRARY: scopeCfg.uiLibrary,
180
+ STATE: scopeCfg.state,
181
+ STYLING: scopeCfg.styling,
182
+ ORM: scopeCfg.orm,
183
+ AUTH: scopeCfg.auth,
184
+ };
185
+ for (const [key, val] of Object.entries(configMap)) {
186
+ if (val) restored = restored.replace(
187
+ new RegExp(`(# @config ${key}\\s*:).*$`, 'm'), `$1 ${val}`
188
+ );
189
+ }
190
+ // Secondary: git history fallback if config values still missing
162
191
  try {
163
- const globalPkg = require('child_process').execSync('npm root -g', { stdio: 'pipe', encoding: 'utf8' }).trim();
164
- const tmplPath = require('path').join(globalPkg, 'multi-agents-cli', 'core', 'templates', scope, 'CLAUDE.md');
165
- if (fs.existsSync(tmplPath)) {
166
- fs.mkdirSync(scopeDir, { recursive: true });
167
- fs.copyFileSync(tmplPath, claudePath);
192
+ const firstCommit = require('child_process').execSync(
193
+ `git log --all --reverse --format=%H -- ${scope}/CLAUDE.md`,
194
+ { cwd: ROOT, stdio: 'pipe', encoding: 'utf8' }
195
+ ).trim().split('\n')[0];
196
+ if (firstCommit) {
197
+ const oldContent = require('child_process').execSync(
198
+ `git show ${firstCommit}:${scope}/CLAUDE.md`,
199
+ { cwd: ROOT, stdio: 'pipe', encoding: 'utf8' }
200
+ );
201
+ for (const line of oldContent.split('\n').filter(l => /^# @config \w/.test(l))) {
202
+ const m = line.match(/^# @config (\w+)\s*:\s*(.+)$/);
203
+ if (m && !configMap[m[1].trim()]) {
204
+ restored = restored.replace(
205
+ new RegExp(`(# @config ${m[1].trim()}\\s*:).*$`, 'm'), `$1 ${m[2].trim()}`
206
+ );
207
+ }
208
+ }
168
209
  }
169
210
  } catch {}
170
- }
171
- require('child_process').execSync('git add -A', { cwd: ROOT, stdio: 'pipe' });
172
- require('child_process').execSync(
173
- `git commit --no-gpg-sign --no-verify -m "chore: remove ${scope} scope content for restart"`,
174
- { cwd: ROOT, stdio: 'pipe' }
175
- );
176
- } catch {}
211
+ fs.writeFileSync(claudePath, restored, 'utf8');
212
+ } catch {}
213
+ }
177
214
  }
178
- }
215
+ } catch {}
216
+ // Commit any scope changes to main
217
+ try {
218
+ require('child_process').execSync('git add -A', { cwd: ROOT, stdio: 'pipe' });
219
+ require('child_process').execSync(
220
+ `git commit --no-gpg-sign --no-verify -m "chore: remove ${scope} scope content for restart"`,
221
+ { cwd: ROOT, stdio: 'pipe' }
222
+ );
223
+ } catch {}
179
224
 
180
225
  if (tracking[scope]?.[agent]) {
181
226
  tracking[scope][agent] = { branch: null, timestamp: null, launchedAt: null, status: null, missingCount: 0, worktreePath: null };
package/init.js CHANGED
@@ -503,6 +503,36 @@ const main = async () => {
503
503
  });
504
504
  console.log(` ${green('✓')} client/CLAUDE.md configured`);
505
505
 
506
+ // Persist resolved config to .scaffold/.config.json for recovery by restart/sync
507
+ try {
508
+ const scaffoldConfig = {
509
+ projectName,
510
+ client: {
511
+ framework: clientFw.value,
512
+ frameworkVersion: clientFwVersion || '',
513
+ language: clientLang,
514
+ state: clientState,
515
+ uiLibrary: clientUi,
516
+ styling: clientStyle,
517
+ },
518
+ };
519
+ if (backendType === 'separate') {
520
+ scaffoldConfig.backend = {
521
+ framework: backendFw,
522
+ frameworkVersion: answers.backendFwVersion || '',
523
+ language: backendLang,
524
+ orm: backendOrm,
525
+ auth: backendAuth,
526
+ };
527
+ }
528
+ fs.writeFileSync(
529
+ path.join(ROOT, '.scaffold', '.config.json'),
530
+ JSON.stringify(scaffoldConfig, null, 2) + '\n',
531
+ 'utf8'
532
+ );
533
+ console.log(` ${green('✓')} .scaffold/.config.json written`);
534
+ } catch {}
535
+
506
536
  if (backendType === 'separate') {
507
537
  writeConfig(path.join(ROOT, 'backend', 'CLAUDE.md'), {
508
538
  PROJECT_NAME: projectName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multi-agents-cli",
3
- "version": "1.1.44",
3
+ "version": "1.1.46",
4
4
  "description": "Multi-agent workflow orchestration for Claude Code — isolated git worktrees, structured state tracking, autonomous task chaining",
5
5
  "keywords": [
6
6
  "claude-code",