musubix2 0.3.6 → 0.3.8

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/index.js CHANGED
@@ -1,3 +1,1457 @@
1
+ // dist/index.js
2
+ import { readFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { readFile as readFile2 } from "node:fs/promises";
5
+ import { join as join2 } from "node:path";
6
+ import { randomUUID } from "node:crypto";
7
+ import { readFile as readFile22, writeFile, mkdir } from "node:fs/promises";
8
+ import { join as join22, dirname } from "node:path";
9
+ import { writeFile as writeFile2, mkdir as mkdir2 } from "node:fs/promises";
10
+ import { join as join3 } from "node:path";
11
+ import ts from "typescript";
12
+ import { readFileSync, existsSync } from "node:fs";
13
+ var ActionableError = class _ActionableError extends Error {
14
+ code;
15
+ severity;
16
+ context;
17
+ suggestions;
18
+ constructor(message, options) {
19
+ super(message);
20
+ this.name = "ActionableError";
21
+ this.code = options.code;
22
+ this.severity = options.severity ?? "error";
23
+ this.context = options.context ?? {};
24
+ this.suggestions = options.suggestions ?? [];
25
+ if (Error.captureStackTrace) {
26
+ Error.captureStackTrace(this, _ActionableError);
27
+ }
28
+ if (options.cause) {
29
+ this.cause = options.cause;
30
+ }
31
+ }
32
+ static withSuggestion(message, code, suggestion) {
33
+ return new _ActionableError(message, {
34
+ code,
35
+ suggestions: [suggestion]
36
+ });
37
+ }
38
+ static fromError(error, code, suggestions) {
39
+ return new _ActionableError(error.message, {
40
+ code,
41
+ cause: error,
42
+ suggestions
43
+ });
44
+ }
45
+ static isActionableError(error) {
46
+ return error instanceof _ActionableError;
47
+ }
48
+ addSuggestion(suggestion) {
49
+ this.suggestions.push(suggestion);
50
+ return this;
51
+ }
52
+ toFormattedString() {
53
+ return ErrorFormatter.format(this);
54
+ }
55
+ };
56
+ var ErrorCodes = {
57
+ // Validation errors
58
+ EARS_VALIDATION_FAILED: "EARS_VALIDATION_FAILED",
59
+ TRACEABILITY_MISSING: "TRACEABILITY_MISSING",
60
+ DESIGN_INCOMPLETE: "DESIGN_INCOMPLETE",
61
+ // File errors
62
+ FILE_NOT_FOUND: "FILE_NOT_FOUND",
63
+ FILE_PARSE_ERROR: "FILE_PARSE_ERROR",
64
+ FILE_WRITE_ERROR: "FILE_WRITE_ERROR",
65
+ // Configuration errors
66
+ CONFIG_MISSING: "CONFIG_MISSING",
67
+ CONFIG_INVALID: "CONFIG_INVALID",
68
+ // Workflow errors
69
+ PHASE_TRANSITION_BLOCKED: "PHASE_TRANSITION_BLOCKED",
70
+ QUALITY_GATE_FAILED: "QUALITY_GATE_FAILED",
71
+ APPROVAL_REQUIRED: "APPROVAL_REQUIRED",
72
+ // Generation errors
73
+ CODEGEN_FAILED: "CODEGEN_FAILED",
74
+ TEMPLATE_NOT_FOUND: "TEMPLATE_NOT_FOUND",
75
+ // Pattern errors
76
+ PATTERN_NOT_FOUND: "PATTERN_NOT_FOUND",
77
+ PATTERN_CONFLICT: "PATTERN_CONFLICT"
78
+ };
79
+ var ErrorFormatter = class _ErrorFormatter {
80
+ static useColors = true;
81
+ static setColorOutput(enabled) {
82
+ _ErrorFormatter.useColors = enabled;
83
+ }
84
+ static format(error) {
85
+ const lines = [];
86
+ const icon = _ErrorFormatter.getSeverityIcon(error.severity);
87
+ const header = `${icon} [${error.code}] ${error.message}`;
88
+ lines.push(_ErrorFormatter.colorize(header, error.severity));
89
+ if (error.context.file) {
90
+ let location = ` \u{1F4CD} ${error.context.file}`;
91
+ if (error.context.line !== void 0) {
92
+ location += `:${error.context.line}`;
93
+ if (error.context.column !== void 0) {
94
+ location += `:${error.context.column}`;
95
+ }
96
+ }
97
+ lines.push(location);
98
+ }
99
+ if (error.context.artifactId) {
100
+ lines.push(` \u{1F4CE} Related: ${error.context.artifactId}`);
101
+ }
102
+ if (error.suggestions.length > 0) {
103
+ lines.push("");
104
+ lines.push(" \u{1F4A1} Suggestions:");
105
+ for (const suggestion of error.suggestions) {
106
+ lines.push(` \u2022 ${suggestion.action}: ${suggestion.description}`);
107
+ if (suggestion.command) {
108
+ lines.push(` $ ${suggestion.command}`);
109
+ }
110
+ if (suggestion.docLink) {
111
+ lines.push(` \u{1F4D6} ${suggestion.docLink}`);
112
+ }
113
+ }
114
+ }
115
+ return lines.join("\n");
116
+ }
117
+ static formatAll(errors) {
118
+ if (errors.length === 0) {
119
+ return _ErrorFormatter.colorize("\u2705 No errors", "info");
120
+ }
121
+ const lines = [];
122
+ const counts = {
123
+ error: errors.filter((e) => e.severity === "error").length,
124
+ warning: errors.filter((e) => e.severity === "warning").length,
125
+ info: errors.filter((e) => e.severity === "info").length
126
+ };
127
+ lines.push(`Found ${errors.length} issue(s): ${counts.error} errors, ${counts.warning} warnings, ${counts.info} info
128
+ `);
129
+ for (const error of errors) {
130
+ lines.push(_ErrorFormatter.format(error));
131
+ lines.push("");
132
+ }
133
+ return lines.join("\n");
134
+ }
135
+ static formatAsJson(error) {
136
+ return JSON.stringify({
137
+ code: error.code,
138
+ severity: error.severity,
139
+ message: error.message,
140
+ context: error.context,
141
+ suggestions: error.suggestions
142
+ }, null, 2);
143
+ }
144
+ static getSeverityIcon(severity) {
145
+ switch (severity) {
146
+ case "error":
147
+ return "\u274C";
148
+ case "warning":
149
+ return "\u26A0\uFE0F";
150
+ case "info":
151
+ return "\u2139\uFE0F";
152
+ }
153
+ }
154
+ static colorize(text, severity) {
155
+ if (!_ErrorFormatter.useColors) {
156
+ return text;
157
+ }
158
+ const colors = {
159
+ error: "\x1B[31m",
160
+ warning: "\x1B[33m",
161
+ info: "\x1B[36m"
162
+ };
163
+ const reset = "\x1B[0m";
164
+ return `${colors[severity]}${text}${reset}`;
165
+ }
166
+ };
167
+ var CommonErrors = {
168
+ fileNotFound(path) {
169
+ return new ActionableError(`File not found: ${path}`, {
170
+ code: ErrorCodes.FILE_NOT_FOUND,
171
+ context: { file: path },
172
+ suggestions: [
173
+ {
174
+ action: "Check path",
175
+ description: "Verify the file path is correct"
176
+ },
177
+ {
178
+ action: "Create file",
179
+ description: "Create the missing file if needed",
180
+ command: `touch ${path}`
181
+ }
182
+ ]
183
+ });
184
+ },
185
+ earsValidationFailed(file, issues) {
186
+ return new ActionableError(`EARS validation failed with ${issues.length} issue(s)`, {
187
+ code: ErrorCodes.EARS_VALIDATION_FAILED,
188
+ context: { file },
189
+ suggestions: [
190
+ {
191
+ action: "Review EARS format",
192
+ description: "Ensure requirements follow EARS patterns (Ubiquitous, Event-driven, etc.)"
193
+ },
194
+ {
195
+ action: "Run validation",
196
+ description: "Use the validation command to see detailed issues",
197
+ command: `npx musubix requirements validate ${file}`
198
+ }
199
+ ]
200
+ });
201
+ },
202
+ traceabilityMissing(reqId, designId) {
203
+ return new ActionableError(`Missing traceability link: ${reqId} \u2192 ${designId}`, {
204
+ code: ErrorCodes.TRACEABILITY_MISSING,
205
+ severity: "warning",
206
+ context: { artifactId: reqId },
207
+ suggestions: [
208
+ {
209
+ action: "Add trace link",
210
+ description: `Link ${reqId} to its design element`,
211
+ command: "npx musubix trace sync"
212
+ }
213
+ ]
214
+ });
215
+ },
216
+ phaseTransitionBlocked(from, to, reason) {
217
+ return new ActionableError(`Cannot transition from ${from} to ${to}: ${reason}`, {
218
+ code: ErrorCodes.PHASE_TRANSITION_BLOCKED,
219
+ suggestions: [
220
+ {
221
+ action: "Complete requirements",
222
+ description: "Ensure all prerequisite artifacts are complete"
223
+ },
224
+ {
225
+ action: "Check quality gates",
226
+ description: "Verify all quality gates pass",
227
+ command: "npx musubix workflow get-status"
228
+ }
229
+ ]
230
+ });
231
+ },
232
+ qualityGateFailed(gate, details) {
233
+ return new ActionableError(`Quality gate failed: ${gate}`, {
234
+ code: ErrorCodes.QUALITY_GATE_FAILED,
235
+ suggestions: [
236
+ {
237
+ action: "Fix issues",
238
+ description: details
239
+ },
240
+ {
241
+ action: "View report",
242
+ description: "Check the quality gate report for details",
243
+ command: "npx musubix workflow validate-transition"
244
+ }
245
+ ]
246
+ });
247
+ }
248
+ };
249
+ var MemoryCacheProvider = class {
250
+ cache = /* @__PURE__ */ new Map();
251
+ async get(key) {
252
+ const entry = this.cache.get(key);
253
+ if (!entry) {
254
+ return null;
255
+ }
256
+ if (entry.expires && entry.expires < Date.now()) {
257
+ this.cache.delete(key);
258
+ return null;
259
+ }
260
+ return entry.value;
261
+ }
262
+ async set(key, value, ttl) {
263
+ this.cache.set(key, {
264
+ value,
265
+ expires: ttl ? Date.now() + ttl : 0
266
+ });
267
+ }
268
+ async delete(key) {
269
+ this.cache.delete(key);
270
+ }
271
+ async clear() {
272
+ this.cache.clear();
273
+ }
274
+ };
275
+ var MemoryQueueProvider = class {
276
+ queue = [];
277
+ counter = 0;
278
+ async enqueue(item) {
279
+ const id = `q-${Date.now()}-${++this.counter}`;
280
+ this.queue.push({ id, item });
281
+ return id;
282
+ }
283
+ async dequeue() {
284
+ const entry = this.queue.shift();
285
+ return entry ? entry.item : null;
286
+ }
287
+ async size() {
288
+ return this.queue.length;
289
+ }
290
+ async clear() {
291
+ this.queue = [];
292
+ }
293
+ };
294
+ var DEFAULT_DEGRADATION_CONFIG = {
295
+ services: [],
296
+ healthCheckInterval: 3e4,
297
+ autoRecovery: true,
298
+ maxQueueSize: 1e3
299
+ };
300
+ var GracefulDegradation = class {
301
+ config;
302
+ serviceStatus;
303
+ currentLevel = "full";
304
+ events = [];
305
+ eventCounter = 0;
306
+ healthCheckTimer;
307
+ cache;
308
+ queue;
309
+ constructor(config) {
310
+ this.config = { ...DEFAULT_DEGRADATION_CONFIG, ...config };
311
+ this.serviceStatus = /* @__PURE__ */ new Map();
312
+ this.cache = config?.cacheProvider ?? new MemoryCacheProvider();
313
+ this.queue = config?.queueProvider ?? new MemoryQueueProvider();
314
+ for (const service of this.config.services) {
315
+ this.serviceStatus.set(service.name, {
316
+ service: service.name,
317
+ status: "unknown"
318
+ });
319
+ }
320
+ }
321
+ start() {
322
+ this.runHealthChecks();
323
+ this.healthCheckTimer = setInterval(() => this.runHealthChecks(), this.config.healthCheckInterval);
324
+ }
325
+ stop() {
326
+ if (this.healthCheckTimer) {
327
+ clearInterval(this.healthCheckTimer);
328
+ this.healthCheckTimer = void 0;
329
+ }
330
+ }
331
+ registerService(service) {
332
+ this.config.services.push(service);
333
+ this.serviceStatus.set(service.name, {
334
+ service: service.name,
335
+ status: "unknown"
336
+ });
337
+ }
338
+ async execute(serviceName, operation, options) {
339
+ const service = this.config.services.find((s) => s.name === serviceName);
340
+ const status = this.serviceStatus.get(serviceName);
341
+ if (!status || status.status === "healthy" || status.status === "unknown") {
342
+ try {
343
+ const value = await this.withTimeout(operation, options?.timeout ?? 3e4);
344
+ if (options?.cacheKey) {
345
+ await this.cache.set(options.cacheKey, value, service?.cacheTtl);
346
+ }
347
+ return {
348
+ value,
349
+ degraded: false,
350
+ level: this.currentLevel,
351
+ warnings: []
352
+ };
353
+ } catch (error) {
354
+ return this.executeFallback(serviceName, error, options);
355
+ }
356
+ }
357
+ return this.executeFallback(serviceName, new Error(`Service ${serviceName} is ${status.status}`), options);
358
+ }
359
+ async executeFallback(serviceName, error, options) {
360
+ const service = this.config.services.find((s) => s.name === serviceName);
361
+ const strategies = service?.fallbackStrategies ?? ["default"];
362
+ const warnings = [`Primary operation failed: ${error.message}`];
363
+ for (const strategy of strategies) {
364
+ try {
365
+ const result = await this.executeStrategy(serviceName, strategy, options);
366
+ if (result !== null) {
367
+ return {
368
+ value: result,
369
+ degraded: true,
370
+ level: this.currentLevel,
371
+ strategy,
372
+ originalError: error,
373
+ warnings
374
+ };
375
+ }
376
+ } catch (e) {
377
+ warnings.push(`Fallback ${strategy} failed: ${e.message}`);
378
+ }
379
+ }
380
+ throw new Error(`All fallback strategies failed for ${serviceName}. Warnings: ${warnings.join("; ")}`);
381
+ }
382
+ async executeStrategy(_serviceName, strategy, options) {
383
+ switch (strategy) {
384
+ case "cache":
385
+ if (options?.cacheKey) {
386
+ const cached = await this.cache.get(options.cacheKey);
387
+ if (cached !== null) {
388
+ return cached;
389
+ }
390
+ }
391
+ return null;
392
+ case "default":
393
+ if (options?.defaultValue !== void 0) {
394
+ return options.defaultValue;
395
+ }
396
+ return null;
397
+ case "retry":
398
+ return null;
399
+ case "alternative":
400
+ return null;
401
+ case "skip":
402
+ return null;
403
+ case "queue":
404
+ if (await this.queue.size() < this.config.maxQueueSize) {
405
+ await this.queue.enqueue({
406
+ service: _serviceName,
407
+ timestamp: /* @__PURE__ */ new Date(),
408
+ options
409
+ });
410
+ }
411
+ return null;
412
+ case "manual":
413
+ return null;
414
+ default:
415
+ return null;
416
+ }
417
+ }
418
+ async runHealthChecks() {
419
+ const results = /* @__PURE__ */ new Map();
420
+ for (const service of this.config.services) {
421
+ const result = await this.checkServiceHealth(service);
422
+ results.set(service.name, result);
423
+ const previousStatus = this.serviceStatus.get(service.name);
424
+ this.serviceStatus.set(service.name, result);
425
+ if (previousStatus?.status !== result.status) {
426
+ if (result.status === "unavailable" || result.status === "degraded") {
427
+ this.handleServiceDegradation(service, result);
428
+ } else if (result.status === "healthy" && previousStatus?.status !== "healthy") {
429
+ this.handleServiceRecovery(service);
430
+ }
431
+ }
432
+ }
433
+ this.recalculateLevel();
434
+ return results;
435
+ }
436
+ async checkServiceHealth(service) {
437
+ const startTime = Date.now();
438
+ try {
439
+ const healthy = await this.withTimeout(service.healthCheck, 5e3);
440
+ const responseTime = Date.now() - startTime;
441
+ return {
442
+ service: service.name,
443
+ status: healthy ? "healthy" : "degraded",
444
+ responseTime,
445
+ lastSuccess: healthy ? /* @__PURE__ */ new Date() : void 0
446
+ };
447
+ } catch (error) {
448
+ return {
449
+ service: service.name,
450
+ status: "unavailable",
451
+ responseTime: Date.now() - startTime,
452
+ error: error.message
453
+ };
454
+ }
455
+ }
456
+ handleServiceDegradation(service, result) {
457
+ const previousLevel = this.currentLevel;
458
+ const event = {
459
+ id: `deg-${Date.now()}-${++this.eventCounter}`,
460
+ timestamp: /* @__PURE__ */ new Date(),
461
+ service: service.name,
462
+ previousLevel,
463
+ newLevel: this.currentLevel,
464
+ reason: result.error ?? `Service ${service.name} is ${result.status}`
465
+ };
466
+ this.events.push(event);
467
+ this.config.onDegradation?.(event);
468
+ }
469
+ handleServiceRecovery(service) {
470
+ this.config.onRecovery?.(service.name, this.currentLevel);
471
+ if (this.config.autoRecovery) {
472
+ this.processQueue(service.name).catch(() => {
473
+ });
474
+ }
475
+ }
476
+ async processQueue(serviceName) {
477
+ let processed = 0;
478
+ const maxProcess = 10;
479
+ while (processed < maxProcess) {
480
+ const item = await this.queue.dequeue();
481
+ if (!item) {
482
+ break;
483
+ }
484
+ if (item.service === serviceName) {
485
+ processed++;
486
+ } else {
487
+ await this.queue.enqueue(item);
488
+ }
489
+ }
490
+ }
491
+ recalculateLevel() {
492
+ const statuses = [...this.serviceStatus.values()];
493
+ const unavailableRequired = this.config.services.filter((s) => s.required && this.serviceStatus.get(s.name)?.status === "unavailable");
494
+ const totalUnavailable = statuses.filter((s) => s.status === "unavailable").length;
495
+ const totalDegraded = statuses.filter((s) => s.status === "degraded").length;
496
+ if (unavailableRequired.length > 0) {
497
+ this.currentLevel = "emergency";
498
+ } else if (totalUnavailable > statuses.length / 2) {
499
+ this.currentLevel = "offline";
500
+ } else if (totalUnavailable > 0) {
501
+ this.currentLevel = "minimal";
502
+ } else if (totalDegraded > 0) {
503
+ this.currentLevel = "reduced";
504
+ } else {
505
+ this.currentLevel = "full";
506
+ }
507
+ }
508
+ getLevel() {
509
+ return this.currentLevel;
510
+ }
511
+ getServiceStatus(serviceName) {
512
+ return this.serviceStatus.get(serviceName);
513
+ }
514
+ getAllStatuses() {
515
+ return new Map(this.serviceStatus);
516
+ }
517
+ getEvents(limit) {
518
+ const events = [...this.events].sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());
519
+ return limit ? events.slice(0, limit) : events;
520
+ }
521
+ isFeatureAvailable(requiredLevel) {
522
+ const levels = ["full", "reduced", "minimal", "offline", "emergency"];
523
+ return levels.indexOf(this.currentLevel) <= levels.indexOf(requiredLevel);
524
+ }
525
+ async cacheValue(key, value, ttl) {
526
+ await this.cache.set(key, value, ttl);
527
+ }
528
+ async getCachedValue(key) {
529
+ return this.cache.get(key);
530
+ }
531
+ async clearCache() {
532
+ await this.cache.clear();
533
+ }
534
+ async withTimeout(operation, timeout) {
535
+ return new Promise((resolve, reject) => {
536
+ const timer = setTimeout(() => {
537
+ reject(new Error(`Operation timed out after ${timeout}ms`));
538
+ }, timeout);
539
+ operation().then((result) => {
540
+ clearTimeout(timer);
541
+ resolve(result);
542
+ }).catch((error) => {
543
+ clearTimeout(timer);
544
+ reject(error);
545
+ });
546
+ });
547
+ }
548
+ };
549
+ function createGracefulDegradation(config) {
550
+ return new GracefulDegradation(config);
551
+ }
552
+ async function retryWithBackoff(operation, options) {
553
+ const maxAttempts = options?.maxAttempts ?? 3;
554
+ const initialDelay = options?.initialDelay ?? 1e3;
555
+ const maxDelay = options?.maxDelay ?? 3e4;
556
+ const backoffFactor = options?.backoffFactor ?? 2;
557
+ let lastError;
558
+ let delay = initialDelay;
559
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
560
+ try {
561
+ return await operation();
562
+ } catch (error) {
563
+ lastError = error;
564
+ if (attempt < maxAttempts) {
565
+ await new Promise((resolve) => setTimeout(resolve, delay));
566
+ delay = Math.min(delay * backoffFactor, maxDelay);
567
+ }
568
+ }
569
+ }
570
+ throw lastError ?? new Error("Operation failed after retries");
571
+ }
572
+ var CircuitBreaker = class {
573
+ threshold;
574
+ resetTimeout;
575
+ failures = 0;
576
+ lastFailure;
577
+ state = "closed";
578
+ constructor(threshold = 5, resetTimeout = 6e4) {
579
+ this.threshold = threshold;
580
+ this.resetTimeout = resetTimeout;
581
+ }
582
+ async execute(operation) {
583
+ if (this.state === "open") {
584
+ if (this.shouldAttemptReset()) {
585
+ this.state = "half-open";
586
+ } else {
587
+ throw new Error("Circuit breaker is open");
588
+ }
589
+ }
590
+ try {
591
+ const result = await operation();
592
+ this.onSuccess();
593
+ return result;
594
+ } catch (error) {
595
+ this.onFailure();
596
+ throw error;
597
+ }
598
+ }
599
+ shouldAttemptReset() {
600
+ if (!this.lastFailure) {
601
+ return true;
602
+ }
603
+ return Date.now() - this.lastFailure.getTime() > this.resetTimeout;
604
+ }
605
+ onSuccess() {
606
+ this.failures = 0;
607
+ this.state = "closed";
608
+ }
609
+ onFailure() {
610
+ this.failures++;
611
+ this.lastFailure = /* @__PURE__ */ new Date();
612
+ if (this.failures >= this.threshold) {
613
+ this.state = "open";
614
+ }
615
+ }
616
+ getState() {
617
+ return this.state;
618
+ }
619
+ reset() {
620
+ this.failures = 0;
621
+ this.lastFailure = void 0;
622
+ this.state = "closed";
623
+ }
624
+ };
625
+ var ConsoleTransport = class {
626
+ write(entry) {
627
+ const prefix = `[${entry.timestamp.toISOString()}] [${entry.level.toUpperCase()}]`;
628
+ const src = entry.source ? ` (${entry.source})` : "";
629
+ const msg = `${prefix}${src} ${entry.message}`;
630
+ switch (entry.level) {
631
+ case "error":
632
+ console.error(msg);
633
+ break;
634
+ case "warn":
635
+ console.warn(msg);
636
+ break;
637
+ case "debug":
638
+ console.debug(msg);
639
+ break;
640
+ default:
641
+ console.log(msg);
642
+ }
643
+ }
644
+ };
645
+ var LOG_LEVEL_ORDER = {
646
+ debug: 0,
647
+ info: 1,
648
+ warn: 2,
649
+ error: 3
650
+ };
651
+ var Logger = class _Logger {
652
+ transports;
653
+ minLevel;
654
+ source;
655
+ constructor(options) {
656
+ this.transports = options?.transports ?? [new ConsoleTransport()];
657
+ this.minLevel = options?.level ?? "info";
658
+ this.source = options?.source;
659
+ }
660
+ debug(message, context) {
661
+ this.log("debug", message, context);
662
+ }
663
+ info(message, context) {
664
+ this.log("info", message, context);
665
+ }
666
+ warn(message, context) {
667
+ this.log("warn", message, context);
668
+ }
669
+ error(message, context) {
670
+ this.log("error", message, context);
671
+ }
672
+ child(source) {
673
+ return new _Logger({
674
+ transports: this.transports,
675
+ level: this.minLevel,
676
+ source: this.source ? `${this.source}:${source}` : source
677
+ });
678
+ }
679
+ log(level, message, context) {
680
+ if (LOG_LEVEL_ORDER[level] < LOG_LEVEL_ORDER[this.minLevel]) {
681
+ return;
682
+ }
683
+ const entry = {
684
+ level,
685
+ message,
686
+ timestamp: /* @__PURE__ */ new Date(),
687
+ context,
688
+ source: this.source
689
+ };
690
+ for (const transport of this.transports) {
691
+ transport.write(entry);
692
+ }
693
+ }
694
+ };
695
+ var AuditLogger = class {
696
+ events = [];
697
+ logger;
698
+ constructor(logger) {
699
+ this.logger = logger ?? new Logger({ source: "audit" });
700
+ }
701
+ record(event) {
702
+ const full = { ...event, timestamp: /* @__PURE__ */ new Date() };
703
+ this.events.push(full);
704
+ this.logger.info(`[AUDIT] ${event.action} on ${event.target} by ${event.actor}: ${event.result}`);
705
+ }
706
+ getEvents(filter) {
707
+ return this.events.filter((e) => {
708
+ if (filter?.action && e.action !== filter.action) {
709
+ return false;
710
+ }
711
+ if (filter?.actor && e.actor !== filter.actor) {
712
+ return false;
713
+ }
714
+ return true;
715
+ });
716
+ }
717
+ clear() {
718
+ this.events.length = 0;
719
+ }
720
+ };
721
+ var DEFAULT_CONFIG = {
722
+ steeringDir: "steering",
723
+ storageDir: "storage",
724
+ llm: {
725
+ provider: "github-copilot",
726
+ model: "default"
727
+ },
728
+ knowledge: {
729
+ basePath: "storage/specs"
730
+ },
731
+ integration: {
732
+ confidenceThreshold: 0.85
733
+ }
734
+ };
735
+ var CONFIG_FILENAME = "musubix.config.json";
736
+ var ConfigLoader = class {
737
+ config = null;
738
+ basePath;
739
+ constructor(basePath) {
740
+ this.basePath = basePath ?? process.cwd();
741
+ }
742
+ async load() {
743
+ const configPath = join(this.basePath, CONFIG_FILENAME);
744
+ try {
745
+ const raw = await readFile(configPath, "utf-8");
746
+ const parsed = JSON.parse(raw);
747
+ this.config = this.merge(parsed);
748
+ return this.config;
749
+ } catch (error) {
750
+ if (error.code === "ENOENT") {
751
+ throw new ActionableError(`Configuration file not found: ${configPath}`, {
752
+ code: ErrorCodes.CONFIG_MISSING,
753
+ context: { file: configPath },
754
+ suggestions: [
755
+ {
756
+ action: "Initialize project",
757
+ description: "Run init to create default configuration",
758
+ command: "npx musubix init"
759
+ }
760
+ ]
761
+ });
762
+ }
763
+ throw new ActionableError(`Failed to parse configuration: ${error.message}`, {
764
+ code: ErrorCodes.CONFIG_INVALID,
765
+ context: { file: configPath },
766
+ cause: error,
767
+ suggestions: [
768
+ {
769
+ action: "Check JSON syntax",
770
+ description: "Ensure musubix.config.json is valid JSON"
771
+ }
772
+ ]
773
+ });
774
+ }
775
+ }
776
+ getConfig() {
777
+ if (!this.config) {
778
+ return DEFAULT_CONFIG;
779
+ }
780
+ return this.config;
781
+ }
782
+ merge(partial) {
783
+ return {
784
+ steeringDir: partial.steeringDir ?? DEFAULT_CONFIG.steeringDir,
785
+ storageDir: partial.storageDir ?? DEFAULT_CONFIG.storageDir,
786
+ llm: {
787
+ ...DEFAULT_CONFIG.llm,
788
+ ...partial.llm
789
+ },
790
+ knowledge: {
791
+ ...DEFAULT_CONFIG.knowledge,
792
+ ...partial.knowledge
793
+ },
794
+ integration: {
795
+ ...DEFAULT_CONFIG.integration,
796
+ ...partial.integration
797
+ }
798
+ };
799
+ }
800
+ };
801
+ var InMemoryRepository = class {
802
+ store = /* @__PURE__ */ new Map();
803
+ async get(id) {
804
+ return this.store.get(id);
805
+ }
806
+ async getAll() {
807
+ return [...this.store.values()];
808
+ }
809
+ async save(entity) {
810
+ this.store.set(entity.id, entity);
811
+ }
812
+ async delete(id) {
813
+ return this.store.delete(id);
814
+ }
815
+ async exists(id) {
816
+ return this.store.has(id);
817
+ }
818
+ };
819
+ function createInMemoryRepository() {
820
+ return new InMemoryRepository();
821
+ }
822
+ var ExitCode = {
823
+ SUCCESS: 0,
824
+ GENERAL_ERROR: 1,
825
+ VALIDATION_ERROR: 2,
826
+ CONFIG_ERROR: 3,
827
+ PHASE_BLOCKED: 4
828
+ };
829
+ function formatSuccess(message) {
830
+ return `\u2705 ${message}`;
831
+ }
832
+ function formatError(message) {
833
+ return `\u274C ${message}`;
834
+ }
835
+ function formatTable(headers, rows) {
836
+ const widths = headers.map((h, i) => {
837
+ const maxRow = Math.max(...rows.map((r) => (r[i] ?? "").length));
838
+ return Math.max(h.length, maxRow);
839
+ });
840
+ const header = headers.map((h, i) => h.padEnd(widths[i])).join(" | ");
841
+ const separator = widths.map((w) => "-".repeat(w)).join("-+-");
842
+ const body = rows.map((row) => row.map((cell, i) => (cell ?? "").padEnd(widths[i])).join(" | ")).join("\n");
843
+ return `${header}
844
+ ${separator}
845
+ ${body}`;
846
+ }
847
+ var PATTERN_RULES = [
848
+ {
849
+ pattern: "event-driven",
850
+ regex: /\bWHEN\b.*\b(THE\s+.+\s+)?SHALL\b/i,
851
+ baseConfidence: 0.6,
852
+ bonus: 0.25
853
+ },
854
+ {
855
+ pattern: "state-driven",
856
+ regex: /\bWHILE\b.*\b(THE\s+.+\s+)?SHALL\b/i,
857
+ baseConfidence: 0.6,
858
+ bonus: 0.25
859
+ },
860
+ {
861
+ pattern: "unwanted",
862
+ regex: /\bSHALL\s+NOT\b/i,
863
+ baseConfidence: 0.6,
864
+ bonus: 0.2
865
+ },
866
+ {
867
+ pattern: "optional",
868
+ regex: /\bWHERE\b.*\b(THE\s+.+\s+)?SHALL\b/i,
869
+ baseConfidence: 0.6,
870
+ bonus: 0.2
871
+ },
872
+ {
873
+ pattern: "complex",
874
+ regex: /\bIF\b.*\bTHEN\b.*\bSHALL\b/i,
875
+ baseConfidence: 0.55,
876
+ bonus: 0.15
877
+ },
878
+ {
879
+ pattern: "ubiquitous",
880
+ regex: /\b(THE\s+.+\s+)?SHALL\b/i,
881
+ baseConfidence: 0.5,
882
+ bonus: 0
883
+ }
884
+ ];
885
+ var COMPLEX_COMBINATIONS = [
886
+ /\bWHEN\b.*\bWHILE\b/i,
887
+ /\bWHILE\b.*\bWHEN\b/i,
888
+ /\bIF\b.*\bWHEN\b/i
889
+ ];
890
+ var EARSValidator = class {
891
+ analyze(text, options) {
892
+ const cleaned = this.cleanText(text, options?.sourceFormat);
893
+ for (const combo of COMPLEX_COMBINATIONS) {
894
+ if (combo.test(cleaned)) {
895
+ const confidence = this.computeConfidence(cleaned, "complex", 0.55, 0.15);
896
+ return {
897
+ pattern: "complex",
898
+ confidence,
899
+ triggers: this.extractTriggers(cleaned, "complex"),
900
+ suggestions: confidence < 0.7 ? ["Consider splitting this complex requirement into simpler EARS patterns"] : []
901
+ };
902
+ }
903
+ }
904
+ let bestResult;
905
+ for (const rule of PATTERN_RULES) {
906
+ if (rule.regex.test(cleaned)) {
907
+ const confidence = this.computeConfidence(cleaned, rule.pattern, rule.baseConfidence, rule.bonus);
908
+ const patternTriggers = this.extractTriggers(cleaned, rule.pattern);
909
+ const patternSuggestions = [];
910
+ if (confidence < 0.7) {
911
+ patternSuggestions.push(this.getSuggestion(rule.pattern));
912
+ }
913
+ const result = {
914
+ pattern: rule.pattern,
915
+ confidence,
916
+ triggers: patternTriggers,
917
+ suggestions: patternSuggestions
918
+ };
919
+ if (confidence >= 0.85) {
920
+ return result;
921
+ }
922
+ if (!bestResult || confidence > bestResult.confidence) {
923
+ bestResult = result;
924
+ }
925
+ return result;
926
+ }
927
+ }
928
+ return {
929
+ pattern: "ubiquitous",
930
+ confidence: 0.3,
931
+ triggers: [],
932
+ suggestions: [
933
+ 'Requirement does not match any EARS pattern. Use "THE <system> SHALL <action>" as minimum.'
934
+ ]
935
+ };
936
+ }
937
+ validate(requirement) {
938
+ const result = this.analyze(requirement);
939
+ const issues = [];
940
+ if (result.confidence < 0.5) {
941
+ issues.push(`Low confidence (${result.confidence.toFixed(2)}): does not clearly match EARS pattern`);
942
+ }
943
+ if (!/\bSHALL\b/i.test(requirement)) {
944
+ issues.push('Missing mandatory keyword "SHALL"');
945
+ }
946
+ return {
947
+ valid: issues.length === 0,
948
+ issues
949
+ };
950
+ }
951
+ cleanText(text, format) {
952
+ let cleaned = text.trim();
953
+ if (format === "markdown-blockquote") {
954
+ cleaned = cleaned.replace(/^>\s*/gm, "");
955
+ }
956
+ return cleaned;
957
+ }
958
+ computeConfidence(text, _pattern, base, bonus) {
959
+ let confidence = base + bonus;
960
+ if (/\bTHE\s+\S+\s+SHALL\b/i.test(text)) {
961
+ confidence += 0.1;
962
+ }
963
+ if (text.endsWith(".") || text.endsWith("\u3002")) {
964
+ confidence += 0.05;
965
+ }
966
+ if (text.split(/\s+/).length < 5) {
967
+ confidence -= 0.15;
968
+ }
969
+ return Math.min(1, Math.max(0, confidence));
970
+ }
971
+ extractTriggers(text, pattern) {
972
+ const triggers = [];
973
+ switch (pattern) {
974
+ case "event-driven": {
975
+ const match = text.match(/\bWHEN\s+(.+?),?\s*(THE\b|$)/i);
976
+ if (match) {
977
+ triggers.push(match[1].trim());
978
+ }
979
+ break;
980
+ }
981
+ case "state-driven": {
982
+ const match = text.match(/\bWHILE\s+(.+?),?\s*(THE\b|$)/i);
983
+ if (match) {
984
+ triggers.push(match[1].trim());
985
+ }
986
+ break;
987
+ }
988
+ case "optional": {
989
+ const match = text.match(/\bWHERE\s+(.+?),?\s*(THE\b|$)/i);
990
+ if (match) {
991
+ triggers.push(match[1].trim());
992
+ }
993
+ break;
994
+ }
995
+ case "complex": {
996
+ const ifMatch = text.match(/\bIF\s+(.+?),?\s*THEN\b/i);
997
+ if (ifMatch) {
998
+ triggers.push(ifMatch[1].trim());
999
+ }
1000
+ break;
1001
+ }
1002
+ }
1003
+ return triggers;
1004
+ }
1005
+ getSuggestion(pattern) {
1006
+ const suggestions = {
1007
+ ubiquitous: 'Use "THE <system> SHALL <action>" format',
1008
+ "event-driven": 'Use "WHEN <event>, THE <system> SHALL <action>" format',
1009
+ "state-driven": 'Use "WHILE <state>, THE <system> SHALL <action>" format',
1010
+ unwanted: 'Use "THE <system> SHALL NOT <action>" format',
1011
+ optional: 'Use "WHERE <condition>, THE <system> SHALL <action>" format',
1012
+ complex: 'Use "IF <condition>, THEN THE <system> SHALL <action>" format'
1013
+ };
1014
+ return suggestions[pattern];
1015
+ }
1016
+ };
1017
+ function createEARSValidator() {
1018
+ return new EARSValidator();
1019
+ }
1020
+ var REQ_HEADING_REGEX = /^#{1,4}\s+(REQ-[A-Z]{3}-\d{3}):\s*(.+)$/;
1021
+ var FIELD_REGEX = {
1022
+ type: /^\*\*種別\*\*:\s*(.+)$/m,
1023
+ priority: /^\*\*優先度\*\*:\s*(P[012])$/m,
1024
+ requirement: /^\*\*要件\*\*:\s*\n([\s\S]+?)(?=\n\*\*|$)/m,
1025
+ acceptanceCriteria: /^\*\*受入基準\*\*:\s*\n((?:[-*]\s+\[[ x]\].+\n?)+)/m,
1026
+ traceability: /^\*\*トレーサビリティ\*\*:\s*(.+)$/m,
1027
+ package: /^\*\*パッケージ\*\*:\s*`(.+)`$/m
1028
+ };
1029
+ var MarkdownEARSParser = class {
1030
+ validator;
1031
+ constructor(validator) {
1032
+ this.validator = validator ?? new EARSValidator();
1033
+ }
1034
+ parse(markdown) {
1035
+ const requirements = [];
1036
+ const lines = markdown.split("\n");
1037
+ let currentReq = null;
1038
+ let currentBlock = "";
1039
+ let blockStartLine = 0;
1040
+ let inCodeBlock = false;
1041
+ for (let i = 0; i < lines.length; i++) {
1042
+ const line = lines[i];
1043
+ if (line.startsWith("```")) {
1044
+ inCodeBlock = !inCodeBlock;
1045
+ if (inCodeBlock) {
1046
+ continue;
1047
+ }
1048
+ }
1049
+ if (inCodeBlock) {
1050
+ continue;
1051
+ }
1052
+ const headingMatch = line.match(REQ_HEADING_REGEX);
1053
+ if (headingMatch) {
1054
+ if (currentReq && currentReq.id) {
1055
+ const parsed = this.parseBlock(currentReq, currentBlock, blockStartLine);
1056
+ requirements.push(parsed);
1057
+ }
1058
+ currentReq = {
1059
+ id: headingMatch[1],
1060
+ title: headingMatch[2].trim(),
1061
+ line: i + 1
1062
+ };
1063
+ currentBlock = "";
1064
+ blockStartLine = i + 1;
1065
+ } else if (currentReq) {
1066
+ currentBlock += line + "\n";
1067
+ }
1068
+ }
1069
+ if (currentReq && currentReq.id) {
1070
+ const parsed = this.parseBlock(currentReq, currentBlock, blockStartLine);
1071
+ requirements.push(parsed);
1072
+ }
1073
+ return requirements;
1074
+ }
1075
+ parseBlock(partial, block, _startLine) {
1076
+ const typeMatch = block.match(FIELD_REGEX.type);
1077
+ const priorityMatch = block.match(FIELD_REGEX.priority);
1078
+ const reqMatch = block.match(FIELD_REGEX.requirement);
1079
+ const acMatch = block.match(FIELD_REGEX.acceptanceCriteria);
1080
+ const traceMatch = block.match(FIELD_REGEX.traceability);
1081
+ const pkgMatch = block.match(FIELD_REGEX.package);
1082
+ const reqText = reqMatch ? reqMatch[1].trim() : "";
1083
+ let pattern;
1084
+ let confidence;
1085
+ if (reqText) {
1086
+ const analysis = this.validator.analyze(reqText);
1087
+ pattern = analysis.pattern;
1088
+ confidence = analysis.confidence;
1089
+ }
1090
+ let acceptanceCriteria;
1091
+ if (acMatch) {
1092
+ acceptanceCriteria = acMatch[1].split("\n").filter((l) => l.match(/^[-*]\s+\[[ x]\]/)).map((l) => l.replace(/^[-*]\s+\[[ x]\]\s*/, "").trim());
1093
+ }
1094
+ return {
1095
+ id: partial.id,
1096
+ title: partial.title ?? "",
1097
+ text: reqText,
1098
+ pattern: typeMatch ? this.normalizePattern(typeMatch[1]) : pattern,
1099
+ confidence,
1100
+ priority: priorityMatch ? priorityMatch[1] : void 0,
1101
+ acceptanceCriteria,
1102
+ traceability: traceMatch ? traceMatch[1].trim() : void 0,
1103
+ package: pkgMatch ? pkgMatch[1] : void 0,
1104
+ line: partial.line
1105
+ };
1106
+ }
1107
+ normalizePattern(raw) {
1108
+ const mapping = {
1109
+ UBIQUITOUS: "ubiquitous",
1110
+ "EVENT-DRIVEN": "event-driven",
1111
+ EVENT_DRIVEN: "event-driven",
1112
+ "STATE-DRIVEN": "state-driven",
1113
+ STATE_DRIVEN: "state-driven",
1114
+ UNWANTED: "unwanted",
1115
+ OPTIONAL: "optional",
1116
+ COMPLEX: "complex"
1117
+ };
1118
+ return mapping[raw.toUpperCase()] ?? "ubiquitous";
1119
+ }
1120
+ };
1121
+ var RequirementsValidator = class {
1122
+ parser;
1123
+ earsValidator;
1124
+ constructor(parser, validator) {
1125
+ this.earsValidator = validator ?? new EARSValidator();
1126
+ this.parser = parser ?? new MarkdownEARSParser(this.earsValidator);
1127
+ }
1128
+ validate(markdown) {
1129
+ const requirements = this.parser.parse(markdown);
1130
+ const issues = [];
1131
+ for (const req of requirements) {
1132
+ if (!req.text) {
1133
+ issues.push({
1134
+ requirementId: req.id,
1135
+ line: req.line ?? 0,
1136
+ column: 0,
1137
+ message: "Requirement text is empty"
1138
+ });
1139
+ continue;
1140
+ }
1141
+ const validation = this.earsValidator.validate(req.text);
1142
+ if (!validation.valid) {
1143
+ for (const issue of validation.issues) {
1144
+ issues.push({
1145
+ requirementId: req.id,
1146
+ line: req.line ?? 0,
1147
+ column: 0,
1148
+ message: issue,
1149
+ suggestion: issue
1150
+ });
1151
+ }
1152
+ }
1153
+ if (!req.acceptanceCriteria || req.acceptanceCriteria.length === 0) {
1154
+ issues.push({
1155
+ requirementId: req.id,
1156
+ line: req.line ?? 0,
1157
+ column: 0,
1158
+ message: "Missing acceptance criteria",
1159
+ suggestion: "Add acceptance criteria in checklist format"
1160
+ });
1161
+ }
1162
+ }
1163
+ return { requirements, issues };
1164
+ }
1165
+ map(requirements) {
1166
+ const map = /* @__PURE__ */ new Map();
1167
+ for (const req of requirements) {
1168
+ map.set(req.id, req);
1169
+ }
1170
+ return map;
1171
+ }
1172
+ search(query, requirements) {
1173
+ const lower = query.toLowerCase();
1174
+ return requirements.filter((req) => {
1175
+ return req.id.toLowerCase().includes(lower) || req.title.toLowerCase().includes(lower) || req.text.toLowerCase().includes(lower);
1176
+ });
1177
+ }
1178
+ };
1179
+ function createMarkdownEARSParser() {
1180
+ return new MarkdownEARSParser();
1181
+ }
1182
+ function createRequirementsValidator() {
1183
+ return new RequirementsValidator();
1184
+ }
1185
+ var DefaultReplFormatter = class {
1186
+ formatResult(value) {
1187
+ if (value === void 0 || value === null) {
1188
+ return "";
1189
+ }
1190
+ if (typeof value === "string") {
1191
+ return value;
1192
+ }
1193
+ return JSON.stringify(value, null, 2);
1194
+ }
1195
+ formatError(error) {
1196
+ return `\u274C ${error.message}`;
1197
+ }
1198
+ formatHelp(commands) {
1199
+ const lines = ["Available commands:", ""];
1200
+ for (const cmd of commands) {
1201
+ const aliases = cmd.aliases?.length ? ` (${cmd.aliases.join(", ")})` : "";
1202
+ lines.push(` ${cmd.name}${aliases} \u2014 ${cmd.description}`);
1203
+ }
1204
+ return lines.join("\n");
1205
+ }
1206
+ };
1207
+ var ReplEngine = class {
1208
+ commands = /* @__PURE__ */ new Map();
1209
+ session;
1210
+ formatter;
1211
+ prompt;
1212
+ maxHistory;
1213
+ running = false;
1214
+ constructor(options) {
1215
+ this.prompt = options?.prompt ?? "musubix> ";
1216
+ this.maxHistory = options?.maxHistory ?? 1e3;
1217
+ this.formatter = new DefaultReplFormatter();
1218
+ this.session = {
1219
+ id: `repl-${Date.now()}`,
1220
+ history: [],
1221
+ variables: /* @__PURE__ */ new Map(),
1222
+ startedAt: /* @__PURE__ */ new Date()
1223
+ };
1224
+ this.registerBuiltIns();
1225
+ if (options?.commands) {
1226
+ for (const cmd of options.commands) {
1227
+ this.register(cmd);
1228
+ }
1229
+ }
1230
+ }
1231
+ register(command) {
1232
+ this.commands.set(command.name, command);
1233
+ if (command.aliases) {
1234
+ for (const alias of command.aliases) {
1235
+ this.commands.set(alias, command);
1236
+ }
1237
+ }
1238
+ }
1239
+ async eval(input) {
1240
+ const trimmed = input.trim();
1241
+ if (!trimmed) {
1242
+ return "";
1243
+ }
1244
+ this.session.history.push(trimmed);
1245
+ if (this.session.history.length > this.maxHistory) {
1246
+ this.session.history.shift();
1247
+ }
1248
+ const [commandName, ...args] = trimmed.split(/\s+/);
1249
+ const command = this.commands.get(commandName);
1250
+ if (!command) {
1251
+ return this.formatter.formatError(new Error(`Unknown command: ${commandName}. Type "help" for available commands.`));
1252
+ }
1253
+ try {
1254
+ const result = await command.execute(args, this.session);
1255
+ return this.formatter.formatResult(result);
1256
+ } catch (error) {
1257
+ return this.formatter.formatError(error);
1258
+ }
1259
+ }
1260
+ complete(partial) {
1261
+ if (!partial) {
1262
+ return [.../* @__PURE__ */ new Set([...this.commands.keys()])];
1263
+ }
1264
+ const [commandPart, ...rest] = partial.split(/\s+/);
1265
+ if (rest.length === 0) {
1266
+ const names = [.../* @__PURE__ */ new Set([...this.commands.keys()])];
1267
+ return names.filter((n) => n.startsWith(commandPart));
1268
+ }
1269
+ const command = this.commands.get(commandPart);
1270
+ if (command?.complete) {
1271
+ return command.complete(rest.join(" "));
1272
+ }
1273
+ return [];
1274
+ }
1275
+ getSession() {
1276
+ return this.session;
1277
+ }
1278
+ getHistory() {
1279
+ return [...this.session.history];
1280
+ }
1281
+ getPrompt() {
1282
+ return this.prompt;
1283
+ }
1284
+ isRunning() {
1285
+ return this.running;
1286
+ }
1287
+ stop() {
1288
+ this.running = false;
1289
+ }
1290
+ registerBuiltIns() {
1291
+ this.register({
1292
+ name: "help",
1293
+ description: "Show available commands",
1294
+ aliases: ["?"],
1295
+ execute: async () => {
1296
+ const uniqueCommands = [
1297
+ ...new Map([...this.commands.entries()].map(([_, cmd]) => [cmd.name, cmd])).values()
1298
+ ];
1299
+ return this.formatter.formatHelp(uniqueCommands);
1300
+ }
1301
+ });
1302
+ this.register({
1303
+ name: "history",
1304
+ description: "Show command history",
1305
+ execute: async () => {
1306
+ return this.session.history.map((h, i) => ` ${i + 1} ${h}`).join("\n");
1307
+ }
1308
+ });
1309
+ this.register({
1310
+ name: "clear",
1311
+ description: "Clear history",
1312
+ execute: async () => {
1313
+ this.session.history = [];
1314
+ return "History cleared";
1315
+ }
1316
+ });
1317
+ this.register({
1318
+ name: "exit",
1319
+ description: "Exit REPL",
1320
+ aliases: ["quit", "q"],
1321
+ execute: async () => {
1322
+ this.running = false;
1323
+ return "Goodbye";
1324
+ }
1325
+ });
1326
+ }
1327
+ };
1328
+ var ReasoningChainRecorder = class {
1329
+ chains = /* @__PURE__ */ new Map();
1330
+ activeChainId = null;
1331
+ stepCounter = 0;
1332
+ startChain(title) {
1333
+ const id = `chain-${Date.now()}-${++this.stepCounter}`;
1334
+ this.chains.set(id, {
1335
+ id,
1336
+ title,
1337
+ steps: [],
1338
+ conclusion: "",
1339
+ overallConfidence: 0,
1340
+ createdAt: /* @__PURE__ */ new Date()
1341
+ });
1342
+ this.activeChainId = id;
1343
+ return id;
1344
+ }
1345
+ addStep(description, evidence, confidence, metadata) {
1346
+ if (!this.activeChainId) {
1347
+ throw new Error("No active reasoning chain. Call startChain() first.");
1348
+ }
1349
+ const chain = this.chains.get(this.activeChainId);
1350
+ const step = {
1351
+ id: `step-${++this.stepCounter}`,
1352
+ description,
1353
+ evidence,
1354
+ confidence: Math.max(0, Math.min(1, confidence)),
1355
+ timestamp: /* @__PURE__ */ new Date(),
1356
+ metadata
1357
+ };
1358
+ chain.steps.push(step);
1359
+ this.updateConfidence(chain);
1360
+ return step;
1361
+ }
1362
+ conclude(conclusion) {
1363
+ if (!this.activeChainId) {
1364
+ throw new Error("No active reasoning chain.");
1365
+ }
1366
+ const chain = this.chains.get(this.activeChainId);
1367
+ chain.conclusion = conclusion;
1368
+ this.activeChainId = null;
1369
+ return chain;
1370
+ }
1371
+ getChain(id) {
1372
+ return this.chains.get(id);
1373
+ }
1374
+ getAllChains() {
1375
+ return [...this.chains.values()];
1376
+ }
1377
+ updateConfidence(chain) {
1378
+ if (chain.steps.length === 0) {
1379
+ chain.overallConfidence = 0;
1380
+ return;
1381
+ }
1382
+ const sum = chain.steps.reduce((acc, s) => acc + s.confidence, 0);
1383
+ chain.overallConfidence = sum / chain.steps.length;
1384
+ }
1385
+ };
1386
+ var ExplanationGenerator = class {
1387
+ generate(chain, options) {
1388
+ const format = options?.format ?? "markdown";
1389
+ const includeEvidence = options?.includeEvidence ?? true;
1390
+ const includeConfidence = options?.includeConfidence ?? true;
1391
+ switch (format) {
1392
+ case "json":
1393
+ return JSON.stringify(chain, null, 2);
1394
+ case "text":
1395
+ return this.generateText(chain, includeEvidence, includeConfidence);
1396
+ case "markdown":
1397
+ default:
1398
+ return this.generateMarkdown(chain, includeEvidence, includeConfidence);
1399
+ }
1400
+ }
1401
+ generateMarkdown(chain, includeEvidence, includeConfidence) {
1402
+ const lines = [];
1403
+ lines.push(`# ${chain.title}`);
1404
+ lines.push("");
1405
+ if (includeConfidence) {
1406
+ lines.push(`**\u4FE1\u983C\u5EA6**: ${(chain.overallConfidence * 100).toFixed(1)}%`);
1407
+ lines.push("");
1408
+ }
1409
+ lines.push("## \u63A8\u8AD6\u30B9\u30C6\u30C3\u30D7");
1410
+ lines.push("");
1411
+ for (let i = 0; i < chain.steps.length; i++) {
1412
+ const step = chain.steps[i];
1413
+ lines.push(`### ${i + 1}. ${step.description}`);
1414
+ if (includeConfidence) {
1415
+ lines.push(`\u4FE1\u983C\u5EA6: ${(step.confidence * 100).toFixed(1)}%`);
1416
+ }
1417
+ if (includeEvidence && step.evidence.length > 0) {
1418
+ lines.push("");
1419
+ lines.push("\u6839\u62E0:");
1420
+ for (const e of step.evidence) {
1421
+ lines.push(`- ${e}`);
1422
+ }
1423
+ }
1424
+ lines.push("");
1425
+ }
1426
+ if (chain.conclusion) {
1427
+ lines.push("## \u7D50\u8AD6");
1428
+ lines.push("");
1429
+ lines.push(chain.conclusion);
1430
+ }
1431
+ return lines.join("\n");
1432
+ }
1433
+ generateText(chain, includeEvidence, includeConfidence) {
1434
+ const lines = [];
1435
+ lines.push(chain.title);
1436
+ lines.push("=".repeat(chain.title.length));
1437
+ lines.push("");
1438
+ for (let i = 0; i < chain.steps.length; i++) {
1439
+ const step = chain.steps[i];
1440
+ const conf = includeConfidence ? ` [${(step.confidence * 100).toFixed(0)}%]` : "";
1441
+ lines.push(`${i + 1}. ${step.description}${conf}`);
1442
+ if (includeEvidence && step.evidence.length > 0) {
1443
+ for (const e of step.evidence) {
1444
+ lines.push(` \u2192 ${e}`);
1445
+ }
1446
+ }
1447
+ }
1448
+ if (chain.conclusion) {
1449
+ lines.push("");
1450
+ lines.push(`\u7D50\u8AD6: ${chain.conclusion}`);
1451
+ }
1452
+ return lines.join("\n");
1453
+ }
1454
+ };
1
1455
  var __defProp = Object.defineProperty;
