claude-flow-novice 1.5.12 → 1.5.13

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.
Files changed (40) hide show
  1. package/.claude-flow-novice/dist/mcp/auth.js +347 -0
  2. package/.claude-flow-novice/dist/mcp/claude-code-wrapper.js +717 -0
  3. package/.claude-flow-novice/dist/mcp/claude-flow-tools.js +1365 -0
  4. package/.claude-flow-novice/dist/mcp/client.js +201 -0
  5. package/.claude-flow-novice/dist/mcp/index.js +192 -0
  6. package/.claude-flow-novice/dist/mcp/integrate-wrapper.js +85 -0
  7. package/.claude-flow-novice/dist/mcp/lifecycle-manager.js +348 -0
  8. package/.claude-flow-novice/dist/mcp/load-balancer.js +386 -0
  9. package/.claude-flow-novice/dist/mcp/mcp-config-manager.js +1362 -0
  10. package/.claude-flow-novice/dist/mcp/mcp-server-novice-simplified.js +583 -0
  11. package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +723 -0
  12. package/.claude-flow-novice/dist/mcp/mcp-server-sdk.js +649 -0
  13. package/.claude-flow-novice/dist/mcp/mcp-server.js +2256 -0
  14. package/.claude-flow-novice/dist/mcp/orchestration-integration.js +800 -0
  15. package/.claude-flow-novice/dist/mcp/performance-monitor.js +489 -0
  16. package/.claude-flow-novice/dist/mcp/protocol-manager.js +376 -0
  17. package/.claude-flow-novice/dist/mcp/router.js +220 -0
  18. package/.claude-flow-novice/dist/mcp/ruv-swarm-tools.js +671 -0
  19. package/.claude-flow-novice/dist/mcp/ruv-swarm-wrapper.js +254 -0
  20. package/.claude-flow-novice/dist/mcp/server-with-wrapper.js +32 -0
  21. package/.claude-flow-novice/dist/mcp/server-wrapper-mode.js +26 -0
  22. package/.claude-flow-novice/dist/mcp/server.js +539 -0
  23. package/.claude-flow-novice/dist/mcp/session-manager.js +338 -0
  24. package/.claude-flow-novice/dist/mcp/sparc-modes.js +455 -0
  25. package/.claude-flow-novice/dist/mcp/swarm-tools.js +903 -0
  26. package/.claude-flow-novice/dist/mcp/tools.js +426 -0
  27. package/.claude-flow-novice/dist/src/cli/commands/swarm.js +23 -1
  28. package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
  29. package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +40 -101
  30. package/.claude-flow-novice/dist/src/coordination/swarm-coordinator-factory.js +36 -0
  31. package/.claude-flow-novice/dist/src/coordination/swarm-coordinator-factory.js.map +1 -0
  32. package/.claude-flow-novice/dist/src/validators/index.js +12 -0
  33. package/.claude-flow-novice/dist/src/validators/index.js.map +1 -0
  34. package/.claude-flow-novice/dist/src/validators/swarm-init-validator.js +261 -0
  35. package/.claude-flow-novice/dist/src/validators/swarm-init-validator.js.map +1 -0
  36. package/.claude-flow-novice/dist/src/validators/todowrite-batching-validator.js +204 -0
  37. package/.claude-flow-novice/dist/src/validators/todowrite-batching-validator.js.map +1 -0
  38. package/.claude-flow-novice/dist/src/validators/todowrite-integration.js +189 -0
  39. package/.claude-flow-novice/dist/src/validators/todowrite-integration.js.map +1 -0
  40. package/package.json +2 -2
