musubix 2.1.1 → 2.2.1

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.
@@ -0,0 +1,513 @@
1
+ # MUSUBIX v2.2.0 Advanced Learning Enhancement
2
+
3
+ **バージョン**: 2.2.0
4
+ **最終更新**: 2026-01-08
5
+
6
+ ---
7
+
8
+ ## 1. 概要
9
+
10
+ MUSUBIX v2.2.0は、**高度な学習機能強化**を実現するメジャーアップデートです。Neural Search、Library Learner、Synthesisの3パッケージに対して、28タスク・464テストを追加しました。
11
+
12
+ ### 1.1 主要機能
13
+
14
+ | 領域 | 機能 | 説明 |
15
+ |------|------|------|
16
+ | **Neural Search** | コンテキスト認識埋め込み | AST構造を考慮した意味的埋め込み |
17
+ | | ハイブリッドランキング | BM25 + ベクトル類似度の統合 |
18
+ | | 埋め込みキャッシュ | LRU + TTL管理による高効率キャッシュ |
19
+ | **Library Learner** | セマンティックチャンキング | AST境界認識によるコード分割 |
20
+ | | パターンバージョン管理 | Git風のパターン履歴管理 |
21
+ | | ドメイン認識抽象化 | ドメイン特化パターン抽出 |
22
+ | **Synthesis** | 演繹的合成エンジン | FlashFill風の仕様分解 |
23
+ | | メタ学習 | タスク類似度ベースの戦略選択 |
24
+ | | DSL拡張 | パターンからの演算子自動生成 |
25
+
26
+ ---
27
+
28
+ ## 2. Neural Search 強化
29
+
30
+ ### 2.1 アーキテクチャ
31
+
32
+ ```
33
+ ┌─────────────────────────────────────────────────────────────┐
34
+ │ Neural Search Engine │
35
+ ├─────────────────────────────────────────────────────────────┤
36
+ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
37
+ │ │ContextAwareEmb- │ │ ScopeEnhancer │ │ HybridRanker│ │
38
+ │ │ edder │ │ │ │ │ │
39
+ │ │ ・AST構造認識 │ │ ・スコープ抽出 │ │ ・BM25 │ │
40
+ │ │ ・文脈埋め込み │ │ ・コード強化 │ │ ・ベクトル │ │
41
+ │ └────────┬────────┘ └────────┬────────┘ └──────┬──────┘ │
42
+ │ │ │ │ │
43
+ │ └────────────────────┼──────────────────┘ │
44
+ │ ▼ │
45
+ │ ┌─────────────────────────────────────────────────────────┐│
46
+ │ │ EmbeddingCache (LRU + TTL) ││
47
+ │ │ ・最大10,000エントリ ・TTL管理 ・ヒット率追跡 ││
48
+ │ └─────────────────────────────────────────────────────────┘│
49
+ │ │ │
50
+ │ ▼ │
51
+ │ ┌─────────────────────────────────────────────────────────┐│
52
+ │ │ OnlineModelUpdater ││
53
+ │ │ ・継続学習 ・フィードバック統合 ・モデル更新 ││
54
+ │ └─────────────────────────────────────────────────────────┘│
55
+ └─────────────────────────────────────────────────────────────┘
56
+ ```
57
+
58
+ ### 2.2 主要コンポーネント
59
+
60
+ #### ContextAwareEmbedder
61
+
62
+ AST構造を認識したコンテキスト埋め込み:
63
+
64
+ ```typescript
65
+ import { ContextAwareEmbedder } from '@nahisaho/musubix-neural-search';
66
+
67
+ const embedder = new ContextAwareEmbedder({
68
+ windowSize: 5, // コンテキストウィンドウサイズ
69
+ includeAST: true, // AST情報を含む
70
+ normalize: true, // 正規化
71
+ });
72
+
73
+ // コード埋め込み生成
74
+ const embedding = embedder.embed(code, {
75
+ surrounding: surroundingCode,
76
+ imports: importStatements,
77
+ });
78
+
79
+ // バッチ埋め込み
80
+ const embeddings = embedder.embedBatch(codeSnippets);
81
+ ```
82
+
83
+ #### HybridRanker
84
+
85
+ BM25とベクトル類似度を組み合わせたハイブリッドランキング:
86
+
87
+ ```typescript
88
+ import { HybridRanker } from '@nahisaho/musubix-neural-search';
89
+
90
+ const ranker = new HybridRanker({
91
+ alpha: 0.6, // BM25の重み (0-1)
92
+ bm25Config: {
93
+ k1: 1.2,
94
+ b: 0.75,
95
+ },
96
+ });
97
+
98
+ const results = ranker.rank(query, documents);
99
+ // results: [{ document, score, bm25Score, vectorScore }]
100
+ ```
101
+
102
+ #### EmbeddingCache
103
+
104
+ LRU + TTL管理による高効率キャッシュ:
105
+
106
+ ```typescript
107
+ import { EmbeddingCache } from '@nahisaho/musubix-neural-search';
108
+
109
+ const cache = new EmbeddingCache({
110
+ maxSize: 10000, // 最大エントリ数
111
+ ttlMs: 3600000, // TTL (1時間)
112
+ });
113
+
114
+ // キャッシュ操作
115
+ cache.set('key', embedding);
116
+ const cached = cache.get('key');
117
+
118
+ // 統計取得
119
+ const stats = cache.getStats();
120
+ // { hits, misses, hitRate, size }
121
+ ```
122
+
123
+ #### TrajectoryLogger (P2)
124
+
125
+ 検索軌跡のロギングとエクスポート:
126
+
127
+ ```typescript
128
+ import { createTrajectoryLogger } from '@nahisaho/musubix-neural-search';
129
+
130
+ const logger = createTrajectoryLogger();
131
+
132
+ // 分岐ログ
133
+ logger.logBranch({
134
+ depth: 1,
135
+ score: 0.85,
136
+ action: 'expand',
137
+ metadata: { nodeType: 'function' },
138
+ });
139
+
140
+ // 軌跡取得
141
+ const trajectory = logger.getTrajectory();
142
+
143
+ // エクスポート
144
+ const json = logger.export('json');
145
+ const parquet = logger.export('parquet');
146
+
147
+ // 統計
148
+ const stats = logger.getStatistics();
149
+ // { maxDepth, bestScore, averageScore, branchesByDepth }
150
+ ```
151
+
152
+ ---
153
+
154
+ ## 3. Library Learner 強化
155
+
156
+ ### 3.1 アーキテクチャ
157
+
158
+ ```
159
+ ┌─────────────────────────────────────────────────────────────┐
160
+ │ Library Learner Engine │
161
+ ├─────────────────────────────────────────────────────────────┤
162
+ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
163
+ │ │ SemanticChunker │ │AbstractionEngine│ │ Iterative- │ │
164
+ │ │ │ │ │ │ Compressor │ │
165
+ │ │ ・AST境界認識 │ │ ・階層抽象化 │ │ ・反復圧縮 │ │
166
+ │ │ ・サイズ制御 │ │ ・変数正規化 │ │ ・最適化 │ │
167
+ │ └────────┬────────┘ └────────┬────────┘ └──────┬──────┘ │
168
+ │ │ │ │ │
169
+ │ └────────────────────┼──────────────────┘ │
170
+ │ ▼ │
171
+ │ ┌─────────────────────────────────────────────────────────┐│
172
+ │ │ ConflictResolver ││
173
+ │ │ ・競合検出 ・自動マージ ・優先度解決 ││
174
+ │ └─────────────────────────────────────────────────────────┘│
175
+ │ │ │
176
+ │ ▼ │
177
+ │ ┌─────────────────────────────────────────────────────────┐│
178
+ │ │ PatternVersionManager ││
179
+ │ │ ・コミット ・ブランチ ・マージ ・履歴追跡 ││
180
+ │ └─────────────────────────────────────────────────────────┘│
181
+ └─────────────────────────────────────────────────────────────┘
182
+ ```
183
+
184
+ ### 3.2 主要コンポーネント
185
+
186
+ #### SemanticChunker
187
+
188
+ AST境界を認識したセマンティックチャンキング:
189
+
190
+ ```typescript
191
+ import { SemanticChunker } from '@nahisaho/musubix-library-learner';
192
+
193
+ const chunker = new SemanticChunker({
194
+ minSize: 50, // 最小チャンクサイズ
195
+ maxSize: 500, // 最大チャンクサイズ
196
+ respectBoundaries: true, // AST境界を尊重
197
+ });
198
+
199
+ const chunks = chunker.chunk(code);
200
+ // chunks: [{ content, startLine, endLine, type }]
201
+ ```
202
+
203
+ #### PatternVersionManager
204
+
205
+ Git風のパターンバージョン管理:
206
+
207
+ ```typescript
208
+ import { PatternVersionManager } from '@nahisaho/musubix-library-learner';
209
+
210
+ const manager = new PatternVersionManager();
211
+
212
+ // コミット
213
+ const commitId = manager.commit(pattern, 'Add validation pattern');
214
+
215
+ // 履歴
216
+ const history = manager.getHistory(patternId);
217
+
218
+ // 差分
219
+ const diff = manager.diff(commitId1, commitId2);
220
+
221
+ // ロールバック
222
+ manager.rollback(patternId, commitId);
223
+ ```
224
+
225
+ #### DomainAwareAbstractor
226
+
227
+ ドメイン特化パターン抽出:
228
+
229
+ ```typescript
230
+ import { DomainAwareAbstractor } from '@nahisaho/musubix-library-learner';
231
+
232
+ const abstractor = new DomainAwareAbstractor();
233
+
234
+ // ドメイン指定抽象化
235
+ const pattern = abstractor.abstract(code, 'web-api');
236
+
237
+ // ドメイン自動検出
238
+ const detectedPattern = abstractor.abstractWithAutoDetection(code);
239
+ ```
240
+
241
+ #### MetricsExporter (P2)
242
+
243
+ 学習メトリクスのエクスポート:
244
+
245
+ ```typescript
246
+ import { createMetricsExporter } from '@nahisaho/musubix-library-learner';
247
+
248
+ const exporter = createMetricsExporter(library);
249
+
250
+ // メトリクス収集
251
+ const metrics = exporter.collectMetrics();
252
+
253
+ // エクスポート
254
+ const json = exporter.export('json');
255
+ const markdown = exporter.export('markdown');
256
+
257
+ // サマリー取得
258
+ const summary = exporter.getSummary();
259
+ // { totalPatterns, averageConfidence, healthStatus }
260
+
261
+ // 健全性評価
262
+ // healthStatus: 'good' | 'warning' | 'poor'
263
+ ```
264
+
265
+ ---
266
+
267
+ ## 4. Synthesis 強化
268
+
269
+ ### 4.1 アーキテクチャ
270
+
271
+ ```
272
+ ┌─────────────────────────────────────────────────────────────┐
273
+ │ Synthesis Engine │
274
+ ├─────────────────────────────────────────────────────────────┤
275
+ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
276
+ │ │DeductiveEngine │ │WitnessFunction │ │MetaLearning │ │
277
+ │ │ │ │ │ │ Engine │ │
278
+ │ │ ・仕様分解 │ │ ・部分仕様生成 │ │ ・戦略選択 │ │
279
+ │ │ ・演繹的探索 │ │ ・分解ルール │ │ ・類似度 │ │
280
+ │ └────────┬────────┘ └────────┬────────┘ └──────┬──────┘ │
281
+ │ │ │ │ │
282
+ │ └────────────────────┼──────────────────┘ │
283
+ │ ▼ │
284
+ │ ┌─────────────────────────────────────────────────────────┐│
285
+ │ │ DSLExtender ││
286
+ │ │ ・パターン分析 ・演算子提案 ・DSL拡張 ││
287
+ │ └─────────────────────────────────────────────────────────┘│
288
+ │ │ │
289
+ │ ▼ │
290
+ │ ┌─────────────────────────────────────────────────────────┐│
291
+ │ │ ExampleAnalyzer ││
292
+ │ │ ・品質分析 ・カバレッジ ・曖昧性検出 ││
293
+ │ └─────────────────────────────────────────────────────────┘│
294
+ └─────────────────────────────────────────────────────────────┘
295
+ ```
296
+
297
+ ### 4.2 主要コンポーネント
298
+
299
+ #### DeductiveEngine
300
+
301
+ FlashFill風の演繹的合成:
302
+
303
+ ```typescript
304
+ import { DeductiveEngine } from '@nahisaho/musubix-synthesis';
305
+
306
+ const engine = new DeductiveEngine(grammar);
307
+
308
+ const result = engine.synthesize({
309
+ examples: [
310
+ { input: 'hello', output: 'HELLO' },
311
+ { input: 'world', output: 'WORLD' },
312
+ ],
313
+ });
314
+
315
+ console.log(result.program); // input.toUpperCase()
316
+ console.log(result.confidence); // 0.95
317
+ ```
318
+
319
+ #### MetaLearningEngine
320
+
321
+ タスク類似度ベースの戦略選択:
322
+
323
+ ```typescript
324
+ import { createMetaLearningEngine } from '@nahisaho/musubix-synthesis';
325
+
326
+ const meta = createMetaLearningEngine({
327
+ historySize: 100,
328
+ similarityThreshold: 0.7,
329
+ });
330
+
331
+ // タスク記録
332
+ meta.recordTask(task, result);
333
+
334
+ // 戦略選択
335
+ const strategy = meta.selectStrategy(newTask);
336
+ // strategy: { algorithm, params, expectedTime }
337
+
338
+ // 類似タスク検索
339
+ const similar = meta.findSimilarTasks(task, 5);
340
+ ```
341
+
342
+ #### DSLExtender
343
+
344
+ パターンからのDSL演算子自動生成:
345
+
346
+ ```typescript
347
+ import { createDSLExtender } from '@nahisaho/musubix-synthesis';
348
+
349
+ const extender = createDSLExtender(baseDSL);
350
+
351
+ // パターンからギャップ検出
352
+ const gaps = extender.detectGaps(patterns);
353
+
354
+ // 演算子提案
355
+ const suggestions = extender.suggestOperators(gaps);
356
+ // suggestions: [{ name, signature, implementation }]
357
+
358
+ // DSL拡張
359
+ const extendedDSL = extender.extend(suggestions);
360
+ ```
361
+
362
+ #### ExampleAnalyzer
363
+
364
+ 例題品質分析:
365
+
366
+ ```typescript
367
+ import { createExampleAnalyzer } from '@nahisaho/musubix-synthesis';
368
+
369
+ const analyzer = createExampleAnalyzer();
370
+
371
+ // 品質分析
372
+ const quality = analyzer.analyzeQuality(examples);
373
+ // quality: { score, issues, suggestions }
374
+
375
+ // カバレッジ分析
376
+ const coverage = analyzer.analyzeCoverage(examples, dsl);
377
+
378
+ // 曖昧性検出
379
+ const ambiguities = analyzer.detectAmbiguity(examples);
380
+ ```
381
+
382
+ #### ExplanationGenerator (P2)
383
+
384
+ 合成プログラムの自然言語説明:
385
+
386
+ ```typescript
387
+ import { createExplanationGenerator } from '@nahisaho/musubix-synthesis';
388
+
389
+ const explainer = createExplanationGenerator();
390
+
391
+ // 説明生成
392
+ const explanation = explainer.generate(program);
393
+ // explanation: { description, steps, exampleWalkthrough, confidence }
394
+
395
+ // 詳細説明
396
+ const detailed = explainer.explain(program);
397
+ // detailed: { ...explanation, rationale, limitations, relationship }
398
+
399
+ // 一行サマリー
400
+ const summary = explainer.summarize(program);
401
+ // "Converts to uppercase"
402
+
403
+ // 信頼度
404
+ const confidence = explainer.getConfidence(program);
405
+ ```
406
+
407
+ ---
408
+
409
+ ## 5. MCP統合
410
+
411
+ ### 5.1 Synthesisツール(5ツール)
412
+
413
+ | ツール | 説明 |
414
+ |--------|------|
415
+ | `synthesis_from_examples` | 例からプログラム合成 |
416
+ | `synthesis_analyze_examples` | 例題品質分析 |
417
+ | `synthesis_learn_patterns` | パターン学習 |
418
+ | `synthesis_query_patterns` | パターン検索 |
419
+ | `synthesis_get_stats` | 統計取得 |
420
+
421
+ ### 5.2 Synthesisプロンプト(2プロンプト)
422
+
423
+ | プロンプト | 説明 |
424
+ |-----------|------|
425
+ | `synthesis_guidance` | 合成ガイダンス |
426
+ | `synthesis_explain_pattern` | パターン説明 |
427
+
428
+ ---
429
+
430
+ ## 6. CLIコマンド
431
+
432
+ ### 6.1 プログラム合成
433
+
434
+ ```bash
435
+ # 例からプログラム合成
436
+ npx musubix synthesize <examples.json>
437
+
438
+ # PBE特化合成
439
+ npx musubix synthesize pbe <examples.json>
440
+
441
+ # エイリアス
442
+ npx musubix syn <examples.json>
443
+ ```
444
+
445
+ ### 6.2 パターンライブラリ管理
446
+
447
+ ```bash
448
+ # コードからパターン学習
449
+ npx musubix library learn <file>
450
+
451
+ # パターン検索
452
+ npx musubix library query <query>
453
+
454
+ # 統計表示
455
+ npx musubix library stats
456
+ npx musubix lib stats # エイリアス
457
+ ```
458
+
459
+ ---
460
+
461
+ ## 7. テスト統計
462
+
463
+ | EPIC | タスク数 | テスト数 |
464
+ |------|---------|---------|
465
+ | Neural Search強化 | 7 | 138 |
466
+ | Library Learner強化 | 7 | 145 |
467
+ | Synthesis強化 | 6 | 108 |
468
+ | 統合・CLI | 4 | 73 |
469
+ | **合計** | **28** | **464** |
470
+
471
+ ### 7.1 パッケージ別テスト数
472
+
473
+ | パッケージ | v2.1.0 | v2.2.0 | 増分 |
474
+ |-----------|--------|--------|------|
475
+ | `@nahisaho/musubix-neural-search` | 144 | 165 | +21 |
476
+ | `@nahisaho/musubix-library-learner` | 132 | 158 | +26 |
477
+ | `@nahisaho/musubix-synthesis` | 146 | 163 | +17 |
478
+
479
+ ---
480
+
481
+ ## 8. マイグレーションガイド
482
+
483
+ ### v2.1.x → v2.2.0
484
+
485
+ v2.2.0は完全な後方互換性を維持しています。新機能を使用するには:
486
+
487
+ ```typescript
488
+ // v2.1.x (引き続き動作)
489
+ import { PBESynthesizer } from '@nahisaho/musubix-synthesis';
490
+
491
+ // v2.2.0 新機能
492
+ import {
493
+ createMetaLearningEngine,
494
+ createExampleAnalyzer,
495
+ createExplanationGenerator,
496
+ } from '@nahisaho/musubix-synthesis';
497
+ ```
498
+
499
+ ---
500
+
501
+ ## 関連ドキュメント
502
+
503
+ | ドキュメント | 説明 |
504
+ |-------------|------|
505
+ | [MUSUBIX-Learning.md](MUSUBIX-Learning.md) | 学習システム概要 |
506
+ | [MUSUBIX-Overview.md](MUSUBIX-Overview.md) | システム全体概要 |
507
+ | [USER-GUIDE.md](../USER-GUIDE.md) | ユーザーガイド |
508
+
509
+ ---
510
+
511
+ **バージョン**: 2.2.0
512
+ **最終更新**: 2026-01-08
513
+ **MUSUBIX Project**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musubix",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
4
4
  "description": "Neuro-Symbolic AI Coding System - MUSUBI × YATA Integration",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -80,6 +80,7 @@
80
80
  "@nahisaho/yata-global": "^2.1.0",
81
81
  "@nahisaho/yata-local": "^2.1.0",
82
82
  "@nahisaho/yata-scale": "^2.1.0",
83
- "@nahisaho/yata-ui": "^2.1.0"
83
+ "@nahisaho/yata-ui": "^2.1.0",
84
+ "musubix": "^2.2.0"
84
85
  }
85
86
  }