@wundr.io/cli 1.0.1 ā 1.0.3
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/dist/ai/ai-service.d.ts +152 -0
- package/dist/ai/ai-service.d.ts.map +1 -0
- package/dist/ai/ai-service.js +430 -0
- package/dist/ai/ai-service.js.map +1 -0
- package/dist/ai/claude-client.d.ts +130 -0
- package/dist/ai/claude-client.d.ts.map +1 -0
- package/dist/ai/claude-client.js +340 -0
- package/dist/ai/claude-client.js.map +1 -0
- package/dist/ai/conversation-manager.d.ts +164 -0
- package/dist/ai/conversation-manager.d.ts.map +1 -0
- package/dist/ai/conversation-manager.js +614 -0
- package/dist/ai/conversation-manager.js.map +1 -0
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +8 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/cli.d.ts +36 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +192 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/ai.d.ts +89 -0
- package/dist/commands/ai.d.ts.map +1 -0
- package/dist/commands/ai.js +735 -0
- package/dist/commands/ai.js.map +1 -0
- package/dist/commands/alignment.d.ts +78 -0
- package/dist/commands/alignment.d.ts.map +1 -0
- package/dist/commands/alignment.js +817 -0
- package/dist/commands/alignment.js.map +1 -0
- package/dist/commands/analyze-optimized.d.ts +14 -0
- package/dist/commands/analyze-optimized.d.ts.map +1 -0
- package/dist/commands/analyze-optimized.js +440 -0
- package/dist/commands/analyze-optimized.js.map +1 -0
- package/dist/commands/analyze.d.ts +65 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +435 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/batch.d.ts +71 -0
- package/dist/commands/batch.d.ts.map +1 -0
- package/dist/commands/batch.js +738 -0
- package/dist/commands/batch.js.map +1 -0
- package/dist/commands/chat.d.ts +71 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +674 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/claude-init.d.ts +28 -0
- package/dist/commands/claude-init.d.ts.map +1 -0
- package/dist/commands/claude-init.js +591 -0
- package/dist/commands/claude-init.js.map +1 -0
- package/dist/commands/claude-setup.d.ts +119 -0
- package/dist/commands/claude-setup.d.ts.map +1 -0
- package/dist/commands/claude-setup.js +1073 -0
- package/dist/commands/claude-setup.js.map +1 -0
- package/dist/commands/computer-setup-commands.d.ts +53 -0
- package/dist/commands/computer-setup-commands.d.ts.map +1 -0
- package/dist/commands/computer-setup-commands.js +705 -0
- package/dist/commands/computer-setup-commands.js.map +1 -0
- package/dist/commands/computer-setup.d.ts +7 -0
- package/dist/commands/computer-setup.d.ts.map +1 -0
- package/dist/commands/computer-setup.js +849 -0
- package/dist/commands/computer-setup.js.map +1 -0
- package/dist/commands/create-command.d.ts +7 -0
- package/dist/commands/create-command.d.ts.map +1 -0
- package/dist/commands/create-command.js +158 -0
- package/dist/commands/create-command.js.map +1 -0
- package/dist/commands/create.d.ts +74 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +556 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dashboard.d.ts +91 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +538 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/govern.d.ts +70 -0
- package/dist/commands/govern.d.ts.map +1 -0
- package/dist/commands/govern.js +481 -0
- package/dist/commands/govern.js.map +1 -0
- package/dist/commands/governance.d.ts +17 -0
- package/dist/commands/governance.d.ts.map +1 -0
- package/dist/commands/governance.js +703 -0
- package/dist/commands/governance.js.map +1 -0
- package/dist/commands/guardian.d.ts +20 -0
- package/dist/commands/guardian.d.ts.map +1 -0
- package/dist/commands/guardian.js +597 -0
- package/dist/commands/guardian.js.map +1 -0
- package/dist/commands/init.d.ts +59 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +650 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/performance-optimizer.d.ts +30 -0
- package/dist/commands/performance-optimizer.d.ts.map +1 -0
- package/dist/commands/performance-optimizer.js +650 -0
- package/dist/commands/performance-optimizer.js.map +1 -0
- package/dist/commands/plugins.d.ts +87 -0
- package/dist/commands/plugins.d.ts.map +1 -0
- package/dist/commands/plugins.js +685 -0
- package/dist/commands/plugins.js.map +1 -0
- package/dist/commands/rag.d.ts +7 -0
- package/dist/commands/rag.d.ts.map +1 -0
- package/dist/commands/rag.js +748 -0
- package/dist/commands/rag.js.map +1 -0
- package/dist/commands/session.d.ts +41 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +441 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/setup.d.ts +29 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +397 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/test-init.d.ts +9 -0
- package/dist/commands/test-init.d.ts.map +1 -0
- package/dist/commands/test-init.js +222 -0
- package/dist/commands/test-init.js.map +1 -0
- package/dist/commands/test.d.ts +25 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +217 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/vp.d.ts +7 -0
- package/dist/commands/vp.d.ts.map +1 -0
- package/dist/commands/vp.js +571 -0
- package/dist/commands/vp.js.map +1 -0
- package/dist/commands/watch.d.ts +76 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +613 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/commands/worktree.d.ts +63 -0
- package/dist/commands/worktree.d.ts.map +1 -0
- package/dist/commands/worktree.js +774 -0
- package/dist/commands/worktree.js.map +1 -0
- package/dist/context/context-manager.d.ts +155 -0
- package/dist/context/context-manager.d.ts.map +1 -0
- package/dist/context/context-manager.js +383 -0
- package/dist/context/context-manager.js.map +1 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +6 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/session-manager.d.ts +207 -0
- package/dist/context/session-manager.d.ts.map +1 -0
- package/dist/context/session-manager.js +686 -0
- package/dist/context/session-manager.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive/interactive-mode.d.ts +76 -0
- package/dist/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/interactive/interactive-mode.js +732 -0
- package/dist/interactive/interactive-mode.js.map +1 -0
- package/dist/nlp/command-mapper.d.ts +174 -0
- package/dist/nlp/command-mapper.d.ts.map +1 -0
- package/dist/nlp/command-mapper.js +624 -0
- package/dist/nlp/command-mapper.js.map +1 -0
- package/dist/nlp/command-parser.d.ts +106 -0
- package/dist/nlp/command-parser.d.ts.map +1 -0
- package/dist/nlp/command-parser.js +417 -0
- package/dist/nlp/command-parser.js.map +1 -0
- package/dist/nlp/index.d.ts +5 -0
- package/dist/nlp/index.d.ts.map +1 -0
- package/dist/nlp/index.js +8 -0
- package/dist/nlp/index.js.map +1 -0
- package/dist/nlp/intent-classifier.d.ts +59 -0
- package/dist/nlp/intent-classifier.d.ts.map +1 -0
- package/dist/nlp/intent-classifier.js +384 -0
- package/dist/nlp/intent-classifier.js.map +1 -0
- package/dist/nlp/intent-parser.d.ts +152 -0
- package/dist/nlp/intent-parser.d.ts.map +1 -0
- package/dist/nlp/intent-parser.js +744 -0
- package/dist/nlp/intent-parser.js.map +1 -0
- package/dist/plugins/plugin-manager.d.ts +120 -0
- package/dist/plugins/plugin-manager.d.ts.map +1 -0
- package/dist/plugins/plugin-manager.js +595 -0
- package/dist/plugins/plugin-manager.js.map +1 -0
- package/dist/types/index.d.ts +224 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/backup-rollback-manager.d.ts +72 -0
- package/dist/utils/backup-rollback-manager.d.ts.map +1 -0
- package/dist/utils/backup-rollback-manager.js +289 -0
- package/dist/utils/backup-rollback-manager.js.map +1 -0
- package/dist/utils/claude-config-installer.d.ts +94 -0
- package/dist/utils/claude-config-installer.d.ts.map +1 -0
- package/dist/utils/claude-config-installer.js +628 -0
- package/dist/utils/claude-config-installer.js.map +1 -0
- package/dist/utils/config-manager.d.ts +73 -0
- package/dist/utils/config-manager.d.ts.map +1 -0
- package/dist/utils/config-manager.js +339 -0
- package/dist/utils/config-manager.js.map +1 -0
- package/dist/utils/error-handler.d.ts +46 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +169 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/logger.d.ts +25 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +105 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +23 -4
- package/src/ai/ai-service.ts +22 -19
- package/src/ai/claude-client.ts +20 -16
- package/src/ai/conversation-manager.ts +37 -30
- package/src/cli.ts +42 -13
- package/src/commands/ai.ts +59 -57
- package/src/commands/alignment.ts +1212 -0
- package/src/commands/analyze-optimized.ts +70 -62
- package/src/commands/analyze.ts +22 -20
- package/src/commands/batch.ts +41 -38
- package/src/commands/chat.ts +37 -34
- package/src/commands/claude-init.ts +38 -30
- package/src/commands/claude-setup.ts +692 -97
- package/src/commands/computer-setup-commands.ts +45 -39
- package/src/commands/computer-setup.ts +474 -4
- package/src/commands/create-command.ts +7 -7
- package/src/commands/create.ts +36 -33
- package/src/commands/dashboard.ts +33 -28
- package/src/commands/govern.ts +34 -29
- package/src/commands/governance.ts +1005 -0
- package/src/commands/guardian.ts +887 -0
- package/src/commands/init.ts +112 -22
- package/src/commands/performance-optimizer.ts +48 -42
- package/src/commands/plugins.ts +35 -32
- package/src/commands/project-update.ts +1053 -0
- package/src/commands/rag.ts +904 -0
- package/src/commands/session.ts +631 -0
- package/src/commands/setup.ts +35 -31
- package/src/commands/test-init.ts +6 -5
- package/src/commands/test.ts +7 -6
- package/src/commands/vp.ts +762 -0
- package/src/commands/watch.ts +44 -33
- package/src/commands/worktree.ts +1057 -0
- package/src/context/context-manager.ts +15 -12
- package/src/context/session-manager.ts +51 -40
- package/src/index.ts +7 -6
- package/src/interactive/interactive-mode.ts +25 -18
- package/src/lib/conflict-resolution.ts +28 -0
- package/src/lib/merge-strategy.ts +28 -0
- package/src/lib/safety-mechanisms.ts +47 -0
- package/src/lib/state-detection.ts +28 -0
- package/src/nlp/command-mapper.ts +35 -30
- package/src/nlp/command-parser.ts +20 -17
- package/src/nlp/intent-classifier.ts +7 -7
- package/src/nlp/intent-parser.ts +61 -49
- package/src/plugins/plugin-manager.ts +27 -23
- package/src/types/index.ts +1 -1
- package/src/types/modules.d.ts +1 -0
- package/src/utils/backup-rollback-manager.ts +13 -11
- package/src/utils/claude-config-installer.ts +18 -16
- package/src/utils/config-manager.ts +12 -9
- package/src/utils/error-handler.ts +5 -3
- package/src/utils/logger.ts +35 -12
package/src/commands/init.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import inquirer from 'inquirer';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
1
|
import path from 'path';
|
|
2
|
+
|
|
5
3
|
import chalk from 'chalk';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
|
|
7
|
+
import { initProjectRag, type RagInitOptions } from '@wundr.io/core';
|
|
9
8
|
import { errorHandler } from '../utils/error-handler';
|
|
9
|
+
import { logger } from '../utils/logger';
|
|
10
|
+
|
|
11
|
+
import type { PluginManager } from '../plugins/plugin-manager';
|
|
12
|
+
import type { ConfigManager } from '../utils/config-manager';
|
|
13
|
+
import type { Command } from 'commander';
|
|
10
14
|
|
|
11
15
|
/**
|
|
12
16
|
* Init commands for project setup and configuration
|
|
@@ -15,7 +19,7 @@ export class InitCommands {
|
|
|
15
19
|
constructor(
|
|
16
20
|
private program: Command,
|
|
17
21
|
private configManager: ConfigManager,
|
|
18
|
-
private pluginManager: PluginManager
|
|
22
|
+
private pluginManager: PluginManager,
|
|
19
23
|
) {
|
|
20
24
|
this.registerCommands();
|
|
21
25
|
}
|
|
@@ -33,10 +37,22 @@ export class InitCommands {
|
|
|
33
37
|
.option('--skip-git', 'skip git initialization')
|
|
34
38
|
.option('--skip-install', 'skip dependency installation')
|
|
35
39
|
.option('--monorepo', 'initialize as monorepo')
|
|
40
|
+
.option('--with-rag', 'initialize RAG (Retrieval-Augmented Generation) support')
|
|
36
41
|
.action(async (name, options) => {
|
|
37
42
|
await this.initProject(name, options);
|
|
38
43
|
});
|
|
39
44
|
|
|
45
|
+
// Initialize RAG for existing project
|
|
46
|
+
initCmd
|
|
47
|
+
.command('rag')
|
|
48
|
+
.description('initialize RAG support for an existing project')
|
|
49
|
+
.option('--force', 'force re-initialization even if config exists')
|
|
50
|
+
.option('--skip-indexing', 'skip initial file indexing')
|
|
51
|
+
.option('--project-name <name>', 'override project name')
|
|
52
|
+
.action(async options => {
|
|
53
|
+
await this.initRag(options);
|
|
54
|
+
});
|
|
55
|
+
|
|
40
56
|
// Initialize configuration
|
|
41
57
|
initCmd
|
|
42
58
|
.command('config')
|
|
@@ -107,16 +123,90 @@ export class InitCommands {
|
|
|
107
123
|
await this.installDependencies(projectPath);
|
|
108
124
|
}
|
|
109
125
|
|
|
126
|
+
// Initialize RAG if --with-rag flag is provided
|
|
127
|
+
if (options.withRag) {
|
|
128
|
+
logger.info('Initializing RAG support...');
|
|
129
|
+
const ragResult = await initProjectRag(projectPath, {
|
|
130
|
+
projectName,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (ragResult.success) {
|
|
134
|
+
logger.success(
|
|
135
|
+
`RAG initialized: ${ragResult.filesIndexed} files indexed`,
|
|
136
|
+
);
|
|
137
|
+
logger.info(
|
|
138
|
+
` Framework detected: ${chalk.cyan(ragResult.framework.name)}`,
|
|
139
|
+
);
|
|
140
|
+
} else {
|
|
141
|
+
logger.warn('RAG initialization had issues:');
|
|
142
|
+
for (const error of ragResult.errors) {
|
|
143
|
+
logger.warn(` - ${error}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
for (const warning of ragResult.warnings) {
|
|
148
|
+
logger.warn(` Warning: ${warning}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
110
152
|
logger.success(`Project ${projectName} initialized successfully!`);
|
|
111
|
-
logger.info(
|
|
153
|
+
logger.info('Next steps:');
|
|
112
154
|
logger.info(` cd ${projectName}`);
|
|
113
|
-
logger.info(
|
|
155
|
+
logger.info(' wundr analyze');
|
|
114
156
|
} catch (error) {
|
|
115
157
|
throw errorHandler.createError(
|
|
116
158
|
'WUNDR_INIT_PROJECT_FAILED',
|
|
117
159
|
'Failed to initialize project',
|
|
118
160
|
{ name, options },
|
|
119
|
-
true
|
|
161
|
+
true,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Initialize RAG support for existing project
|
|
168
|
+
*/
|
|
169
|
+
private async initRag(options: {
|
|
170
|
+
force?: boolean;
|
|
171
|
+
skipIndexing?: boolean;
|
|
172
|
+
projectName?: string;
|
|
173
|
+
}): Promise<void> {
|
|
174
|
+
try {
|
|
175
|
+
const projectPath = process.cwd();
|
|
176
|
+
logger.info(`Initializing RAG support in: ${chalk.cyan(projectPath)}`);
|
|
177
|
+
|
|
178
|
+
const ragOptions: RagInitOptions = {
|
|
179
|
+
force: options.force,
|
|
180
|
+
skipIndexing: options.skipIndexing,
|
|
181
|
+
projectName: options.projectName,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const result = await initProjectRag(projectPath, ragOptions);
|
|
185
|
+
|
|
186
|
+
if (result.success) {
|
|
187
|
+
logger.success('RAG initialization complete!');
|
|
188
|
+
logger.info(` Config: ${chalk.cyan(result.configPath)}`);
|
|
189
|
+
logger.info(` Exclusions: ${chalk.cyan(result.excludePath)}`);
|
|
190
|
+
logger.info(` Files indexed: ${chalk.cyan(result.filesIndexed)}`);
|
|
191
|
+
logger.info(
|
|
192
|
+
` Framework: ${chalk.cyan(result.framework.name)} (${result.framework.projectType})`,
|
|
193
|
+
);
|
|
194
|
+
} else {
|
|
195
|
+
logger.error('RAG initialization failed:');
|
|
196
|
+
for (const error of result.errors) {
|
|
197
|
+
logger.error(` - ${error}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
for (const warning of result.warnings) {
|
|
202
|
+
logger.warn(` Warning: ${warning}`);
|
|
203
|
+
}
|
|
204
|
+
} catch (error) {
|
|
205
|
+
throw errorHandler.createError(
|
|
206
|
+
'WUNDR_INIT_RAG_FAILED',
|
|
207
|
+
'Failed to initialize RAG',
|
|
208
|
+
{ options },
|
|
209
|
+
true,
|
|
120
210
|
);
|
|
121
211
|
}
|
|
122
212
|
}
|
|
@@ -144,7 +234,7 @@ export class InitCommands {
|
|
|
144
234
|
'WUNDR_INIT_CONFIG_FAILED',
|
|
145
235
|
'Failed to initialize configuration',
|
|
146
236
|
{ options },
|
|
147
|
-
true
|
|
237
|
+
true,
|
|
148
238
|
);
|
|
149
239
|
}
|
|
150
240
|
}
|
|
@@ -179,7 +269,7 @@ export class InitCommands {
|
|
|
179
269
|
// Create workspace-specific wundr config
|
|
180
270
|
await this.configManager.loadConfig();
|
|
181
271
|
await this.configManager.saveConfig(
|
|
182
|
-
path.join(process.cwd(), 'wundr.config.json')
|
|
272
|
+
path.join(process.cwd(), 'wundr.config.json'),
|
|
183
273
|
);
|
|
184
274
|
|
|
185
275
|
logger.success('Workspace initialized successfully!');
|
|
@@ -188,7 +278,7 @@ export class InitCommands {
|
|
|
188
278
|
'WUNDR_INIT_WORKSPACE_FAILED',
|
|
189
279
|
'Failed to initialize workspace',
|
|
190
280
|
{ options },
|
|
191
|
-
true
|
|
281
|
+
true,
|
|
192
282
|
);
|
|
193
283
|
}
|
|
194
284
|
}
|
|
@@ -215,7 +305,7 @@ export class InitCommands {
|
|
|
215
305
|
'WUNDR_INIT_PLUGINS_FAILED',
|
|
216
306
|
'Failed to initialize plugins',
|
|
217
307
|
{ options },
|
|
218
|
-
true
|
|
308
|
+
true,
|
|
219
309
|
);
|
|
220
310
|
}
|
|
221
311
|
}
|
|
@@ -225,7 +315,7 @@ export class InitCommands {
|
|
|
225
315
|
*/
|
|
226
316
|
private async createProjectStructure(
|
|
227
317
|
projectPath: string,
|
|
228
|
-
options: any
|
|
318
|
+
options: any,
|
|
229
319
|
): Promise<void> {
|
|
230
320
|
await fs.ensureDir(projectPath);
|
|
231
321
|
|
|
@@ -242,7 +332,7 @@ export class InitCommands {
|
|
|
242
332
|
// Create project-specific config
|
|
243
333
|
const config = await this.configManager.loadConfig();
|
|
244
334
|
await this.configManager.saveConfig(
|
|
245
|
-
path.join(projectPath, 'wundr.config.json')
|
|
335
|
+
path.join(projectPath, 'wundr.config.json'),
|
|
246
336
|
);
|
|
247
337
|
}
|
|
248
338
|
|
|
@@ -251,7 +341,7 @@ export class InitCommands {
|
|
|
251
341
|
*/
|
|
252
342
|
private async createDefaultStructure(
|
|
253
343
|
projectPath: string,
|
|
254
|
-
options: any
|
|
344
|
+
options: any,
|
|
255
345
|
): Promise<void> {
|
|
256
346
|
const directories = options.monorepo
|
|
257
347
|
? ['packages', 'apps', 'tools', 'docs', 'scripts', '.claude-flow']
|
|
@@ -554,11 +644,11 @@ fi
|
|
|
554
644
|
|
|
555
645
|
await fs.writeFile(
|
|
556
646
|
path.join(projectPath, 'scripts', 'verify-claims.sh'),
|
|
557
|
-
verifyScript
|
|
647
|
+
verifyScript,
|
|
558
648
|
);
|
|
559
649
|
await fs.chmod(
|
|
560
650
|
path.join(projectPath, 'scripts', 'verify-claims.sh'),
|
|
561
|
-
'755'
|
|
651
|
+
'755',
|
|
562
652
|
);
|
|
563
653
|
|
|
564
654
|
// Create FAILURES.md
|
|
@@ -588,7 +678,7 @@ _(None yet - will be populated when failures are resolved)_
|
|
|
588
678
|
|
|
589
679
|
await fs.writeFile(
|
|
590
680
|
path.join(projectPath, 'docs', 'FAILURES.md'),
|
|
591
|
-
failuresMd
|
|
681
|
+
failuresMd,
|
|
592
682
|
);
|
|
593
683
|
|
|
594
684
|
// Create verification hooks
|
|
@@ -628,7 +718,7 @@ _(None yet - will be populated when failures are resolved)_
|
|
|
628
718
|
await fs.writeJson(
|
|
629
719
|
path.join(projectPath, '.claude-flow', 'verification-hooks.json'),
|
|
630
720
|
verificationHooks,
|
|
631
|
-
{ spaces: 2 }
|
|
721
|
+
{ spaces: 2 },
|
|
632
722
|
);
|
|
633
723
|
|
|
634
724
|
// Create agent verification protocol
|
|
@@ -669,7 +759,7 @@ Remember: It's better to report a failure honestly than to claim false success.
|
|
|
669
759
|
|
|
670
760
|
await fs.writeFile(
|
|
671
761
|
path.join(projectPath, 'docs', 'AGENT_VERIFICATION_PROTOCOL.md'),
|
|
672
|
-
agentProtocol
|
|
762
|
+
agentProtocol,
|
|
673
763
|
);
|
|
674
764
|
|
|
675
765
|
logger.debug('Verification files created');
|
|
@@ -3,17 +3,21 @@
|
|
|
3
3
|
* Implements intelligent optimization strategies for Wundr platform performance
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Command } from 'commander';
|
|
7
|
-
import fs from 'fs-extra';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import chalk from 'chalk';
|
|
10
|
-
import { ConfigManager } from '../utils/config-manager';
|
|
11
|
-
import { logger } from '../utils/logger';
|
|
12
|
-
import { errorHandler } from '../utils/error-handler';
|
|
13
6
|
import { spawn } from 'child_process';
|
|
7
|
+
import path from 'path';
|
|
14
8
|
import { performance } from 'perf_hooks';
|
|
15
9
|
import { memoryUsage, cpuUsage } from 'process';
|
|
16
10
|
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import fs from 'fs-extra';
|
|
13
|
+
|
|
14
|
+
import { errorHandler } from '../utils/error-handler';
|
|
15
|
+
import { logger } from '../utils/logger';
|
|
16
|
+
|
|
17
|
+
import type { ConfigManager } from '../utils/config-manager';
|
|
18
|
+
import type { Command } from 'commander';
|
|
19
|
+
|
|
20
|
+
|
|
17
21
|
interface OptimizationResult {
|
|
18
22
|
category: 'memory' | 'concurrency' | 'cpu' | 'io' | 'network';
|
|
19
23
|
description: string;
|
|
@@ -133,7 +137,7 @@ class MemoryOptimizer {
|
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
async optimizeMemoryUsage(
|
|
136
|
-
optimizations: OptimizationResult[]
|
|
140
|
+
optimizations: OptimizationResult[],
|
|
137
141
|
): Promise<void> {
|
|
138
142
|
for (const opt of optimizations.filter(o => o.automated && !o.applied)) {
|
|
139
143
|
logger.info(`Applying memory optimization: ${opt.description}`);
|
|
@@ -152,7 +156,7 @@ class MemoryOptimizer {
|
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
private async applyMemoryOptimization(
|
|
155
|
-
opt: OptimizationResult
|
|
159
|
+
opt: OptimizationResult,
|
|
156
160
|
): Promise<void> {
|
|
157
161
|
// Force garbage collection if available
|
|
158
162
|
if (
|
|
@@ -171,7 +175,7 @@ class MemoryOptimizer {
|
|
|
171
175
|
) {
|
|
172
176
|
// 1GB
|
|
173
177
|
logger.warn(
|
|
174
|
-
'Consider increasing Node.js heap size with --max-old-space-size'
|
|
178
|
+
'Consider increasing Node.js heap size with --max-old-space-size',
|
|
175
179
|
);
|
|
176
180
|
}
|
|
177
181
|
}
|
|
@@ -247,7 +251,7 @@ class ConcurrencyOptimizer {
|
|
|
247
251
|
}
|
|
248
252
|
|
|
249
253
|
async optimizeConcurrency(
|
|
250
|
-
optimizations: OptimizationResult[]
|
|
254
|
+
optimizations: OptimizationResult[],
|
|
251
255
|
): Promise<void> {
|
|
252
256
|
for (const opt of optimizations.filter(o => o.automated && !o.applied)) {
|
|
253
257
|
logger.info(`Applying concurrency optimization: ${opt.description}`);
|
|
@@ -262,16 +266,16 @@ class ConcurrencyOptimizer {
|
|
|
262
266
|
}
|
|
263
267
|
|
|
264
268
|
private async applyConcurrencyOptimization(
|
|
265
|
-
opt: OptimizationResult
|
|
269
|
+
opt: OptimizationResult,
|
|
266
270
|
): Promise<void> {
|
|
267
271
|
if (opt.metrics?.['utilization'] && opt.metrics['utilization'] < 0.7) {
|
|
268
272
|
// Increase worker thread pool for better CPU utilization
|
|
269
273
|
const newWorkerCount = Math.min(
|
|
270
274
|
this.workerThreads,
|
|
271
|
-
Math.floor(this.workerThreads * 1.2)
|
|
275
|
+
Math.floor(this.workerThreads * 1.2),
|
|
272
276
|
);
|
|
273
277
|
logger.info(
|
|
274
|
-
`Increasing worker threads from ${this.activeWorkers} to ${newWorkerCount}
|
|
278
|
+
`Increasing worker threads from ${this.activeWorkers} to ${newWorkerCount}`,
|
|
275
279
|
);
|
|
276
280
|
// Implementation would update the actual worker pool
|
|
277
281
|
}
|
|
@@ -355,7 +359,7 @@ export class PerformanceOptimizerCommands {
|
|
|
355
359
|
|
|
356
360
|
constructor(
|
|
357
361
|
private program: Command,
|
|
358
|
-
private configManager: ConfigManager
|
|
362
|
+
private configManager: ConfigManager,
|
|
359
363
|
) {
|
|
360
364
|
this.registerCommands();
|
|
361
365
|
}
|
|
@@ -403,7 +407,7 @@ export class PerformanceOptimizerCommands {
|
|
|
403
407
|
.description('run all optimization analyses and apply safe optimizations')
|
|
404
408
|
.option(
|
|
405
409
|
'--dry-run',
|
|
406
|
-
'show what would be optimized without applying changes'
|
|
410
|
+
'show what would be optimized without applying changes',
|
|
407
411
|
)
|
|
408
412
|
.option('--report <path>', 'generate comprehensive optimization report')
|
|
409
413
|
.action(async options => {
|
|
@@ -443,7 +447,7 @@ export class PerformanceOptimizerCommands {
|
|
|
443
447
|
}
|
|
444
448
|
|
|
445
449
|
logger.info(
|
|
446
|
-
`Found ${optimizations.length} memory optimization opportunities
|
|
450
|
+
`Found ${optimizations.length} memory optimization opportunities:`,
|
|
447
451
|
);
|
|
448
452
|
optimizations.forEach(opt => {
|
|
449
453
|
const impactColor =
|
|
@@ -453,7 +457,7 @@ export class PerformanceOptimizerCommands {
|
|
|
453
457
|
? 'yellow'
|
|
454
458
|
: 'green';
|
|
455
459
|
console.log(
|
|
456
|
-
` ${chalk[impactColor](`[${opt.impact.toUpperCase()}]`)} ${opt.description}
|
|
460
|
+
` ${chalk[impactColor](`[${opt.impact.toUpperCase()}]`)} ${opt.description}`,
|
|
457
461
|
);
|
|
458
462
|
});
|
|
459
463
|
|
|
@@ -468,7 +472,7 @@ export class PerformanceOptimizerCommands {
|
|
|
468
472
|
await this.generateOptimizationReport(
|
|
469
473
|
optimizations,
|
|
470
474
|
options.report,
|
|
471
|
-
'memory'
|
|
475
|
+
'memory',
|
|
472
476
|
);
|
|
473
477
|
}
|
|
474
478
|
} catch (error) {
|
|
@@ -476,7 +480,7 @@ export class PerformanceOptimizerCommands {
|
|
|
476
480
|
'WUNDR_MEMORY_OPTIMIZATION_FAILED',
|
|
477
481
|
'Failed to optimize memory usage',
|
|
478
482
|
{ options },
|
|
479
|
-
true
|
|
483
|
+
true,
|
|
480
484
|
);
|
|
481
485
|
}
|
|
482
486
|
}
|
|
@@ -487,7 +491,7 @@ export class PerformanceOptimizerCommands {
|
|
|
487
491
|
|
|
488
492
|
if (options.workers) {
|
|
489
493
|
this.concurrencyOptimizer.updateActiveWorkers(
|
|
490
|
-
parseInt(options.workers)
|
|
494
|
+
parseInt(options.workers),
|
|
491
495
|
);
|
|
492
496
|
}
|
|
493
497
|
|
|
@@ -500,7 +504,7 @@ export class PerformanceOptimizerCommands {
|
|
|
500
504
|
}
|
|
501
505
|
|
|
502
506
|
logger.info(
|
|
503
|
-
`Found ${optimizations.length} concurrency optimization opportunities
|
|
507
|
+
`Found ${optimizations.length} concurrency optimization opportunities:`,
|
|
504
508
|
);
|
|
505
509
|
optimizations.forEach(opt => {
|
|
506
510
|
const impactColor =
|
|
@@ -510,7 +514,7 @@ export class PerformanceOptimizerCommands {
|
|
|
510
514
|
? 'yellow'
|
|
511
515
|
: 'green';
|
|
512
516
|
console.log(
|
|
513
|
-
` ${chalk[impactColor](`[${opt.impact.toUpperCase()}]`)} ${opt.description}
|
|
517
|
+
` ${chalk[impactColor](`[${opt.impact.toUpperCase()}]`)} ${opt.description}`,
|
|
514
518
|
);
|
|
515
519
|
});
|
|
516
520
|
|
|
@@ -525,7 +529,7 @@ export class PerformanceOptimizerCommands {
|
|
|
525
529
|
'WUNDR_CONCURRENCY_OPTIMIZATION_FAILED',
|
|
526
530
|
'Failed to optimize concurrency',
|
|
527
531
|
{ options },
|
|
528
|
-
true
|
|
532
|
+
true,
|
|
529
533
|
);
|
|
530
534
|
}
|
|
531
535
|
}
|
|
@@ -544,7 +548,7 @@ export class PerformanceOptimizerCommands {
|
|
|
544
548
|
}
|
|
545
549
|
|
|
546
550
|
logger.info(
|
|
547
|
-
`Found ${optimizations.length} bundle optimization opportunities
|
|
551
|
+
`Found ${optimizations.length} bundle optimization opportunities:`,
|
|
548
552
|
);
|
|
549
553
|
optimizations.forEach(opt => {
|
|
550
554
|
const impactColor =
|
|
@@ -554,7 +558,7 @@ export class PerformanceOptimizerCommands {
|
|
|
554
558
|
? 'yellow'
|
|
555
559
|
: 'green';
|
|
556
560
|
console.log(
|
|
557
|
-
` ${chalk[impactColor](`[${opt.impact.toUpperCase()}]`)} ${opt.description}
|
|
561
|
+
` ${chalk[impactColor](`[${opt.impact.toUpperCase()}]`)} ${opt.description}`,
|
|
558
562
|
);
|
|
559
563
|
opt.recommendations.forEach(rec => console.log(` ⢠${rec}`));
|
|
560
564
|
});
|
|
@@ -563,7 +567,7 @@ export class PerformanceOptimizerCommands {
|
|
|
563
567
|
'WUNDR_BUNDLE_OPTIMIZATION_FAILED',
|
|
564
568
|
'Failed to optimize bundle',
|
|
565
569
|
{ options },
|
|
566
|
-
true
|
|
570
|
+
true,
|
|
567
571
|
);
|
|
568
572
|
}
|
|
569
573
|
}
|
|
@@ -579,7 +583,7 @@ export class PerformanceOptimizerCommands {
|
|
|
579
583
|
const concurrencyOpts =
|
|
580
584
|
await this.concurrencyOptimizer.analyzeConcurrency();
|
|
581
585
|
const bundleOpts = await this.assetOptimizer.analyzeBundleSize(
|
|
582
|
-
process.cwd()
|
|
586
|
+
process.cwd(),
|
|
583
587
|
);
|
|
584
588
|
|
|
585
589
|
allOptimizations.push(...memoryOpts, ...concurrencyOpts, ...bundleOpts);
|
|
@@ -593,18 +597,20 @@ export class PerformanceOptimizerCommands {
|
|
|
593
597
|
const grouped = allOptimizations.reduce(
|
|
594
598
|
(acc, opt) => {
|
|
595
599
|
if (opt && opt.category) {
|
|
596
|
-
if (!acc[opt.category])
|
|
600
|
+
if (!acc[opt.category]) {
|
|
601
|
+
acc[opt.category] = [];
|
|
602
|
+
}
|
|
597
603
|
acc[opt.category]!.push(opt);
|
|
598
604
|
}
|
|
599
605
|
return acc;
|
|
600
606
|
},
|
|
601
|
-
{} as Record<string, OptimizationResult[]
|
|
607
|
+
{} as Record<string, OptimizationResult[]>,
|
|
602
608
|
);
|
|
603
609
|
|
|
604
|
-
logger.info(
|
|
610
|
+
logger.info('\nš Optimization Summary:');
|
|
605
611
|
Object.entries(grouped).forEach(([category, opts]) => {
|
|
606
612
|
console.log(
|
|
607
|
-
` ${chalk.bold(category.toUpperCase())}: ${opts.length} opportunities
|
|
613
|
+
` ${chalk.bold(category.toUpperCase())}: ${opts.length} opportunities`,
|
|
608
614
|
);
|
|
609
615
|
});
|
|
610
616
|
|
|
@@ -613,7 +619,7 @@ export class PerformanceOptimizerCommands {
|
|
|
613
619
|
const automated = allOptimizations.filter(o => o.automated);
|
|
614
620
|
if (automated.length > 0) {
|
|
615
621
|
logger.info(
|
|
616
|
-
`\nš§ Applying ${automated.length} automated optimizations
|
|
622
|
+
`\nš§ Applying ${automated.length} automated optimizations...`,
|
|
617
623
|
);
|
|
618
624
|
|
|
619
625
|
for (const opt of automated) {
|
|
@@ -635,7 +641,7 @@ export class PerformanceOptimizerCommands {
|
|
|
635
641
|
const manual = allOptimizations.filter(o => !o.automated).length;
|
|
636
642
|
if (manual > 0) {
|
|
637
643
|
logger.info(
|
|
638
|
-
`ā¹ļø ${manual} optimizations require manual intervention
|
|
644
|
+
`ā¹ļø ${manual} optimizations require manual intervention`,
|
|
639
645
|
);
|
|
640
646
|
}
|
|
641
647
|
}
|
|
@@ -644,7 +650,7 @@ export class PerformanceOptimizerCommands {
|
|
|
644
650
|
await this.generateOptimizationReport(
|
|
645
651
|
allOptimizations,
|
|
646
652
|
options.report,
|
|
647
|
-
'comprehensive'
|
|
653
|
+
'comprehensive',
|
|
648
654
|
);
|
|
649
655
|
}
|
|
650
656
|
} catch (error) {
|
|
@@ -652,7 +658,7 @@ export class PerformanceOptimizerCommands {
|
|
|
652
658
|
'WUNDR_COMPREHENSIVE_OPTIMIZATION_FAILED',
|
|
653
659
|
'Failed to run comprehensive optimization',
|
|
654
660
|
{ options },
|
|
655
|
-
true
|
|
661
|
+
true,
|
|
656
662
|
);
|
|
657
663
|
}
|
|
658
664
|
}
|
|
@@ -663,7 +669,7 @@ export class PerformanceOptimizerCommands {
|
|
|
663
669
|
const startTime = Date.now();
|
|
664
670
|
|
|
665
671
|
logger.info(
|
|
666
|
-
`š Starting performance monitoring for ${options.duration} seconds
|
|
672
|
+
`š Starting performance monitoring for ${options.duration} seconds...`,
|
|
667
673
|
);
|
|
668
674
|
|
|
669
675
|
const metrics: SystemMetrics[] = [];
|
|
@@ -700,7 +706,7 @@ export class PerformanceOptimizerCommands {
|
|
|
700
706
|
const heapMB = (memory.heapUsed / 1024 / 1024).toFixed(2);
|
|
701
707
|
const rssMB = (memory.rss / 1024 / 1024).toFixed(2);
|
|
702
708
|
process.stdout.write(
|
|
703
|
-
`\rš¾ Heap: ${heapMB}MB | RSS: ${rssMB}MB | CPU: ${cpu.user}μs
|
|
709
|
+
`\rš¾ Heap: ${heapMB}MB | RSS: ${rssMB}MB | CPU: ${cpu.user}μs`,
|
|
704
710
|
);
|
|
705
711
|
}, interval);
|
|
706
712
|
|
|
@@ -716,7 +722,7 @@ export class PerformanceOptimizerCommands {
|
|
|
716
722
|
const peakHeap = Math.max(...metrics.map(m => m.memory.heapUsed));
|
|
717
723
|
const peakRSS = Math.max(...metrics.map(m => m.memory.rss));
|
|
718
724
|
|
|
719
|
-
console.log(
|
|
725
|
+
console.log('\nMemory Statistics:');
|
|
720
726
|
console.log(` Average Heap: ${(avgHeap / 1024 / 1024).toFixed(2)} MB`);
|
|
721
727
|
console.log(` Average RSS: ${(avgRSS / 1024 / 1024).toFixed(2)} MB`);
|
|
722
728
|
console.log(` Peak Heap: ${(peakHeap / 1024 / 1024).toFixed(2)} MB`);
|
|
@@ -786,7 +792,7 @@ export class PerformanceOptimizerCommands {
|
|
|
786
792
|
'WUNDR_BENCHMARK_FAILED',
|
|
787
793
|
'Failed to run performance benchmarks',
|
|
788
794
|
{ options },
|
|
789
|
-
true
|
|
795
|
+
true,
|
|
790
796
|
);
|
|
791
797
|
}
|
|
792
798
|
}
|
|
@@ -813,7 +819,7 @@ export class PerformanceOptimizerCommands {
|
|
|
813
819
|
// Simulate concurrent task processing
|
|
814
820
|
const tasks = Array.from(
|
|
815
821
|
{ length: 100 },
|
|
816
|
-
(_, i) => new Promise(resolve => setTimeout(resolve, Math.random() * 10))
|
|
822
|
+
(_, i) => new Promise(resolve => setTimeout(resolve, Math.random() * 10)),
|
|
817
823
|
);
|
|
818
824
|
await Promise.all(tasks);
|
|
819
825
|
}
|
|
@@ -833,7 +839,7 @@ export class PerformanceOptimizerCommands {
|
|
|
833
839
|
private async generateOptimizationReport(
|
|
834
840
|
optimizations: OptimizationResult[],
|
|
835
841
|
reportPath: string,
|
|
836
|
-
type: string
|
|
842
|
+
type: string,
|
|
837
843
|
): Promise<void> {
|
|
838
844
|
const report = {
|
|
839
845
|
timestamp: new Date().toISOString(),
|