@@ -0,0 +1,204 @@
1
+ /**
2
+ * TodoWrite Batching Validator
3
+ *
4
+ * Detects and warns about TodoWrite anti-patterns where multiple small calls
5
+ * are made instead of a single batched call with 5-10+ items.
6
+ *
7
+ * Anti-pattern example (bad):
8
+ * TodoWrite([{...}]) // Call 1: 1 item
9
+ * TodoWrite([{...}]) // Call 2: 1 item
10
+ * TodoWrite([{...}]) // Call 3: 1 item
11
+ *
12
+ * Best practice (good):
13
+ * TodoWrite([{...}, {...}, {...}, {...}, {...}]) // Single call: 5+ items
14
+ *
15
+ * @module validators/todowrite-batching-validator
16
+ */ /**
17
+ * Validates TodoWrite call patterns to ensure proper batching behavior
18
+ *
19
+ * Tracks call frequency within a sliding time window and detects anti-patterns
20
+ * where multiple small calls are made instead of a single batched call.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const validator = new TodoWriteValidator({ strictMode: false });
25
+ *
26
+ * // Good: Single batched call
27
+ * validator.validateBatching([
28
+ * { content: "Task 1", status: "pending", activeForm: "Doing task 1" },
29
+ * { content: "Task 2", status: "pending", activeForm: "Doing task 2" },
30
+ * { content: "Task 3", status: "pending", activeForm: "Doing task 3" },
31
+ * { content: "Task 4", status: "pending", activeForm: "Doing task 4" },
32
+ * { content: "Task 5", status: "pending", activeForm: "Doing task 5" }
33
+ * ]); // ✅ No warning
34
+ *
35
+ * // Bad: Multiple small calls
36
+ * validator.validateBatching([{ content: "Task 1", status: "pending", activeForm: "Doing task 1" }]);
37
+ * validator.validateBatching([{ content: "Task 2", status: "pending", activeForm: "Doing task 2" }]);
38
+ * // ⚠️ Warning: Batching anti-pattern detected
39
+ * ```
40
+ */ export class TodoWriteValidator {
41
+ callLog = [];
42
+ totalCallCount = 0;
43
+ config;
44
+ constructor(config = {}){
45
+ this.config = {
46
+ timeWindowMs: config.timeWindowMs ?? 300000,
47
+ callThreshold: config.callThreshold ?? 2,
48
+ strictMode: config.strictMode ?? false,
49
+ minRecommendedItems: config.minRecommendedItems ?? 5,
50
+ verbose: config.verbose ?? false
51
+ };
52
+ }
53
+ /**
54
+ * Validates a TodoWrite call and checks for batching anti-patterns
55
+ *
56
+ * @param todos - Array of todos being written
57
+ * @throws Error if strictMode is enabled and anti-pattern detected
58
+ * @returns ValidationResult with detailed analysis
59
+ */ validateBatching(todos) {
60
+ const now = Date.now();
61
+ this.totalCallCount++;
62
+ // Log this call
63
+ this.callLog.push({
64
+ timestamp: now,
65
+ count: todos.length,
66
+ callIndex: this.totalCallCount
67
+ });
68
+ // Clean old entries outside time window
69
+ this.callLog = this.callLog.filter((entry)=>now - entry.timestamp < this.config.timeWindowMs);
70
+ // Calculate statistics
71
+ const totalItems = this.callLog.reduce((sum, entry)=>sum + entry.count, 0);
72
+ const averageItemsPerCall = totalItems / this.callLog.length;
73
+ const warnings = [];
74
+ const recommendations = [];
75
+ let isValid = true;
76
+ // Check for anti-pattern: too many calls in time window
77
+ if (this.callLog.length >= this.config.callThreshold) {
78
+ isValid = false;
79
+ const warningMessage = this.buildWarningMessage(totalItems, averageItemsPerCall);
80
+ warnings.push(warningMessage);
81
+ // Generate specific recommendations
82
+ recommendations.push(`Batch ALL todos in SINGLE TodoWrite call with ${this.config.minRecommendedItems}+ items`);
83
+ recommendations.push(`See CLAUDE.md: "TodoWrite batching requirement" and "1 MESSAGE = ALL RELATED OPERATIONS"`);
84
+ recommendations.push(`Example: TodoWrite([todo1, todo2, todo3, todo4, todo5]) instead of multiple calls`);
85
+ if (this.config.verbose) {
86
+ console.log('\n📊 TodoWrite Call Statistics:');
87
+ console.log(` Total calls in window: ${this.callLog.length}`);
88
+ console.log(` Total items: ${totalItems}`);
89
+ console.log(` Average items per call: ${averageItemsPerCall.toFixed(2)}`);
90
+ console.log(` Time window: ${this.config.timeWindowMs / 1000}s`);
91
+ }
92
+ // In strict mode, throw error
93
+ if (this.config.strictMode) {
94
+ throw new Error(`TodoWrite Batching Violation: ${warningMessage}\n\n` + `Recommendations:\n${recommendations.map((r)=>` - ${r}`).join('\n')}`);
95
+ }
96
+ // Otherwise, log warning
97
+ console.warn(warningMessage);
98
+ }
99
+ // Additional check: warn if single call has too few items (informational only)
100
+ if (todos.length < this.config.minRecommendedItems && this.callLog.length === 1) {
101
+ recommendations.push(`Consider adding more todos to this batch (current: ${todos.length}, recommended: ${this.config.minRecommendedItems}+)`);
102
+ }
103
+ return {
104
+ isValid,
105
+ callCount: this.callLog.length,
106
+ totalItems,
107
+ averageItemsPerCall,
108
+ warnings,
109
+ recommendations
110
+ };
111
+ }
112
+ /**
113
+ * Builds a detailed warning message for batching anti-patterns
114
+ * @private
115
+ */ buildWarningMessage(totalItems, averageItemsPerCall) {
116
+ const timeWindowMinutes = this.config.timeWindowMs / 60000;
117
+ return `
118
+ ⚠️ TODOWRITE BATCHING ANTI-PATTERN DETECTED
119
+
120
+ You have made ${this.callLog.length} TodoWrite calls in the last ${timeWindowMinutes} minutes.
121
+
122
+ Best Practice: Batch ALL todos in SINGLE TodoWrite call with ${this.config.minRecommendedItems}-10+ items.
123
+
124
+ Current calls (within ${timeWindowMinutes}min window):
125
+ ${this.callLog.map((entry, i)=>` ${i + 1}. Call #${entry.callIndex}: ${entry.count} item${entry.count !== 1 ? 's' : ''} (${this.formatTimestamp(entry.timestamp)})`).join('\n')}
126
+
127
+ Statistics:
128
+ - Total calls: ${this.callLog.length}
129
+ - Total items: ${totalItems}
130
+ - Average items per call: ${averageItemsPerCall.toFixed(2)}
131
+ - Recommended: 1 call with ${this.config.minRecommendedItems}+ items
132
+
133
+ Impact:
134
+ - Multiple calls waste API resources
135
+ - Harder to track task relationships
136
+ - Violates "1 MESSAGE = ALL RELATED OPERATIONS" principle
137
+
138
+ See CLAUDE.md: "TodoWrite batching requirement"
139
+ `.trim();
140
+ }
141
+ /**
142
+ * Formats timestamp for display in warning messages
143
+ * @private
144
+ */ formatTimestamp(timestamp) {
145
+ const secondsAgo = Math.floor((Date.now() - timestamp) / 1000);
146
+ if (secondsAgo < 60) return `${secondsAgo}s ago`;
147
+ const minutesAgo = Math.floor(secondsAgo / 60);
148
+ return `${minutesAgo}m ago`;
149
+ }
150
+ /**
151
+ * Gets current validation statistics
152
+ */ getStatistics() {
153
+ return {
154
+ totalCalls: this.totalCallCount,
155
+ callsInWindow: this.callLog.length,
156
+ timeWindowMs: this.config.timeWindowMs,
157
+ threshold: this.config.callThreshold
158
+ };
159
+ }
160
+ /**
161
+ * Resets the validator state (useful for testing)
162
+ */ reset() {
163
+ this.callLog = [];
164
+ this.totalCallCount = 0;
165
+ }
166
+ /**
167
+ * Updates validator configuration
168
+ */ updateConfig(config) {
169
+ this.config = {
170
+ ...this.config,
171
+ ...config
172
+ };
173
+ }
174
+ /**
175
+ * Checks if validation is currently passing (no anti-patterns detected)
176
+ */ isCurrentlyValid() {
177
+ return this.callLog.length < this.config.callThreshold;
178
+ }
179
+ }
180
+ /**
181
+ * Global singleton instance for use across the application
182
+ */ let globalValidator = null;
183
+ /**
184
+ * Gets the global TodoWrite validator instance
185
+ * Creates one if it doesn't exist
186
+ */ export function getGlobalValidator(config) {
187
+ if (!globalValidator) {
188
+ globalValidator = new TodoWriteValidator(config);
189
+ } else if (config) {
190
+ globalValidator.updateConfig(config);
191
+ }
192
+ return globalValidator;
193
+ }
194
+ /**
195
+ * Resets the global validator instance
196
+ * Useful for testing and cleanup
197
+ */ export function resetGlobalValidator() {
198
+ if (globalValidator) {
199
+ globalValidator.reset();
200
+ }
201
+ globalValidator = null;
202
+ }
203
+
204
+ //# sourceMappingURL=todowrite-batching-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/validators/todowrite-batching-validator.ts"],"names":["TodoWriteValidator","callLog","totalCallCount","config","timeWindowMs","callThreshold","strictMode","minRecommendedItems","verbose","validateBatching","todos","now","Date","push","timestamp","count","length","callIndex","filter","entry","totalItems","reduce","sum","averageItemsPerCall","warnings","recommendations","isValid","warningMessage","buildWarningMessage","console","log","toFixed","Error","map","r","join","warn","callCount","timeWindowMinutes","i","formatTimestamp","trim","secondsAgo","Math","floor","minutesAgo","getStatistics","totalCalls","callsInWindow","threshold","reset","updateConfig","isCurrentlyValid","globalValidator","getGlobalValidator","resetGlobalValidator"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAwCD;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,MAAMA;IACHC,UAA8B,EAAE,CAAC;IACjCC,iBAAiB,EAAE;IAEnBC,OAA2C;IAEnD,YAAYA,SAAmC,CAAC,CAAC,CAAE;QACjD,IAAI,CAACA,MAAM,GAAG;YACZC,cAAcD,OAAOC,YAAY,IAAI;YACrCC,eAAeF,OAAOE,aAAa,IAAI;YACvCC,YAAYH,OAAOG,UAAU,IAAI;YACjCC,qBAAqBJ,OAAOI,mBAAmB,IAAI;YACnDC,SAASL,OAAOK,OAAO,IAAI;QAC7B;IACF;IAEA;;;;;;GAMC,GACDC,iBAAiBC,KAAa,EAAoB;QAChD,MA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OAAO,IAAI,CAACnD,OAAO,CAACe,MAAM,GAAG,IAAI,CAACb,MAAM,CAACE,aAAa;IACxD;AACF;AAEA;;CAEC,GACD,IAAIgD,kBAA6C;AAEjD;;;CAGC,GACD,OAAO,SAASC,mBACdnD,MAAiC;IAEjC,IAAI,CAACkD,iBAAiB;QACpBA,kBAAkB,IAAIrD,mBAAmBG;IAC3C,OAAO,IAAIA,QAAQ;QACjBkD,gBAAgBF,YAAY,CAAChD;IAC/B;IACA,OAAOkD;AACT;AAEA;;;CAGC,GACD,OAAO,SAASE;IACd,IAAIF,iBAAiB;QACnBA,gBAAgBH,KAAK;IACvB;IACAG,kBAAkB;AACpB"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * TodoWrite Validator Integration
3
+ *
4
+ * Provides CLI flag support and tool integration for the TodoWrite batching validator.
5
+ * Can be enabled via --validate-batching flag or VALIDATE_TODOWRITE_BATCHING env var.
6
+ *
7
+ * @module validators/todowrite-integration
8
+ */ import { getGlobalValidator } from './todowrite-batching-validator';
9
+ /**
10
+ * Environment variables for controlling validation
11
+ */ const ENV_VALIDATE_BATCHING = 'VALIDATE_TODOWRITE_BATCHING';
12
+ const ENV_STRICT_MODE = 'TODOWRITE_STRICT_MODE';
13
+ const ENV_VERBOSE = 'TODOWRITE_VERBOSE';
14
+ /**
15
+ * Checks if validation is enabled via environment or config
16
+ */ export function isValidationEnabled(config) {
17
+ // Check environment variable first
18
+ if (process.env[ENV_VALIDATE_BATCHING] === 'true') {
19
+ return true;
20
+ }
21
+ // Check config
22
+ return config?.enabled ?? false;
23
+ }
24
+ /**
25
+ * Gets integration config from environment and explicit config
26
+ */ export function getIntegrationConfig(explicitConfig) {
27
+ return {
28
+ enabled: isValidationEnabled(explicitConfig),
29
+ strictMode: process.env[ENV_STRICT_MODE] === 'true' || explicitConfig?.strictMode,
30
+ verbose: process.env[ENV_VERBOSE] === 'true' || explicitConfig?.verbose,
31
+ timeWindowMs: explicitConfig?.timeWindowMs,
32
+ callThreshold: explicitConfig?.callThreshold,
33
+ minRecommendedItems: explicitConfig?.minRecommendedItems
34
+ };
35
+ }
36
+ /**
37
+ * Validates a TodoWrite call with integrated configuration
38
+ *
39
+ * @param todos - Array of todos being written
40
+ * @param config - Optional configuration override
41
+ * @returns Validation result if enabled, null if disabled
42
+ */ export function validateTodoWrite(todos, config) {
43
+ const integrationConfig = getIntegrationConfig(config);
44
+ // Skip validation if not enabled
45
+ if (!integrationConfig.enabled) {
46
+ return null;
47
+ }
48
+ // Get global validator and update config
49
+ const validator = getGlobalValidator({
50
+ strictMode: integrationConfig.strictMode,
51
+ verbose: integrationConfig.verbose,
52
+ timeWindowMs: integrationConfig.timeWindowMs,
53
+ callThreshold: integrationConfig.callThreshold,
54
+ minRecommendedItems: integrationConfig.minRecommendedItems
55
+ });
56
+ // Validate and return result
57
+ return validator.validateBatching(todos);
58
+ }
59
+ /**
60
+ * CLI argument parser for validation flags
61
+ */ export function parseValidationFlags(args) {
62
+ const config = {
63
+ enabled: false,
64
+ strictMode: false,
65
+ verbose: false
66
+ };
67
+ for(let i = 0; i < args.length; i++){
68
+ const arg = args[i];
69
+ switch(arg){
70
+ case '--validate-batching':
71
+ config.enabled = true;
72
+ break;
73
+ case '--strict':
74
+ case '--strict-mode':
75
+ config.strictMode = true;
76
+ break;
77
+ case '--verbose':
78
+ case '-v':
79
+ config.verbose = true;
80
+ break;
81
+ case '--time-window':
82
+ config.timeWindowMs = parseInt(args[++i], 10);
83
+ break;
84
+ case '--threshold':
85
+ config.callThreshold = parseInt(args[++i], 10);
86
+ break;
87
+ case '--min-items':
88
+ config.minRecommendedItems = parseInt(args[++i], 10);
89
+ break;
90
+ }
91
+ }
92
+ return config;
93
+ }
94
+ /**
95
+ * Helper to display usage information
96
+ */ export function displayValidationHelp() {
97
+ console.log(`
98
+ TodoWrite Batching Validator - Usage
99
+
100
+ Detects anti-patterns where multiple small TodoWrite calls are made
101
+ instead of a single batched call with 5-10+ items.
102
+
103
+ CLI Flags:
104
+ --validate-batching Enable TodoWrite batching validation
105
+ --strict, --strict-mode Throw error on anti-pattern (default: warn)
106
+ --verbose, -v Show detailed statistics
107
+ --time-window <ms> Time window for detection (default: 300000 = 5min)
108
+ --threshold <count> Number of calls before warning (default: 2)
109
+ --min-items <count> Minimum recommended items (default: 5)
110
+
111
+ Environment Variables:
112
+ VALIDATE_TODOWRITE_BATCHING=true Enable validation globally
113
+ TODOWRITE_STRICT_MODE=true Enable strict mode globally
114
+ TODOWRITE_VERBOSE=true Enable verbose logging globally
115
+
116
+ Examples:
117
+ # Enable validation with defaults
118
+ npx claude-flow-novice task --validate-batching
119
+
120
+ # Enable strict mode (throw error on anti-pattern)
121
+ npx claude-flow-novice task --validate-batching --strict
122
+
123
+ # Custom thresholds
124
+ npx claude-flow-novice task --validate-batching --threshold 3 --time-window 600000
125
+
126
+ # Via environment
127
+ export VALIDATE_TODOWRITE_BATCHING=true
128
+ npx claude-flow-novice task
129
+
130
+ Best Practice:
131
+ Always batch ALL todos in SINGLE TodoWrite call with 5-10+ items.
132
+ See CLAUDE.md: "TodoWrite batching requirement"
133
+ `.trim());
134
+ }
135
+ /**
136
+ * Example integration with TodoWrite tool
137
+ * This function wraps the actual TodoWrite implementation
138
+ */ export function todoWriteWithValidation(todos, config) {
139
+ // Validate first if enabled
140
+ const validationResult = validateTodoWrite(todos, config);
141
+ if (validationResult && !validationResult.isValid) {
142
+ console.warn('\n⚠️ TodoWrite Batching Issue Detected\n');
143
+ console.warn('Recommendations:');
144
+ validationResult.recommendations.forEach((rec, i)=>{
145
+ console.warn(` ${i + 1}. ${rec}`);
146
+ });
147
+ console.warn('');
148
+ }
149
+ // Proceed with actual TodoWrite implementation
150
+ // (This would call the real TodoWrite tool)
151
+ // For now, just log what would be written
152
+ if (config?.verbose) {
153
+ console.log(`\n✅ Writing ${todos.length} todos...`);
154
+ }
155
+ }
156
+ /**
157
+ * Express middleware for validation (if using HTTP API)
158
+ */ export function createValidationMiddleware(config) {
159
+ return (req, res, next)=>{
160
+ if (req.body && Array.isArray(req.body.todos)) {
161
+ try {
162
+ validateTodoWrite(req.body.todos, config);
163
+ } catch (error) {
164
+ // In strict mode, validation errors become HTTP errors
165
+ if (config?.strictMode) {
166
+ return res.status(400).json({
167
+ error: 'TodoWrite Batching Violation',
168
+ message: error.message
169
+ });
170
+ }
171
+ }
172
+ }
173
+ next();
174
+ };
175
+ }
176
+ /**
177
+ * Integration status checker
178
+ */ export function getValidationStatus() {
179
+ const config = getIntegrationConfig();
180
+ const validator = getGlobalValidator();
181
+ return {
182
+ enabled: config.enabled,
183
+ strictMode: config.strictMode ?? false,
184
+ verbose: config.verbose ?? false,
185
+ statistics: validator.getStatistics()
186
+ };
187
+ }
188
+
189
+ //# sourceMappingURL=todowrite-integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/validators/todowrite-integration.ts"],"names":["getGlobalValidator","ENV_VALIDATE_BATCHING","ENV_STRICT_MODE","ENV_VERBOSE","isValidationEnabled","config","process","env","enabled","getIntegrationConfig","explicitConfig","strictMode","verbose","timeWindowMs","callThreshold","minRecommendedItems","validateTodoWrite","todos","integrationConfig","validator","validateBatching","parseValidationFlags","args","i","length","arg","parseInt","displayValidationHelp","console","log","trim","todoWriteWithValidation","validationResult","isValid","warn","recommendations","forEach","rec","createValidationMiddleware","req","res","next","body","Array","isArray","error","status","json","message","getValidationStatus","statistics","getStatistics"],"mappings":"AAAA;;;;;;;CAOC,GAED,SAASA,kBAAkB,QAAmB,iCAAiC;AAE/E;;CAEC,GACD,MAAMC,wBAAwB;AAC9B,MAAMC,kBAAkB;AACxB,MAAMC,cAAc;AAcpB;;CAEC,GACD,OAAO,SAASC,oBAAoBC,MAAmC;IACrE,mCAAmC;IACnC,IAAIC,QAAQC,GAAG,CAACN,sBAAsB,KAAK,QAAQ;QACjD,OAAO;IACT;IAEA,eAAe;IACf,OAAOI,QAAQG,WAAW;AAC5B;AAEA;;CAEC,GACD,OAAO,SAASC,qBACdC,cAA2C;IAE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oBACnC;gBACF;YACF;QACF;QACAP;IACF;AACF;AAEA;;CAEC,GACD,OAAO,SAASQ;IAMd,MAAM5C,SAASI;IACf,MAAMU,YAAYnB;IAElB,OAAO;QACLQ,SAASH,OAAOG,OAAO;QACvBG,YAAYN,OAAOM,UAAU,IAAI;QACjCC,SAASP,OAAOO,OAAO,IAAI;QAC3BsC,YAAY/B,UAAUgC,aAAa;IACrC;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow-novice",
3
- "version": "1.5.12",
3
+ "version": "1.5.13",
4
4
  "description": "Standalone Claude Flow for beginners - AI agent orchestration made easy with enhanced TDD testing pipeline. Enhanced init command creates complete agent system, MCP configuration with 30 essential tools, and automated hooks with single-file testing, real-time coverage analysis, and advanced validation. Fully standalone with zero external dependencies, complete project setup in one command.",
5
5
  "mcpName": "io.github.ruvnet/claude-flow",
6
6
  "main": ".claude-flow-novice/dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "optimize:validate:hardware": "node scripts/optimization/config-validator.js validate hardware",
40
40
  "optimize:validate:monitoring": "node scripts/optimization/config-validator.js validate monitoring",
41
41
  "build": "scripts/build/unified-builder.sh safe",
42
- "build:swc": "swc src -d .claude-flow-novice/dist --only='**/*.ts' --config-file .swcrc && cp -r src/slash-commands .claude-flow-novice/dist/src/ && cp -r src/cli/simple-commands/hooks .claude-flow-novice/dist/src/cli/simple-commands/ && cp -r src/cli/simple-commands/init/templates .claude-flow-novice/dist/src/cli/simple-commands/init/ && cp src/cli/simple-commands/init/index.js .claude-flow-novice/dist/src/cli/simple-commands/init/ && cp src/cli/simple-commands/init.js .claude-flow-novice/dist/src/cli/simple-commands/ && cp src/cli/simple-commands/mcp.js .claude-flow-novice/dist/src/cli/simple-commands/ && cp src/mcp/*.js .claude-flow-novice/dist/src/mcp/ && cp -r .claude/agents .claude-flow-novice/.claude/",
42
+ "build:swc": "swc src -d .claude-flow-novice/dist --only='**/*.ts' --config-file .swcrc && cp -r src/slash-commands .claude-flow-novice/dist/src/ && cp -r src/cli/simple-commands/hooks .claude-flow-novice/dist/src/cli/simple-commands/ && cp -r src/cli/simple-commands/init/templates .claude-flow-novice/dist/src/cli/simple-commands/init/ && cp src/cli/simple-commands/init/index.js .claude-flow-novice/dist/src/cli/simple-commands/init/ && cp src/cli/simple-commands/init.js .claude-flow-novice/dist/src/cli/simple-commands/ && cp src/cli/simple-commands/mcp.js .claude-flow-novice/dist/src/cli/simple-commands/ && cp src/mcp/*.js .claude-flow-novice/dist/src/mcp/ && mkdir -p .claude-flow-novice/dist/mcp && cp .claude-flow-novice/dist/src/mcp/*.js .claude-flow-novice/dist/mcp/ && cp -r .claude/agents .claude-flow-novice/.claude/",
43
43
  "build:types": "tsc --project config/typescript/tsconfig.json --emitDeclarationOnly --outDir .claude-flow-novice/dist --skipLibCheck",
44
44
  "build:watch": "swc src -d .claude-flow-novice/dist --watch --config-file .swcrc && cp -r src/slash-commands .claude-flow-novice/dist/src/ && cp -r src/cli/simple-commands/hooks .claude-flow-novice/dist/src/cli/simple-commands/ && cp -r src/cli/simple-commands/init/templates .claude-flow-novice/dist/src/cli/simple-commands/init/ && npm run copy:agents",
45
45
  "build:legacy": "scripts/build/unified-builder.sh migration",