2
1456
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
1457
  var __esm = (fn, res) => function __init() {
@@ -7,13 +1461,14 @@ var __export = (target, all) => {
7
1461
  for (var name in all)
8
1462
  __defProp(target, name, { get: all[name], enumerable: true });
9
1463
  };
10
-
11
- // ../core/dist/error/actionable-error.js
12
- var ActionableError, ErrorCodes, ErrorFormatter, CommonErrors;
1464
+ var ActionableError2;
1465
+ var ErrorCodes2;
1466
+ var ErrorFormatter2;
1467
+ var CommonErrors2;
13
1468
  var init_actionable_error = __esm({
14
1469
  "../core/dist/error/actionable-error.js"() {
15
1470
  "use strict";
16
- ActionableError = class _ActionableError extends Error {
1471
+ ActionableError2 = class _ActionableError2 extends Error {
17
1472
  code;
18
1473
  severity;
19
1474
  context;
@@ -26,37 +1481,37 @@ var init_actionable_error = __esm({
26
1481
  this.context = options.context ?? {};
27
1482
  this.suggestions = options.suggestions ?? [];
28
1483
  if (Error.captureStackTrace) {
29
- Error.captureStackTrace(this, _ActionableError);
1484
+ Error.captureStackTrace(this, _ActionableError2);
30
1485
  }
31
1486
  if (options.cause) {
32
1487
  this.cause = options.cause;
33
1488
  }
34
1489
  }
35
1490
  static withSuggestion(message, code, suggestion) {
36
- return new _ActionableError(message, {
1491
+ return new _ActionableError2(message, {
37
1492
  code,
38
1493
  suggestions: [suggestion]
39
1494
  });
40
1495
  }
41
1496
  static fromError(error, code, suggestions) {
42
- return new _ActionableError(error.message, {
1497
+ return new _ActionableError2(error.message, {
43
1498
  code,
44
1499
  cause: error,
45
1500
  suggestions
46
1501
  });
47
1502
  }
48
1503
  static isActionableError(error) {
49
- return error instanceof _ActionableError;
1504
+ return error instanceof _ActionableError2;
50
1505
  }
51
1506
  addSuggestion(suggestion) {
52
1507
  this.suggestions.push(suggestion);
53
1508
  return this;
54
1509
  }
55
1510
  toFormattedString() {
56
- return ErrorFormatter.format(this);
1511
+ return ErrorFormatter2.format(this);
57
1512
  }
58
1513
  };
59
- ErrorCodes = {
1514
+ ErrorCodes2 = {
60
1515
  // Validation errors
61
1516
  EARS_VALIDATION_FAILED: "EARS_VALIDATION_FAILED",
62
1517
  TRACEABILITY_MISSING: "TRACEABILITY_MISSING",
@@ -79,16 +1534,16 @@ var init_actionable_error = __esm({
79
1534
  PATTERN_NOT_FOUND: "PATTERN_NOT_FOUND",
80
1535
  PATTERN_CONFLICT: "PATTERN_CONFLICT"
81
1536
  };
82
- ErrorFormatter = class _ErrorFormatter {
1537
+ ErrorFormatter2 = class _ErrorFormatter2 {
83
1538
  static useColors = true;
84
1539
  static setColorOutput(enabled) {
85
- _ErrorFormatter.useColors = enabled;
1540
+ _ErrorFormatter2.useColors = enabled;
86
1541
  }
87
1542
  static format(error) {
88
1543
  const lines = [];
89
- const icon = _ErrorFormatter.getSeverityIcon(error.severity);
1544
+ const icon = _ErrorFormatter2.getSeverityIcon(error.severity);
90
1545
  const header = `${icon} [${error.code}] ${error.message}`;
91
- lines.push(_ErrorFormatter.colorize(header, error.severity));
1546
+ lines.push(_ErrorFormatter2.colorize(header, error.severity));
92
1547
  if (error.context.file) {
93
1548
  let location = ` \u{1F4CD} ${error.context.file}`;
94
1549
  if (error.context.line !== void 0) {
@@ -119,7 +1574,7 @@ var init_actionable_error = __esm({
119
1574
  }
120
1575
  static formatAll(errors) {
121
1576
  if (errors.length === 0) {
122
- return _ErrorFormatter.colorize("\u2705 No errors", "info");
1577
+ return _ErrorFormatter2.colorize("\u2705 No errors", "info");
123
1578
  }
124
1579
  const lines = [];
125
1580
  const counts = {
@@ -130,7 +1585,7 @@ var init_actionable_error = __esm({
130
1585
  lines.push(`Found ${errors.length} issue(s): ${counts.error} errors, ${counts.warning} warnings, ${counts.info} info
131
1586
  `);
132
1587
  for (const error of errors) {
133
- lines.push(_ErrorFormatter.format(error));
1588
+ lines.push(_ErrorFormatter2.format(error));
134
1589
  lines.push("");
135
1590
  }
136
1591
  return lines.join("\n");
@@ -155,7 +1610,7 @@ var init_actionable_error = __esm({
155
1610
  }
156
1611
  }
157
1612
  static colorize(text, severity) {
158
- if (!_ErrorFormatter.useColors) {
1613
+ if (!_ErrorFormatter2.useColors) {
159
1614
  return text;
160
1615
  }
161
1616
  const colors = {
@@ -167,10 +1622,10 @@ var init_actionable_error = __esm({
167
1622
  return `${colors[severity]}${text}${reset}`;
168
1623
  }
169
1624
  };
170
- CommonErrors = {
1625
+ CommonErrors2 = {
171
1626
  fileNotFound(path) {
172
- return new ActionableError(`File not found: ${path}`, {
173
- code: ErrorCodes.FILE_NOT_FOUND,
1627
+ return new ActionableError2(`File not found: ${path}`, {
1628
+ code: ErrorCodes2.FILE_NOT_FOUND,
174
1629
  context: { file: path },
175
1630
  suggestions: [
176
1631
  {
@@ -186,8 +1641,8 @@ var init_actionable_error = __esm({
186
1641
  });
187
1642
  },
188
1643
  earsValidationFailed(file, issues) {
189
- return new ActionableError(`EARS validation failed with ${issues.length} issue(s)`, {
190
- code: ErrorCodes.EARS_VALIDATION_FAILED,
1644
+ return new ActionableError2(`EARS validation failed with ${issues.length} issue(s)`, {
1645
+ code: ErrorCodes2.EARS_VALIDATION_FAILED,
191
1646
  context: { file },
192
1647
  suggestions: [
193
1648
  {
@@ -203,8 +1658,8 @@ var init_actionable_error = __esm({
203
1658
  });
204
1659
  },
205
1660
  traceabilityMissing(reqId, designId) {
206
- return new ActionableError(`Missing traceability link: ${reqId} \u2192 ${designId}`, {
207
- code: ErrorCodes.TRACEABILITY_MISSING,
1661
+ return new ActionableError2(`Missing traceability link: ${reqId} \u2192 ${designId}`, {
1662
+ code: ErrorCodes2.TRACEABILITY_MISSING,
208
1663
  severity: "warning",
209
1664
  context: { artifactId: reqId },
210
1665
  suggestions: [
@@ -217,8 +1672,8 @@ var init_actionable_error = __esm({
217
1672
  });
218
1673
  },
219
1674
  phaseTransitionBlocked(from, to, reason) {
220
- return new ActionableError(`Cannot transition from ${from} to ${to}: ${reason}`, {
221
- code: ErrorCodes.PHASE_TRANSITION_BLOCKED,
1675
+ return new ActionableError2(`Cannot transition from ${from} to ${to}: ${reason}`, {
1676
+ code: ErrorCodes2.PHASE_TRANSITION_BLOCKED,
222
1677
  suggestions: [
223
1678
  {
224
1679
  action: "Complete requirements",
@@ -233,8 +1688,8 @@ var init_actionable_error = __esm({
233
1688
  });
234
1689
  },
235
1690
  qualityGateFailed(gate, details) {
236
- return new ActionableError(`Quality gate failed: ${gate}`, {
237
- code: ErrorCodes.QUALITY_GATE_FAILED,
1691
+ return new ActionableError2(`Quality gate failed: ${gate}`, {
1692
+ code: ErrorCodes2.QUALITY_GATE_FAILED,
238
1693
  suggestions: [
239
1694
  {
240
1695
  action: "Fix issues",
@@ -251,12 +1706,10 @@ var init_actionable_error = __esm({
251
1706
  };
252
1707
  }
253
1708
  });
254
-
255
- // ../core/dist/error/graceful-degradation.js
256
- function createGracefulDegradation(config) {
257
- return new GracefulDegradation(config);
1709
+ function createGracefulDegradation2(config) {
1710
+ return new GracefulDegradation2(config);
258
1711
  }
259
- async function retryWithBackoff(operation, options) {
1712
+ async function retryWithBackoff2(operation, options) {
260
1713
  const maxAttempts = options?.maxAttempts ?? 3;
261
1714
  const initialDelay = options?.initialDelay ?? 1e3;
262
1715
  const maxDelay = options?.maxDelay ?? 3e4;
@@ -276,11 +1729,15 @@ async function retryWithBackoff(operation, options) {
276
1729
  }
277
1730
  throw lastError ?? new Error("Operation failed after retries");
278
1731
  }
279
- var MemoryCacheProvider, MemoryQueueProvider, DEFAULT_DEGRADATION_CONFIG, GracefulDegradation, CircuitBreaker;
1732
+ var MemoryCacheProvider2;
1733
+ var MemoryQueueProvider2;
1734
+ var DEFAULT_DEGRADATION_CONFIG2;
1735
+ var GracefulDegradation2;
1736
+ var CircuitBreaker2;
280
1737
  var init_graceful_degradation = __esm({
281
1738
  "../core/dist/error/graceful-degradation.js"() {
282
1739
  "use strict";
283
- MemoryCacheProvider = class {
1740
+ MemoryCacheProvider2 = class {
284
1741
  cache = /* @__PURE__ */ new Map();
285
1742
  async get(key) {
286
1743
  const entry = this.cache.get(key);
@@ -306,7 +1763,7 @@ var init_graceful_degradation = __esm({
306
1763
  this.cache.clear();
307
1764
  }
308
1765
  };
309
- MemoryQueueProvider = class {
1766
+ MemoryQueueProvider2 = class {
310
1767
  queue = [];
311
1768
  counter = 0;
312
1769
  async enqueue(item) {
@@ -325,13 +1782,13 @@ var init_graceful_degradation = __esm({
325
1782
  this.queue = [];
326
1783
  }
327
1784
  };
328
- DEFAULT_DEGRADATION_CONFIG = {
1785
+ DEFAULT_DEGRADATION_CONFIG2 = {
329
1786
  services: [],
330
1787
  healthCheckInterval: 3e4,
331
1788
  autoRecovery: true,
332
1789
  maxQueueSize: 1e3
333
1790
  };
334
- GracefulDegradation = class {
1791
+ GracefulDegradation2 = class {
335
1792
  config;
336
1793
  serviceStatus;
337
1794
  currentLevel = "full";
@@ -341,10 +1798,10 @@ var init_graceful_degradation = __esm({
341
1798
  cache;
342
1799
  queue;
343
1800
  constructor(config) {
344
- this.config = { ...DEFAULT_DEGRADATION_CONFIG, ...config };
1801
+ this.config = { ...DEFAULT_DEGRADATION_CONFIG2, ...config };
345
1802
  this.serviceStatus = /* @__PURE__ */ new Map();
346
- this.cache = config?.cacheProvider ?? new MemoryCacheProvider();
347
- this.queue = config?.queueProvider ?? new MemoryQueueProvider();
1803
+ this.cache = config?.cacheProvider ?? new MemoryCacheProvider2();
1804
+ this.queue = config?.queueProvider ?? new MemoryQueueProvider2();
348
1805
  for (const service of this.config.services) {
349
1806
  this.serviceStatus.set(service.name, {
350
1807
  service: service.name,
@@ -580,7 +2037,7 @@ var init_graceful_degradation = __esm({
580
2037
  });
581
2038
  }
582
2039
  };
583
- CircuitBreaker = class {
2040
+ CircuitBreaker2 = class {
584
2041
  threshold;
585
2042
  resetTimeout;
586
2043
  failures = 0;
@@ -635,8 +2092,6 @@ var init_graceful_degradation = __esm({
635
2092
  };
636
2093
  }
637
2094
  });
638
-
639
- // ../core/dist/error/index.js
640
2095
  var init_error = __esm({
641
2096
  "../core/dist/error/index.js"() {
642
2097
  "use strict";
@@ -644,13 +2099,15 @@ var init_error = __esm({
644
2099
  init_graceful_degradation();
645
2100
  }
646
2101
  });
647
-
648
- // ../core/dist/logging/index.js
649
- var ConsoleTransport, MemoryTransport, LOG_LEVEL_ORDER, Logger, AuditLogger;
2102
+ var ConsoleTransport2;
2103
+ var MemoryTransport2;
2104
+ var LOG_LEVEL_ORDER2;
2105
+ var Logger2;
2106
+ var AuditLogger2;
650
2107
  var init_logging = __esm({
651
2108
  "../core/dist/logging/index.js"() {
652
2109
  "use strict";
653
- ConsoleTransport = class {
2110
+ ConsoleTransport2 = class {
654
2111
  write(entry) {
655
2112
  const prefix = `[${entry.timestamp.toISOString()}] [${entry.level.toUpperCase()}]`;
656
2113
  const src = entry.source ? ` (${entry.source})` : "";
@@ -670,7 +2127,7 @@ var init_logging = __esm({
670
2127
  }
671
2128
  }
672
2129
  };
673
- MemoryTransport = class {
2130
+ MemoryTransport2 = class {
674
2131
  entries = [];
675
2132
  write(entry) {
676
2133
  this.entries.push(entry);
@@ -679,18 +2136,18 @@ var init_logging = __esm({
679
2136
  this.entries.length = 0;
680
2137
  }
681
2138
  };
682
- LOG_LEVEL_ORDER = {
2139
+ LOG_LEVEL_ORDER2 = {
683
2140
  debug: 0,
684
2141
  info: 1,
685
2142
  warn: 2,
686
2143
  error: 3
687
2144
  };
688
- Logger = class _Logger {
2145
+ Logger2 = class _Logger2 {
689
2146
  transports;
690
2147
  minLevel;
691
2148
  source;
692
2149
  constructor(options) {
693
- this.transports = options?.transports ?? [new ConsoleTransport()];
2150
+ this.transports = options?.transports ?? [new ConsoleTransport2()];
694
2151
  this.minLevel = options?.level ?? "info";
695
2152
  this.source = options?.source;
696
2153
  }
@@ -707,14 +2164,14 @@ var init_logging = __esm({
707
2164
  this.log("error", message, context);
708
2165
  }
709
2166
  child(source) {
710
- return new _Logger({
2167
+ return new _Logger2({
711
2168
  transports: this.transports,
712
2169
  level: this.minLevel,
713
2170
  source: this.source ? `${this.source}:${source}` : source
714
2171
  });
715
2172
  }
716
2173
  log(level, message, context) {
717
- if (LOG_LEVEL_ORDER[level] < LOG_LEVEL_ORDER[this.minLevel]) {
2174
+ if (LOG_LEVEL_ORDER2[level] < LOG_LEVEL_ORDER2[this.minLevel]) {
718
2175
  return;
719
2176
  }
720
2177
  const entry = {
@@ -729,11 +2186,11 @@ var init_logging = __esm({
729
2186
  }
730
2187
  }
731
2188
  };
732
- AuditLogger = class {
2189
+ AuditLogger2 = class {
733
2190
  events = [];
734
2191
  logger;
735
2192
  constructor(logger) {
736
- this.logger = logger ?? new Logger({ source: "audit" });
2193
+ this.logger = logger ?? new Logger2({ source: "audit" });
737
2194
  }
738
2195
  record(event) {
739
2196
  const full = { ...event, timestamp: /* @__PURE__ */ new Date() };
@@ -757,16 +2214,14 @@ var init_logging = __esm({
757
2214
  };
758
2215
  }
759
2216
  });
760
-
761
- // ../core/dist/config/index.js
762
- import { readFile } from "node:fs/promises";
763
- import { join } from "node:path";
764
- var DEFAULT_CONFIG, CONFIG_FILENAME, ConfigLoader;
2217
+ var DEFAULT_CONFIG2;
2218
+ var CONFIG_FILENAME2;
2219
+ var ConfigLoader2;
765
2220
  var init_config = __esm({
766
2221
  "../core/dist/config/index.js"() {
767
2222
  "use strict";
768
2223
  init_error();
769
- DEFAULT_CONFIG = {
2224
+ DEFAULT_CONFIG2 = {
770
2225
  steeringDir: "steering",
771
2226
  storageDir: "storage",
772
2227
  llm: {
@@ -780,24 +2235,24 @@ var init_config = __esm({
780
2235
  confidenceThreshold: 0.85
781
2236
  }
782
2237
  };
783
- CONFIG_FILENAME = "musubix.config.json";
784
- ConfigLoader = class {
2238
+ CONFIG_FILENAME2 = "musubix.config.json";
2239
+ ConfigLoader2 = class {
785
2240
  config = null;
786
2241
  basePath;
787
2242
  constructor(basePath) {
788
2243
  this.basePath = basePath ?? process.cwd();
789
2244
  }
790
2245
  async load() {
791
- const configPath = join(this.basePath, CONFIG_FILENAME);
2246
+ const configPath = join2(this.basePath, CONFIG_FILENAME2);
792
2247
  try {
793
- const raw = await readFile(configPath, "utf-8");
2248
+ const raw = await readFile2(configPath, "utf-8");
794
2249
  const parsed = JSON.parse(raw);
795
2250
  this.config = this.merge(parsed);
796
2251
  return this.config;
797
2252
  } catch (error) {
798
2253
  if (error.code === "ENOENT") {
799
- throw new ActionableError(`Configuration file not found: ${configPath}`, {
800
- code: ErrorCodes.CONFIG_MISSING,
2254
+ throw new ActionableError2(`Configuration file not found: ${configPath}`, {
2255
+ code: ErrorCodes2.CONFIG_MISSING,
801
2256
  context: { file: configPath },
802
2257
  suggestions: [
803
2258
  {
@@ -808,8 +2263,8 @@ var init_config = __esm({
808
2263
  ]
809
2264
  });
810
2265
  }
811
- throw new ActionableError(`Failed to parse configuration: ${error.message}`, {
812
- code: ErrorCodes.CONFIG_INVALID,
2266
+ throw new ActionableError2(`Failed to parse configuration: ${error.message}`, {
2267
+ code: ErrorCodes2.CONFIG_INVALID,
813
2268
  context: { file: configPath },
814
2269
  cause: error,
815
2270
  suggestions: [
@@ -823,24 +2278,24 @@ var init_config = __esm({
823
2278
  }
824
2279
  getConfig() {
825
2280
  if (!this.config) {
826
- return DEFAULT_CONFIG;
2281
+ return DEFAULT_CONFIG2;
827
2282
  }
828
2283
  return this.config;
829
2284
  }
830
2285
  merge(partial) {
831
2286
  return {
832
- steeringDir: partial.steeringDir ?? DEFAULT_CONFIG.steeringDir,
833
- storageDir: partial.storageDir ?? DEFAULT_CONFIG.storageDir,
2287
+ steeringDir: partial.steeringDir ?? DEFAULT_CONFIG2.steeringDir,
2288
+ storageDir: partial.storageDir ?? DEFAULT_CONFIG2.storageDir,
834
2289
  llm: {
835
- ...DEFAULT_CONFIG.llm,
2290
+ ...DEFAULT_CONFIG2.llm,
836
2291
  ...partial.llm
837
2292
  },
838
2293
  knowledge: {
839
- ...DEFAULT_CONFIG.knowledge,
2294
+ ...DEFAULT_CONFIG2.knowledge,
840
2295
  ...partial.knowledge
841
2296
  },
842
2297
  integration: {
843
- ...DEFAULT_CONFIG.integration,
2298
+ ...DEFAULT_CONFIG2.integration,
844
2299
  ...partial.integration
845
2300
  }
846
2301
  };
@@ -848,22 +2303,22 @@ var init_config = __esm({
848
2303
  };
849
2304
  }
850
2305
  });
851
-
852
- // ../core/dist/infrastructure/repository.js
853
- function createInMemoryRepository() {
854
- return new InMemoryRepository();
2306
+ function createInMemoryRepository2() {
2307
+ return new InMemoryRepository2();
855
2308
  }
856
- function createInMemorySearchableRepository() {
857
- return new InMemorySearchableRepository();
2309
+ function createInMemorySearchableRepository2() {
2310
+ return new InMemorySearchableRepository2();
858
2311
  }
859
- function createInMemoryPaginatedRepository() {
860
- return new InMemoryPaginatedRepository();
2312
+ function createInMemoryPaginatedRepository2() {
2313
+ return new InMemoryPaginatedRepository2();
861
2314
  }
862
- var InMemoryRepository, InMemorySearchableRepository, InMemoryPaginatedRepository;
2315
+ var InMemoryRepository2;
2316
+ var InMemorySearchableRepository2;
2317
+ var InMemoryPaginatedRepository2;
863
2318
  var init_repository = __esm({
864
2319
  "../core/dist/infrastructure/repository.js"() {
865
2320
  "use strict";
866
- InMemoryRepository = class {
2321
+ InMemoryRepository2 = class {
867
2322
  store = /* @__PURE__ */ new Map();
868
2323
  async get(id) {
869
2324
  return this.store.get(id);
@@ -881,7 +2336,7 @@ var init_repository = __esm({
881
2336
  return this.store.has(id);
882
2337
  }
883
2338
  };
884
- InMemorySearchableRepository = class extends InMemoryRepository {
2339
+ InMemorySearchableRepository2 = class extends InMemoryRepository2 {
885
2340
  async search(query) {
886
2341
  const lower = query.toLowerCase();
887
2342
  return [...this.store.values()].filter((entity) => {
@@ -894,7 +2349,7 @@ var init_repository = __esm({
894
2349
  });
895
2350
  }
896
2351
  };
897
- InMemoryPaginatedRepository = class extends InMemoryRepository {
2352
+ InMemoryPaginatedRepository2 = class extends InMemoryRepository2 {
898
2353
  async getPage(page, size) {
899
2354
  const all = [...this.store.values()];
900
2355
  const total = all.length;
@@ -909,21 +2364,19 @@ var init_repository = __esm({
909
2364
  };
910
2365
  }
911
2366
  });
912
-
913
- // ../core/dist/interface/cli/index.js
914
- function formatSuccess(message) {
2367
+ function formatSuccess2(message) {
915
2368
  return `\u2705 ${message}`;
916
2369
  }
917
- function formatError(message) {
2370
+ function formatError2(message) {
918
2371
  return `\u274C ${message}`;
919
2372
  }
920
- function formatWarning(message) {
2373
+ function formatWarning2(message) {
921
2374
  return `\u26A0\uFE0F ${message}`;
922
2375
  }
923
- function formatInfo(message) {
2376
+ function formatInfo2(message) {
924
2377
  return `\u2139\uFE0F ${message}`;
925
2378
  }
926
- function formatTable(headers, rows) {
2379
+ function formatTable2(headers, rows) {
927
2380
  const widths = headers.map((h, i) => {
928
2381
  const maxRow = Math.max(...rows.map((r) => (r[i] ?? "").length));
929
2382
  return Math.max(h.length, maxRow);
@@ -935,11 +2388,11 @@ function formatTable(headers, rows) {
935
2388
  ${separator}
936
2389
  ${body}`;
937
2390
  }
938
- var ExitCode;
2391
+ var ExitCode2;
939
2392
  var init_cli = __esm({
940
2393
  "../core/dist/interface/cli/index.js"() {
941
2394
  "use strict";
942
- ExitCode = {
2395
+ ExitCode2 = {
943
2396
  SUCCESS: 0,
944
2397
  GENERAL_ERROR: 1,
945
2398
  VALIDATION_ERROR: 2,
@@ -948,9 +2401,7 @@ var init_cli = __esm({
948
2401
  };
949
2402
  }
950
2403
  });
951
-
952
- // ../core/dist/validators/ears-validator.js
953
- function convertToEARS(naturalLanguage) {
2404
+ function convertToEARS2(naturalLanguage) {
954
2405
  const text = naturalLanguage.trim();
955
2406
  const whenMatch = text.match(/^when\s+(.+?),?\s+(the\s+\S+)\s+(shall|should|must)\s+(.+)$/i);
956
2407
  if (whenMatch) {
@@ -987,14 +2438,16 @@ function convertToEARS(naturalLanguage) {
987
2438
  }
988
2439
  return `THE system SHALL ${text}`;
989
2440
  }
990
- function createEARSValidator() {
991
- return new EARSValidator();
2441
+ function createEARSValidator2() {
2442
+ return new EARSValidator2();
992
2443
  }
993
- var PATTERN_RULES, COMPLEX_COMBINATIONS, EARSValidator;
2444
+ var PATTERN_RULES2;
2445
+ var COMPLEX_COMBINATIONS2;
2446
+ var EARSValidator2;
994
2447
  var init_ears_validator = __esm({
995
2448
  "../core/dist/validators/ears-validator.js"() {
996
2449
  "use strict";
997
- PATTERN_RULES = [
2450
+ PATTERN_RULES2 = [
998
2451
  {
999
2452
  pattern: "event-driven",
1000
2453
  regex: /\bWHEN\b.*\b(THE\s+.+\s+)?SHALL\b/i,
@@ -1032,15 +2485,15 @@ var init_ears_validator = __esm({
1032
2485
  bonus: 0
1033
2486
  }
1034
2487
  ];
1035
- COMPLEX_COMBINATIONS = [
2488
+ COMPLEX_COMBINATIONS2 = [
1036
2489
  /\bWHEN\b.*\bWHILE\b/i,
1037
2490
  /\bWHILE\b.*\bWHEN\b/i,
1038
2491
  /\bIF\b.*\bWHEN\b/i
1039
2492
  ];
1040
- EARSValidator = class {
2493
+ EARSValidator2 = class {
1041
2494
  analyze(text, options) {
1042
2495
  const cleaned = this.cleanText(text, options?.sourceFormat);
1043
- for (const combo of COMPLEX_COMBINATIONS) {
2496
+ for (const combo of COMPLEX_COMBINATIONS2) {
1044
2497
  if (combo.test(cleaned)) {
1045
2498
  const confidence = this.computeConfidence(cleaned, "complex", 0.55, 0.15);
1046
2499
  return {
@@ -1052,7 +2505,7 @@ var init_ears_validator = __esm({
1052
2505
  }
1053
2506
  }
1054
2507
  let bestResult;
1055
- for (const rule of PATTERN_RULES) {
2508
+ for (const rule of PATTERN_RULES2) {
1056
2509
  if (rule.regex.test(cleaned)) {
1057
2510
  const confidence = this.computeConfidence(cleaned, rule.pattern, rule.baseConfidence, rule.bonus);
1058
2511
  const patternTriggers = this.extractTriggers(cleaned, rule.pattern);
@@ -1166,21 +2619,22 @@ var init_ears_validator = __esm({
1166
2619
  };
1167
2620
  }
1168
2621
  });
1169
-
1170
- // ../core/dist/validators/markdown-ears-parser.js
1171
- function createMarkdownEARSParser() {
1172
- return new MarkdownEARSParser();
2622
+ function createMarkdownEARSParser2() {
2623
+ return new MarkdownEARSParser2();
1173
2624
  }
1174
- function createRequirementsValidator() {
1175
- return new RequirementsValidator();
2625
+ function createRequirementsValidator2() {
2626
+ return new RequirementsValidator2();
1176
2627
  }
1177
- var REQ_HEADING_REGEX, FIELD_REGEX, MarkdownEARSParser, RequirementsValidator;
2628
+ var REQ_HEADING_REGEX2;
2629
+ var FIELD_REGEX2;
2630
+ var MarkdownEARSParser2;
2631
+ var RequirementsValidator2;
1178
2632
  var init_markdown_ears_parser = __esm({
1179
2633
  "../core/dist/validators/markdown-ears-parser.js"() {
1180
2634
  "use strict";
1181
2635
  init_ears_validator();
1182
- REQ_HEADING_REGEX = /^#{1,4}\s+(REQ-[A-Z]{3}-\d{3}):\s*(.+)$/;
1183
- FIELD_REGEX = {
2636
+ REQ_HEADING_REGEX2 = /^#{1,4}\s+(REQ-[A-Z]{3}-\d{3}):\s*(.+)$/;
2637
+ FIELD_REGEX2 = {
1184
2638
  type: /^\*\*種別\*\*:\s*(.+)$/m,
1185
2639
  priority: /^\*\*優先度\*\*:\s*(P[012])$/m,
1186
2640
  requirement: /^\*\*要件\*\*:\s*\n([\s\S]+?)(?=\n\*\*|$)/m,
@@ -1188,10 +2642,10 @@ var init_markdown_ears_parser = __esm({
1188
2642
  traceability: /^\*\*トレーサビリティ\*\*:\s*(.+)$/m,
1189
2643
  package: /^\*\*パッケージ\*\*:\s*`(.+)`$/m
1190
2644
  };
1191
- MarkdownEARSParser = class {
2645
+ MarkdownEARSParser2 = class {
1192
2646
  validator;
1193
2647
  constructor(validator) {
1194
- this.validator = validator ?? new EARSValidator();
2648
+ this.validator = validator ?? new EARSValidator2();
1195
2649
  }
1196
2650
  parse(markdown) {
1197
2651
  const requirements = [];
@@ -1211,7 +2665,7 @@ var init_markdown_ears_parser = __esm({
1211
2665
  if (inCodeBlock) {
1212
2666
  continue;
1213
2667
  }
1214
- const headingMatch = line.match(REQ_HEADING_REGEX);
2668
+ const headingMatch = line.match(REQ_HEADING_REGEX2);
1215
2669
  if (headingMatch) {
1216
2670
  if (currentReq && currentReq.id) {
1217
2671
  const parsed = this.parseBlock(currentReq, currentBlock, blockStartLine);
@@ -1235,12 +2689,12 @@ var init_markdown_ears_parser = __esm({
1235
2689
  return requirements;
1236
2690
  }
1237
2691
  parseBlock(partial, block, _startLine) {
1238
- const typeMatch = block.match(FIELD_REGEX.type);
1239
- const priorityMatch = block.match(FIELD_REGEX.priority);
1240
- const reqMatch = block.match(FIELD_REGEX.requirement);
1241
- const acMatch = block.match(FIELD_REGEX.acceptanceCriteria);
1242
- const traceMatch = block.match(FIELD_REGEX.traceability);
1243
- const pkgMatch = block.match(FIELD_REGEX.package);
2692
+ const typeMatch = block.match(FIELD_REGEX2.type);
2693
+ const priorityMatch = block.match(FIELD_REGEX2.priority);
2694
+ const reqMatch = block.match(FIELD_REGEX2.requirement);
2695
+ const acMatch = block.match(FIELD_REGEX2.acceptanceCriteria);
2696
+ const traceMatch = block.match(FIELD_REGEX2.traceability);
2697
+ const pkgMatch = block.match(FIELD_REGEX2.package);
1244
2698
  const reqText = reqMatch ? reqMatch[1].trim() : "";
1245
2699
  let pattern;
1246
2700
  let confidence;
@@ -1280,12 +2734,12 @@ var init_markdown_ears_parser = __esm({
1280
2734
  return mapping[raw.toUpperCase()] ?? "ubiquitous";
1281
2735
  }
1282
2736
  };
1283
- RequirementsValidator = class {
2737
+ RequirementsValidator2 = class {
1284
2738
  parser;
1285
2739
  earsValidator;
1286
2740
  constructor(parser, validator) {
1287
- this.earsValidator = validator ?? new EARSValidator();
1288
- this.parser = parser ?? new MarkdownEARSParser(this.earsValidator);
2741
+ this.earsValidator = validator ?? new EARSValidator2();
2742
+ this.parser = parser ?? new MarkdownEARSParser2(this.earsValidator);
1289
2743
  }
1290
2744
  validate(markdown) {
1291
2745
  const requirements = this.parser.parse(markdown);
@@ -1340,8 +2794,6 @@ var init_markdown_ears_parser = __esm({
1340
2794
  };
1341
2795
  }
1342
2796
  });
1343
-
1344
- // ../core/dist/validators/index.js
1345
2797
  var init_validators = __esm({
1346
2798
  "../core/dist/validators/index.js"() {
1347
2799
  "use strict";
@@ -1349,13 +2801,12 @@ var init_validators = __esm({
1349
2801
  init_markdown_ears_parser();
1350
2802
  }
1351
2803
  });
1352
-
1353
- // ../core/dist/repl/index.js
1354
- var DefaultReplFormatter, ReplEngine;
2804
+ var DefaultReplFormatter2;
2805
+ var ReplEngine2;
1355
2806
  var init_repl = __esm({
1356
2807
  "../core/dist/repl/index.js"() {
1357
2808
  "use strict";
1358
- DefaultReplFormatter = class {
2809
+ DefaultReplFormatter2 = class {
1359
2810
  formatResult(value) {
1360
2811
  if (value === void 0 || value === null) {
1361
2812
  return "";
@@ -1377,7 +2828,7 @@ var init_repl = __esm({
1377
2828
  return lines.join("\n");
1378
2829
  }
1379
2830
  };
1380
- ReplEngine = class {
2831
+ ReplEngine2 = class {
1381
2832
  commands = /* @__PURE__ */ new Map();
1382
2833
  session;
1383
2834
  formatter;
@@ -1387,7 +2838,7 @@ var init_repl = __esm({
1387
2838
  constructor(options) {
1388
2839
  this.prompt = options?.prompt ?? "musubix> ";
1389
2840
  this.maxHistory = options?.maxHistory ?? 1e3;
1390
- this.formatter = new DefaultReplFormatter();
2841
+ this.formatter = new DefaultReplFormatter2();
1391
2842
  this.session = {
1392
2843
  id: `repl-${Date.now()}`,
1393
2844
  history: [],
@@ -1500,13 +2951,12 @@ var init_repl = __esm({
1500
2951
  };
1501
2952
  }
1502
2953
  });
1503
-
1504
- // ../core/dist/explanation/index.js
1505
- var ReasoningChainRecorder, ExplanationGenerator;
2954
+ var ReasoningChainRecorder2;
2955
+ var ExplanationGenerator2;
1506
2956
  var init_explanation = __esm({
1507
2957
  "../core/dist/explanation/index.js"() {
1508
2958
  "use strict";
1509
- ReasoningChainRecorder = class {
2959
+ ReasoningChainRecorder2 = class {
1510
2960
  chains = /* @__PURE__ */ new Map();
1511
2961
  activeChainId = null;
1512
2962
  stepCounter = 0;
@@ -1564,7 +3014,7 @@ var init_explanation = __esm({
1564
3014
  chain.overallConfidence = sum / chain.steps.length;
1565
3015
  }
1566
3016
  };
1567
- ExplanationGenerator = class {
3017
+ ExplanationGenerator2 = class {
1568
3018
  generate(chain, options) {
1569
3019
  const format = options?.format ?? "markdown";
1570
3020
  const includeEvidence = options?.includeEvidence ?? true;
@@ -1635,16 +3085,14 @@ var init_explanation = __esm({
1635
3085
  };
1636
3086
  }
1637
3087
  });
1638
-
1639
- // ../core/dist/validators/traceability-validator.js
1640
- function createTraceabilityValidator() {
1641
- return new TraceabilityValidator();
3088
+ function createTraceabilityValidator2() {
3089
+ return new TraceabilityValidator2();
1642
3090
  }
1643
- var TraceabilityValidator;
3091
+ var TraceabilityValidator2;
1644
3092
  var init_traceability_validator = __esm({
1645
3093
  "../core/dist/validators/traceability-validator.js"() {
1646
3094
  "use strict";
1647
- TraceabilityValidator = class {
3095
+ TraceabilityValidator2 = class {
1648
3096
  /**
1649
3097
  * Validate traceability coverage.
1650
3098
  * @param requirementIds - list of requirement IDs (e.g., ['REQ-001', 'REQ-002'])
@@ -1708,8 +3156,6 @@ var init_traceability_validator = __esm({
1708
3156
  };
1709
3157
  }
1710
3158
  });
1711
-
1712
- // ../core/dist/requirements/interviewer.js
1713
3159
  function buildQuestionBank() {
1714
3160
  return [
1715
3161
  {
@@ -1837,14 +3283,14 @@ function buildQuestionBank() {
1837
3283
  }
1838
3284
  ];
1839
3285
  }
1840
- function createRequirementsInterviewer() {
1841
- return new RequirementsInterviewer();
3286
+ function createRequirementsInterviewer2() {
3287
+ return new RequirementsInterviewer2();
1842
3288
  }
1843
- var RequirementsInterviewer;
3289
+ var RequirementsInterviewer2;
1844
3290
  var init_interviewer = __esm({
1845
3291
  "../core/dist/requirements/interviewer.js"() {
1846
3292
  "use strict";
1847
- RequirementsInterviewer = class {
3293
+ RequirementsInterviewer2 = class {
1848
3294
  state;
1849
3295
  questions;
1850
3296
  constructor() {
@@ -2144,16 +3590,14 @@ var init_interviewer = __esm({
2144
3590
  };
2145
3591
  }
2146
3592
  });
2147
-
2148
- // ../core/dist/requirements/generator.js
2149
- function createRequirementsDocGenerator() {
2150
- return new RequirementsDocGenerator();
3593
+ function createRequirementsDocGenerator2() {
3594
+ return new RequirementsDocGenerator2();
2151
3595
  }
2152
- var RequirementsDocGenerator;
3596
+ var RequirementsDocGenerator2;
2153
3597
  var init_generator = __esm({
2154
3598
  "../core/dist/requirements/generator.js"() {
2155
3599
  "use strict";
2156
- RequirementsDocGenerator = class {
3600
+ RequirementsDocGenerator2 = class {
2157
3601
  counter = 0;
2158
3602
  /**
2159
3603
  * Generate a complete requirements specification from gathered context
@@ -2390,15 +3834,15 @@ var init_generator = __esm({
2390
3834
  };
2391
3835
  }
2392
3836
  });
2393
-
2394
- // ../core/dist/requirements/index.js
2395
- function createRequirementWizard() {
2396
- return new RequirementWizard();
3837
+ function createRequirementWizard2() {
3838
+ return new RequirementWizard2();
2397
3839
  }
2398
- function createAcceptanceCriteriaGenerator() {
2399
- return new AcceptanceCriteriaGenerator();
3840
+ function createAcceptanceCriteriaGenerator2() {
3841
+ return new AcceptanceCriteriaGenerator2();
2400
3842
  }
2401
- var WIZARD_STEPS, RequirementWizard, AcceptanceCriteriaGenerator;
3843
+ var WIZARD_STEPS;
3844
+ var RequirementWizard2;
3845
+ var AcceptanceCriteriaGenerator2;
2402
3846
  var init_requirements = __esm({
2403
3847
  "../core/dist/requirements/index.js"() {
2404
3848
  "use strict";
@@ -2438,7 +3882,7 @@ var init_requirements = __esm({
2438
3882
  transform: (input) => ({ action: input.trim() })
2439
3883
  }
2440
3884
  ];
2441
- RequirementWizard = class {
3885
+ RequirementWizard2 = class {
2442
3886
  steps;
2443
3887
  counter = 0;
2444
3888
  constructor(steps) {
@@ -2506,7 +3950,7 @@ var init_requirements = __esm({
2506
3950
  ].join("\n");
2507
3951
  }
2508
3952
  };
2509
- AcceptanceCriteriaGenerator = class {
3953
+ AcceptanceCriteriaGenerator2 = class {
2510
3954
  generate(requirementText, context) {
2511
3955
  const criteria = [];
2512
3956
  criteria.push(`- [ ] ${context.projectName}: \u8981\u4EF6\u3092\u6E80\u305F\u3059\u52D5\u4F5C\u304C\u5B9F\u88C5\u3055\u308C\u3066\u3044\u308B\u3053\u3068`);
@@ -2529,19 +3973,18 @@ var init_requirements = __esm({
2529
3973
  };
2530
3974
  }
2531
3975
  });
2532
-
2533
- // ../core/dist/design/index.js
2534
- function createDesignGenerator() {
2535
- return new DesignGenerator();
3976
+ function createDesignGenerator2() {
3977
+ return new DesignGenerator2();
2536
3978
  }
2537
- function createSOLIDValidator() {
2538
- return new SOLIDValidator();
3979
+ function createSOLIDValidator2() {
3980
+ return new SOLIDValidator2();
2539
3981
  }
2540
- var DesignGenerator, SOLIDValidator;
3982
+ var DesignGenerator2;
3983
+ var SOLIDValidator2;
2541
3984
  var init_design = __esm({
2542
3985
  "../core/dist/design/index.js"() {
2543
3986
  "use strict";
2544
- DesignGenerator = class {
3987
+ DesignGenerator2 = class {
2545
3988
  counter = 0;
2546
3989
  generate(requirements) {
2547
3990
  this.counter++;
@@ -2644,7 +4087,7 @@ var init_design = __esm({
2644
4087
  return [...patterns];
2645
4088
  }
2646
4089
  };
2647
- SOLIDValidator = class {
4090
+ SOLIDValidator2 = class {
2648
4091
  validate(design) {
2649
4092
  const violations = [];
2650
4093
  const principleScores = {
@@ -2689,12 +4132,12 @@ var init_design = __esm({
2689
4132
  };
2690
4133
  }
2691
4134
  });
2692
-
2693
- // ../core/dist/project/index.js
2694
- function createProjectInitializer() {
2695
- return new ProjectInitializer();
4135
+ function createProjectInitializer2() {
4136
+ return new ProjectInitializer2();
2696
4137
  }
2697
- var PROJECT_NAME_PATTERN, TEMPLATES, ProjectInitializer;
4138
+ var PROJECT_NAME_PATTERN;
4139
+ var TEMPLATES;
4140
+ var ProjectInitializer2;
2698
4141
  var init_project = __esm({
2699
4142
  "../core/dist/project/index.js"() {
2700
4143
  "use strict";
@@ -2723,7 +4166,7 @@ var init_project = __esm({
2723
4166
  "musubix.config.json"
2724
4167
  ]
2725
4168
  };
2726
- ProjectInitializer = class {
4169
+ ProjectInitializer2 = class {
2727
4170
  init(options) {
2728
4171
  const errors = [];
2729
4172
  const nameCheck = this.validateProjectName(options.projectName);
@@ -2768,16 +4211,14 @@ var init_project = __esm({
2768
4211
  };
2769
4212
  }
2770
4213
  });
2771
-
2772
- // ../core/dist/design/c4-generator.js
2773
- function createC4ModelGenerator() {
2774
- return new C4ModelGenerator();
4214
+ function createC4ModelGenerator2() {
4215
+ return new C4ModelGenerator2();
2775
4216
  }
2776
- var C4ModelGenerator;
4217
+ var C4ModelGenerator2;
2777
4218
  var init_c4_generator = __esm({
2778
4219
  "../core/dist/design/c4-generator.js"() {
2779
4220
  "use strict";
2780
- C4ModelGenerator = class {
4221
+ C4ModelGenerator2 = class {
2781
4222
  elements = [];
2782
4223
  relationships = [];
2783
4224
  addElement(element) {
@@ -2880,16 +4321,15 @@ var init_c4_generator = __esm({
2880
4321
  };
2881
4322
  }
2882
4323
  });
2883
-
2884
- // ../core/dist/design/pattern-detector.js
2885
- function createPatternDetector() {
2886
- return new PatternDetector();
4324
+ function createPatternDetector2() {
4325
+ return new PatternDetector2();
2887
4326
  }
2888
- var PATTERN_RULES2, PatternDetector;
4327
+ var PATTERN_RULES22;
4328
+ var PatternDetector2;
2889
4329
  var init_pattern_detector = __esm({
2890
4330
  "../core/dist/design/pattern-detector.js"() {
2891
4331
  "use strict";
2892
- PATTERN_RULES2 = [
4332
+ PATTERN_RULES22 = [
2893
4333
  {
2894
4334
  pattern: "singleton",
2895
4335
  matchers: [
@@ -2963,10 +4403,10 @@ var init_pattern_detector = __esm({
2963
4403
  ]
2964
4404
  }
2965
4405
  ];
2966
- PatternDetector = class {
4406
+ PatternDetector2 = class {
2967
4407
  detect(code) {
2968
4408
  const detections = [];
2969
- for (const rule of PATTERN_RULES2) {
4409
+ for (const rule of PATTERN_RULES22) {
2970
4410
  let totalConfidence = 0;
2971
4411
  const evidence = [];
2972
4412
  let firstMatchLine = -1;
@@ -2995,21 +4435,19 @@ var init_pattern_detector = __esm({
2995
4435
  return detections.sort((a, b) => b.confidence - a.confidence);
2996
4436
  }
2997
4437
  getSupportedPatterns() {
2998
- return PATTERN_RULES2.map((r) => r.pattern);
4438
+ return PATTERN_RULES22.map((r) => r.pattern);
2999
4439
  }
3000
4440
  };
3001
4441
  }
3002
4442
  });
3003
-
3004
- // ../core/dist/codegen/index.js
3005
- function createCodeGenerator() {
3006
- return new CodeGenerator();
4443
+ function createCodeGenerator2() {
4444
+ return new CodeGenerator2();
3007
4445
  }
3008
- var CodeGenerator;
4446
+ var CodeGenerator2;
3009
4447
  var init_codegen = __esm({
3010
4448
  "../core/dist/codegen/index.js"() {
3011
4449
  "use strict";
3012
- CodeGenerator = class {
4450
+ CodeGenerator2 = class {
3013
4451
  generate(options) {
3014
4452
  const code = this.renderTemplate(options);
3015
4453
  const filePath = this.resolveFilePath(options);
@@ -3273,21 +4711,22 @@ var init_codegen = __esm({
3273
4711
  };
3274
4712
  }
3275
4713
  });
3276
-
3277
- // ../core/dist/codegen/static-analyzer.js
3278
- function createStaticAnalyzer() {
3279
- return new StaticAnalyzer();
4714
+ function createStaticAnalyzer2() {
4715
+ return new StaticAnalyzer2();
3280
4716
  }
3281
- function createQualityMetricsCalculator() {
3282
- return new QualityMetricsCalculator();
4717
+ function createQualityMetricsCalculator2() {
4718
+ return new QualityMetricsCalculator2();
3283
4719
  }
3284
- var COMPLEXITY_THRESHOLD, FUNCTION_LENGTH_THRESHOLD, StaticAnalyzer, QualityMetricsCalculator;
4720
+ var COMPLEXITY_THRESHOLD;
4721
+ var FUNCTION_LENGTH_THRESHOLD;
4722
+ var StaticAnalyzer2;
4723
+ var QualityMetricsCalculator2;
3285
4724
  var init_static_analyzer = __esm({
3286
4725
  "../core/dist/codegen/static-analyzer.js"() {
3287
4726
  "use strict";
3288
4727
  COMPLEXITY_THRESHOLD = 10;
3289
4728
  FUNCTION_LENGTH_THRESHOLD = 30;
3290
- StaticAnalyzer = class {
4729
+ StaticAnalyzer2 = class {
3291
4730
  analyze(code) {
3292
4731
  const issues = [];
3293
4732
  const complexity = this.calculateComplexity(code);
@@ -3467,7 +4906,7 @@ var init_static_analyzer = __esm({
3467
4906
  return maxLen;
3468
4907
  }
3469
4908
  };
3470
- QualityMetricsCalculator = class {
4909
+ QualityMetricsCalculator2 = class {
3471
4910
  calculate(analysisResults) {
3472
4911
  if (analysisResults.length === 0) {
3473
4912
  return { averageScore: 100, worstFile: "none", totalIssues: 0 };
@@ -3492,16 +4931,14 @@ var init_static_analyzer = __esm({
3492
4931
  };
3493
4932
  }
3494
4933
  });
3495
-
3496
- // ../core/dist/traceability/index.js
3497
- function createTraceabilityManager() {
3498
- return new TraceabilityManager();
4934
+ function createTraceabilityManager2() {
4935
+ return new TraceabilityManager2();
3499
4936
  }
3500
- var TraceabilityManager;
4937
+ var TraceabilityManager2;
3501
4938
  var init_traceability = __esm({
3502
4939
  "../core/dist/traceability/index.js"() {
3503
4940
  "use strict";
3504
- TraceabilityManager = class {
4941
+ TraceabilityManager2 = class {
3505
4942
  links = [];
3506
4943
  linkCounter = 0;
3507
4944
  addLink(sourceId, targetId, type) {
@@ -3566,22 +5003,24 @@ var init_traceability = __esm({
3566
5003
  };
3567
5004
  }
3568
5005
  });
3569
-
3570
- // ../core/dist/neurosymbolic/index.js
3571
- function createSemanticCodeFilterPipeline() {
3572
- return new SemanticCodeFilterPipeline();
5006
+ function createSemanticCodeFilterPipeline2() {
5007
+ return new SemanticCodeFilterPipeline2();
3573
5008
  }
3574
- function createHallucinationDetector() {
3575
- return new HallucinationDetector();
5009
+ function createHallucinationDetector2() {
5010
+ return new HallucinationDetector2();
3576
5011
  }
3577
- function createRejectionGate(threshold) {
3578
- return new RejectionGate(threshold);
5012
+ function createRejectionGate2(threshold) {
5013
+ return new RejectionGate2(threshold);
3579
5014
  }
3580
- var SemanticCodeFilterPipeline, BUILTIN_TYPES, BUILTIN_FUNCTIONS, HallucinationDetector, RejectionGate;
5015
+ var SemanticCodeFilterPipeline2;
5016
+ var BUILTIN_TYPES;
5017
+ var BUILTIN_FUNCTIONS;
5018
+ var HallucinationDetector2;
5019
+ var RejectionGate2;
3581
5020
  var init_neurosymbolic = __esm({
3582
5021
  "../core/dist/neurosymbolic/index.js"() {
3583
5022
  "use strict";
3584
- SemanticCodeFilterPipeline = class {
5023
+ SemanticCodeFilterPipeline2 = class {
3585
5024
  filters = [];
3586
5025
  addFilter(filter) {
3587
5026
  this.filters.push(filter);
@@ -3657,7 +5096,7 @@ var init_neurosymbolic = __esm({
3657
5096
  "finally",
3658
5097
  "new"
3659
5098
  ]);
3660
- HallucinationDetector = class {
5099
+ HallucinationDetector2 = class {
3661
5100
  detect(generatedCode, context) {
3662
5101
  const issues = [];
3663
5102
  const knownTypes = new Set(context.existingTypes);
@@ -3695,7 +5134,7 @@ var init_neurosymbolic = __esm({
3695
5134
  };
3696
5135
  }
3697
5136
  };
3698
- RejectionGate = class {
5137
+ RejectionGate2 = class {
3699
5138
  threshold;
3700
5139
  constructor(threshold = 0.7) {
3701
5140
  this.threshold = threshold;
@@ -3724,19 +5163,18 @@ var init_neurosymbolic = __esm({
3724
5163
  };
3725
5164
  }
3726
5165
  });
3727
-
3728
- // ../core/dist/learning/index.js
3729
- function createPatternExtractor() {
3730
- return new PatternExtractor();
5166
+ function createPatternExtractor2() {
5167
+ return new PatternExtractor2();
3731
5168
  }
3732
- function createLearningEngine() {
3733
- return new LearningEngine();
5169
+ function createLearningEngine2() {
5170
+ return new LearningEngine2();
3734
5171
  }
3735
- var PatternExtractor, LearningEngine;
5172
+ var PatternExtractor2;
5173
+ var LearningEngine2;
3736
5174
  var init_learning = __esm({
3737
5175
  "../core/dist/learning/index.js"() {
3738
5176
  "use strict";
3739
- PatternExtractor = class {
5177
+ PatternExtractor2 = class {
3740
5178
  extract(code) {
3741
5179
  const patterns = [];
3742
5180
  const now = /* @__PURE__ */ new Date();
@@ -3826,7 +5264,7 @@ var init_learning = __esm({
3826
5264
  return ["code-style", "architecture", "testing", "error-handling", "naming", "api-design"];
3827
5265
  }
3828
5266
  };
3829
- LearningEngine = class {
5267
+ LearningEngine2 = class {
3830
5268
  patterns = /* @__PURE__ */ new Map();
3831
5269
  events = [];
3832
5270
  recordPattern(pattern) {
@@ -3864,16 +5302,14 @@ var init_learning = __esm({
3864
5302
  };
3865
5303
  }
3866
5304
  });
3867
-
3868
- // ../core/dist/codegen/scaffold-generator.js
3869
- function createScaffoldGenerator() {
3870
- return new ScaffoldGenerator();
5305
+ function createScaffoldGenerator2() {
5306
+ return new ScaffoldGenerator2();
3871
5307
  }
3872
- var ScaffoldGenerator;
5308
+ var ScaffoldGenerator2;
3873
5309
  var init_scaffold_generator = __esm({
3874
5310
  "../core/dist/codegen/scaffold-generator.js"() {
3875
5311
  "use strict";
3876
- ScaffoldGenerator = class {
5312
+ ScaffoldGenerator2 = class {
3877
5313
  generate(config) {
3878
5314
  const files = [];
3879
5315
  files.push(...this.generateMinimalFiles(config));
@@ -3970,21 +5406,22 @@ ${config.description}
3970
5406
  };
3971
5407
  }
3972
5408
  });
3973
-
3974
- // ../core/dist/codegen/test-generator.js
3975
- function createUnitTestGenerator() {
3976
- return new UnitTestGenerator();
5409
+ function createUnitTestGenerator2() {
5410
+ return new UnitTestGenerator2();
3977
5411
  }
3978
- function createCoverageReporter() {
3979
- return new CoverageReporter();
5412
+ function createCoverageReporter2() {
5413
+ return new CoverageReporter2();
3980
5414
  }
3981
- var EXPORT_FUNCTION_RE, EXPORT_CLASS_RE, UnitTestGenerator, CoverageReporter;
5415
+ var EXPORT_FUNCTION_RE;
5416
+ var EXPORT_CLASS_RE;
5417
+ var UnitTestGenerator2;
5418
+ var CoverageReporter2;
3982
5419
  var init_test_generator = __esm({
3983
5420
  "../core/dist/codegen/test-generator.js"() {
3984
5421
  "use strict";
3985
5422
  EXPORT_FUNCTION_RE = /export\s+(?:async\s+)?function\s+(\w+)/g;
3986
5423
  EXPORT_CLASS_RE = /export\s+class\s+(\w+)/g;
3987
- UnitTestGenerator = class {
5424
+ UnitTestGenerator2 = class {
3988
5425
  generate(sourceCode, style) {
3989
5426
  const functions = this.extractNames(sourceCode, EXPORT_FUNCTION_RE);
3990
5427
  const classes = this.extractNames(sourceCode, EXPORT_CLASS_RE);
@@ -4045,7 +5482,7 @@ var init_test_generator = __esm({
4045
5482
  return names;
4046
5483
  }
4047
5484
  };
4048
- CoverageReporter = class {
5485
+ CoverageReporter2 = class {
4049
5486
  formatReport(covered, total, uncoveredLines) {
4050
5487
  const percent = total === 0 ? 100 : Math.round(covered / total * 100);
4051
5488
  const lines = [
@@ -4065,16 +5502,14 @@ var init_test_generator = __esm({
4065
5502
  };
4066
5503
  }
4067
5504
  });
4068
-
4069
- // ../core/dist/codegen/status-transition.js
4070
- function createStatusTransitionGenerator() {
4071
- return new StatusTransitionGenerator();
5505
+ function createStatusTransitionGenerator2() {
5506
+ return new StatusTransitionGenerator2();
4072
5507
  }
4073
- var StatusTransitionGenerator;
5508
+ var StatusTransitionGenerator2;
4074
5509
  var init_status_transition = __esm({
4075
5510
  "../core/dist/codegen/status-transition.js"() {
4076
5511
  "use strict";
4077
- StatusTransitionGenerator = class {
5512
+ StatusTransitionGenerator2 = class {
4078
5513
  generate(spec) {
4079
5514
  const statusNames = spec.statuses.map((s) => `'${s.name}'`).join(" | ");
4080
5515
  const transitionEntries = spec.transitions.map((t) => {
@@ -4171,16 +5606,14 @@ var init_status_transition = __esm({
4171
5606
  };
4172
5607
  }
4173
5608
  });
4174
-
4175
- // ../core/dist/traceability/matrix-generator.js
4176
- function createMatrixGenerator() {
4177
- return new MatrixGenerator();
5609
+ function createMatrixGenerator2() {
5610
+ return new MatrixGenerator2();
4178
5611
  }
4179
- var MatrixGenerator;
5612
+ var MatrixGenerator2;
4180
5613
  var init_matrix_generator = __esm({
4181
5614
  "../core/dist/traceability/matrix-generator.js"() {
4182
5615
  "use strict";
4183
- MatrixGenerator = class {
5616
+ MatrixGenerator2 = class {
4184
5617
  generate(sourceIds, targetIds, links) {
4185
5618
  const linkMap = /* @__PURE__ */ new Map();
4186
5619
  for (const link of links) {
@@ -4283,19 +5716,18 @@ var init_matrix_generator = __esm({
4283
5716
  };
4284
5717
  }
4285
5718
  });
4286
-
4287
- // ../core/dist/traceability/impact-analyzer.js
4288
- function createImpactAnalyzer() {
4289
- return new ImpactAnalyzer();
5719
+ function createImpactAnalyzer2() {
5720
+ return new ImpactAnalyzer2();
4290
5721
  }
4291
- function createTraceSyncService() {
4292
- return new TraceSyncService();
5722
+ function createTraceSyncService2() {
5723
+ return new TraceSyncService2();
4293
5724
  }
4294
- var ImpactAnalyzer, TraceSyncService;
5725
+ var ImpactAnalyzer2;
5726
+ var TraceSyncService2;
4295
5727
  var init_impact_analyzer = __esm({
4296
5728
  "../core/dist/traceability/impact-analyzer.js"() {
4297
5729
  "use strict";
4298
- ImpactAnalyzer = class {
5730
+ ImpactAnalyzer2 = class {
4299
5731
  analyze(changedId, links) {
4300
5732
  const affected = /* @__PURE__ */ new Set();
4301
5733
  const queue = [changedId];
@@ -4338,7 +5770,7 @@ var init_impact_analyzer = __esm({
4338
5770
  return "critical";
4339
5771
  }
4340
5772
  };
4341
- TraceSyncService = class {
5773
+ TraceSyncService2 = class {
4342
5774
  checkSync(currentLinks, expectedSources, expectedTargets) {
4343
5775
  const linkedSources = new Set(currentLinks.map((l) => l.source));
4344
5776
  const linkedTargets = new Set(currentLinks.map((l) => l.target));
@@ -4369,12 +5801,13 @@ var init_impact_analyzer = __esm({
4369
5801
  };
4370
5802
  }
4371
5803
  });
4372
-
4373
- // ../core/dist/domain/index.js
4374
- function createDomainDetector() {
4375
- return new DomainDetector();
5804
+ function createDomainDetector2() {
5805
+ return new DomainDetector2();
4376
5806
  }
4377
- var DOMAIN_KEYWORDS, FILE_EXTENSION_SIGNALS, FILENAME_SIGNALS, DomainDetector;
5807
+ var DOMAIN_KEYWORDS;
5808
+ var FILE_EXTENSION_SIGNALS;
5809
+ var FILENAME_SIGNALS;
5810
+ var DomainDetector2;
4378
5811
  var init_domain = __esm({
4379
5812
  "../core/dist/domain/index.js"() {
4380
5813
  "use strict";
@@ -4485,7 +5918,7 @@ var init_domain = __esm({
4485
5918
  terraform: ["devops", "cloud"],
4486
5919
  ".github": ["devops"]
4487
5920
  };
4488
- DomainDetector = class {
5921
+ DomainDetector2 = class {
4489
5922
  detect(projectFiles, packageJson) {
4490
5923
  const scores = /* @__PURE__ */ new Map();
4491
5924
  const addScore = (domain, score, evidence) => {
@@ -4561,19 +5994,18 @@ var init_domain = __esm({
4561
5994
  };
4562
5995
  }
4563
5996
  });
4564
-
4565
- // ../core/dist/performance/index.js
4566
- function createLazyLoader() {
4567
- return new LazyLoader();
5997
+ function createLazyLoader2() {
5998
+ return new LazyLoader2();
4568
5999
  }
4569
- function createMemoryMonitor() {
4570
- return new MemoryMonitor();
6000
+ function createMemoryMonitor2() {
6001
+ return new MemoryMonitor2();
4571
6002
  }
4572
- var LazyLoader, MemoryMonitor;
6003
+ var LazyLoader2;
6004
+ var MemoryMonitor2;
4573
6005
  var init_performance = __esm({
4574
6006
  "../core/dist/performance/index.js"() {
4575
6007
  "use strict";
4576
- LazyLoader = class {
6008
+ LazyLoader2 = class {
4577
6009
  modules = /* @__PURE__ */ new Map();
4578
6010
  register(key, loader) {
4579
6011
  this.modules.set(key, { loader, loaded: false });
@@ -4609,7 +6041,7 @@ var init_performance = __esm({
4609
6041
  return { registered: keys.length, loaded, keys };
4610
6042
  }
4611
6043
  };
4612
- MemoryMonitor = class {
6044
+ MemoryMonitor2 = class {
4613
6045
  getUsage() {
4614
6046
  const mem = process.memoryUsage();
4615
6047
  return {
@@ -4640,24 +6072,24 @@ var init_performance = __esm({
4640
6072
  };
4641
6073
  }
4642
6074
  });
4643
-
4644
- // ../core/dist/monitoring/file-watcher.js
4645
- function createFileWatcher() {
4646
- return new FileWatcher();
6075
+ function createFileWatcher2() {
6076
+ return new FileWatcher2();
4647
6077
  }
4648
- function createTaskScheduler() {
4649
- return new TaskScheduler();
6078
+ function createTaskScheduler2() {
6079
+ return new TaskScheduler2();
4650
6080
  }
4651
- var DEFAULT_WATCHER_CONFIG, FileWatcher, TaskScheduler;
6081
+ var DEFAULT_WATCHER_CONFIG2;
6082
+ var FileWatcher2;
6083
+ var TaskScheduler2;
4652
6084
  var init_file_watcher = __esm({
4653
6085
  "../core/dist/monitoring/file-watcher.js"() {
4654
6086
  "use strict";
4655
- DEFAULT_WATCHER_CONFIG = {
6087
+ DEFAULT_WATCHER_CONFIG2 = {
4656
6088
  patterns: ["**/*.ts"],
4657
6089
  ignorePatterns: ["node_modules", "dist", ".git"],
4658
6090
  debounceMs: 300
4659
6091
  };
4660
- FileWatcher = class {
6092
+ FileWatcher2 = class {
4661
6093
  handlers = /* @__PURE__ */ new Map();
4662
6094
  on(eventType, handler) {
4663
6095
  const existing = this.handlers.get(eventType) ?? [];
@@ -4711,7 +6143,7 @@ var init_file_watcher = __esm({
4711
6143
  return path === pattern;
4712
6144
  }
4713
6145
  };
4714
- TaskScheduler = class {
6146
+ TaskScheduler2 = class {
4715
6147
  tasks = /* @__PURE__ */ new Map();
4716
6148
  register(task) {
4717
6149
  this.tasks.set(task.id, task);
@@ -4735,12 +6167,11 @@ var init_file_watcher = __esm({
4735
6167
  };
4736
6168
  }
4737
6169
  });
4738
-
4739
- // ../core/dist/monitoring/quality-reporter.js
4740
- function createQualityGateReporter() {
4741
- return new QualityGateReporter();
6170
+ function createQualityGateReporter2() {
6171
+ return new QualityGateReporter2();
4742
6172
  }
4743
- var STATUS_EMOJI, QualityGateReporter;
6173
+ var STATUS_EMOJI;
6174
+ var QualityGateReporter2;
4744
6175
  var init_quality_reporter = __esm({
4745
6176
  "../core/dist/monitoring/quality-reporter.js"() {
4746
6177
  "use strict";
@@ -4750,7 +6181,7 @@ var init_quality_reporter = __esm({
4750
6181
  skipped: "\u23ED\uFE0F",
4751
6182
  warning: "\u26A0\uFE0F"
4752
6183
  };
4753
- QualityGateReporter = class {
6184
+ QualityGateReporter2 = class {
4754
6185
  entries = [];
4755
6186
  addEntry(entry) {
4756
6187
  this.entries.push(entry);
@@ -4822,16 +6253,14 @@ var init_quality_reporter = __esm({
4822
6253
  };
4823
6254
  }
4824
6255
  });
4825
-
4826
- // ../core/dist/learning/realtime-engine.js
4827
- function createRealtimeLearningEngine(maxBufferSize) {
4828
- return new RealtimeLearningEngine(maxBufferSize);
6256
+ function createRealtimeLearningEngine2(maxBufferSize) {
6257
+ return new RealtimeLearningEngine2(maxBufferSize);
4829
6258
  }
4830
- var RealtimeLearningEngine;
6259
+ var RealtimeLearningEngine2;
4831
6260
  var init_realtime_engine = __esm({
4832
6261
  "../core/dist/learning/realtime-engine.js"() {
4833
6262
  "use strict";
4834
- RealtimeLearningEngine = class {
6263
+ RealtimeLearningEngine2 = class {
4835
6264
  buffer = [];
4836
6265
  maxBufferSize;
4837
6266
  allPatterns = [];
@@ -4906,13 +6335,11 @@ var init_realtime_engine = __esm({
4906
6335
  };
4907
6336
  }
4908
6337
  });
4909
-
4910
- // ../core/dist/fixtures/virtual-projects.js
4911
- var VIRTUAL_PROJECTS;
6338
+ var VIRTUAL_PROJECTS2;
4912
6339
  var init_virtual_projects = __esm({
4913
6340
  "../core/dist/fixtures/virtual-projects.js"() {
4914
6341
  "use strict";
4915
- VIRTUAL_PROJECTS = [
6342
+ VIRTUAL_PROJECTS2 = [
4916
6343
  // 1. pet-clinic
4917
6344
  {
4918
6345
  id: "pet-clinic",
@@ -5308,118 +6735,116 @@ var init_virtual_projects = __esm({
5308
6735
  ];
5309
6736
  }
5310
6737
  });
5311
-
5312
- // ../core/dist/index.js
5313
6738
  var dist_exports = {};
5314
6739
  __export(dist_exports, {
5315
- AcceptanceCriteriaGenerator: () => AcceptanceCriteriaGenerator,
5316
- ActionableError: () => ActionableError,
5317
- AuditLogger: () => AuditLogger,
5318
- C4ModelGenerator: () => C4ModelGenerator,
5319
- CircuitBreaker: () => CircuitBreaker,
5320
- CodeGenerator: () => CodeGenerator,
5321
- CommonErrors: () => CommonErrors,
5322
- ConfigLoader: () => ConfigLoader,
5323
- ConsoleTransport: () => ConsoleTransport,
5324
- CoverageReporter: () => CoverageReporter,
5325
- DEFAULT_CONFIG: () => DEFAULT_CONFIG,
5326
- DEFAULT_WATCHER_CONFIG: () => DEFAULT_WATCHER_CONFIG,
5327
- DefaultReplFormatter: () => DefaultReplFormatter,
5328
- DesignGenerator: () => DesignGenerator,
5329
- DomainDetector: () => DomainDetector,
5330
- EARSValidator: () => EARSValidator,
5331
- ErrorCodes: () => ErrorCodes,
5332
- ErrorFormatter: () => ErrorFormatter,
5333
- ExitCode: () => ExitCode,
5334
- ExplanationGenerator: () => ExplanationGenerator,
5335
- FileWatcher: () => FileWatcher,
5336
- GracefulDegradation: () => GracefulDegradation,
5337
- HallucinationDetector: () => HallucinationDetector,
5338
- ImpactAnalyzer: () => ImpactAnalyzer,
5339
- InMemoryPaginatedRepository: () => InMemoryPaginatedRepository,
5340
- InMemoryRepository: () => InMemoryRepository,
5341
- InMemorySearchableRepository: () => InMemorySearchableRepository,
5342
- LazyLoader: () => LazyLoader,
5343
- LearningEngine: () => LearningEngine,
5344
- Logger: () => Logger,
5345
- MarkdownEARSParser: () => MarkdownEARSParser,
5346
- MatrixGenerator: () => MatrixGenerator,
5347
- MemoryCacheProvider: () => MemoryCacheProvider,
5348
- MemoryMonitor: () => MemoryMonitor,
5349
- MemoryQueueProvider: () => MemoryQueueProvider,
5350
- MemoryTransport: () => MemoryTransport,
5351
- PatternDetector: () => PatternDetector,
5352
- PatternExtractor: () => PatternExtractor,
5353
- ProjectInitializer: () => ProjectInitializer,
5354
- QualityGateReporter: () => QualityGateReporter,
5355
- QualityMetricsCalculator: () => QualityMetricsCalculator,
5356
- RealtimeLearningEngine: () => RealtimeLearningEngine,
5357
- ReasoningChainRecorder: () => ReasoningChainRecorder,
5358
- RejectionGate: () => RejectionGate,
5359
- ReplEngine: () => ReplEngine,
5360
- RequirementWizard: () => RequirementWizard,
5361
- RequirementsDocGenerator: () => RequirementsDocGenerator,
5362
- RequirementsInterviewer: () => RequirementsInterviewer,
5363
- RequirementsValidator: () => RequirementsValidator,
5364
- SOLIDValidator: () => SOLIDValidator,
5365
- ScaffoldGenerator: () => ScaffoldGenerator,
5366
- SemanticCodeFilterPipeline: () => SemanticCodeFilterPipeline,
5367
- StaticAnalyzer: () => StaticAnalyzer,
5368
- StatusTransitionGenerator: () => StatusTransitionGenerator,
5369
- TaskScheduler: () => TaskScheduler,
5370
- TraceSyncService: () => TraceSyncService,
5371
- TraceabilityManager: () => TraceabilityManager,
5372
- TraceabilityValidator: () => TraceabilityValidator,
5373
- UnitTestGenerator: () => UnitTestGenerator,
6740
+ AcceptanceCriteriaGenerator: () => AcceptanceCriteriaGenerator2,
6741
+ ActionableError: () => ActionableError2,
6742
+ AuditLogger: () => AuditLogger2,
6743
+ C4ModelGenerator: () => C4ModelGenerator2,
6744
+ CircuitBreaker: () => CircuitBreaker2,
6745
+ CodeGenerator: () => CodeGenerator2,
6746
+ CommonErrors: () => CommonErrors2,
6747
+ ConfigLoader: () => ConfigLoader2,
6748
+ ConsoleTransport: () => ConsoleTransport2,
6749
+ CoverageReporter: () => CoverageReporter2,
6750
+ DEFAULT_CONFIG: () => DEFAULT_CONFIG2,
6751
+ DEFAULT_WATCHER_CONFIG: () => DEFAULT_WATCHER_CONFIG2,
6752
+ DefaultReplFormatter: () => DefaultReplFormatter2,
6753
+ DesignGenerator: () => DesignGenerator2,
6754
+ DomainDetector: () => DomainDetector2,
6755
+ EARSValidator: () => EARSValidator2,
6756
+ ErrorCodes: () => ErrorCodes2,
6757
+ ErrorFormatter: () => ErrorFormatter2,
6758
+ ExitCode: () => ExitCode2,
6759
+ ExplanationGenerator: () => ExplanationGenerator2,
6760
+ FileWatcher: () => FileWatcher2,
6761
+ GracefulDegradation: () => GracefulDegradation2,
6762
+ HallucinationDetector: () => HallucinationDetector2,
6763
+ ImpactAnalyzer: () => ImpactAnalyzer2,
6764
+ InMemoryPaginatedRepository: () => InMemoryPaginatedRepository2,
6765
+ InMemoryRepository: () => InMemoryRepository2,
6766
+ InMemorySearchableRepository: () => InMemorySearchableRepository2,
6767
+ LazyLoader: () => LazyLoader2,
6768
+ LearningEngine: () => LearningEngine2,
6769
+ Logger: () => Logger2,
6770
+ MarkdownEARSParser: () => MarkdownEARSParser2,
6771
+ MatrixGenerator: () => MatrixGenerator2,
6772
+ MemoryCacheProvider: () => MemoryCacheProvider2,
6773
+ MemoryMonitor: () => MemoryMonitor2,
6774
+ MemoryQueueProvider: () => MemoryQueueProvider2,
6775
+ MemoryTransport: () => MemoryTransport2,
6776
+ PatternDetector: () => PatternDetector2,
6777
+ PatternExtractor: () => PatternExtractor2,
6778
+ ProjectInitializer: () => ProjectInitializer2,
6779
+ QualityGateReporter: () => QualityGateReporter2,
6780
+ QualityMetricsCalculator: () => QualityMetricsCalculator2,
6781
+ RealtimeLearningEngine: () => RealtimeLearningEngine2,
6782
+ ReasoningChainRecorder: () => ReasoningChainRecorder2,
6783
+ RejectionGate: () => RejectionGate2,
6784
+ ReplEngine: () => ReplEngine2,
6785
+ RequirementWizard: () => RequirementWizard2,
6786
+ RequirementsDocGenerator: () => RequirementsDocGenerator2,
6787
+ RequirementsInterviewer: () => RequirementsInterviewer2,
6788
+ RequirementsValidator: () => RequirementsValidator2,
6789
+ SOLIDValidator: () => SOLIDValidator2,
6790
+ ScaffoldGenerator: () => ScaffoldGenerator2,
6791
+ SemanticCodeFilterPipeline: () => SemanticCodeFilterPipeline2,
6792
+ StaticAnalyzer: () => StaticAnalyzer2,
6793
+ StatusTransitionGenerator: () => StatusTransitionGenerator2,
6794
+ TaskScheduler: () => TaskScheduler2,
6795
+ TraceSyncService: () => TraceSyncService2,
6796
+ TraceabilityManager: () => TraceabilityManager2,
6797
+ TraceabilityValidator: () => TraceabilityValidator2,
6798
+ UnitTestGenerator: () => UnitTestGenerator2,
5374
6799
  VERSION: () => VERSION,
5375
- VIRTUAL_PROJECTS: () => VIRTUAL_PROJECTS,
5376
- convertToEARS: () => convertToEARS,
5377
- createAcceptanceCriteriaGenerator: () => createAcceptanceCriteriaGenerator,
5378
- createC4ModelGenerator: () => createC4ModelGenerator,
5379
- createCodeGenerator: () => createCodeGenerator,
5380
- createCoverageReporter: () => createCoverageReporter,
5381
- createDesignGenerator: () => createDesignGenerator,
5382
- createDomainDetector: () => createDomainDetector,
5383
- createEARSValidator: () => createEARSValidator,
5384
- createFileWatcher: () => createFileWatcher,
5385
- createGracefulDegradation: () => createGracefulDegradation,
5386
- createHallucinationDetector: () => createHallucinationDetector,
5387
- createImpactAnalyzer: () => createImpactAnalyzer,
5388
- createInMemoryPaginatedRepository: () => createInMemoryPaginatedRepository,
5389
- createInMemoryRepository: () => createInMemoryRepository,
5390
- createInMemorySearchableRepository: () => createInMemorySearchableRepository,
5391
- createLazyLoader: () => createLazyLoader,
5392
- createLearningEngine: () => createLearningEngine,
5393
- createMarkdownEARSParser: () => createMarkdownEARSParser,
5394
- createMatrixGenerator: () => createMatrixGenerator,
5395
- createMemoryMonitor: () => createMemoryMonitor,
5396
- createPatternDetector: () => createPatternDetector,
5397
- createPatternExtractor: () => createPatternExtractor,
5398
- createProjectInitializer: () => createProjectInitializer,
5399
- createQualityGateReporter: () => createQualityGateReporter,
5400
- createQualityMetricsCalculator: () => createQualityMetricsCalculator,
5401
- createRealtimeLearningEngine: () => createRealtimeLearningEngine,
5402
- createRejectionGate: () => createRejectionGate,
5403
- createRequirementWizard: () => createRequirementWizard,
5404
- createRequirementsDocGenerator: () => createRequirementsDocGenerator,
5405
- createRequirementsInterviewer: () => createRequirementsInterviewer,
5406
- createRequirementsValidator: () => createRequirementsValidator,
5407
- createSOLIDValidator: () => createSOLIDValidator,
5408
- createScaffoldGenerator: () => createScaffoldGenerator,
5409
- createSemanticCodeFilterPipeline: () => createSemanticCodeFilterPipeline,
5410
- createStaticAnalyzer: () => createStaticAnalyzer,
5411
- createStatusTransitionGenerator: () => createStatusTransitionGenerator,
5412
- createTaskScheduler: () => createTaskScheduler,
5413
- createTraceSyncService: () => createTraceSyncService,
5414
- createTraceabilityManager: () => createTraceabilityManager,
5415
- createTraceabilityValidator: () => createTraceabilityValidator,
5416
- createUnitTestGenerator: () => createUnitTestGenerator,
5417
- formatError: () => formatError,
5418
- formatInfo: () => formatInfo,
5419
- formatSuccess: () => formatSuccess,
5420
- formatTable: () => formatTable,
5421
- formatWarning: () => formatWarning,
5422
- retryWithBackoff: () => retryWithBackoff
6800
+ VIRTUAL_PROJECTS: () => VIRTUAL_PROJECTS2,
6801
+ convertToEARS: () => convertToEARS2,
6802
+ createAcceptanceCriteriaGenerator: () => createAcceptanceCriteriaGenerator2,
6803
+ createC4ModelGenerator: () => createC4ModelGenerator2,
6804
+ createCodeGenerator: () => createCodeGenerator2,
6805
+ createCoverageReporter: () => createCoverageReporter2,
6806
+ createDesignGenerator: () => createDesignGenerator2,
6807
+ createDomainDetector: () => createDomainDetector2,
6808
+ createEARSValidator: () => createEARSValidator2,
6809
+ createFileWatcher: () => createFileWatcher2,
6810
+ createGracefulDegradation: () => createGracefulDegradation2,
6811
+ createHallucinationDetector: () => createHallucinationDetector2,
6812
+ createImpactAnalyzer: () => createImpactAnalyzer2,
6813
+ createInMemoryPaginatedRepository: () => createInMemoryPaginatedRepository2,
6814
+ createInMemoryRepository: () => createInMemoryRepository2,
6815
+ createInMemorySearchableRepository: () => createInMemorySearchableRepository2,
6816
+ createLazyLoader: () => createLazyLoader2,
6817
+ createLearningEngine: () => createLearningEngine2,
6818
+ createMarkdownEARSParser: () => createMarkdownEARSParser2,
6819
+ createMatrixGenerator: () => createMatrixGenerator2,
6820
+ createMemoryMonitor: () => createMemoryMonitor2,
6821
+ createPatternDetector: () => createPatternDetector2,
6822
+ createPatternExtractor: () => createPatternExtractor2,
6823
+ createProjectInitializer: () => createProjectInitializer2,
6824
+ createQualityGateReporter: () => createQualityGateReporter2,
6825
+ createQualityMetricsCalculator: () => createQualityMetricsCalculator2,
6826
+ createRealtimeLearningEngine: () => createRealtimeLearningEngine2,
6827
+ createRejectionGate: () => createRejectionGate2,
6828
+ createRequirementWizard: () => createRequirementWizard2,
6829
+ createRequirementsDocGenerator: () => createRequirementsDocGenerator2,
6830
+ createRequirementsInterviewer: () => createRequirementsInterviewer2,
6831
+ createRequirementsValidator: () => createRequirementsValidator2,
6832
+ createSOLIDValidator: () => createSOLIDValidator2,
6833
+ createScaffoldGenerator: () => createScaffoldGenerator2,
6834
+ createSemanticCodeFilterPipeline: () => createSemanticCodeFilterPipeline2,
6835
+ createStaticAnalyzer: () => createStaticAnalyzer2,
6836
+ createStatusTransitionGenerator: () => createStatusTransitionGenerator2,
6837
+ createTaskScheduler: () => createTaskScheduler2,
6838
+ createTraceSyncService: () => createTraceSyncService2,
6839
+ createTraceabilityManager: () => createTraceabilityManager2,
6840
+ createTraceabilityValidator: () => createTraceabilityValidator2,
6841
+ createUnitTestGenerator: () => createUnitTestGenerator2,
6842
+ formatError: () => formatError2,
6843
+ formatInfo: () => formatInfo2,
6844
+ formatSuccess: () => formatSuccess2,
6845
+ formatTable: () => formatTable2,
6846
+ formatWarning: () => formatWarning2,
6847
+ retryWithBackoff: () => retryWithBackoff2
5423
6848
  });
5424
6849
  var VERSION;
5425
6850
  var init_dist = __esm({
@@ -5459,8 +6884,6 @@ var init_dist = __esm({
5459
6884
  VERSION = "0.1.0";
5460
6885
  }
5461
6886
  });
5462
-
5463
- // ../skill-manager/dist/executor.js
5464
6887
  function createSkillExecutor(registry) {
5465
6888
  return new SkillExecutor(registry);
5466
6889
  }
@@ -5527,8 +6950,6 @@ var init_executor = __esm({
5527
6950
  };
5528
6951
  }
5529
6952
  });
5530
-
5531
- // ../skill-manager/dist/index.js
5532
6953
  var dist_exports2 = {};
5533
6954
  __export(dist_exports2, {
5534
6955
  SkillExecutor: () => SkillExecutor,
@@ -5538,7 +6959,6 @@ __export(dist_exports2, {
5538
6959
  createSkillManager: () => createSkillManager,
5539
6960
  createSkillRegistry: () => createSkillRegistry
5540
6961
  });
5541
- import { randomUUID } from "node:crypto";
5542
6962
  function createSkillRegistry() {
5543
6963
  return new SkillRegistry();
5544
6964
  }
@@ -5546,7 +6966,8 @@ function createSkillManager() {
5546
6966
  const registry = createSkillRegistry();
5547
6967
  return new SkillManager(registry);
5548
6968
  }
5549
- var SkillRegistry, SkillManager;
6969
+ var SkillRegistry;
6970
+ var SkillManager;
5550
6971
  var init_dist2 = __esm({
5551
6972
  "../skill-manager/dist/index.js"() {
5552
6973
  "use strict";
@@ -5640,15 +7061,11 @@ var init_dist2 = __esm({
5640
7061
  };
5641
7062
  }
5642
7063
  });
5643
-
5644
- // ../knowledge/dist/index.js
5645
7064
  var dist_exports3 = {};
5646
7065
  __export(dist_exports3, {
5647
7066
  FileKnowledgeStore: () => FileKnowledgeStore,
5648
7067
  createKnowledgeStore: () => createKnowledgeStore
5649
7068
  });
5650
- import { readFile as readFile2, writeFile, mkdir } from "node:fs/promises";
5651
- import { join as join2, dirname } from "node:path";
5652
7069
  function createEmptyGraph() {
5653
7070
  return {
5654
7071
  version: "1.0.0",
@@ -5668,12 +7085,12 @@ var init_dist3 = __esm({
5668
7085
  graph;
5669
7086
  filePath;
5670
7087
  constructor(basePath) {
5671
- this.filePath = join2(basePath, "knowledge-graph.json");
7088
+ this.filePath = join22(basePath, "knowledge-graph.json");
5672
7089
  this.graph = createEmptyGraph();
5673
7090
  }
5674
7091
  async load() {
5675
7092
  try {
5676
- const raw = await readFile2(this.filePath, "utf-8");
7093
+ const raw = await readFile22(this.filePath, "utf-8");
5677
7094
  this.graph = JSON.parse(raw);
5678
7095
  } catch {
5679
7096
  this.graph = createEmptyGraph();
@@ -5864,20 +7281,17 @@ var init_dist3 = __esm({
5864
7281
  };
5865
7282
  }
5866
7283
  });
5867
-
5868
- // ../decisions/dist/index.js
5869
7284
  var dist_exports4 = {};
5870
7285
  __export(dist_exports4, {
5871
7286
  ADR_TEMPLATE: () => ADR_TEMPLATE,
5872
7287
  DecisionManager: () => DecisionManager,
5873
7288
  createDecisionManager: () => createDecisionManager
5874
7289
  });
5875
- import { writeFile as writeFile2, mkdir as mkdir2 } from "node:fs/promises";
5876
- import { join as join3 } from "node:path";
5877
7290
  function createDecisionManager(basePath) {
5878
7291
  return new DecisionManager(basePath);
5879
7292
  }
5880
- var ADR_TEMPLATE, DecisionManager;
7293
+ var ADR_TEMPLATE;
7294
+ var DecisionManager;
5881
7295
  var init_dist4 = __esm({
5882
7296
  "../decisions/dist/index.js"() {
5883
7297
  "use strict";
@@ -5995,8 +7409,6 @@ var init_dist4 = __esm({
5995
7409
  };
5996
7410
  }
5997
7411
  });
5998
-
5999
- // ../deep-research/dist/index.js
6000
7412
  var dist_exports5 = {};
6001
7413
  __export(dist_exports5, {
6002
7414
  BreadthFirstStrategy: () => BreadthFirstStrategy,
@@ -6059,7 +7471,12 @@ function createResearchEngine() {
6059
7471
  const securityFilter = createSecurityFilter();
6060
7472
  return new ResearchEngine(accumulator, securityFilter);
6061
7473
  }
6062
- var DEFAULT_SECURITY_FILTER_CONFIG, DepthFirstStrategy, BreadthFirstStrategy, SecurityFilter, KnowledgeAccumulator, ResearchEngine;
7474
+ var DEFAULT_SECURITY_FILTER_CONFIG;
7475
+ var DepthFirstStrategy;
7476
+ var BreadthFirstStrategy;
7477
+ var SecurityFilter;
7478
+ var KnowledgeAccumulator;
7479
+ var ResearchEngine;
6063
7480
  var init_dist5 = __esm({
6064
7481
  "../deep-research/dist/index.js"() {
6065
7482
  "use strict";
@@ -6495,8 +7912,6 @@ var init_dist5 = __esm({
6495
7912
  };
6496
7913
  }
6497
7914
  });
6498
-
6499
- // ../library-learner/dist/index.js
6500
7915
  var dist_exports6 = {};
6501
7916
  __export(dist_exports6, {
6502
7917
  EGraphEngine: () => EGraphEngine,
@@ -6554,7 +7969,11 @@ function createEGraphEngine() {
6554
7969
  function createLibraryLearner() {
6555
7970
  return new LibraryLearner();
6556
7971
  }
6557
- var EGraphEngine, FUNCTION_SIG_RE, ARROW_FN_RE, METHOD_RE, LibraryLearner;
7972
+ var EGraphEngine;
7973
+ var FUNCTION_SIG_RE;
7974
+ var ARROW_FN_RE;
7975
+ var METHOD_RE;
7976
+ var LibraryLearner;
6558
7977
  var init_dist6 = __esm({
6559
7978
  "../library-learner/dist/index.js"() {
6560
7979
  "use strict";
@@ -6719,8 +8138,6 @@ var init_dist6 = __esm({
6719
8138
  };
6720
8139
  }
6721
8140
  });
6722
-
6723
- // ../synthesis/dist/index.js
6724
8141
  var dist_exports7 = {};
6725
8142
  __export(dist_exports7, {
6726
8143
  DSLBuilder: () => DSLBuilder,
@@ -6739,7 +8156,12 @@ function createVersionSpaceManager() {
6739
8156
  function createSynthesisEngine() {
6740
8157
  return new SynthesisEngine();
6741
8158
  }
6742
- var KEYWORDS, OPERATORS, DELIMITERS, DSLBuilder, VersionSpaceManager, SynthesisEngine;
8159
+ var KEYWORDS;
8160
+ var OPERATORS;
8161
+ var DELIMITERS;
8162
+ var DSLBuilder;
8163
+ var VersionSpaceManager;
8164
+ var SynthesisEngine;
6743
8165
  var init_dist7 = __esm({
6744
8166
  "../synthesis/dist/index.js"() {
6745
8167
  "use strict";
@@ -7571,16 +8993,8 @@ var init_dist7 = __esm({
7571
8993
  };
7572
8994
  }
7573
8995
  });
7574
-
7575
- // dist/index.js
7576
- init_dist();
7577
- init_dist();
7578
-
7579
- // dist/cli.js
7580
8996
  init_dist();
7581
8997
  init_dist();
7582
-
7583
- // ../policy/dist/index.js
7584
8998
  var CONSTITUTION_ARTICLES = [
7585
8999
  {
7586
9000
  article: 1,
@@ -7720,8 +9134,6 @@ var PolicyEngine = class {
7720
9134
  }
7721
9135
  }
7722
9136
  };
7723
-
7724
- // ../ontology-mcp/dist/index.js
7725
9137
  var N3Store = class {
7726
9138
  triples = [];
7727
9139
  addTriple(triple) {
@@ -7858,11 +9270,6 @@ function createOntologyStore() {
7858
9270
  function createConsistencyValidator() {
7859
9271
  return new ConsistencyValidator();
7860
9272
  }
7861
-
7862
- // ../codegraph/dist/index.js
7863
- import ts from "typescript";
7864
-
7865
- // ../codegraph/dist/multi-lang-parser.js
7866
9273
  var BraceBlockTracker = class {
7867
9274
  depth = 0;
7868
9275
  blockStack = [];
@@ -9228,8 +10635,6 @@ var MultiLanguageParser = class {
9228
10635
  return { language, nodes, imports, exports: [], errors: [] };
9229
10636
  }
9230
10637
  };
9231
-
9232
- // ../codegraph/dist/index.js
9233
10638
  var ALL_LANGUAGES = [
9234
10639
  "typescript",
9235
10640
  "javascript",
@@ -9663,8 +11068,6 @@ function createASTParser(options) {
9663
11068
  function createGraphEngine() {
9664
11069
  return new GraphEngine();
9665
11070
  }
9666
-
9667
- // ../security/dist/index.js
9668
11071
  function getLineNumber(code, index) {
9669
11072
  return code.substring(0, index).split("\n").length;
9670
11073
  }
@@ -9855,8 +11258,6 @@ var DependencyScanner = class {
9855
11258
  function createSecretDetector() {
9856
11259
  return new SecretDetector();
9857
11260
  }
9858
-
9859
- // ../workflow-engine/dist/task-breakdown.js
9860
11261
  var TaskBreakdownManager = class {
9861
11262
  tasks = /* @__PURE__ */ new Map();
9862
11263
  addTask(task) {
@@ -9937,8 +11338,6 @@ var TaskBreakdownManager = class {
9937
11338
  function createTaskBreakdownManager() {
9938
11339
  return new TaskBreakdownManager();
9939
11340
  }
9940
-
9941
- // ../workflow-engine/dist/index.js
9942
11341
  var PHASE_ORDER = [
9943
11342
  "requirements",
9944
11343
  "design",
@@ -10212,11 +11611,8 @@ function createDefaultGates() {
10212
11611
  }
10213
11612
  ];
10214
11613
  }
10215
-
10216
- // dist/cli.js
10217
11614
  init_dist();
10218
11615
  init_dist();
10219
- import { readFileSync, existsSync } from "node:fs";
10220
11616
  function parseArgs(argv) {
10221
11617
  const command = argv[0] ?? "";
10222
11618
  let subcommand;
@@ -10429,17 +11825,17 @@ var CLIDispatcher = class {
10429
11825
  if (argv.length === 0 || argv.includes("--help") && !argv[0]?.match(/^[a-z]/) || argv.includes("-h") && !argv[0]?.match(/^[a-z]/)) {
10430
11826
  if (argv.length === 0 || argv[0] === "--help" || argv[0] === "-h") {
10431
11827
  console.log(showHelp());
10432
- return ExitCode.SUCCESS;
11828
+ return ExitCode2.SUCCESS;
10433
11829
  }
10434
11830
  }
10435
11831
  const parsed = parseArgs(argv);
10436
11832
  if (parsed.flags["help"] === true || parsed.flags["h"] === true) {
10437
11833
  console.log(showHelp(parsed.command));
10438
- return ExitCode.SUCCESS;
11834
+ return ExitCode2.SUCCESS;
10439
11835
  }
10440
11836
  if (!parsed.command) {
10441
11837
  console.log(showHelp());
10442
- return ExitCode.SUCCESS;
11838
+ return ExitCode2.SUCCESS;
10443
11839
  }
10444
11840
  try {
10445
11841
  await this.dispatch(parsed.command, {
@@ -10447,11 +11843,11 @@ var CLIDispatcher = class {
10447
11843
  args: parsed.args,
10448
11844
  ...parsed.flags
10449
11845
  });
10450
- return ExitCode.SUCCESS;
11846
+ return ExitCode2.SUCCESS;
10451
11847
  } catch (err) {
10452
11848
  const message = err instanceof Error ? err.message : String(err);
10453
11849
  console.error(message);
10454
- return ExitCode.GENERAL_ERROR;
11850
+ return ExitCode2.GENERAL_ERROR;
10455
11851
  }
10456
11852
  }
10457
11853
  };
@@ -10486,33 +11882,33 @@ async function handleTasksValidate(filePath) {
10486
11882
  const manager = loadManagerFromFile(filePath);
10487
11883
  const breakdown = manager.getBreakdown();
10488
11884
  console.log(`\u2705 ${filePath}: ${breakdown.totalTasks} tasks parsed successfully`);
10489
- return ExitCode.SUCCESS;
11885
+ return ExitCode2.SUCCESS;
10490
11886
  } catch (err) {
10491
11887
  const msg = err instanceof Error ? err.message : String(err);
10492
11888
  console.error(`\u274C Validation failed: ${msg}`);
10493
- return ExitCode.VALIDATION_ERROR;
11889
+ return ExitCode2.VALIDATION_ERROR;
10494
11890
  }
10495
11891
  }
10496
11892
  async function handleTasksList(filePath) {
10497
11893
  try {
10498
11894
  if (!filePath) {
10499
11895
  console.error("\u274C --file <path> is required");
10500
- return ExitCode.GENERAL_ERROR;
11896
+ return ExitCode2.GENERAL_ERROR;
10501
11897
  }
10502
11898
  const manager = loadManagerFromFile(filePath);
10503
11899
  console.log(manager.toMarkdown());
10504
- return ExitCode.SUCCESS;
11900
+ return ExitCode2.SUCCESS;
10505
11901
  } catch (err) {
10506
11902
  const msg = err instanceof Error ? err.message : String(err);
10507
11903
  console.error(`\u274C ${msg}`);
10508
- return ExitCode.GENERAL_ERROR;
11904
+ return ExitCode2.GENERAL_ERROR;
10509
11905
  }
10510
11906
  }
10511
11907
  async function handleTasksStats(filePath) {
10512
11908
  try {
10513
11909
  if (!filePath) {
10514
11910
  console.error("\u274C --file <path> is required");
10515
- return ExitCode.GENERAL_ERROR;
11911
+ return ExitCode2.GENERAL_ERROR;
10516
11912
  }
10517
11913
  const manager = loadManagerFromFile(filePath);
10518
11914
  const b = manager.getBreakdown();
@@ -10522,15 +11918,15 @@ async function handleTasksStats(filePath) {
10522
11918
  `Blocked: ${b.blockedTasks}`,
10523
11919
  `Pending: ${b.totalTasks - b.completedTasks - b.blockedTasks}`
10524
11920
  ].join("\n"));
10525
- return ExitCode.SUCCESS;
11921
+ return ExitCode2.SUCCESS;
10526
11922
  } catch (err) {
10527
11923
  const msg = err instanceof Error ? err.message : String(err);
10528
11924
  console.error(`\u274C ${msg}`);
10529
- return ExitCode.GENERAL_ERROR;
11925
+ return ExitCode2.GENERAL_ERROR;
10530
11926
  }
10531
11927
  }
10532
11928
  async function handleInit(targetPath = ".", name, force) {
10533
- const initializer = createProjectInitializer();
11929
+ const initializer = createProjectInitializer2();
10534
11930
  const projectName = name ?? "my-project";
10535
11931
  const result = initializer.init({
10536
11932
  projectName,
@@ -10542,7 +11938,7 @@ async function handleInit(targetPath = ".", name, force) {
10542
11938
  for (const err of result.errors) {
10543
11939
  console.error(`\u274C ${err}`);
10544
11940
  }
10545
- return ExitCode.VALIDATION_ERROR;
11941
+ return ExitCode2.VALIDATION_ERROR;
10546
11942
  }
10547
11943
  console.log(`\u2705 Initialized project "${projectName}" at ${targetPath}`);
10548
11944
  for (const f of result.createdFiles) {
@@ -10570,28 +11966,28 @@ async function handleInit(targetPath = ".", name, force) {
10570
11966
  }
10571
11967
  } catch {
10572
11968
  }
10573
- return ExitCode.SUCCESS;
11969
+ return ExitCode2.SUCCESS;
10574
11970
  }
10575
11971
  async function handleTrace(sub, args) {
10576
11972
  switch (sub) {
10577
11973
  case "matrix": {
10578
- const generator = createMatrixGenerator();
11974
+ const generator = createMatrixGenerator2();
10579
11975
  const report = generator.generate([], [], []);
10580
11976
  console.log(generator.toMarkdown(report));
10581
- return ExitCode.SUCCESS;
11977
+ return ExitCode2.SUCCESS;
10582
11978
  }
10583
11979
  case "validate": {
10584
- const manager = createTraceabilityManager();
11980
+ const manager = createTraceabilityManager2();
10585
11981
  console.log(manager.toMarkdown());
10586
- return ExitCode.SUCCESS;
11982
+ return ExitCode2.SUCCESS;
10587
11983
  }
10588
11984
  case "impact": {
10589
11985
  const targetId = args[0];
10590
11986
  if (!targetId) {
10591
11987
  console.error("\u274C Usage: musubix trace impact <target-id>");
10592
- return ExitCode.GENERAL_ERROR;
11988
+ return ExitCode2.GENERAL_ERROR;
10593
11989
  }
10594
- const analyzer = createImpactAnalyzer();
11990
+ const analyzer = createImpactAnalyzer2();
10595
11991
  const result = analyzer.analyze(targetId, []);
10596
11992
  console.log(`Impact analysis for ${targetId}:`);
10597
11993
  console.log(` Level: ${result.level}`);
@@ -10599,15 +11995,15 @@ async function handleTrace(sub, args) {
10599
11995
  for (const id of result.affectedIds) {
10600
11996
  console.log(` - ${id}`);
10601
11997
  }
10602
- return ExitCode.SUCCESS;
11998
+ return ExitCode2.SUCCESS;
10603
11999
  }
10604
12000
  default:
10605
12001
  console.log(showHelp("trace"));
10606
- return ExitCode.SUCCESS;
12002
+ return ExitCode2.SUCCESS;
10607
12003
  }
10608
12004
  }
10609
12005
  async function handleTraceVerify() {
10610
- const validator = createTraceabilityValidator();
12006
+ const validator = createTraceabilityValidator2();
10611
12007
  const report = validator.validateCoverage([], [], [], []);
10612
12008
  console.log(`Coverage: ${report.coveragePercent}%`);
10613
12009
  console.log(`Requirements: ${report.coveredRequirements}/${report.totalRequirements}`);
@@ -10619,7 +12015,7 @@ async function handleTraceVerify() {
10619
12015
  } else {
10620
12016
  console.log("No gaps found");
10621
12017
  }
10622
- return ExitCode.SUCCESS;
12018
+ return ExitCode2.SUCCESS;
10623
12019
  }
10624
12020
  async function handlePolicy(sub, args) {
10625
12021
  switch (sub) {
@@ -10635,34 +12031,34 @@ async function handlePolicy(sub, args) {
10635
12031
  if (report.violations.length > 0) {
10636
12032
  console.log(`Violations: ${report.violations.length}`);
10637
12033
  }
10638
- return ExitCode.SUCCESS;
12034
+ return ExitCode2.SUCCESS;
10639
12035
  }
10640
12036
  case "list": {
10641
12037
  console.log("Constitution Articles:");
10642
12038
  for (const art of CONSTITUTION_ARTICLES) {
10643
12039
  console.log(` Article ${art.article}: ${art.name} \u2014 ${art.description}`);
10644
12040
  }
10645
- return ExitCode.SUCCESS;
12041
+ return ExitCode2.SUCCESS;
10646
12042
  }
10647
12043
  case "info": {
10648
12044
  const articleNum = parseInt(args[0], 10);
10649
12045
  if (isNaN(articleNum)) {
10650
12046
  console.error("\u274C Usage: musubix policy info <article-number>");
10651
- return ExitCode.GENERAL_ERROR;
12047
+ return ExitCode2.GENERAL_ERROR;
10652
12048
  }
10653
12049
  const article = CONSTITUTION_ARTICLES.find((a) => a.article === articleNum);
10654
12050
  if (!article) {
10655
12051
  console.error(`\u274C Unknown article: ${articleNum}`);
10656
- return ExitCode.GENERAL_ERROR;
12052
+ return ExitCode2.GENERAL_ERROR;
10657
12053
  }
10658
12054
  console.log(`Article ${article.article}: ${article.name}`);
10659
12055
  console.log(` Policy ID: ${article.policyId}`);
10660
12056
  console.log(` ${article.description}`);
10661
- return ExitCode.SUCCESS;
12057
+ return ExitCode2.SUCCESS;
10662
12058
  }
10663
12059
  default:
10664
12060
  console.log(showHelp("policy"));
10665
- return ExitCode.SUCCESS;
12061
+ return ExitCode2.SUCCESS;
10666
12062
  }
10667
12063
  }
10668
12064
  async function handleOntology(sub) {
@@ -10678,16 +12074,16 @@ async function handleOntology(sub) {
10678
12074
  console.log(` - ${JSON.stringify(v)}`);
10679
12075
  }
10680
12076
  }
10681
- return ExitCode.SUCCESS;
12077
+ return ExitCode2.SUCCESS;
10682
12078
  }
10683
12079
  case "stats": {
10684
12080
  const store = createOntologyStore();
10685
12081
  console.log(`Triples: ${store.size()}`);
10686
- return ExitCode.SUCCESS;
12082
+ return ExitCode2.SUCCESS;
10687
12083
  }
10688
12084
  default:
10689
12085
  console.log(showHelp("ontology"));
10690
- return ExitCode.SUCCESS;
12086
+ return ExitCode2.SUCCESS;
10691
12087
  }
10692
12088
  }
10693
12089
  var EXT_TO_LANG = {
@@ -10714,7 +12110,7 @@ async function handleCodegraph(sub, args) {
10714
12110
  const targetPath = args[0];
10715
12111
  if (!targetPath) {
10716
12112
  console.error("\u274C Usage: musubix cg index <path>");
10717
- return ExitCode.GENERAL_ERROR;
12113
+ return ExitCode2.GENERAL_ERROR;
10718
12114
  }
10719
12115
  try {
10720
12116
  const parser = createASTParser();
@@ -10723,7 +12119,7 @@ async function handleCodegraph(sub, args) {
10723
12119
  const lang = EXT_TO_LANG[ext];
10724
12120
  if (!lang) {
10725
12121
  console.error(`\u274C Unsupported file extension: .${ext}`);
10726
- return ExitCode.GENERAL_ERROR;
12122
+ return ExitCode2.GENERAL_ERROR;
10727
12123
  }
10728
12124
  const nodes = parser.parse(content, lang);
10729
12125
  const engine = createGraphEngine();
@@ -10743,21 +12139,21 @@ async function handleCodegraph(sub, args) {
10743
12139
  } catch (err) {
10744
12140
  const msg = err instanceof Error ? err.message : String(err);
10745
12141
  console.error(`\u274C ${msg}`);
10746
- return ExitCode.GENERAL_ERROR;
12142
+ return ExitCode2.GENERAL_ERROR;
10747
12143
  }
10748
- return ExitCode.SUCCESS;
12144
+ return ExitCode2.SUCCESS;
10749
12145
  }
10750
12146
  case "search": {
10751
12147
  const query = args[0];
10752
12148
  if (!query) {
10753
12149
  console.error("\u274C Usage: musubix cg search <query>");
10754
- return ExitCode.GENERAL_ERROR;
12150
+ return ExitCode2.GENERAL_ERROR;
10755
12151
  }
10756
12152
  const engine = createGraphEngine();
10757
12153
  const search = new GraphRAGSearch(engine);
10758
12154
  const results = search.globalSearch(query);
10759
12155
  console.log(`Results for "${query}": ${results.length} found`);
10760
- return ExitCode.SUCCESS;
12156
+ return ExitCode2.SUCCESS;
10761
12157
  }
10762
12158
  case "stats": {
10763
12159
  const engine = createGraphEngine();
@@ -10765,7 +12161,7 @@ async function handleCodegraph(sub, args) {
10765
12161
  console.log(`Nodes: ${stats.nodeCount}`);
10766
12162
  console.log(`Edges: ${stats.edgeCount}`);
10767
12163
  console.log(`Languages: ${[...stats.languages].join(", ") || "none"}`);
10768
- return ExitCode.SUCCESS;
12164
+ return ExitCode2.SUCCESS;
10769
12165
  }
10770
12166
  case "languages": {
10771
12167
  const parser = createASTParser();
@@ -10774,18 +12170,18 @@ async function handleCodegraph(sub, args) {
10774
12170
  for (const lang of langs) {
10775
12171
  console.log(` - ${lang}`);
10776
12172
  }
10777
- return ExitCode.SUCCESS;
12173
+ return ExitCode2.SUCCESS;
10778
12174
  }
10779
12175
  default:
10780
12176
  console.log(showHelp("cg"));
10781
- return ExitCode.SUCCESS;
12177
+ return ExitCode2.SUCCESS;
10782
12178
  }
10783
12179
  }
10784
12180
  async function handleSecurity(filePath) {
10785
12181
  try {
10786
12182
  if (!existsSync(filePath)) {
10787
12183
  console.error(`\u274C File not found: ${filePath}`);
10788
- return ExitCode.GENERAL_ERROR;
12184
+ return ExitCode2.GENERAL_ERROR;
10789
12185
  }
10790
12186
  const code = readFileSync(filePath, "utf-8");
10791
12187
  const secrets = createSecretDetector();
@@ -10815,11 +12211,11 @@ async function handleSecurity(filePath) {
10815
12211
  }
10816
12212
  }
10817
12213
  }
10818
- return ExitCode.SUCCESS;
12214
+ return ExitCode2.SUCCESS;
10819
12215
  } catch (err) {
10820
12216
  const msg = err instanceof Error ? err.message : String(err);
10821
12217
  console.error(`\u274C ${msg}`);
10822
- return ExitCode.GENERAL_ERROR;
12218
+ return ExitCode2.GENERAL_ERROR;
10823
12219
  }
10824
12220
  }
10825
12221
  async function handleWorkflow(sub, args) {
@@ -10835,36 +12231,36 @@ async function handleWorkflow(sub, args) {
10835
12231
  const icon = approved ? "\u2705" : "\u2B1C";
10836
12232
  console.log(` ${icon} ${phase}`);
10837
12233
  }
10838
- return ExitCode.SUCCESS;
12234
+ return ExitCode2.SUCCESS;
10839
12235
  }
10840
12236
  case "approve": {
10841
12237
  const phase = args[0];
10842
12238
  if (!phase) {
10843
12239
  console.error("\u274C Usage: musubix workflow approve <phase>");
10844
- return ExitCode.GENERAL_ERROR;
12240
+ return ExitCode2.GENERAL_ERROR;
10845
12241
  }
10846
12242
  tracker.approve(phase);
10847
12243
  console.log(`\u2705 Approved: ${phase}`);
10848
- return ExitCode.SUCCESS;
12244
+ return ExitCode2.SUCCESS;
10849
12245
  }
10850
12246
  case "transition": {
10851
12247
  const phase = args[0];
10852
12248
  if (!phase) {
10853
12249
  console.error("\u274C Usage: musubix workflow transition <phase>");
10854
- return ExitCode.GENERAL_ERROR;
12250
+ return ExitCode2.GENERAL_ERROR;
10855
12251
  }
10856
12252
  const result = await controller.transitionTo(phase);
10857
12253
  if (result.success) {
10858
12254
  console.log(`\u2705 Transitioned: ${result.fromPhase} \u2192 ${result.toPhase}`);
10859
12255
  } else {
10860
12256
  console.error(`\u274C Transition failed: ${result.errors.join(", ")}`);
10861
- return ExitCode.PHASE_BLOCKED;
12257
+ return ExitCode2.PHASE_BLOCKED;
10862
12258
  }
10863
- return ExitCode.SUCCESS;
12259
+ return ExitCode2.SUCCESS;
10864
12260
  }
10865
12261
  default:
10866
12262
  console.log(showHelp("workflow"));
10867
- return ExitCode.SUCCESS;
12263
+ return ExitCode2.SUCCESS;
10868
12264
  }
10869
12265
  }
10870
12266
  async function handleStatus() {
@@ -10879,14 +12275,14 @@ Constitution: ${CONSTITUTION_ARTICLES.length} articles`);
10879
12275
  for (const art of CONSTITUTION_ARTICLES) {
10880
12276
  console.log(` Article ${art.article}: ${art.name}`);
10881
12277
  }
10882
- return ExitCode.SUCCESS;
12278
+ return ExitCode2.SUCCESS;
10883
12279
  }
10884
12280
  async function handleReqValidate(filePath) {
10885
12281
  try {
10886
12282
  const content = readFileSync(filePath, "utf-8");
10887
- const parser = new MarkdownEARSParser();
12283
+ const parser = new MarkdownEARSParser2();
10888
12284
  const requirements = parser.parse(content);
10889
- const validator = createEARSValidator();
12285
+ const validator = createEARSValidator2();
10890
12286
  let hasIssues = false;
10891
12287
  for (const req of requirements) {
10892
12288
  const analysis = validator.analyze(req.text);
@@ -10902,42 +12298,42 @@ async function handleReqValidate(filePath) {
10902
12298
  if (requirements.length === 0) {
10903
12299
  console.log("No requirements found in file");
10904
12300
  }
10905
- return hasIssues ? ExitCode.VALIDATION_ERROR : ExitCode.SUCCESS;
12301
+ return hasIssues ? ExitCode2.VALIDATION_ERROR : ExitCode2.SUCCESS;
10906
12302
  } catch (err) {
10907
12303
  const msg = err instanceof Error ? err.message : String(err);
10908
12304
  console.error(`\u274C ${msg}`);
10909
- return ExitCode.GENERAL_ERROR;
12305
+ return ExitCode2.GENERAL_ERROR;
10910
12306
  }
10911
12307
  }
10912
12308
  async function handleReqWizard() {
10913
12309
  try {
10914
- const wizard = createRequirementWizard();
12310
+ const wizard = createRequirementWizard2();
10915
12311
  const steps = wizard.getSteps();
10916
12312
  console.log("\u{1F9D9} Requirements Creation Wizard");
10917
12313
  console.log("Interactive mode \u2014 follow these steps to create a requirement:\n");
10918
12314
  for (let i = 0; i < steps.length; i++) {
10919
12315
  console.log(` ${i + 1}. ${steps[i].prompt}`);
10920
12316
  }
10921
- return ExitCode.SUCCESS;
12317
+ return ExitCode2.SUCCESS;
10922
12318
  } catch (err) {
10923
12319
  const msg = err instanceof Error ? err.message : String(err);
10924
12320
  console.error(`\u274C ${msg}`);
10925
- return ExitCode.GENERAL_ERROR;
12321
+ return ExitCode2.GENERAL_ERROR;
10926
12322
  }
10927
12323
  }
10928
12324
  var _interviewer = null;
10929
12325
  function getInterviewer() {
10930
12326
  if (!_interviewer)
10931
- _interviewer = createRequirementsInterviewer();
12327
+ _interviewer = createRequirementsInterviewer2();
10932
12328
  return _interviewer;
10933
12329
  }
10934
12330
  async function handleReqInterview(args) {
10935
12331
  try {
10936
12332
  const interviewer = getInterviewer();
10937
12333
  if (args["reset"] === true) {
10938
- _interviewer = createRequirementsInterviewer();
12334
+ _interviewer = createRequirementsInterviewer2();
10939
12335
  console.log("\u{1F504} Interview state reset.");
10940
- return ExitCode.SUCCESS;
12336
+ return ExitCode2.SUCCESS;
10941
12337
  }
10942
12338
  if (args["state"] === true) {
10943
12339
  const state = interviewer.getState();
@@ -10951,14 +12347,14 @@ async function handleReqInterview(args) {
10951
12347
  if (state.currentQuestion) {
10952
12348
  console.log(` Current question: ${state.currentQuestion.question}`);
10953
12349
  }
10954
- return ExitCode.SUCCESS;
12350
+ return ExitCode2.SUCCESS;
10955
12351
  }
10956
12352
  if (args["generate"] === true) {
10957
12353
  const state = interviewer.getState();
10958
- const generator = createRequirementsDocGenerator();
12354
+ const generator = createRequirementsDocGenerator2();
10959
12355
  const doc = generator.generate(state.context);
10960
12356
  console.log(doc.markdown);
10961
- return ExitCode.SUCCESS;
12357
+ return ExitCode2.SUCCESS;
10962
12358
  }
10963
12359
  if (args["answer"] === true || typeof args["answer"] === "string") {
10964
12360
  const positionalArgs2 = args["args"] ?? [];
@@ -10966,7 +12362,7 @@ async function handleReqInterview(args) {
10966
12362
  const response = typeof args["answer"] === "string" ? positionalArgs2.join(" ") : positionalArgs2.slice(1).join(" ");
10967
12363
  if (!questionId || !response) {
10968
12364
  console.error("\u274C Usage: musubix req:interview --answer <question-id> <response>");
10969
- return ExitCode.GENERAL_ERROR;
12365
+ return ExitCode2.GENERAL_ERROR;
10970
12366
  }
10971
12367
  const result2 = interviewer.answer(questionId, response);
10972
12368
  if (result2.status === "complete") {
@@ -10979,7 +12375,7 @@ async function handleReqInterview(args) {
10979
12375
  console.log(` \u{1F4A1} ${result2.question.hint}`);
10980
12376
  }
10981
12377
  }
10982
- return ExitCode.SUCCESS;
12378
+ return ExitCode2.SUCCESS;
10983
12379
  }
10984
12380
  const positionalArgs = args["args"] ?? [];
10985
12381
  const inputText = args["subcommand"] ? [args["subcommand"], ...positionalArgs].join(" ") : positionalArgs.join(" ");
@@ -10992,12 +12388,12 @@ async function handleReqInterview(args) {
10992
12388
  console.log(" musubix req:interview --state Show interview state");
10993
12389
  console.log(" musubix req:interview --generate Generate requirements doc");
10994
12390
  console.log(" musubix req:interview --reset Reset interview");
10995
- return ExitCode.SUCCESS;
12391
+ return ExitCode2.SUCCESS;
10996
12392
  }
10997
12393
  const result = interviewer.analyzeInput(inputText);
10998
12394
  if (result.status === "complete") {
10999
12395
  console.log("\u2705 Sufficient info gathered! Generating requirements...");
11000
- const generator = createRequirementsDocGenerator();
12396
+ const generator = createRequirementsDocGenerator2();
11001
12397
  const doc = generator.generate(result.context);
11002
12398
  console.log(doc.markdown);
11003
12399
  } else {
@@ -11010,19 +12406,19 @@ async function handleReqInterview(args) {
11010
12406
  console.log(` \u9078\u629E\u80A2: ${result.question.choices.join(" | ")}`);
11011
12407
  }
11012
12408
  }
11013
- return ExitCode.SUCCESS;
12409
+ return ExitCode2.SUCCESS;
11014
12410
  } catch (err) {
11015
12411
  const msg = err instanceof Error ? err.message : String(err);
11016
12412
  console.error(`\u274C ${msg}`);
11017
- return ExitCode.GENERAL_ERROR;
12413
+ return ExitCode2.GENERAL_ERROR;
11018
12414
  }
11019
12415
  }
11020
12416
  async function handleDesignGenerate(filePath) {
11021
12417
  try {
11022
12418
  const content = readFileSync(filePath, "utf-8");
11023
- const parser = new MarkdownEARSParser();
12419
+ const parser = new MarkdownEARSParser2();
11024
12420
  const requirements = parser.parse(content);
11025
- const generator = createDesignGenerator();
12421
+ const generator = createDesignGenerator2();
11026
12422
  const mapped = requirements.map((r) => ({
11027
12423
  id: r.id,
11028
12424
  title: r.title,
@@ -11036,18 +12432,18 @@ async function handleDesignGenerate(filePath) {
11036
12432
  ## ${section.title}`);
11037
12433
  console.log(section.description);
11038
12434
  }
11039
- return ExitCode.SUCCESS;
12435
+ return ExitCode2.SUCCESS;
11040
12436
  } catch (err) {
11041
12437
  const msg = err instanceof Error ? err.message : String(err);
11042
12438
  console.error(`\u274C ${msg}`);
11043
- return ExitCode.GENERAL_ERROR;
12439
+ return ExitCode2.GENERAL_ERROR;
11044
12440
  }
11045
12441
  }
11046
12442
  async function handleDesignC4(filePath, level = "context") {
11047
12443
  try {
11048
12444
  const content = readFileSync(filePath, "utf-8");
11049
12445
  const data = JSON.parse(content);
11050
- const generator = createC4ModelGenerator();
12446
+ const generator = createC4ModelGenerator2();
11051
12447
  for (const el of data.elements ?? []) {
11052
12448
  generator.addElement(el);
11053
12449
  }
@@ -11058,61 +12454,61 @@ async function handleDesignC4(filePath, level = "context") {
11058
12454
  const diagram = generator.generateDiagram(c4Level, data.title ?? "System");
11059
12455
  const mermaid = generator.toMermaid(diagram);
11060
12456
  console.log(mermaid);
11061
- return ExitCode.SUCCESS;
12457
+ return ExitCode2.SUCCESS;
11062
12458
  } catch (err) {
11063
12459
  const msg = err instanceof Error ? err.message : String(err);
11064
12460
  console.error(`\u274C ${msg}`);
11065
- return ExitCode.GENERAL_ERROR;
12461
+ return ExitCode2.GENERAL_ERROR;
11066
12462
  }
11067
12463
  }
11068
12464
  async function handleDesignVerify(filePath) {
11069
12465
  try {
11070
12466
  const content = readFileSync(filePath, "utf-8");
11071
12467
  const design = JSON.parse(content);
11072
- const validator = createSOLIDValidator();
12468
+ const validator = createSOLIDValidator2();
11073
12469
  const report = validator.validate(design);
11074
12470
  if (report.violations.length === 0) {
11075
12471
  console.log("\u2705 All SOLID principles satisfied");
11076
12472
  console.log(`Score: ${report.score}/100`);
11077
- return ExitCode.SUCCESS;
12473
+ return ExitCode2.SUCCESS;
11078
12474
  }
11079
12475
  console.log(`SOLID score: ${report.score}/100`);
11080
12476
  for (const v of report.violations) {
11081
12477
  console.log(` \u26A0 [${v.principle}] ${v.message}`);
11082
12478
  }
11083
- return ExitCode.VALIDATION_ERROR;
12479
+ return ExitCode2.VALIDATION_ERROR;
11084
12480
  } catch (err) {
11085
12481
  const msg = err instanceof Error ? err.message : String(err);
11086
12482
  console.error(`\u274C ${msg}`);
11087
- return ExitCode.GENERAL_ERROR;
12483
+ return ExitCode2.GENERAL_ERROR;
11088
12484
  }
11089
12485
  }
11090
12486
  async function handleCodegen(name, type = "class") {
11091
12487
  try {
11092
- const generator = createCodeGenerator();
12488
+ const generator = createCodeGenerator2();
11093
12489
  const result = generator.generate({
11094
12490
  templateType: type,
11095
12491
  name
11096
12492
  });
11097
12493
  console.log(result.code);
11098
- return ExitCode.SUCCESS;
12494
+ return ExitCode2.SUCCESS;
11099
12495
  } catch (err) {
11100
12496
  const msg = err instanceof Error ? err.message : String(err);
11101
12497
  console.error(`\u274C ${msg}`);
11102
- return ExitCode.GENERAL_ERROR;
12498
+ return ExitCode2.GENERAL_ERROR;
11103
12499
  }
11104
12500
  }
11105
12501
  async function handleTestGen(filePath) {
11106
12502
  try {
11107
12503
  const content = readFileSync(filePath, "utf-8");
11108
- const generator = createUnitTestGenerator();
12504
+ const generator = createUnitTestGenerator2();
11109
12505
  const suite = generator.generate(content, "unit");
11110
12506
  console.log(suite.code);
11111
- return ExitCode.SUCCESS;
12507
+ return ExitCode2.SUCCESS;
11112
12508
  } catch (err) {
11113
12509
  const msg = err instanceof Error ? err.message : String(err);
11114
12510
  console.error(`\u274C ${msg}`);
11115
- return ExitCode.GENERAL_ERROR;
12511
+ return ExitCode2.GENERAL_ERROR;
11116
12512
  }
11117
12513
  }
11118
12514
  async function handleSkills(sub, args) {
@@ -11129,13 +12525,13 @@ async function handleSkills(sub, args) {
11129
12525
  console.log(` ${skill.metadata.name}`);
11130
12526
  }
11131
12527
  }
11132
- return ExitCode.SUCCESS;
12528
+ return ExitCode2.SUCCESS;
11133
12529
  }
11134
12530
  case "validate": {
11135
12531
  const path = args[0];
11136
12532
  if (!path) {
11137
12533
  console.error("\u274C Usage: musubix skills validate <path>");
11138
- return ExitCode.GENERAL_ERROR;
12534
+ return ExitCode2.GENERAL_ERROR;
11139
12535
  }
11140
12536
  try {
11141
12537
  const content = readFileSync(path, "utf-8");
@@ -11150,32 +12546,32 @@ async function handleSkills(sub, args) {
11150
12546
  if (errors.length > 0) {
11151
12547
  for (const e of errors)
11152
12548
  console.error(` \u274C ${e}`);
11153
- return ExitCode.VALIDATION_ERROR;
12549
+ return ExitCode2.VALIDATION_ERROR;
11154
12550
  }
11155
12551
  console.log(`\u2705 Skill definition valid: ${definition["name"]}`);
11156
- return ExitCode.SUCCESS;
12552
+ return ExitCode2.SUCCESS;
11157
12553
  } catch (err) {
11158
12554
  const msg = err instanceof Error ? err.message : String(err);
11159
12555
  console.error(`\u274C ${msg}`);
11160
- return ExitCode.GENERAL_ERROR;
12556
+ return ExitCode2.GENERAL_ERROR;
11161
12557
  }
11162
12558
  }
11163
12559
  case "create": {
11164
12560
  const name = args[0];
11165
12561
  if (!name) {
11166
12562
  console.error("\u274C Usage: musubix skills create <name>");
11167
- return ExitCode.GENERAL_ERROR;
12563
+ return ExitCode2.GENERAL_ERROR;
11168
12564
  }
11169
12565
  console.log(`\u2705 Scaffolded skill: ${name}`);
11170
12566
  console.log(` ${name}/`);
11171
12567
  console.log(` \u251C\u2500\u2500 skill.json`);
11172
12568
  console.log(` \u251C\u2500\u2500 index.ts`);
11173
12569
  console.log(` \u2514\u2500\u2500 tests/`);
11174
- return ExitCode.SUCCESS;
12570
+ return ExitCode2.SUCCESS;
11175
12571
  }
11176
12572
  default:
11177
12573
  console.log("Usage: musubix skills <list|validate|create> [args]");
11178
- return ExitCode.SUCCESS;
12574
+ return ExitCode2.SUCCESS;
11179
12575
  }
11180
12576
  }
11181
12577
  async function handleKnowledge(sub, args, flags) {
@@ -11187,36 +12583,36 @@ async function handleKnowledge(sub, args, flags) {
11187
12583
  const id = args[0];
11188
12584
  if (!id) {
11189
12585
  console.error("\u274C Usage: musubix knowledge get <id>");
11190
- return ExitCode.GENERAL_ERROR;
12586
+ return ExitCode2.GENERAL_ERROR;
11191
12587
  }
11192
12588
  const entity = store.getEntity(id);
11193
12589
  if (!entity) {
11194
12590
  console.error(`\u274C Entity not found: ${id}`);
11195
- return ExitCode.GENERAL_ERROR;
12591
+ return ExitCode2.GENERAL_ERROR;
11196
12592
  }
11197
12593
  console.log(JSON.stringify(entity, null, 2));
11198
- return ExitCode.SUCCESS;
12594
+ return ExitCode2.SUCCESS;
11199
12595
  }
11200
12596
  case "put": {
11201
12597
  const id = args[0];
11202
12598
  const type = args[1];
11203
12599
  if (!id || !type) {
11204
12600
  console.error("\u274C Usage: musubix knowledge put <id> <type>");
11205
- return ExitCode.GENERAL_ERROR;
12601
+ return ExitCode2.GENERAL_ERROR;
11206
12602
  }
11207
12603
  store.putEntity({ id, type, properties: {} });
11208
12604
  console.log(`\u2705 Stored entity: ${id} (${type})`);
11209
- return ExitCode.SUCCESS;
12605
+ return ExitCode2.SUCCESS;
11210
12606
  }
11211
12607
  case "delete": {
11212
12608
  const id = args[0];
11213
12609
  if (!id) {
11214
12610
  console.error("\u274C Usage: musubix knowledge delete <id>");
11215
- return ExitCode.GENERAL_ERROR;
12611
+ return ExitCode2.GENERAL_ERROR;
11216
12612
  }
11217
12613
  store.deleteEntity(id);
11218
12614
  console.log(`\u2705 Deleted entity: ${id}`);
11219
- return ExitCode.SUCCESS;
12615
+ return ExitCode2.SUCCESS;
11220
12616
  }
11221
12617
  case "link": {
11222
12618
  const from = args[0];
@@ -11224,61 +12620,61 @@ async function handleKnowledge(sub, args, flags) {
11224
12620
  const to = args[2];
11225
12621
  if (!from || !rel || !to) {
11226
12622
  console.error("\u274C Usage: musubix knowledge link <from> <rel> <to>");
11227
- return ExitCode.GENERAL_ERROR;
12623
+ return ExitCode2.GENERAL_ERROR;
11228
12624
  }
11229
12625
  store.addRelation({ from, to, type: rel });
11230
12626
  console.log(`\u2705 Linked: ${from} \u2014[${rel}]\u2192 ${to}`);
11231
- return ExitCode.SUCCESS;
12627
+ return ExitCode2.SUCCESS;
11232
12628
  }
11233
12629
  case "query": {
11234
12630
  const filter = args[0];
11235
12631
  if (!filter) {
11236
12632
  console.error("\u274C Usage: musubix knowledge query <filter>");
11237
- return ExitCode.GENERAL_ERROR;
12633
+ return ExitCode2.GENERAL_ERROR;
11238
12634
  }
11239
12635
  const results = await store.query({ type: filter });
11240
12636
  console.log(`Results: ${results.length} entities`);
11241
12637
  for (const e of results) {
11242
12638
  console.log(` ${e.id} (${e.type})`);
11243
12639
  }
11244
- return ExitCode.SUCCESS;
12640
+ return ExitCode2.SUCCESS;
11245
12641
  }
11246
12642
  case "traverse": {
11247
12643
  const startId = args[0];
11248
12644
  if (!startId) {
11249
12645
  console.error("\u274C Usage: musubix knowledge traverse <startId>");
11250
- return ExitCode.GENERAL_ERROR;
12646
+ return ExitCode2.GENERAL_ERROR;
11251
12647
  }
11252
12648
  const traversed = await store.traverse(startId);
11253
12649
  console.log(`Traversal from ${startId}: ${traversed.length} nodes`);
11254
12650
  for (const node of traversed) {
11255
12651
  console.log(` ${node.id} (${node.type})`);
11256
12652
  }
11257
- return ExitCode.SUCCESS;
12653
+ return ExitCode2.SUCCESS;
11258
12654
  }
11259
12655
  case "search": {
11260
12656
  const term = args[0];
11261
12657
  if (!term) {
11262
12658
  console.error("\u274C Usage: musubix knowledge search <term>");
11263
- return ExitCode.GENERAL_ERROR;
12659
+ return ExitCode2.GENERAL_ERROR;
11264
12660
  }
11265
12661
  const results = await store.search(term);
11266
12662
  console.log(`Search "${term}": ${results.length} results`);
11267
12663
  for (const e of results) {
11268
12664
  console.log(` ${e.id} (${e.type})`);
11269
12665
  }
11270
- return ExitCode.SUCCESS;
12666
+ return ExitCode2.SUCCESS;
11271
12667
  }
11272
12668
  case "stats": {
11273
12669
  const stats = store.getStats();
11274
12670
  console.log(`Entities: ${stats.entityCount}`);
11275
12671
  console.log(`Relations: ${stats.relationCount}`);
11276
12672
  console.log(`Types: ${Object.keys(stats.types).join(", ") || "none"}`);
11277
- return ExitCode.SUCCESS;
12673
+ return ExitCode2.SUCCESS;
11278
12674
  }
11279
12675
  default:
11280
12676
  console.log("Usage: musubix knowledge <get|put|delete|link|query|traverse|search|stats> [args]");
11281
- return ExitCode.SUCCESS;
12677
+ return ExitCode2.SUCCESS;
11282
12678
  }
11283
12679
  }
11284
12680
  async function handleDecision(sub, args, flags) {
@@ -11290,11 +12686,11 @@ async function handleDecision(sub, args, flags) {
11290
12686
  const title = args[0];
11291
12687
  if (!title) {
11292
12688
  console.error("\u274C Usage: musubix decision create <title>");
11293
- return ExitCode.GENERAL_ERROR;
12689
+ return ExitCode2.GENERAL_ERROR;
11294
12690
  }
11295
12691
  const adr = await manager.create({ title, context: "", decision: "", consequences: "" });
11296
12692
  console.log(`\u2705 Created ADR: ${adr.id} \u2014 ${adr.title}`);
11297
- return ExitCode.SUCCESS;
12693
+ return ExitCode2.SUCCESS;
11298
12694
  }
11299
12695
  case "list": {
11300
12696
  const adrs = await manager.list();
@@ -11306,66 +12702,66 @@ async function handleDecision(sub, args, flags) {
11306
12702
  console.log(` ${adr.id}: ${adr.title} [${adr.status}]`);
11307
12703
  }
11308
12704
  }
11309
- return ExitCode.SUCCESS;
12705
+ return ExitCode2.SUCCESS;
11310
12706
  }
11311
12707
  case "get": {
11312
12708
  const id = args[0];
11313
12709
  if (!id) {
11314
12710
  console.error("\u274C Usage: musubix decision get <id>");
11315
- return ExitCode.GENERAL_ERROR;
12711
+ return ExitCode2.GENERAL_ERROR;
11316
12712
  }
11317
12713
  const adr = await manager.get(id);
11318
12714
  if (!adr) {
11319
12715
  console.error(`\u274C ADR not found: ${id}`);
11320
- return ExitCode.GENERAL_ERROR;
12716
+ return ExitCode2.GENERAL_ERROR;
11321
12717
  }
11322
12718
  console.log(`${adr.id}: ${adr.title}`);
11323
12719
  console.log(`Status: ${adr.status}`);
11324
12720
  console.log(`Context: ${adr.context}`);
11325
12721
  console.log(`Decision: ${adr.decision}`);
11326
- return ExitCode.SUCCESS;
12722
+ return ExitCode2.SUCCESS;
11327
12723
  }
11328
12724
  case "accept": {
11329
12725
  const id = args[0];
11330
12726
  if (!id) {
11331
12727
  console.error("\u274C Usage: musubix decision accept <id>");
11332
- return ExitCode.GENERAL_ERROR;
12728
+ return ExitCode2.GENERAL_ERROR;
11333
12729
  }
11334
12730
  await manager.accept(id);
11335
12731
  console.log(`\u2705 Accepted: ${id}`);
11336
- return ExitCode.SUCCESS;
12732
+ return ExitCode2.SUCCESS;
11337
12733
  }
11338
12734
  case "deprecate": {
11339
12735
  const id = args[0];
11340
12736
  if (!id) {
11341
12737
  console.error("\u274C Usage: musubix decision deprecate <id>");
11342
- return ExitCode.GENERAL_ERROR;
12738
+ return ExitCode2.GENERAL_ERROR;
11343
12739
  }
11344
12740
  await manager.deprecate(id);
11345
12741
  console.log(`\u2705 Deprecated: ${id}`);
11346
- return ExitCode.SUCCESS;
12742
+ return ExitCode2.SUCCESS;
11347
12743
  }
11348
12744
  case "search": {
11349
12745
  const query = args[0];
11350
12746
  if (!query) {
11351
12747
  console.error("\u274C Usage: musubix decision search <query>");
11352
- return ExitCode.GENERAL_ERROR;
12748
+ return ExitCode2.GENERAL_ERROR;
11353
12749
  }
11354
12750
  const results = await manager.search(query);
11355
12751
  console.log(`Search "${query}": ${results.length} results`);
11356
12752
  for (const adr of results) {
11357
12753
  console.log(` ${adr.id}: ${adr.title} [${adr.status}]`);
11358
12754
  }
11359
- return ExitCode.SUCCESS;
12755
+ return ExitCode2.SUCCESS;
11360
12756
  }
11361
12757
  case "index": {
11362
12758
  const index = await manager.generateIndex();
11363
12759
  console.log(index);
11364
- return ExitCode.SUCCESS;
12760
+ return ExitCode2.SUCCESS;
11365
12761
  }
11366
12762
  default:
11367
12763
  console.log("Usage: musubix decision <create|list|get|accept|deprecate|search|index> [args]");
11368
- return ExitCode.SUCCESS;
12764
+ return ExitCode2.SUCCESS;
11369
12765
  }
11370
12766
  }
11371
12767
  async function handleDeepResearch(sub, args) {
@@ -11376,62 +12772,62 @@ async function handleDeepResearch(sub, args) {
11376
12772
  const question = args[0];
11377
12773
  if (!question) {
11378
12774
  console.error("\u274C Usage: musubix deep-research query <question>");
11379
- return ExitCode.GENERAL_ERROR;
12775
+ return ExitCode2.GENERAL_ERROR;
11380
12776
  }
11381
12777
  const result = engine.research({ topic: question, depth: "medium" }, []);
11382
12778
  console.log(`Question: ${question}`);
11383
12779
  console.log(`Confidence: ${result.confidence}`);
11384
12780
  console.log(`Sources: ${result.sources.length}`);
11385
12781
  console.log(`Answer: ${result.summary}`);
11386
- return ExitCode.SUCCESS;
12782
+ return ExitCode2.SUCCESS;
11387
12783
  }
11388
12784
  case "iterative": {
11389
12785
  const question = args[0];
11390
12786
  if (!question) {
11391
12787
  console.error("\u274C Usage: musubix deep-research iterative <question>");
11392
- return ExitCode.GENERAL_ERROR;
12788
+ return ExitCode2.GENERAL_ERROR;
11393
12789
  }
11394
12790
  const result = engine.researchIterative({ topic: question, depth: "medium" }, () => []);
11395
12791
  console.log(`Iterative research: ${question}`);
11396
12792
  console.log(`Confidence: ${result.confidence}`);
11397
12793
  console.log(`Answer: ${result.summary}`);
11398
- return ExitCode.SUCCESS;
12794
+ return ExitCode2.SUCCESS;
11399
12795
  }
11400
12796
  case "evidence": {
11401
12797
  const topic = args[0];
11402
12798
  if (!topic) {
11403
12799
  console.error("\u274C Usage: musubix deep-research evidence <topic>");
11404
- return ExitCode.GENERAL_ERROR;
12800
+ return ExitCode2.GENERAL_ERROR;
11405
12801
  }
11406
12802
  const evidence = engine.generateEvidenceChain(topic);
11407
12803
  console.log(`Evidence for "${topic}": ${evidence.length} items`);
11408
12804
  for (const e of evidence) {
11409
12805
  console.log(` - ${JSON.stringify(e)}`);
11410
12806
  }
11411
- return ExitCode.SUCCESS;
12807
+ return ExitCode2.SUCCESS;
11412
12808
  }
11413
12809
  default:
11414
12810
  console.log("Usage: musubix deep-research <query|iterative|evidence> [args]");
11415
- return ExitCode.SUCCESS;
12811
+ return ExitCode2.SUCCESS;
11416
12812
  }
11417
12813
  }
11418
12814
  async function handleRepl() {
11419
- const { ReplEngine: ReplEngine2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
11420
- const repl = new ReplEngine2();
12815
+ const { ReplEngine: ReplEngine22 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
12816
+ const repl = new ReplEngine22();
11421
12817
  console.log("MUSUBIX2 Interactive REPL");
11422
12818
  console.log('Type "help" for commands, "exit" to quit.\n');
11423
12819
  console.log(repl.getPrompt());
11424
- return ExitCode.SUCCESS;
12820
+ return ExitCode2.SUCCESS;
11425
12821
  }
11426
12822
  async function handleScaffold(sub, args) {
11427
- const { createProjectInitializer: createProjectInitializer2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
11428
- const initializer = createProjectInitializer2();
12823
+ const { createProjectInitializer: createProjectInitializer22 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
12824
+ const initializer = createProjectInitializer22();
11429
12825
  switch (sub) {
11430
12826
  case "project": {
11431
12827
  const name = args[0];
11432
12828
  if (!name) {
11433
12829
  console.error("\u274C Usage: musubix scaffold project <name>");
11434
- return ExitCode.GENERAL_ERROR;
12830
+ return ExitCode2.GENERAL_ERROR;
11435
12831
  }
11436
12832
  const result = initializer.init({
11437
12833
  projectName: name,
@@ -11446,15 +12842,15 @@ async function handleScaffold(sub, args) {
11446
12842
  } else {
11447
12843
  for (const e of result.errors)
11448
12844
  console.error(`\u274C ${e}`);
11449
- return ExitCode.GENERAL_ERROR;
12845
+ return ExitCode2.GENERAL_ERROR;
11450
12846
  }
11451
- return ExitCode.SUCCESS;
12847
+ return ExitCode2.SUCCESS;
11452
12848
  }
11453
12849
  case "package": {
11454
12850
  const name = args[0];
11455
12851
  if (!name) {
11456
12852
  console.error("\u274C Usage: musubix scaffold package <name>");
11457
- return ExitCode.GENERAL_ERROR;
12853
+ return ExitCode2.GENERAL_ERROR;
11458
12854
  }
11459
12855
  console.log(`\u2705 Scaffolded package: ${name}`);
11460
12856
  console.log(` packages/${name}/`);
@@ -11462,34 +12858,34 @@ async function handleScaffold(sub, args) {
11462
12858
  console.log(` \u251C\u2500\u2500 tsconfig.json`);
11463
12859
  console.log(` \u251C\u2500\u2500 src/index.ts`);
11464
12860
  console.log(` \u2514\u2500\u2500 tests/`);
11465
- return ExitCode.SUCCESS;
12861
+ return ExitCode2.SUCCESS;
11466
12862
  }
11467
12863
  case "skill": {
11468
12864
  const name = args[0];
11469
12865
  if (!name) {
11470
12866
  console.error("\u274C Usage: musubix scaffold skill <name>");
11471
- return ExitCode.GENERAL_ERROR;
12867
+ return ExitCode2.GENERAL_ERROR;
11472
12868
  }
11473
12869
  console.log(`\u2705 Scaffolded skill: ${name}`);
11474
12870
  console.log(` skills/${name}/`);
11475
12871
  console.log(` \u251C\u2500\u2500 skill.json`);
11476
12872
  console.log(` \u251C\u2500\u2500 index.ts`);
11477
12873
  console.log(` \u2514\u2500\u2500 tests/`);
11478
- return ExitCode.SUCCESS;
12874
+ return ExitCode2.SUCCESS;
11479
12875
  }
11480
12876
  default:
11481
12877
  console.log("Usage: musubix scaffold <project|package|skill> <name>");
11482
- return ExitCode.SUCCESS;
12878
+ return ExitCode2.SUCCESS;
11483
12879
  }
11484
12880
  }
11485
12881
  async function handleExplain(input) {
11486
- const { ExplanationGenerator: ExplanationGenerator2, ReasoningChainRecorder: ReasoningChainRecorder2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
12882
+ const { ExplanationGenerator: ExplanationGenerator22, ReasoningChainRecorder: ReasoningChainRecorder22 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
11487
12883
  if (!input) {
11488
12884
  console.error("\u274C Usage: musubix explain <file-or-snippet>");
11489
- return ExitCode.GENERAL_ERROR;
12885
+ return ExitCode2.GENERAL_ERROR;
11490
12886
  }
11491
- const recorder = new ReasoningChainRecorder2();
11492
- const generator = new ExplanationGenerator2();
12887
+ const recorder = new ReasoningChainRecorder22();
12888
+ const generator = new ExplanationGenerator22();
11493
12889
  let code;
11494
12890
  if (existsSync(input)) {
11495
12891
  code = readFileSync(input, "utf-8");
@@ -11503,7 +12899,7 @@ async function handleExplain(input) {
11503
12899
  const explanation = generator.generate(chain);
11504
12900
  console.log("=== Code Explanation ===\n");
11505
12901
  console.log(explanation);
11506
- return ExitCode.SUCCESS;
12902
+ return ExitCode2.SUCCESS;
11507
12903
  }
11508
12904
  async function handleLearn(sub, args) {
11509
12905
  const { createLibraryLearner: createLibraryLearner2 } = await Promise.resolve().then(() => (init_dist6(), dist_exports6));
@@ -11513,7 +12909,7 @@ async function handleLearn(sub, args) {
11513
12909
  const path = args[0];
11514
12910
  if (!path) {
11515
12911
  console.error("\u274C Usage: musubix learn analyze <path>");
11516
- return ExitCode.GENERAL_ERROR;
12912
+ return ExitCode2.GENERAL_ERROR;
11517
12913
  }
11518
12914
  try {
11519
12915
  const content = readFileSync(path, "utf-8");
@@ -11526,9 +12922,9 @@ async function handleLearn(sub, args) {
11526
12922
  } catch (err) {
11527
12923
  const msg = err instanceof Error ? err.message : String(err);
11528
12924
  console.error(`\u274C ${msg}`);
11529
- return ExitCode.GENERAL_ERROR;
12925
+ return ExitCode2.GENERAL_ERROR;
11530
12926
  }
11531
- return ExitCode.SUCCESS;
12927
+ return ExitCode2.SUCCESS;
11532
12928
  }
11533
12929
  case "patterns": {
11534
12930
  const patterns = learner.getPatterns();
@@ -11540,7 +12936,7 @@ async function handleLearn(sub, args) {
11540
12936
  console.log(` - ${p.name}: ${p.abstraction}`);
11541
12937
  }
11542
12938
  }
11543
- return ExitCode.SUCCESS;
12939
+ return ExitCode2.SUCCESS;
11544
12940
  }
11545
12941
  case "suggest": {
11546
12942
  const code = args[0] ?? "";
@@ -11553,11 +12949,11 @@ async function handleLearn(sub, args) {
11553
12949
  console.log(` - ${s.name}: ${s.abstraction}`);
11554
12950
  }
11555
12951
  }
11556
- return ExitCode.SUCCESS;
12952
+ return ExitCode2.SUCCESS;
11557
12953
  }
11558
12954
  default:
11559
12955
  console.log("Usage: musubix learn <analyze|patterns|suggest> [args]");
11560
- return ExitCode.SUCCESS;
12956
+ return ExitCode2.SUCCESS;
11561
12957
  }
11562
12958
  }
11563
12959
  async function handleSynthesis(sub, args) {
@@ -11576,7 +12972,7 @@ async function handleSynthesis(sub, args) {
11576
12972
  } else {
11577
12973
  console.log(" No rule could be synthesized");
11578
12974
  }
11579
- return ExitCode.SUCCESS;
12975
+ return ExitCode2.SUCCESS;
11580
12976
  }
11581
12977
  case "dsl": {
11582
12978
  const { createDSLBuilder: createDSLBuilder2 } = await Promise.resolve().then(() => (init_dist7(), dist_exports7));
@@ -11584,13 +12980,13 @@ async function handleSynthesis(sub, args) {
11584
12980
  const input = args[0];
11585
12981
  if (!input) {
11586
12982
  console.error("\u274C Usage: musubix synthesis dsl <input>");
11587
- return ExitCode.GENERAL_ERROR;
12983
+ return ExitCode2.GENERAL_ERROR;
11588
12984
  }
11589
12985
  const result = builder.execute(input);
11590
12986
  console.log(`DSL output:`);
11591
12987
  console.log(` Input: ${input}`);
11592
12988
  console.log(` Result: ${result}`);
11593
- return ExitCode.SUCCESS;
12989
+ return ExitCode2.SUCCESS;
11594
12990
  }
11595
12991
  case "version-space": {
11596
12992
  const { createVersionSpaceManager: createVersionSpaceManager2 } = await Promise.resolve().then(() => (init_dist7(), dist_exports7));
@@ -11598,26 +12994,26 @@ async function handleSynthesis(sub, args) {
11598
12994
  const spaces = manager.getSpaces();
11599
12995
  console.log(`Version space:`);
11600
12996
  console.log(` Spaces: ${spaces.size}`);
11601
- return ExitCode.SUCCESS;
12997
+ return ExitCode2.SUCCESS;
11602
12998
  }
11603
12999
  default:
11604
13000
  console.log("Usage: musubix synthesis <fromExamples|dsl|version-space> [args]");
11605
- return ExitCode.SUCCESS;
13001
+ return ExitCode2.SUCCESS;
11606
13002
  }
11607
13003
  }
11608
13004
  async function handleWatch(pattern) {
11609
- const { createFileWatcher: createFileWatcher2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
13005
+ const { createFileWatcher: createFileWatcher22 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
11610
13006
  if (!pattern) {
11611
13007
  console.error("\u274C Usage: musubix watch <glob-pattern>");
11612
- return ExitCode.GENERAL_ERROR;
13008
+ return ExitCode2.GENERAL_ERROR;
11613
13009
  }
11614
- const watcher = createFileWatcher2();
13010
+ const watcher = createFileWatcher22();
11615
13011
  console.log(`\u{1F441} Watching: ${pattern}`);
11616
13012
  console.log("Press Ctrl+C to stop.\n");
11617
13013
  watcher.on("modify", (event) => {
11618
13014
  console.log(` [${event.type}] ${event.path}`);
11619
13015
  });
11620
- return ExitCode.SUCCESS;
13016
+ return ExitCode2.SUCCESS;
11621
13017
  }
11622
13018
  function getDefaultCommands() {
11623
13019
  return [
@@ -12036,9 +13432,7 @@ function createCLIDispatcher() {
12036
13432
  dispatcher.registerBatch(getDefaultCommands());
12037
13433
  return dispatcher;
12038
13434
  }
12039
-
12040
- // dist/index.js
12041
- var MUSUBI_VERSION = "0.3.6";
13435
+ var MUSUBI_VERSION = "0.3.8";
12042
13436
  function createEARSPipeline() {
12043
13437
  const validator = createEARSValidator();
12044
13438
  const parser = createMarkdownEARSParser();