@monoes/cli 1.0.7 → 1.0.9

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.
@@ -130,6 +130,86 @@ const DIRECTORIES = {
130
130
  '.monobrain/workflows',
131
131
  ],
132
132
  };
133
+ /**
134
+ * Remove legacy ruflo/ruv-swarm configuration from existing project files.
135
+ * Also fixes old @monobrain/cli@latest MCP package name → monobrain@latest.
136
+ */
137
+ function cleanupLegacyTools(targetDir) {
138
+ const cleaned = [];
139
+ // Helper to fix MCP server args
140
+ function fixMcpArgs(servers) {
141
+ let changed = false;
142
+ for (const name of Object.keys(servers)) {
143
+ const srv = servers[name];
144
+ if (Array.isArray(srv.args)) {
145
+ srv.args = srv.args.map((a) => {
146
+ if (typeof a === 'string' && a.includes('@monobrain/cli@')) {
147
+ changed = true;
148
+ return a.replace(/@monobrain\/cli@[^\s]*/g, 'monobrain@latest');
149
+ }
150
+ return a;
151
+ });
152
+ }
153
+ }
154
+ return changed;
155
+ }
156
+ // Clean ruv-swarm from .mcp.json and fix old MCP package name
157
+ const mcpJsonPath = path.join(targetDir, '.mcp.json');
158
+ if (fs.existsSync(mcpJsonPath)) {
159
+ try {
160
+ const mcp = JSON.parse(fs.readFileSync(mcpJsonPath, 'utf-8'));
161
+ let mcpChanged = false;
162
+ if (mcp.mcpServers && mcp.mcpServers['ruv-swarm']) {
163
+ delete mcp.mcpServers['ruv-swarm'];
164
+ mcpChanged = true;
165
+ cleaned.push('.mcp.json: removed ruv-swarm entry');
166
+ }
167
+ if (mcp.mcpServers && fixMcpArgs(mcp.mcpServers)) {
168
+ mcpChanged = true;
169
+ cleaned.push('.mcp.json: updated MCP package name to monobrain@latest');
170
+ }
171
+ if (mcpChanged) {
172
+ fs.writeFileSync(mcpJsonPath, JSON.stringify(mcp, null, 2));
173
+ }
174
+ }
175
+ catch { /* non-fatal */ }
176
+ }
177
+ // Clean ruflo / ruv-swarm from .claude/settings.json hooks and fix MCP package name
178
+ const settingsPath = path.join(targetDir, '.claude', 'settings.json');
179
+ if (fs.existsSync(settingsPath)) {
180
+ try {
181
+ const raw = fs.readFileSync(settingsPath, 'utf-8');
182
+ const settings = JSON.parse(raw);
183
+ let settingsChanged = false;
184
+ if (raw.includes('ruflo') || raw.includes('ruv-swarm')) {
185
+ const hookKeys = ['PreToolUse', 'PostToolUse', 'UserPromptSubmit', 'SessionStart', 'SessionEnd', 'Stop', 'SubagentStart', 'SubagentStop', 'PreCompact'];
186
+ for (const key of hookKeys) {
187
+ if (Array.isArray(settings.hooks?.[key])) {
188
+ const before = settings.hooks[key].length;
189
+ settings.hooks[key] = settings.hooks[key].filter((entry) => {
190
+ const str = JSON.stringify(entry);
191
+ return !str.includes('ruflo') && !str.includes('ruv-swarm');
192
+ });
193
+ if (settings.hooks[key].length !== before) settingsChanged = true;
194
+ }
195
+ }
196
+ if (settingsChanged) {
197
+ cleaned.push('.claude/settings.json: removed ruflo/ruv-swarm hooks');
198
+ }
199
+ }
200
+ // Fix wrong MCP package name in mcpServers
201
+ if (settings.mcpServers && fixMcpArgs(settings.mcpServers)) {
202
+ settingsChanged = true;
203
+ cleaned.push('.claude/settings.json: updated MCP package name to monobrain@latest');
204
+ }
205
+ if (settingsChanged) {
206
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
207
+ }
208
+ }
209
+ catch { /* non-fatal */ }
210
+ }
211
+ return cleaned;
212
+ }
133
213
  /**
134
214
  * Execute initialization
135
215
  */
@@ -154,6 +234,11 @@ export async function executeInit(options) {
154
234
  };
155
235
  const targetDir = options.targetDir;
156
236
  try {
237
+ // Remove legacy ruflo/ruv-swarm configs and fix old MCP package names
238
+ const legacyCleaned = cleanupLegacyTools(targetDir);
239
+ for (const msg of legacyCleaned) {
240
+ result.created.files.push(`[cleaned] ${msg}`);
241
+ }
157
242
  // Create directory structure
158
243
  await createDirectories(targetDir, options, result);
159
244
  // Generate and write settings.json
@@ -340,6 +425,11 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
340
425
  settingsUpdated: [],
341
426
  };
342
427
  try {
428
+ // Fix legacy ruflo/ruv-swarm configs and old MCP package names
429
+ const legacyCleaned = cleanupLegacyTools(targetDir);
430
+ for (const msg of legacyCleaned) {
431
+ result.updated.push(`[cleaned] ${msg}`);
432
+ }
343
433
  // Ensure required directories exist
344
434
  const dirs = [
345
435
  '.claude/helpers',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monoes/cli",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "description": "Monobrain CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",