musubix 3.0.7 → 3.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/.github/AGENTS.md +858 -0
  2. package/.github/prompts/sdd-change-apply.prompt.md +283 -0
  3. package/.github/prompts/sdd-change-archive.prompt.md +241 -0
  4. package/.github/prompts/sdd-change-init.prompt.md +269 -0
  5. package/.github/prompts/sdd-design.prompt.md +250 -0
  6. package/.github/prompts/sdd-implement.prompt.md +387 -0
  7. package/.github/prompts/sdd-requirements.prompt.md +193 -0
  8. package/.github/prompts/sdd-review.prompt.md +155 -0
  9. package/.github/prompts/sdd-security.prompt.md +228 -0
  10. package/.github/prompts/sdd-steering.prompt.md +269 -0
  11. package/.github/prompts/sdd-tasks.prompt.md +255 -0
  12. package/.github/prompts/sdd-test.prompt.md +230 -0
  13. package/.github/prompts/sdd-validate.prompt.md +304 -0
  14. package/.github/skills/musubix-adr-generation/SKILL.md +209 -0
  15. package/.github/skills/musubix-best-practices/SKILL.md +315 -0
  16. package/.github/skills/musubix-c4-design/SKILL.md +162 -0
  17. package/.github/skills/musubix-code-generation/SKILL.md +229 -0
  18. package/.github/skills/musubix-domain-inference/SKILL.md +196 -0
  19. package/.github/skills/musubix-ears-validation/SKILL.md +161 -0
  20. package/.github/skills/musubix-sdd-workflow/SKILL.md +210 -0
  21. package/.github/skills/musubix-technical-writing/SKILL.md +444 -0
  22. package/.github/skills/musubix-test-generation/SKILL.md +212 -0
  23. package/.github/skills/musubix-traceability/SKILL.md +141 -0
  24. package/AGENTS.md +873 -0
  25. package/LICENSE +21 -0
  26. package/README.ja.md +296 -0
  27. package/README.md +305 -44
  28. package/bin/musubix-mcp.js +15 -0
  29. package/bin/musubix.js +9 -1
  30. package/docs/API-REFERENCE.md +1425 -0
  31. package/docs/GITHUB-ACTIONS-NPM-SETUP.md +132 -0
  32. package/docs/INSTALL-GUIDE.ja.md +459 -0
  33. package/docs/INSTALL-GUIDE.md +459 -0
  34. package/docs/MIGRATION-v3.0.md +324 -0
  35. package/docs/MUSUBI-enhancement_roadmap_20260105.md +651 -0
  36. package/docs/MUSUBIX-v3.0-User-Guide.md +1357 -0
  37. package/docs/MUSUBIXv2.2.0-Manual-outline.md +136 -0
  38. package/docs/MUSUBIXv2.2.0-Manual.md +3123 -0
  39. package/docs/MUSUBIXv2.3.5-Refactering.md +1310 -0
  40. package/docs/MUSUBIv1.6.1-enhancement_roadmap_20260105.md +291 -0
  41. package/docs/MUSUBIv2.2.0-USERGUIDE.md +2079 -0
  42. package/docs/ROADMAP-v1.5.md +116 -0
  43. package/docs/SwarmCoding.md +1284 -0
  44. package/docs/Test-prompt.md +105 -0
  45. package/docs/USER-GUIDE-v1.8.0.md +2371 -0
  46. package/docs/USER-GUIDE.ja.md +2147 -0
  47. package/docs/USER-GUIDE.md +2847 -0
  48. package/docs/YATA-GLOBAL-GUIDE.ja.md +750 -0
  49. package/docs/YATA-GLOBAL-GUIDE.md +595 -0
  50. package/docs/YATA-LOCAL-GUIDE.ja.md +989 -0
  51. package/docs/YATA-LOCAL-GUIDE.md +730 -0
  52. package/docs/adr/0001-real-time-pattern-learning-architecture-for-v1-5-0.md +75 -0
  53. package/docs/adr/0002-pattern-sharing-protocol-for-cross-team-collaborat.md +79 -0
  54. package/docs/adr/0003-owl-2-rl-implementation-strategy-for-advanced-infe.md +90 -0
  55. package/docs/enterprise-knowledge-management.md +1737 -0
  56. package/docs/evolution-from-musubi-to-musubix.md +2170 -0
  57. package/docs/getting-started-with-sdd.md +1602 -0
  58. package/docs/moodle-refactering-codegraph-musubix.md +391 -0
  59. package/docs/moodle-refactering-codegraph.md +278 -0
  60. package/docs/overview/MUSUBIX-CodeGraph.md +322 -0
  61. package/docs/overview/MUSUBIX-Core.md +671 -0
  62. package/docs/overview/MUSUBIX-Decisions.md +494 -0
  63. package/docs/overview/MUSUBIX-FormalVerify.md +566 -0
  64. package/docs/overview/MUSUBIX-Knowledge.md +1231 -0
  65. package/docs/overview/MUSUBIX-Learning.md +837 -0
  66. package/docs/overview/MUSUBIX-MCP-Server.md +535 -0
  67. package/docs/overview/MUSUBIX-Overview.md +264 -0
  68. package/docs/overview/MUSUBIX-Phase1-Complete.md +271 -0
  69. package/docs/overview/MUSUBIX-Phase2-Complete.md +310 -0
  70. package/docs/overview/MUSUBIX-Policy.md +477 -0
  71. package/docs/overview/MUSUBIX-Roadmap-v2.md +399 -0
  72. package/docs/overview/MUSUBIX-Security-Plan.md +939 -0
  73. package/docs/overview/MUSUBIX-Security-v2.1.md +668 -0
  74. package/docs/overview/MUSUBIX-Security.md +891 -0
  75. package/docs/overview/MUSUBIX-YATA.md +666 -0
  76. package/docs/overview/MUSUBIX-v2.2.0-Advanced-Learning.md +513 -0
  77. package/docs/overview/Neuro-SymbolicAI.md +159 -0
  78. package/docs/packages/knowledge.md +594 -0
  79. package/docs/qiita-linux-kernel-knowledge-graph.md +596 -0
  80. package/package.json +56 -51
  81. package/scripts/generate-quality-gate-report.ts +106 -0
  82. package/scripts/postinstall.js +94 -0
  83. package/steering/.musubi-version +1 -0
  84. package/steering/product.ja.md +572 -0
  85. package/steering/project.yml +66 -0
  86. package/steering/rules/constitution.md +491 -0
  87. package/steering/structure.ja.md +503 -0
  88. package/steering/tech.ja.md +208 -0
  89. package/dist/index.d.ts +0 -25
  90. package/dist/index.d.ts.map +0 -1
  91. package/dist/index.js +0 -74
  92. package/dist/index.js.map +0 -1
@@ -0,0 +1,2147 @@
1
+ # MUSUBIX ユーザーガイド
2
+
3
+ > Neuro-Symbolic AI による仕様駆動開発システム
4
+
5
+ ## 目次
6
+
7
+ 1. [はじめに](#はじめに)
8
+ 2. [インストール](#インストール)
9
+ 3. [CLIの使い方](#cliの使い方)
10
+ 4. [クイックスタート](#クイックスタート)
11
+ 5. [基本的なワークフロー](#基本的なワークフロー)
12
+ 6. [要件フェーズ](#要件フェーズ)
13
+ 7. [設計フェーズ](#設計フェーズ)
14
+ 8. [タスクフェーズ](#タスクフェーズ)
15
+ 9. [検証フェーズ](#検証フェーズ)
16
+ 10. [自己学習システム](#自己学習システム)
17
+ 11. [C4コード生成](#c4コード生成)
18
+ 12. [シンボリック推論](#シンボリック推論) *(v1.2.0)*
19
+ 13. [正誤性検証](#正誤性検証) *(v1.4.1)*
20
+ 14. [高度な推論](#高度な推論) *(v1.4.5)*
21
+ 15. [対話的REPLモード](#対話的replモード) *(v1.5.0)*
22
+ 16. [YATA Local](#yata-local) *(v1.6.3)*
23
+ 17. [YATA Global](#yata-global) *(v1.6.3)*
24
+ 18. [KGPR - Knowledge Graph Pull Request](#kgpr---knowledge-graph-pull-request) *(v1.6.4)*
25
+ 19. [YATA プラットフォーム拡張](#yata-プラットフォーム拡張) *(v1.7.0)*
26
+ 20. [形式検証](#形式検証) *(v1.7.5)*
27
+ 21. [セキュリティ分析](#セキュリティ分析) *(v1.8.0)*
28
+ 22. [MCPサーバー連携](#mcpサーバー連携)
29
+ 23. [YATA知識グラフ](#yata知識グラフ)
30
+ 24. [ベストプラクティス](#ベストプラクティス)
31
+ 25. [トラブルシューティング](#トラブルシューティング)
32
+
33
+ ---
34
+
35
+ ## はじめに
36
+
37
+ ### MUSUBIXとは?
38
+
39
+ MUSUBIXは、**MUSUBI**(仕様駆動開発LLM)と**YATA**(知識グラフ)を組み合わせた**ニューロシンボリックAIシステム**です。
40
+
41
+ ```
42
+ MUSUBIX = MUSUBI (LLM) + YATA (Knowledge Graph)
43
+ ```
44
+
45
+ ### 主な特徴
46
+
47
+ - 🎯 **仕様駆動開発**: EARS形式の要件から実装まで一貫した開発
48
+ - 🏛️ **9条憲法**: 品質を保証する9つの原則に基づく開発
49
+ - 🔗 **完全なトレーサビリティ**: 要件→設計→タスク→テストの追跡
50
+ - 🧠 **知識グラフ統合**: YATAによるコンテキスト認識
51
+ - 🌐 **MCP対応**: Model Context Protocol による柔軟な統合
52
+
53
+ ### 9条憲法(Constitutional Articles)
54
+
55
+ | 条項 | 名称 | 説明 |
56
+ |------|------|------|
57
+ | I | プロジェクトメモリ | 一貫したプロジェクトコンテキストの維持 |
58
+ | II | 要件仕様 | EARS形式の完全な要件定義 |
59
+ | III | 設計文書 | C4モデル + ADRによる設計 |
60
+ | IV | タスク分解 | トレーサブルなタスク生成 |
61
+ | V | トレーサビリティ | 双方向の追跡性 |
62
+ | VI | 説明可能性 | AI判断の透明性 |
63
+ | VII | 統合性 | シームレスな統合 |
64
+ | VIII | 適応性 | 柔軟な方法論対応 |
65
+ | IX | 品質保証 | 継続的な品質確保 |
66
+
67
+ ---
68
+
69
+ ## インストール
70
+
71
+ ### 前提条件
72
+
73
+ | 項目 | 要件 |
74
+ |------|------|
75
+ | **Node.js** | >= 20.0.0 |
76
+ | **npm** | >= 10.0.0 |
77
+ | **TypeScript** | >= 5.3(開発時) |
78
+
79
+ ### 方法1: npm グローバルインストール(推奨)
80
+
81
+ ```bash
82
+ # グローバルインストール
83
+ npm install -g musubix
84
+
85
+ # バージョン確認
86
+ musubix --version
87
+ musubix-mcp --version
88
+ ```
89
+
90
+ ### 方法2: npx で直接実行
91
+
92
+ ```bash
93
+ # インストールなしで実行
94
+ npx musubix --help
95
+ npx musubix init my-project
96
+
97
+ # MCPサーバー起動
98
+ npx @nahisaho/musubix-mcp-server
99
+ npx musubix-mcp --transport stdio
100
+ ```
101
+
102
+ ### 方法3: プロジェクトへのインストール
103
+
104
+ ```bash
105
+ # 個別パッケージのインストール
106
+ npm install @nahisaho/musubix-core
107
+ npm install @nahisaho/musubix-mcp-server
108
+ npm install @nahisaho/musubix-yata-client # YATA連携用(オプション)
109
+ ```
110
+
111
+ ### 方法4: ソースからビルド
112
+
113
+ ```bash
114
+ # リポジトリをクローン
115
+ git clone https://github.com/nahisaho/MUSUBIX.git
116
+ cd MUSUBIX
117
+
118
+ # 依存関係インストール & ビルド
119
+ npm install
120
+ npm run build
121
+ ```
122
+
123
+ ### YATA のインストール(オプション)
124
+
125
+ 知識グラフ機能を使用する場合は、YATA を別途インストールします:
126
+
127
+ ```bash
128
+ # YATA リポジトリをクローン
129
+ git clone https://github.com/nahisaho/YATA.git
130
+ cd YATA
131
+
132
+ # uv で依存関係をインストール
133
+ uv sync --all-packages
134
+
135
+ # サーバー起動
136
+ uv run yata serve
137
+ ```
138
+
139
+ 詳細は [INSTALL-GUIDE.ja.md](INSTALL-GUIDE.ja.md) を参照してください。
140
+
141
+ ### プロジェクト初期化
142
+
143
+ ```bash
144
+ # MUSUBIXプロジェクトの初期化
145
+ musubix init my-project
146
+ # または
147
+ npx musubix init my-project
148
+
149
+ # steering ディレクトリの確認
150
+ ls steering/
151
+ # product.md structure.md tech.md rules/
152
+ ```
153
+
154
+ ---
155
+
156
+ ## CLIの使い方
157
+
158
+ ### musubix コマンド
159
+
160
+ MUSUBIXのメインCLI:
161
+
162
+ ```bash
163
+ # ヘルプ表示
164
+ musubix --help
165
+
166
+ # バージョン表示
167
+ musubix --version
168
+
169
+ # プロジェクト初期化
170
+ musubix init [path] [options]
171
+
172
+ # オプション
173
+ # --name <name> プロジェクト名
174
+ # --template <type> テンプレート(default, minimal, full)
175
+ # --force 既存ファイルを上書き
176
+ # --json JSON形式で出力
177
+ # --verbose 詳細出力
178
+ ```
179
+
180
+ ### musubix-mcp コマンド
181
+
182
+ MCPサーバーの起動:
183
+
184
+ ```bash
185
+ # ヘルプ表示
186
+ musubix-mcp --help
187
+
188
+ # stdio モードで起動(デフォルト)
189
+ musubix-mcp
190
+ musubix-mcp --transport stdio
191
+
192
+ # SSE モードで起動
193
+ musubix-mcp --transport sse --port 8080
194
+ ```
195
+
196
+ | オプション | 説明 |
197
+ |-----------|------|
198
+ | `-t, --transport` | トランスポート: `stdio` または `sse` |
199
+ | `-p, --port` | SSE モードのポート(デフォルト: 3000) |
200
+ | `-h, --help` | ヘルプ表示 |
201
+ | `-v, --version` | バージョン表示 |
202
+
203
+ ---
204
+
205
+ ## クイックスタート
206
+
207
+ ### 5分で始めるMUSUBIX
208
+
209
+ ```typescript
210
+ import {
211
+ createRequirementsAnalyzer,
212
+ createC4ModelGenerator,
213
+ createTaskGenerator,
214
+ createConstitutionalValidator
215
+ } from '@nahisaho/musubix-core';
216
+
217
+ // 1. 要件の分析
218
+ const analyzer = createRequirementsAnalyzer();
219
+ const requirement = analyzer.analyze(`
220
+ ユーザーがログインボタンをクリックしたとき、
221
+ システムは認証画面を表示しなければならない。
222
+ `);
223
+
224
+ console.log('要件ID:', requirement.id);
225
+ console.log('タイプ:', requirement.type);
226
+
227
+ // 2. 設計の生成
228
+ const c4Generator = createC4ModelGenerator();
229
+ const diagram = c4Generator.generateContext({
230
+ name: '認証システム',
231
+ description: 'ユーザー認証を管理するシステム'
232
+ });
233
+
234
+ console.log('C4図:', diagram.export('mermaid'));
235
+
236
+ // 3. タスクの生成
237
+ const taskGenerator = createTaskGenerator();
238
+ const tasks = taskGenerator.generate([requirement]);
239
+
240
+ console.log('生成されたタスク:', tasks.length);
241
+
242
+ // 4. 検証
243
+ const validator = createConstitutionalValidator();
244
+ const result = validator.validate(requirement);
245
+
246
+ console.log('検証結果:', result.valid ? '合格' : '不合格');
247
+ ```
248
+
249
+ ---
250
+
251
+ ## 基本的なワークフロー
252
+
253
+ ### SDDワークフロー概要
254
+
255
+ ```
256
+ ┌─────────────────────────────────────────────────────────────┐
257
+ │ SDDワークフロー │
258
+ ├─────────────────────────────────────────────────────────────┤
259
+ │ │
260
+ │ ① ステアリング プロジェクトコンテキストの設定 │
261
+ │ ↓ │
262
+ │ ② 要件定義 EARS形式で要件を記述 │
263
+ │ ↓ │
264
+ │ ③ 設計 C4モデル + ADRの作成 │
265
+ │ ↓ │
266
+ │ ④ タスク生成 実装タスクへの分解 │
267
+ │ ↓ │
268
+ │ ⑤ 実装 コード生成・開発 │
269
+ │ ↓ │
270
+ │ ⑥ 検証 憲法に基づく検証 │
271
+ │ ↓ │
272
+ │ ⑦ レビュー 品質レビューゲート │
273
+ │ │
274
+ └─────────────────────────────────────────────────────────────┘
275
+ ```
276
+
277
+ ### ステアリングファイル
278
+
279
+ プロジェクトの基盤となる設定ファイル:
280
+
281
+ ```
282
+ steering/
283
+ ├── product.md # プロダクト情報
284
+ ├── structure.md # アーキテクチャパターン
285
+ ├── tech.md # 技術スタック
286
+ └── rules/
287
+ └── constitution.md # 9条憲法
288
+ ```
289
+
290
+ ---
291
+
292
+ ## 要件フェーズ
293
+
294
+ ### EARS形式による要件定義
295
+
296
+ **EARS (Easy Approach to Requirements Syntax)** は、明確で検証可能な要件を書くための形式です。
297
+
298
+ #### 基本パターン
299
+
300
+ ```
301
+ [条件] [主語] [助動詞] [動作] [目的語]
302
+ ```
303
+
304
+ #### 例
305
+
306
+ ```
307
+ 【機能要件】
308
+ ユーザーがログインフォームで正しい認証情報を入力したとき、
309
+ システムはダッシュボード画面を表示しなければならない。
310
+
311
+ 【非機能要件】
312
+ システムは、すべてのAPIリクエストに対して
313
+ 500ミリ秒以内にレスポンスを返さなければならない。
314
+
315
+ 【制約】
316
+ システムは、個人情報保護法に準拠して
317
+ ユーザーデータを暗号化しなければならない。
318
+ ```
319
+
320
+ ### RequirementsAnalyzer の使用
321
+
322
+ ```typescript
323
+ import { createRequirementsAnalyzer } from '@nahisaho/musubix-core';
324
+
325
+ const analyzer = createRequirementsAnalyzer({
326
+ strictMode: true, // 厳密な検証
327
+ validateEARS: true, // EARS形式の検証
328
+ autoClassify: true // 自動分類
329
+ });
330
+
331
+ // 要件テキストの分析
332
+ const result = analyzer.analyze(`
333
+ ユーザーが商品をカートに追加したとき、
334
+ システムはカート内の合計金額を更新しなければならない。
335
+ `);
336
+
337
+ console.log('ID:', result.id); // REQ-001
338
+ console.log('タイプ:', result.type); // functional
339
+ console.log('優先度:', result.priority); // must
340
+ ```
341
+
342
+ ### RequirementsDecomposer の使用
343
+
344
+ 複雑な要件を小さな単位に分解:
345
+
346
+ ```typescript
347
+ import { createRequirementsDecomposer } from '@nahisaho/musubix-core';
348
+
349
+ const decomposer = createRequirementsDecomposer({
350
+ maxDepth: 4, // 最大分解深度
351
+ targetUnitSize: 4 // 目標単位サイズ(時間)
352
+ });
353
+
354
+ const result = decomposer.decompose(requirement, 'functional');
355
+
356
+ console.log('分解単位数:', result.units.length);
357
+ console.log('推定総工数:', result.stats.estimatedTotalEffort);
358
+
359
+ // Markdownでエクスポート
360
+ const markdown = decomposer.exportMarkdown(result);
361
+ ```
362
+
363
+ ---
364
+
365
+ ## 設計フェーズ
366
+
367
+ ### C4モデルの生成
368
+
369
+ C4モデルは4つのレベルでシステムを表現します:
370
+
371
+ 1. **Context**: システムの境界と外部エンティティ
372
+ 2. **Container**: アプリケーション・データストアの構成
373
+ 3. **Component**: コンテナ内のコンポーネント
374
+ 4. **Code**: コードレベルの詳細
375
+
376
+ ```typescript
377
+ import { createC4ModelGenerator } from '@nahisaho/musubix-core';
378
+
379
+ const generator = createC4ModelGenerator({
380
+ defaultFormat: 'mermaid'
381
+ });
382
+
383
+ // コンテキスト図の生成
384
+ const contextDiagram = generator.generateContext({
385
+ name: 'Eコマースシステム',
386
+ description: 'オンラインショッピングプラットフォーム',
387
+ actors: [
388
+ { name: '顧客', description: '商品を購入するユーザー' },
389
+ { name: '管理者', description: 'システムを管理するスタッフ' }
390
+ ],
391
+ externalSystems: [
392
+ { name: '決済システム', description: 'クレジットカード決済' },
393
+ { name: '配送システム', description: '物流管理' }
394
+ ]
395
+ });
396
+
397
+ // Mermaidでエクスポート
398
+ console.log(generator.export(contextDiagram, 'mermaid'));
399
+ ```
400
+
401
+ ### ADR(アーキテクチャ決定記録)
402
+
403
+ 重要なアーキテクチャ決定を記録:
404
+
405
+ ```typescript
406
+ import { createADRGenerator } from '@nahisaho/musubix-core';
407
+
408
+ const adrGenerator = createADRGenerator({
409
+ template: 'madr',
410
+ outputFormat: 'markdown'
411
+ });
412
+
413
+ const adr = adrGenerator.generate({
414
+ title: 'TypeScriptの採用',
415
+ status: 'accepted',
416
+ context: 'プロジェクトの言語選定が必要',
417
+ decision: 'TypeScriptを採用する',
418
+ rationale: '型安全性とIDEサポートの向上',
419
+ consequences: {
420
+ positive: ['バグの早期発見', 'リファクタリングの容易さ'],
421
+ negative: ['学習コスト', 'ビルド時間の増加']
422
+ },
423
+ alternatives: [
424
+ { name: 'JavaScript', reason: '型がないため却下' },
425
+ { name: 'Flow', reason: 'エコシステムが小さいため却下' }
426
+ ]
427
+ });
428
+
429
+ console.log(adr.export());
430
+ ```
431
+
432
+ ---
433
+
434
+ ## タスクフェーズ
435
+
436
+ ### タスクの自動生成
437
+
438
+ 要件から実装タスクを生成:
439
+
440
+ ```typescript
441
+ import { createTaskGenerator } from '@nahisaho/musubix-core';
442
+
443
+ const taskGenerator = createTaskGenerator({
444
+ estimateEffort: true, // 工数見積もり
445
+ includeTests: true, // テストタスクを含む
446
+ assignmentStrategy: 'balanced'
447
+ });
448
+
449
+ const tasks = taskGenerator.generate(requirements);
450
+
451
+ for (const task of tasks) {
452
+ console.log(`
453
+ タスク: ${task.id}
454
+ タイトル: ${task.title}
455
+ 要件参照: ${task.requirementRef}
456
+ 推定工数: ${task.estimatedHours}時間
457
+ ステータス: ${task.status}
458
+ `);
459
+ }
460
+ ```
461
+
462
+ ### タスクの優先順位付け
463
+
464
+ ```typescript
465
+ // 優先順位付け
466
+ const prioritized = taskGenerator.prioritize(tasks, {
467
+ criteria: ['dependency', 'risk', 'value'],
468
+ weights: [0.4, 0.3, 0.3]
469
+ });
470
+
471
+ console.log('優先度順タスク:');
472
+ prioritized.forEach((task, index) => {
473
+ console.log(`${index + 1}. ${task.title} (スコア: ${task.priorityScore})`);
474
+ });
475
+ ```
476
+
477
+ ---
478
+
479
+ ## 検証フェーズ
480
+
481
+ ### 憲法に基づく検証
482
+
483
+ ```typescript
484
+ import { createConstitutionalValidator } from '@nahisaho/musubix-core';
485
+
486
+ const validator = createConstitutionalValidator({
487
+ strictMode: true,
488
+ articles: ['all'] // すべての条項を検証
489
+ });
490
+
491
+ const result = validator.validate(artifact);
492
+
493
+ console.log('検証結果:', result.valid ? '✅ 合格' : '❌ 不合格');
494
+ console.log('スコア:', result.score);
495
+ console.log('エラー数:', result.errors.length);
496
+ console.log('警告数:', result.warnings.length);
497
+
498
+ // 詳細レポート
499
+ if (!result.valid) {
500
+ for (const error of result.errors) {
501
+ console.log(`
502
+ 条項: ${error.article}
503
+ メッセージ: ${error.message}
504
+ 推奨対応: ${error.recommendation}
505
+ `);
506
+ }
507
+ }
508
+ ```
509
+
510
+ ### カバレッジの確認
511
+
512
+ ```typescript
513
+ console.log('カバレッジ:');
514
+ console.log(` 要件: ${result.coverage.requirements}%`);
515
+ console.log(` 設計: ${result.coverage.design}%`);
516
+ console.log(` タスク: ${result.coverage.tasks}%`);
517
+ console.log(` テスト: ${result.coverage.tests}%`);
518
+ ```
519
+
520
+ ---
521
+
522
+ ## 自己学習システム
523
+
524
+ MUSUBIXには、フィードバック収集とパターン抽出により改善を続ける自己学習システムが含まれています。
525
+
526
+ ### 学習CLIコマンド
527
+
528
+ ```bash
529
+ # 学習状態ダッシュボードを表示
530
+ musubix learn status
531
+
532
+ # 成果物にフィードバックを記録
533
+ musubix learn feedback <artifact-id> --type accept|reject|modify --artifact-type requirement|design|code|test --reason "説明"
534
+
535
+ # 学習済みパターン一覧を表示
536
+ musubix learn patterns
537
+
538
+ # パターンを手動登録
539
+ musubix learn add-pattern <name> --category code|design|requirement|test --action prefer|avoid --description "パターンの説明"
540
+
541
+ # パターンを削除
542
+ musubix learn remove-pattern <pattern-id>
543
+
544
+ # コンテキストベースの推奨を取得
545
+ musubix learn recommend --artifact-type code
546
+
547
+ # 未使用パターンの減衰を適用
548
+ musubix learn decay
549
+
550
+ # 学習データをエクスポート(v1.4.0 拡張)
551
+ musubix learn export --output learning-data.json
552
+ # オプション:
553
+ # --privacy-filter 機密情報を除去(APIキー、パスワード等)
554
+ # --patterns-only パターンのみエクスポート
555
+ # --feedback-only フィードバックのみエクスポート
556
+ # --min-confidence <n> 最小信頼度(0-1)
557
+
558
+ # 学習データをインポート(v1.4.0 マージ戦略対応)
559
+ musubix learn import learning-data.json
560
+ # オプション:
561
+ # --merge-strategy <skip|overwrite|merge> 重複の処理方法
562
+ # --dry-run 変更をプレビュー
563
+ # --patterns-only パターンのみインポート
564
+ # --feedback-only フィードバックのみインポート
565
+ ```
566
+
567
+ ### プログラムからの使用
568
+
569
+ ```typescript
570
+ import { createLearningEngine } from '@nahisaho/musubix-core';
571
+
572
+ const learningEngine = createLearningEngine();
573
+
574
+ // フィードバックを記録
575
+ await learningEngine.recordFeedback({
576
+ type: 'accept',
577
+ artifactType: 'code',
578
+ artifactId: 'AUTH-001',
579
+ reason: 'JWT認証の良い実装'
580
+ });
581
+
582
+ // 推奨を取得
583
+ const recommendations = await learningEngine.getRecommendations({
584
+ artifactType: 'code',
585
+ context: 'authentication'
586
+ });
587
+
588
+ // 学習データをエクスポート
589
+ const data = await learningEngine.exportData();
590
+ ```
591
+
592
+ ### パターン抽出
593
+
594
+ 類似のフィードバックが複数回(デフォルト閾値:3回)記録されると、パターンが自動的に抽出されます。
595
+
596
+ ```typescript
597
+ // パターンは出現ごとに信頼度が上昇
598
+ // 高信頼度パターン(≥70%)は推奨に表示される
599
+ const stats = await learningEngine.getStats();
600
+ console.log(`総パターン数: ${stats.totalPatterns}`);
601
+ console.log(`高信頼度パターン: ${stats.highConfidencePatterns}`);
602
+ ```
603
+
604
+ ---
605
+
606
+ ## C4コード生成
607
+
608
+ C4設計ドキュメントからTypeScriptスケルトンコードを生成します。
609
+
610
+ ### CLIの使用
611
+
612
+ ```bash
613
+ # C4設計からコード生成
614
+ musubix codegen generate design-c4.md --output src/
615
+
616
+ # 言語を指定
617
+ musubix codegen generate design-c4.md --output src/ --language typescript
618
+ ```
619
+
620
+ ### 生成されるコード構造
621
+
622
+ 以下のようなコンポーネントを持つC4設計から:
623
+
624
+ | ID | Name | Type | Description |
625
+ |----|------|------|-------------|
626
+ | auth | AuthService | component | 認証 |
627
+
628
+ MUSUBIXは以下を生成します:
629
+
630
+ ```typescript
631
+ // auth-service.ts
632
+ export interface IAuthService {
633
+ authenticate(credentials: { username: string; password: string }): Promise<{ token: string }>;
634
+ validate(token: string): Promise<boolean>;
635
+ }
636
+
637
+ export class AuthService implements IAuthService {
638
+ async authenticate(credentials: { username: string; password: string }): Promise<{ token: string }> {
639
+ // TODO: authenticateを実装
640
+ throw new Error('Not implemented');
641
+ }
642
+
643
+ async validate(token: string): Promise<boolean> {
644
+ // TODO: validateを実装
645
+ throw new Error('Not implemented');
646
+ }
647
+ }
648
+
649
+ export function createAuthService(): IAuthService {
650
+ return new AuthService();
651
+ }
652
+ ```
653
+
654
+ ---
655
+
656
+ ## シンボリック推論
657
+
658
+ *(v1.2.0 新機能)*
659
+
660
+ ### 概要
661
+
662
+ シンボリック推論は、形式検証と知識グラフベースの推論を適用して、LLM出力を強化します。このハイブリッドアプローチ(ニューロシンボリック)は、ニューラルネットワークの創造性とシンボリックロジックの精度を組み合わせます。
663
+
664
+ ### 主要コンポーネント
665
+
666
+ | コンポーネント | 説明 |
667
+ |--------------|------|
668
+ | `SemanticCodeFilterPipeline` | コード品質のためのLLM出力フィルタリング |
669
+ | `HallucinationDetector` | ハルシネーション(幻覚)出力の検出と防止 |
670
+ | `EarsToFormalSpecConverter` | EARS要件からZ3形式仕様への変換 |
671
+ | `Z3Adapter` | 形式検証のためのZ3ソルバーインターフェース |
672
+ | `QualityGateValidator` | 17品質ゲートチェックに対する検証 |
673
+
674
+ ### 使用方法
675
+
676
+ #### セマンティックコードフィルタリング
677
+
678
+ ```typescript
679
+ import { SemanticCodeFilterPipeline } from '@nahisaho/musubix-core';
680
+
681
+ const pipeline = new SemanticCodeFilterPipeline({
682
+ enableHallucinationDetection: true,
683
+ maxRetries: 3
684
+ });
685
+
686
+ const result = await pipeline.filter({
687
+ code: generatedCode,
688
+ context: { language: 'typescript', domain: 'authentication' }
689
+ });
690
+
691
+ if (result.isValid) {
692
+ console.log('コードが検証に合格:', result.filteredCode);
693
+ } else {
694
+ console.log('問題が検出されました:', result.issues);
695
+ }
696
+ ```
697
+
698
+ #### ハルシネーション検出
699
+
700
+ ```typescript
701
+ import { HallucinationDetector } from '@nahisaho/musubix-core';
702
+
703
+ const detector = new HallucinationDetector();
704
+
705
+ const analysis = await detector.analyze({
706
+ response: llmResponse,
707
+ groundTruth: knownFacts,
708
+ context: projectContext
709
+ });
710
+
711
+ console.log('信頼度スコア:', analysis.confidence);
712
+ console.log('ハルシネーションリスク:', analysis.risks);
713
+ ```
714
+
715
+ #### EARSから形式仕様への変換
716
+
717
+ ```typescript
718
+ import { EarsToFormalSpecConverter } from '@nahisaho/musubix-core';
719
+
720
+ const converter = new EarsToFormalSpecConverter();
721
+
722
+ const formalSpec = await converter.convert({
723
+ earsRequirement: 'WHEN user clicks login, THE system SHALL authenticate within 2 seconds',
724
+ requirementId: 'REQ-AUTH-001'
725
+ });
726
+
727
+ // Z3互換の仕様を返す
728
+ console.log(formalSpec.z3Expression);
729
+ ```
730
+
731
+ #### 品質ゲート検証
732
+
733
+ ```typescript
734
+ import { QualityGateValidator } from '@nahisaho/musubix-core';
735
+
736
+ const validator = new QualityGateValidator();
737
+
738
+ const gateResult = await validator.validate({
739
+ requirements: requirementsList,
740
+ designs: designDocuments,
741
+ tasks: taskList
742
+ });
743
+
744
+ console.log('全ゲート合格:', gateResult.allPassed);
745
+ console.log('ゲート詳細:', gateResult.gates);
746
+ // EARS準拠、トレーサビリティなど17の品質チェック
747
+ ```
748
+
749
+ ### 品質ゲートチェック
750
+
751
+ | ゲート | 説明 |
752
+ |--------|------|
753
+ | EARS準拠 | 要件がEARSパターンに従っているか |
754
+ | 一意のID | すべての成果物に一意の識別子があるか |
755
+ | トレーサビリティ | 完全なトレーサビリティチェーンが存在するか |
756
+ | 設計カバレッジ | すべての要件に設計があるか |
757
+ | タスクカバレッジ | すべての設計にタスクがあるか |
758
+ | 孤立なし | 孤立した要件やタスクがないか |
759
+ | 完全性 | すべての必須フィールドが存在するか |
760
+ | ... | その他10の品質チェック |
761
+
762
+ ---
763
+
764
+ ## 正誤性検証
765
+
766
+ *(v1.4.1 新機能)*
767
+
768
+ ### 概要
769
+
770
+ 正誤性検証は、知識グラフへのトリプル追加時にデータの整合性を確保します。OWL制約に基づいて違反を検出し、不正なデータの登録を防止します。
771
+
772
+ ### 検証タイプ
773
+
774
+ | タイプ | 説明 | 重大度 |
775
+ |--------|------|--------|
776
+ | `disjoint-class-membership` | 排他的クラスの両方に所属 | error |
777
+ | `functional-property-violation` | 関数型プロパティに複数値 | error |
778
+ | `inverse-functional-violation` | 同じ値が複数の主語にマップ | error |
779
+ | `asymmetric-violation` | 非対称プロパティに逆方向が存在 | error |
780
+ | `irreflexive-violation` | 非反射プロパティで自己参照 | error |
781
+ | `duplicate-triple` | 完全一致の重複トリプル | warning |
782
+ | `circular-dependency` | subClassOfの循環チェーン | error |
783
+
784
+ ### 使用方法
785
+
786
+ #### 検証付きトリプル追加
787
+
788
+ ```typescript
789
+ import { N3Store } from '@nahisaho/musubix-ontology-mcp';
790
+
791
+ // 追加時検証を有効化
792
+ const store = new N3Store({}, true);
793
+
794
+ // 検証付き追加
795
+ const result = store.addTripleValidated({
796
+ subject: 'http://example.org/Person1',
797
+ predicate: 'http://example.org/hasMother',
798
+ object: 'http://example.org/Mother1'
799
+ });
800
+
801
+ if (!result.success) {
802
+ console.error('検証エラー:', result.validation.errors);
803
+ }
804
+ ```
805
+
806
+ #### ストア全体の整合性チェック
807
+
808
+ ```typescript
809
+ // ストア全体をチェック
810
+ const consistency = store.checkConsistency();
811
+
812
+ if (!consistency.consistent) {
813
+ for (const violation of consistency.violations) {
814
+ console.log(`${violation.type}: ${violation.message}`);
815
+ console.log('関連トリプル:', violation.triples);
816
+ }
817
+
818
+ // 修正提案を取得
819
+ for (const suggestion of consistency.suggestions) {
820
+ console.log(`提案: ${suggestion.suggestion}`);
821
+ console.log(`自動修正可能: ${suggestion.autoFixable}`);
822
+ }
823
+ }
824
+ ```
825
+
826
+ #### 直接バリデータを使用
827
+
828
+ ```typescript
829
+ import { ConsistencyValidator } from '@nahisaho/musubix-ontology-mcp';
830
+
831
+ const validator = new ConsistencyValidator({
832
+ checkDisjointClasses: true,
833
+ checkFunctionalProperties: true,
834
+ checkDuplicates: true,
835
+ checkCircularDependencies: true
836
+ });
837
+
838
+ // 追加前に検証
839
+ const validation = validator.validateTriple(newTriple, existingTriples);
840
+ if (!validation.valid) {
841
+ console.error(validation.errors);
842
+ }
843
+
844
+ // 重複を検出
845
+ const duplicates = validator.findDuplicates(allTriples);
846
+ const semanticDuplicates = validator.findSemanticDuplicates(allTriples);
847
+ ```
848
+
849
+ ---
850
+
851
+ ## 高度な推論
852
+
853
+ *(v1.4.5 新機能)*
854
+
855
+ ### 概要
856
+
857
+ 高度な推論は、知識グラフにOWL 2 RL推論とDatalog評価機能を提供します。暗黙的な事実の実体化、ルールベースの推論、人間が理解しやすい説明の生成をサポートします。
858
+
859
+ ### 主要コンポーネント
860
+
861
+ | コンポーネント | 説明 |
862
+ |--------------|------|
863
+ | `OWL2RLReasoner` | 20以上のビルトインルールを持つOWL 2 RL推論エンジン |
864
+ | `DatalogEngine` | 階層化評価対応のDatalogエンジン |
865
+ | `InferenceExplainer` | 自然言語での説明生成 |
866
+ | `ProgressReporter` | リアルタイム推論進捗追跡 |
867
+
868
+ ### OWL 2 RL 推論
869
+
870
+ ```typescript
871
+ import { OWL2RLReasoner } from '@nahisaho/musubix-ontology-mcp';
872
+
873
+ const reasoner = new OWL2RLReasoner({
874
+ maxIterations: 100,
875
+ enablePropertyChains: true,
876
+ enableInverseProperties: true
877
+ });
878
+
879
+ // ストアに対して推論を実行
880
+ const result = await reasoner.reason(store, {
881
+ onProgress: (progress) => {
882
+ console.log(`反復 ${progress.iteration}: ${progress.newTriples} 新規トリプル`);
883
+ }
884
+ });
885
+
886
+ console.log(`${result.inferredCount} 個の新しい事実を推論`);
887
+ console.log(`適用ルール: ${result.rulesApplied.join(', ')}`);
888
+ ```
889
+
890
+ ### OWL 2 RL ルール
891
+
892
+ | ルールID | 名称 | 説明 |
893
+ |---------|------|------|
894
+ | `prp-dom` | Property Domain | プロパティのドメインから型を推論 |
895
+ | `prp-rng` | Property Range | プロパティのレンジから型を推論 |
896
+ | `prp-inv1/2` | Inverse Properties | 逆関係を推論 |
897
+ | `prp-trp` | Transitive Properties | 推移的プロパティを連鎖 |
898
+ | `prp-symp` | Symmetric Properties | 対称関係を推論 |
899
+ | `cax-sco` | SubClassOf | クラスメンバーシップを伝播 |
900
+ | `scm-spo` | SubPropertyOf | プロパティの包摂関係 |
901
+ | `eq-rep-s/p/o` | SameAs Replacement | 同一個体の置換 |
902
+
903
+ ### Datalog 評価
904
+
905
+ ```typescript
906
+ import { DatalogEngine } from '@nahisaho/musubix-ontology-mcp';
907
+
908
+ const engine = new DatalogEngine();
909
+
910
+ // ルールを定義
911
+ const rules = [
912
+ {
913
+ head: { predicate: 'ancestor', args: ['?x', '?y'] },
914
+ body: [
915
+ { predicate: 'parent', args: ['?x', '?y'] }
916
+ ]
917
+ },
918
+ {
919
+ head: { predicate: 'ancestor', args: ['?x', '?z'] },
920
+ body: [
921
+ { predicate: 'parent', args: ['?x', '?y'] },
922
+ { predicate: 'ancestor', args: ['?y', '?z'] }
923
+ ]
924
+ }
925
+ ];
926
+
927
+ // ルールを評価
928
+ const result = await engine.evaluate(rules, facts, {
929
+ onProgress: (progress) => {
930
+ console.log(`階層 ${progress.stratum}: ${progress.rule} を評価中`);
931
+ }
932
+ });
933
+
934
+ console.log(`${result.derivedFacts.length} 個の新しい事実を導出`);
935
+ ```
936
+
937
+ ### 推論説明
938
+
939
+ ```typescript
940
+ import { InferenceExplainer, ExplanationFormat } from '@nahisaho/musubix-ontology-mcp';
941
+
942
+ const explainer = new InferenceExplainer(reasoner.getProvenanceLog());
943
+
944
+ // 特定のトリプルの説明を取得
945
+ const explanation = explainer.explain(
946
+ 'http://example.org/Animal',
947
+ 'rdf:type',
948
+ 'owl:Class',
949
+ ExplanationFormat.TEXT
950
+ );
951
+
952
+ console.log(explanation);
953
+ // 出力: "Animal は owl:Class として宣言されているため Class です(ルール cax-sco)"
954
+
955
+ // HTML形式の説明を生成
956
+ const htmlExplanation = explainer.explain(
957
+ subject, predicate, object,
958
+ ExplanationFormat.HTML
959
+ );
960
+ ```
961
+
962
+ ### 進捗レポート
963
+
964
+ ```typescript
965
+ import { createProgressReporter } from '@nahisaho/musubix-ontology-mcp';
966
+
967
+ const reporter = createProgressReporter({
968
+ onProgress: (info) => {
969
+ console.log(`フェーズ: ${info.phase}`);
970
+ console.log(`反復: ${info.iteration}/${info.maxIterations}`);
971
+ console.log(`トリプル数: ${info.totalTriples}`);
972
+ console.log(`新規推論: ${info.newInferences}`);
973
+ },
974
+ throttleMs: 500 // 500ms間隔でレポート
975
+ });
976
+
977
+ await reasoner.reason(store, { progressReporter: reporter });
978
+ ```
979
+
980
+ ---
981
+
982
+ ## 対話的REPLモード
983
+
984
+ *(v1.5.0 新規、v1.6.0 強化)*
985
+
986
+ MUSUBIXは、リアルタイムでコマンドを実行・探索できる対話的REPLシェルを提供します。
987
+
988
+ ### REPLの起動
989
+
990
+ ```bash
991
+ # 対話的REPLを起動
992
+ musubix repl
993
+
994
+ # カスタム履歴ファイルを指定
995
+ musubix repl --history ~/.musubix-repl-history
996
+
997
+ # カラー表示なし
998
+ musubix repl --no-color
999
+ ```
1000
+
1001
+ ### REPL機能
1002
+
1003
+ | 機能 | 説明 |
1004
+ |------|------|
1005
+ | コマンド補完 | TABキーでコマンド・オプションを補完 |
1006
+ | 履歴ナビゲーション | 上下矢印、履歴検索 |
1007
+ | セッション変数 | `$name=value` で設定、`$name` で参照 |
1008
+ | 出力フォーマット | JSON、YAML、テーブル自動整形 |
1009
+ | CLI統合 | CLIコマンドをそのまま実行可能 |
1010
+
1011
+ ### 基本的な使い方
1012
+
1013
+ ```bash
1014
+ musubix> help # すべてのコマンドを表示
1015
+ musubix> help requirements # コマンド詳細を表示
1016
+ musubix> requirements analyze input.md # CLIコマンドを実行
1017
+ musubix> $project=my-app # セッション変数を設定
1018
+ musubix> design generate $project # 変数をコマンドで使用
1019
+ musubix> history # コマンド履歴を表示
1020
+ musubix> exit # REPLを終了
1021
+ ```
1022
+
1023
+ ### セッション変数
1024
+
1025
+ ```bash
1026
+ # 変数の設定
1027
+ musubix> $req=REQ-001
1028
+ musubix> $file=./docs/requirements.md
1029
+
1030
+ # コマンドで使用
1031
+ musubix> requirements validate $file
1032
+ musubix> trace impact $req
1033
+
1034
+ # 特殊変数: $_ は前回の実行結果を保持
1035
+ musubix> requirements analyze input.md
1036
+ musubix> $_ # 前回の結果にアクセス
1037
+ ```
1038
+
1039
+ ### 出力フォーマット
1040
+
1041
+ ```bash
1042
+ # 自動検出(デフォルト)
1043
+ musubix> learn status
1044
+
1045
+ # JSON出力を強制
1046
+ musubix> set format json
1047
+ musubix> learn patterns
1048
+
1049
+ # YAML出力を強制
1050
+ musubix> set format yaml
1051
+
1052
+ # テーブル出力を強制
1053
+ musubix> set format table
1054
+ ```
1055
+
1056
+ ### 履歴管理
1057
+
1058
+ ```bash
1059
+ # 最近のコマンドを表示
1060
+ musubix> history
1061
+
1062
+ # 履歴を検索(Ctrl+Rスタイル)
1063
+ musubix> history search requirements
1064
+
1065
+ # 履歴をクリア
1066
+ musubix> history clear
1067
+ ```
1068
+
1069
+ ### REPLコンポーネント
1070
+
1071
+ | コンポーネント | 役割 |
1072
+ |---------------|------|
1073
+ | `ReplEngine` | REPLメインコントローラー |
1074
+ | `CommandCompleter` | TAB補完プロバイダー |
1075
+ | `HistoryManager` | コマンド履歴の永続化 |
1076
+ | `SessionState` | 変数ストレージ |
1077
+ | `OutputFormatter` | JSON/YAML/テーブル出力 |
1078
+ | `PromptRenderer` | 動的プロンプト表示 |
1079
+
1080
+ ---
1081
+
1082
+ ## YATA Local
1083
+
1084
+ *(v1.6.3 新規)*
1085
+
1086
+ YATA Localは、高性能なSQLiteベースのローカル知識グラフです。推論機能を内蔵し、シングルユーザー・オフライン環境でデータ主権と速度が重要な場合に最適です。
1087
+
1088
+ ### 機能
1089
+
1090
+ | 機能 | 説明 |
1091
+ |------|------|
1092
+ | **SQLiteストレージ** | WALモードで並行読み取り、シングルライター |
1093
+ | **全文検索** | FTS5ベースのトリプル検索 |
1094
+ | **グラフ探索** | BFS/DFSアルゴリズム、深度制御 |
1095
+ | **推論エンジン** | 4つのOWL-liteルール(推移性、対称性、逆関係、ドメイン/レンジ) |
1096
+ | **制約** | 4つの検証ルール(カーディナリティ、排他、一意性、必須) |
1097
+ | **ACIDトランザクション** | 完全なトランザクションサポート |
1098
+
1099
+ ### インストール
1100
+
1101
+ ```bash
1102
+ npm install @nahisaho/yata-local
1103
+ ```
1104
+
1105
+ ### クイックスタート
1106
+
1107
+ ```typescript
1108
+ import { YataLocal } from '@nahisaho/yata-local';
1109
+
1110
+ // デフォルト設定で初期化
1111
+ const yata = new YataLocal('./knowledge.db');
1112
+ await yata.initialize();
1113
+
1114
+ // トリプルを追加
1115
+ await yata.addTriple({
1116
+ subject: 'Person:john',
1117
+ predicate: 'hasParent',
1118
+ object: 'Person:mary'
1119
+ });
1120
+
1121
+ // トリプルをクエリ
1122
+ const results = await yata.query({
1123
+ subject: 'Person:john',
1124
+ predicate: 'hasParent'
1125
+ });
1126
+
1127
+ // 全文検索
1128
+ const searchResults = await yata.search('john parent');
1129
+
1130
+ // グラフ探索(BFS)
1131
+ const ancestors = await yata.traverse('Person:john', 'hasParent', {
1132
+ direction: 'outgoing',
1133
+ maxDepth: 5,
1134
+ algorithm: 'bfs'
1135
+ });
1136
+
1137
+ // クリーンアップ
1138
+ await yata.close();
1139
+ ```
1140
+
1141
+ ### 推論エンジン
1142
+
1143
+ YATA Localは4つのOWL-lite推論ルールをサポートします:
1144
+
1145
+ | ルール | 説明 | 例 |
1146
+ |--------|------|-----|
1147
+ | **推移性** | A→BかつB→CならA→C | hasAncestorは推移的 |
1148
+ | **対称性** | A→BならB→A | friendOfは対称的 |
1149
+ | **逆関係** | A→B(P経由)ならB→A(P⁻¹経由) | hasChild ↔ hasParent |
1150
+ | **ドメイン/レンジ** | 述語から型を推論 | hasAgeはPersonを示唆 |
1151
+
1152
+ ```typescript
1153
+ // 推論を実行
1154
+ const inferred = await yata.infer();
1155
+ console.log(`${inferred.length}個の新しいトリプルを推論`);
1156
+ ```
1157
+
1158
+ ### 制約
1159
+
1160
+ ```typescript
1161
+ // 制約を定義
1162
+ await yata.addConstraint({
1163
+ type: 'cardinality',
1164
+ predicate: 'hasSpouse',
1165
+ max: 1
1166
+ });
1167
+
1168
+ // 検証
1169
+ const violations = await yata.validate();
1170
+ if (violations.length > 0) {
1171
+ console.error('制約違反:', violations);
1172
+ }
1173
+ ```
1174
+
1175
+ ### 設定オプション
1176
+
1177
+ ```typescript
1178
+ const yata = new YataLocal('./knowledge.db', {
1179
+ // WALモードで並行性向上(デフォルト: true)
1180
+ walMode: true,
1181
+
1182
+ // FTS5検索を有効化(デフォルト: true)
1183
+ enableSearch: true,
1184
+
1185
+ // 書き込み時に自動推論(デフォルト: false)
1186
+ autoInfer: false,
1187
+
1188
+ // ジャーナルモード(デフォルト: 'wal')
1189
+ journalMode: 'wal'
1190
+ });
1191
+ ```
1192
+
1193
+ ---
1194
+
1195
+ ## YATA Global
1196
+
1197
+ *(v1.6.3 新規)*
1198
+
1199
+ YATA Globalは、チームコラボレーション向けの分散型知識グラフプラットフォームです。共有知識グラフへのREST APIアクセスと、オフラインサポート・インテリジェントな同期機能を提供します。
1200
+
1201
+ ### 機能
1202
+
1203
+ | 機能 | 説明 |
1204
+ |------|------|
1205
+ | **REST API** | HTTP経由の完全なCRUD操作 |
1206
+ | **オフラインキャッシュ** | SQLiteベースのローカルキャッシュ |
1207
+ | **同期エンジン** | Push/Pullと競合解決 |
1208
+ | **競合解決** | Last-write-winsまたはカスタム戦略 |
1209
+ | **認証** | APIキーベースの認証 |
1210
+ | **バッチ操作** | 一括トリプル操作 |
1211
+
1212
+ ### インストール
1213
+
1214
+ ```bash
1215
+ npm install @nahisaho/yata-global
1216
+ ```
1217
+
1218
+ ### クイックスタート
1219
+
1220
+ ```typescript
1221
+ import { YataGlobal } from '@nahisaho/yata-global';
1222
+
1223
+ // クライアントを初期化
1224
+ const yata = new YataGlobal({
1225
+ endpoint: 'https://yata.example.com/api',
1226
+ apiKey: 'your-api-key',
1227
+ graphId: 'project-knowledge'
1228
+ });
1229
+
1230
+ await yata.initialize();
1231
+
1232
+ // トリプルを追加(バッチ)
1233
+ await yata.addTriples([
1234
+ { subject: 'Task:001', predicate: 'assignedTo', object: 'User:alice' },
1235
+ { subject: 'Task:001', predicate: 'status', object: 'in-progress' }
1236
+ ]);
1237
+
1238
+ // フィルタ付きクエリ
1239
+ const tasks = await yata.query({
1240
+ predicate: 'assignedTo',
1241
+ object: 'User:alice'
1242
+ });
1243
+
1244
+ // クリーンアップ
1245
+ await yata.close();
1246
+ ```
1247
+
1248
+ ### オフラインサポート
1249
+
1250
+ YATA Globalは自動同期によるオフラインファースト操作をサポートします:
1251
+
1252
+ ```typescript
1253
+ const yata = new YataGlobal({
1254
+ endpoint: 'https://yata.example.com/api',
1255
+ apiKey: 'your-api-key',
1256
+ graphId: 'project-knowledge',
1257
+
1258
+ // オフライン設定
1259
+ offlineMode: true,
1260
+ cachePath: './yata-cache.db',
1261
+ syncInterval: 60000 // 60秒ごとに自動同期
1262
+ });
1263
+
1264
+ // オフラインでも動作 - ローカルにキャッシュ
1265
+ await yata.addTriple({
1266
+ subject: 'Note:001',
1267
+ predicate: 'content',
1268
+ object: '重要な会議メモ'
1269
+ });
1270
+
1271
+ // オンライン時に手動同期
1272
+ await yata.sync();
1273
+ ```
1274
+
1275
+ ### 競合解決
1276
+
1277
+ ```typescript
1278
+ const yata = new YataGlobal({
1279
+ // ... その他のオプション
1280
+
1281
+ conflictStrategy: 'last-write-wins', // デフォルト
1282
+ // または: 'server-wins', 'client-wins', 'manual'
1283
+
1284
+ onConflict: async (local, remote) => {
1285
+ // カスタム解決ロジック
1286
+ console.log('競合を検出:', local, remote);
1287
+ return remote; // リモート版を優先
1288
+ }
1289
+ });
1290
+ ```
1291
+
1292
+ ### 同期ステータス
1293
+
1294
+ ```typescript
1295
+ // 同期ステータスを確認
1296
+ const status = await yata.getSyncStatus();
1297
+ console.log(`保留中の変更: ${status.pendingPush}`);
1298
+ console.log(`最終同期: ${status.lastSyncAt}`);
1299
+
1300
+ // 完全同期を強制
1301
+ await yata.sync({ force: true });
1302
+ ```
1303
+
1304
+ ### YATA Local vs YATA Global の選択
1305
+
1306
+ | ユースケース | 推奨 |
1307
+ |-------------|------|
1308
+ | 個人用ナレッジベース | YATA Local |
1309
+ | シングルユーザーアプリ | YATA Local |
1310
+ | プライバシー重視のデータ | YATA Local |
1311
+ | チームコラボレーション | YATA Global |
1312
+ | クロスデバイスアクセス | YATA Global |
1313
+ | 共有プロジェクト知識 | YATA Global |
1314
+ | 同期付きオフラインファースト | YATA Global |
1315
+
1316
+ ---
1317
+
1318
+ ## KGPR - Knowledge Graph Pull Request
1319
+
1320
+ *(v1.6.4)*
1321
+
1322
+ KGPR(Knowledge Graph Pull Request)は、GitHub PRと同様のワークフローで、YATA LocalからYATA Globalへ安全に知識グラフを共有する機能です。
1323
+
1324
+ ### ワークフロー
1325
+
1326
+ ```
1327
+ ┌─────────────┐ ┌──────────────┐ ┌───────────────┐
1328
+ │ YATA Local │ ──► │ KGPR (Draft) │ ──► │ YATA Global │
1329
+ │ (ローカルKG) │ │ (差分抽出) │ │ (レビュー・マージ) │
1330
+ └─────────────┘ └──────────────┘ └───────────────┘
1331
+
1332
+ ステータス遷移:
1333
+ draft → open → reviewing → approved/changes_requested → merged/closed
1334
+ ```
1335
+
1336
+ ### プライバシーレベル
1337
+
1338
+ | レベル | フィルタ対象 |
1339
+ |-------|------------|
1340
+ | `strict` | ファイルパス、URL、認証情報、全メタデータ |
1341
+ | `moderate` | ファイルパス、URL、認証情報 |
1342
+ | `none` | フィルタなし |
1343
+
1344
+ ### CLIコマンド
1345
+
1346
+ ```bash
1347
+ # KGPRを作成
1348
+ musubix kgpr create -t "認証パターンの追加"
1349
+
1350
+ # 作成前に差分をプレビュー
1351
+ musubix kgpr diff --namespace myproject --privacy moderate
1352
+
1353
+ # KGPR一覧を表示
1354
+ musubix kgpr list
1355
+
1356
+ # KGPRをレビューに送信
1357
+ musubix kgpr submit <id>
1358
+
1359
+ # KGPR詳細を表示
1360
+ musubix kgpr show <id>
1361
+
1362
+ # マージせずにクローズ
1363
+ musubix kgpr close <id>
1364
+ ```
1365
+
1366
+ ### MCPツール
1367
+
1368
+ | ツール | 説明 |
1369
+ |-------|------|
1370
+ | `kgpr_create` | ローカル知識グラフからKGPRを作成 |
1371
+ | `kgpr_diff` | KGPR作成前に差分をプレビュー |
1372
+ | `kgpr_list` | 全KGPRを一覧表示 |
1373
+ | `kgpr_submit` | KGPRをレビューに送信 |
1374
+ | `kgpr_review` | KGPRをレビュー(approve/changes_requested/commented) |
1375
+
1376
+ ### 使用例
1377
+
1378
+ ```bash
1379
+ # 1. 共有内容をプレビュー
1380
+ musubix kgpr diff --privacy strict
1381
+
1382
+ # 2. 説明付きでKGPRを作成
1383
+ musubix kgpr create -t "Reactパターンの共有" -d "project-xから学習したパターン"
1384
+
1385
+ # 3. KGPRを確認
1386
+ musubix kgpr show KGPR-001
1387
+
1388
+ # 4. レビューに送信
1389
+ musubix kgpr submit KGPR-001
1390
+ ```
1391
+
1392
+ ---
1393
+
1394
+ ## YATA プラットフォーム拡張
1395
+
1396
+ *(v1.7.0)*
1397
+
1398
+ バージョン1.7.0では、YATAプラットフォームに5つの主要機能が追加されました。
1399
+
1400
+ ### Phase 1: インデックス最適化
1401
+
1402
+ YATA Localのクエリパフォーマンスを複合インデックスで最適化。
1403
+
1404
+ ```typescript
1405
+ import { IndexOptimizer } from '@nahisaho/yata-local';
1406
+
1407
+ const optimizer = new IndexOptimizer(database);
1408
+
1409
+ // クエリパターンを分析して最適なインデックスを作成
1410
+ const analysis = await optimizer.analyzeQueryPatterns();
1411
+ const created = await optimizer.createOptimalIndexes();
1412
+
1413
+ // インデックスの健全性をチェック
1414
+ const health = await optimizer.checkIndexHealth();
1415
+ ```
1416
+
1417
+ **主な機能:**
1418
+ - 一般的なクエリパターン用の複合インデックス作成
1419
+ - 断片化検出によるインデックス健全性監視
1420
+ - 自動最適化推奨
1421
+
1422
+ ### Phase 2: 拡張エクスポートパイプライン
1423
+
1424
+ 増分エクスポートと複数フォーマット対応の強力なエクスポート機能。
1425
+
1426
+ ```typescript
1427
+ import { ExportPipeline } from '@nahisaho/yata-local';
1428
+
1429
+ const pipeline = new ExportPipeline(database);
1430
+
1431
+ // フルエクスポート
1432
+ const fullData = await pipeline.exportFull({ namespace: 'myproject' });
1433
+
1434
+ // 増分エクスポート(前回エクスポート以降の変更)
1435
+ const changes = await pipeline.exportIncremental({
1436
+ since: lastExportTimestamp,
1437
+ format: 'json'
1438
+ });
1439
+
1440
+ // 変換付きエクスポート
1441
+ const transformed = await pipeline.exportWithTransform({
1442
+ format: 'rdf',
1443
+ includeMetadata: true
1444
+ });
1445
+ ```
1446
+
1447
+ **対応フォーマット:**
1448
+ - JSON(デフォルト)
1449
+ - RDF/Turtle
1450
+ - N-Triples
1451
+ - カスタムトランスフォーマー
1452
+
1453
+ ### Phase 3: Global同期統合
1454
+
1455
+ YATA LocalとYATA Global間のシームレスな同期。
1456
+
1457
+ ```typescript
1458
+ import { GlobalSyncClient, SyncEngine } from '@nahisaho/yata-global';
1459
+
1460
+ const client = new GlobalSyncClient({
1461
+ endpoint: 'https://yata-global.example.com',
1462
+ offlineMode: true
1463
+ });
1464
+
1465
+ // 同期を初期化
1466
+ await client.initialize();
1467
+
1468
+ // ローカル変更をプッシュ
1469
+ const syncResult = await client.sync({
1470
+ namespace: 'myproject',
1471
+ direction: 'push'
1472
+ });
1473
+
1474
+ // グローバルから更新をプル
1475
+ await client.sync({
1476
+ namespace: 'shared-patterns',
1477
+ direction: 'pull'
1478
+ });
1479
+ ```
1480
+
1481
+ **機能:**
1482
+ - オフラインファーストと自動同期
1483
+ - 競合解決戦略
1484
+ - 選択的な名前空間同期
1485
+ - フレームワークパターンリポジトリ
1486
+
1487
+ ### Phase 4: コードジェネレーター強化
1488
+
1489
+ 設計ドキュメントからの高度なコード生成。
1490
+
1491
+ ```typescript
1492
+ import { CodeGenerator } from '@nahisaho/yata-local';
1493
+
1494
+ const generator = new CodeGenerator({
1495
+ language: 'typescript',
1496
+ outputDir: './src/generated'
1497
+ });
1498
+
1499
+ // C4設計から生成
1500
+ const result = await generator.generateFromC4(designDocument);
1501
+
1502
+ // カスタムテンプレートで生成
1503
+ await generator.generate({
1504
+ template: 'repository-pattern',
1505
+ context: { entityName: 'User' }
1506
+ });
1507
+ ```
1508
+
1509
+ **対応パターン:**
1510
+ - Repositoryパターン
1511
+ - Serviceレイヤー
1512
+ - Factoryパターン
1513
+ - ドメインイベント
1514
+ - Value Objects
1515
+
1516
+ ### Phase 5: YATA UI(Web可視化)
1517
+
1518
+ 知識グラフのWebベース可視化・管理インターフェース。
1519
+
1520
+ ```typescript
1521
+ import { YataUIServer, createYataUIServer } from '@nahisaho/yata-ui';
1522
+
1523
+ // サーバーを作成して起動
1524
+ const server = createYataUIServer({
1525
+ port: 3000,
1526
+ enableRealtime: true
1527
+ });
1528
+
1529
+ // データプロバイダーを設定
1530
+ server.setDataProvider(async () => ({
1531
+ nodes: await getEntities(),
1532
+ edges: await getRelationships()
1533
+ }));
1534
+
1535
+ await server.start();
1536
+ console.log(`UI: ${server.getUrl()}`);
1537
+ ```
1538
+
1539
+ **UI機能:**
1540
+ - インタラクティブなグラフ可視化
1541
+ - WebSocketによるリアルタイム更新
1542
+ - 名前空間フィルタリング
1543
+ - エンティティ/リレーションシップ編集
1544
+ - エクスポート/インポート機能
1545
+
1546
+ ### v1.7.0 パッケージ概要
1547
+
1548
+ | パッケージ | 説明 |
1549
+ |-----------|------|
1550
+ | `@nahisaho/yata-local` | IndexOptimizer, ExportPipeline, CodeGenerator |
1551
+ | `@nahisaho/yata-global` | GlobalSyncClient, SyncEngine, CacheManager |
1552
+ | `@nahisaho/yata-ui` | YataUIServer, グラフ可視化 |
1553
+
1554
+ ---
1555
+
1556
+ ## 形式検証
1557
+
1558
+ *(v1.7.5)*
1559
+
1560
+ `@nahisaho/musubix-formal-verify` パッケージは、Z3 SMTソルバーを使用した形式検証機能を提供します。
1561
+
1562
+ ### インストール
1563
+
1564
+ ```bash
1565
+ npm install @nahisaho/musubix-formal-verify
1566
+ # オプション: WebAssemblyサポート用にz3-solverをインストール
1567
+ npm install z3-solver
1568
+ ```
1569
+
1570
+ ### Z3 SMTソルバー統合
1571
+
1572
+ ```typescript
1573
+ import { Z3Adapter, PreconditionVerifier, PostconditionVerifier } from '@nahisaho/musubix-formal-verify';
1574
+
1575
+ // Z3アダプター作成(バックエンド自動選択)
1576
+ const z3 = await Z3Adapter.create();
1577
+
1578
+ // 事前条件検証
1579
+ const preVerifier = new PreconditionVerifier(z3);
1580
+ const result = await preVerifier.verify({
1581
+ condition: { expression: 'amount > 0 && balance >= amount', format: 'javascript' },
1582
+ variables: [
1583
+ { name: 'amount', type: 'Int' },
1584
+ { name: 'balance', type: 'Int' },
1585
+ ],
1586
+ });
1587
+
1588
+ console.log(result.status); // 'valid' | 'invalid' | 'unknown' | 'error'
1589
+ ```
1590
+
1591
+ ### Hoareトリプル検証
1592
+
1593
+ ```typescript
1594
+ // {P} C {Q} の検証
1595
+ const postVerifier = new PostconditionVerifier(z3);
1596
+ const hoareResult = await postVerifier.verify({
1597
+ precondition: { expression: 'balance >= amount', format: 'javascript' },
1598
+ postcondition: { expression: 'balance_new == balance - amount', format: 'javascript' },
1599
+ preVariables: [{ name: 'balance', type: 'Int' }, { name: 'amount', type: 'Int' }],
1600
+ postVariables: [{ name: 'balance_new', type: 'Int' }],
1601
+ transition: 'balance_new == balance - amount',
1602
+ });
1603
+ ```
1604
+
1605
+ ### EARS→SMT変換
1606
+
1607
+ ```typescript
1608
+ import { EarsToSmtConverter } from '@nahisaho/musubix-formal-verify';
1609
+
1610
+ const converter = new EarsToSmtConverter();
1611
+
1612
+ // EARS要件をSMT-LIB2に変換
1613
+ const results = converter.convertMultiple([
1614
+ 'THE system SHALL validate inputs', // ubiquitous
1615
+ 'WHEN error, THE system SHALL notify user', // event-driven
1616
+ 'WHILE busy, THE system SHALL queue requests', // state-driven
1617
+ 'THE system SHALL NOT expose secrets', // unwanted
1618
+ 'IF admin, THEN THE system SHALL allow edit', // optional
1619
+ ]);
1620
+
1621
+ results.forEach(r => {
1622
+ console.log(`パターン: ${r.formula?.metadata.earsPattern.type}`);
1623
+ console.log(`SMT: ${r.formula?.smtLib2}`);
1624
+ });
1625
+ ```
1626
+
1627
+ ### トレーサビリティデータベース
1628
+
1629
+ ```typescript
1630
+ import { TraceabilityDB, ImpactAnalyzer } from '@nahisaho/musubix-formal-verify';
1631
+
1632
+ // SQLiteベースのトレーサビリティDB作成
1633
+ const db = new TraceabilityDB('./trace.db');
1634
+
1635
+ // ノード追加
1636
+ await db.addNode({ id: 'REQ-001', type: 'requirement', title: 'ユーザー認証' });
1637
+ await db.addNode({ id: 'DES-001', type: 'design', title: 'AuthService' });
1638
+ await db.addNode({ id: 'CODE-001', type: 'code', title: 'auth.ts' });
1639
+
1640
+ // トレーサビリティリンク追加
1641
+ await db.addLink({ source: 'DES-001', target: 'REQ-001', type: 'satisfies' });
1642
+ await db.addLink({ source: 'CODE-001', target: 'DES-001', type: 'implements' });
1643
+
1644
+ // 影響分析
1645
+ const analyzer = new ImpactAnalyzer(db);
1646
+ const impact = await analyzer.analyze('REQ-001');
1647
+ console.log(`影響ノード数: ${impact.totalImpacted}`);
1648
+ ```
1649
+
1650
+ ### v1.7.5 パッケージ概要
1651
+
1652
+ | パッケージ | 説明 |
1653
+ |-----------|------|
1654
+ | `@nahisaho/musubix-formal-verify` | Z3統合、Hoare検証、EARS→SMT、トレーサビリティDB |
1655
+
1656
+ ### サポートされる変数型
1657
+
1658
+ | 型 | 説明 |
1659
+ |----|------|
1660
+ | `Int` | 整数値 |
1661
+ | `Real` | 実数 |
1662
+ | `Bool` | 真偽値 |
1663
+ | `String` | 文字列 |
1664
+ | `Array` | 配列型 |
1665
+ | `BitVec` | ビットベクトル |
1666
+
1667
+ ---
1668
+
1669
+ ## セキュリティ分析
1670
+
1671
+ *(v1.8.0)*
1672
+
1673
+ `@nahisaho/musubix-security` パッケージは、TypeScript/JavaScriptプロジェクト向けの包括的なセキュリティ分析機能を提供します。
1674
+
1675
+ ### インストール
1676
+
1677
+ ```bash
1678
+ npm install @nahisaho/musubix-security
1679
+ ```
1680
+
1681
+ ### 脆弱性スキャン
1682
+
1683
+ AST解析によりOWASP Top 10およびCWE Top 25の脆弱性を検出します:
1684
+
1685
+ ```typescript
1686
+ import { VulnerabilityScanner, createSecurityService } from '@nahisaho/musubix-security';
1687
+
1688
+ // 単一ファイルのスキャン
1689
+ const scanner = new VulnerabilityScanner();
1690
+ const vulnerabilities = scanner.scanFile('src/api.ts');
1691
+
1692
+ // ディレクトリのスキャン
1693
+ const result = await scanner.scanDirectory('./src');
1694
+ console.log(`検出された脆弱性: ${result.vulnerabilities.length}`);
1695
+ console.log(`スキャンしたファイル: ${result.scannedFiles}`);
1696
+ ```
1697
+
1698
+ ### 検出可能な脆弱性
1699
+
1700
+ | カテゴリ | CWE | 重要度 |
1701
+ |---------|-----|--------|
1702
+ | SQLインジェクション | CWE-89 | Critical |
1703
+ | コマンドインジェクション | CWE-78 | Critical |
1704
+ | XSS | CWE-79 | High |
1705
+ | パストラバーサル | CWE-22 | High |
1706
+ | コードインジェクション | CWE-94 | Critical |
1707
+ | NoSQLインジェクション | CWE-943 | High |
1708
+
1709
+ ### シークレット検出
1710
+
1711
+ ハードコードされた認証情報や機密情報を検出します:
1712
+
1713
+ ```typescript
1714
+ import { SecretDetector } from '@nahisaho/musubix-security';
1715
+
1716
+ const detector = new SecretDetector();
1717
+ const secrets = detector.scanContent(content, 'config.ts');
1718
+ const result = await detector.scan('./src');
1719
+
1720
+ console.log(`検出されたシークレット: ${result.summary.total}`);
1721
+ ```
1722
+
1723
+ ### 検出可能なシークレットタイプ
1724
+
1725
+ | タイプ | パターン |
1726
+ |--------|--------|
1727
+ | AWS Access Key | `AKIA...` |
1728
+ | AWS Secret Key | 40文字のbase64 |
1729
+ | GitHub Token | `ghp_*`, `gho_*`, `ghu_*` |
1730
+ | 秘密鍵 | PEM形式 |
1731
+ | データベースURL | `postgres://`, `mongodb://` |
1732
+ | JWTシークレット | JWT署名シークレット |
1733
+ | Stripe Key | `sk_live_*`, `sk_test_*` |
1734
+
1735
+ ### テイント解析
1736
+
1737
+ ユーザー入力(ソース)から危険な関数(シンク)へのデータフローを追跡します:
1738
+
1739
+ ```typescript
1740
+ import { TaintAnalyzer } from '@nahisaho/musubix-security';
1741
+
1742
+ const analyzer = new TaintAnalyzer();
1743
+ const result = analyzer.analyze('./src');
1744
+
1745
+ console.log(`ソース: ${result.sources.length}`);
1746
+ console.log(`シンク: ${result.sinks.length}`);
1747
+ console.log(`テイントパス: ${result.paths.length}`);
1748
+ ```
1749
+
1750
+ ### 依存関係監査
1751
+
1752
+ npm auditと統合して脆弱な依存関係を検出します:
1753
+
1754
+ ```typescript
1755
+ import { DependencyAuditor } from '@nahisaho/musubix-security';
1756
+
1757
+ const auditor = new DependencyAuditor();
1758
+ const result = await auditor.audit('./project');
1759
+
1760
+ console.log(`Critical: ${result.summary.critical}`);
1761
+ console.log(`High: ${result.summary.high}`);
1762
+ ```
1763
+
1764
+ ### 統合セキュリティサービス
1765
+
1766
+ すべてのセキュリティ分析機能を統合:
1767
+
1768
+ ```typescript
1769
+ import { createSecurityService } from '@nahisaho/musubix-security';
1770
+
1771
+ const service = createSecurityService();
1772
+
1773
+ // フルセキュリティスキャン
1774
+ const result = await service.scan({
1775
+ target: './src',
1776
+ vulnerabilities: true,
1777
+ taint: true,
1778
+ secrets: true,
1779
+ dependencies: true,
1780
+ generateFixes: true,
1781
+ });
1782
+
1783
+ console.log(`総脆弱性数: ${result.summary.totalVulnerabilities}`);
1784
+ console.log(`総シークレット数: ${result.summary.totalSecrets}`);
1785
+ console.log(`生成された修正: ${result.summary.fixesGenerated}`);
1786
+ ```
1787
+
1788
+ ### レポート生成
1789
+
1790
+ 複数のフォーマットでレポートを生成:
1791
+
1792
+ ```typescript
1793
+ // SARIF形式(GitHub Code Scanning対応)
1794
+ const sarifReport = await service.generateReport(result, 'sarif');
1795
+
1796
+ // Markdown形式
1797
+ const mdReport = await service.generateReport(result, 'markdown');
1798
+
1799
+ // HTML形式
1800
+ const htmlReport = await service.generateReport(result, 'html');
1801
+ ```
1802
+
1803
+ ### CLIの使い方
1804
+
1805
+ ```bash
1806
+ # フルセキュリティスキャン
1807
+ npx musubix-security scan ./src
1808
+
1809
+ # 脆弱性スキャンのみ
1810
+ npx musubix-security scan ./src --vulnerabilities-only
1811
+
1812
+ # シークレット検出
1813
+ npx musubix-security secrets ./src
1814
+
1815
+ # テイント解析
1816
+ npx musubix-security taint ./src
1817
+
1818
+ # 依存関係監査
1819
+ npx musubix-security audit ./project
1820
+
1821
+ # SARIFレポート生成
1822
+ npx musubix-security scan ./src --format sarif --output report.sarif
1823
+ ```
1824
+
1825
+ ### v1.8.0 パッケージ概要
1826
+
1827
+ | パッケージ | 説明 |
1828
+ |-----------|------|
1829
+ | `@nahisaho/musubix-security` | 脆弱性スキャン、シークレット検出、テイント解析、依存関係監査 |
1830
+
1831
+ ---
1832
+
1833
+ ## MCPサーバー連携
1834
+
1835
+ ### MCPサーバーの起動
1836
+
1837
+ #### CLI から起動
1838
+
1839
+ ```bash
1840
+ # stdio モード(推奨)
1841
+ musubix-mcp
1842
+ npx @nahisaho/musubix-mcp-server
1843
+
1844
+ # SSE モード
1845
+ musubix-mcp --transport sse --port 8080
1846
+ ```
1847
+
1848
+ #### プログラムから起動
1849
+
1850
+ ```typescript
1851
+ import { startServer, createMCPServer } from '@nahisaho/musubix-mcp-server';
1852
+
1853
+ // 簡易起動
1854
+ await startServer({ transport: 'stdio' });
1855
+
1856
+ // カスタム設定
1857
+ const server = createMCPServer({
1858
+ name: 'my-musubix-server',
1859
+ version: '1.0.0',
1860
+ transport: 'stdio'
1861
+ });
1862
+
1863
+ await server.start();
1864
+ console.log('MCPサーバーが起動しました');
1865
+ ```
1866
+
1867
+ ### GitHub Copilot (VS Code) との連携
1868
+
1869
+ `.vscode/mcp.json`:
1870
+
1871
+ ```json
1872
+ {
1873
+ "mcpServers": {
1874
+ "musubix": {
1875
+ "command": "npx",
1876
+ "args": ["@nahisaho/musubix-mcp-server"]
1877
+ },
1878
+ "yata": {
1879
+ "command": "uv",
1880
+ "args": ["run", "yata", "serve"],
1881
+ "cwd": "/path/to/YATA"
1882
+ }
1883
+ }
1884
+ }
1885
+ ```
1886
+
1887
+ ### Claude Desktop との連携
1888
+
1889
+ 設定ファイルの場所:
1890
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
1891
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
1892
+ - **Linux**: `~/.config/Claude/claude_desktop_config.json`
1893
+
1894
+ ```json
1895
+ {
1896
+ "mcpServers": {
1897
+ "musubix": {
1898
+ "command": "npx",
1899
+ "args": ["@nahisaho/musubix-mcp-server"]
1900
+ },
1901
+ "yata": {
1902
+ "command": "uv",
1903
+ "args": ["run", "yata", "serve"],
1904
+ "cwd": "/path/to/YATA"
1905
+ }
1906
+ }
1907
+ }
1908
+ ```
1909
+
1910
+ ### Cursor IDE との連携
1911
+
1912
+ `.cursor/mcp.json`:
1913
+
1914
+ ```json
1915
+ {
1916
+ "mcpServers": {
1917
+ "musubix": {
1918
+ "command": "npx",
1919
+ "args": ["@nahisaho/musubix-mcp-server"]
1920
+ }
1921
+ }
1922
+ }
1923
+ ```
1924
+
1925
+ ### ツールの呼び出し
1926
+
1927
+ ```typescript
1928
+ // MCP経由でのツール呼び出し例
1929
+ const response = await client.callTool({
1930
+ tool: 'analyze_requirements',
1931
+ arguments: {
1932
+ text: 'システムは...',
1933
+ options: { validateEARS: true }
1934
+ }
1935
+ });
1936
+ ```
1937
+
1938
+ ---
1939
+
1940
+ ## YATA知識グラフ
1941
+
1942
+ ### YATAとは?
1943
+
1944
+ YATA(八咫)は、AIコーディング支援のための知識グラフMCPサーバーです。MUSUBIXと組み合わせることで、ニューロシンボリックAI機能を実現します。
1945
+
1946
+ | 機能 | 説明 |
1947
+ |------|------|
1948
+ | **コード解析** | Tree-sitterによる24言語対応AST解析 |
1949
+ | **知識グラフ** | NetworkXによるエンティティ・関係性グラフ |
1950
+ | **フレームワーク知識** | 47フレームワーク、457K+エンティティ |
1951
+ | **MCP対応** | 34 Tools, 3 Prompts, 1 Resource |
1952
+
1953
+ ### YATAサーバーの起動
1954
+
1955
+ ```bash
1956
+ # YATAディレクトリに移動
1957
+ cd /path/to/YATA
1958
+
1959
+ # stdio モードで起動
1960
+ uv run yata serve
1961
+
1962
+ # SSE モードで起動
1963
+ uv run yata serve --transport sse --port 8080
1964
+ ```
1965
+
1966
+ ### YATAクライアントの設定
1967
+
1968
+ ```typescript
1969
+ import { createYATAClient } from '@nahisaho/musubix-yata-client';
1970
+
1971
+ const yata = createYATAClient({
1972
+ transport: 'stdio', // または { type: 'sse', endpoint: 'http://localhost:8080' }
1973
+ });
1974
+
1975
+ await yata.connect();
1976
+ ```
1977
+
1978
+ ### 知識のクエリ
1979
+
1980
+ ```typescript
1981
+ // 要件の検索
1982
+ const requirements = await yata.query({
1983
+ type: 'requirement',
1984
+ filters: {
1985
+ priority: 'must',
1986
+ status: 'approved'
1987
+ }
1988
+ });
1989
+
1990
+ // 関連エンティティの取得
1991
+ const related = await yata.getRelated({
1992
+ entityId: 'REQ-001',
1993
+ relationTypes: ['implements', 'depends_on']
1994
+ });
1995
+ ```
1996
+
1997
+ ### 知識の保存
1998
+
1999
+ ```typescript
2000
+ // 新しい要件を保存
2001
+ await yata.store({
2002
+ type: 'requirement',
2003
+ data: requirement,
2004
+ relations: [
2005
+ { type: 'part_of', target: 'EPIC-001' }
2006
+ ]
2007
+ });
2008
+
2009
+ // エンティティ間のリンク
2010
+ await yata.link({
2011
+ source: 'TSK-001',
2012
+ target: 'REQ-001',
2013
+ type: 'implements'
2014
+ });
2015
+ ```
2016
+
2017
+ ---
2018
+
2019
+ ## ベストプラクティス
2020
+
2021
+ ### 1. 要件定義のベストプラクティス
2022
+
2023
+ ✅ **推奨**:
2024
+ - EARS形式を使用する
2025
+ - 検証可能な受け入れ基準を含める
2026
+ - 1つの要件に1つの機能
2027
+
2028
+ ❌ **避けるべき**:
2029
+ - 曖昧な表現(「適切に」「迅速に」など)
2030
+ - 複数の機能を1つの要件に含める
2031
+ - 実装詳細を要件に含める
2032
+
2033
+ ### 2. 設計のベストプラクティス
2034
+
2035
+ ✅ **推奨**:
2036
+ - C4の4レベルを活用
2037
+ - 重要な決定はADRで記録
2038
+ - 要件とのトレーサビリティを維持
2039
+
2040
+ ❌ **避けるべき**:
2041
+ - 詳細すぎる最初の設計
2042
+ - 決定理由の省略
2043
+ - 孤立した設計ドキュメント
2044
+
2045
+ ### 3. タスク管理のベストプラクティス
2046
+
2047
+ ✅ **推奨**:
2048
+ - 4時間以内の粒度
2049
+ - 要件への明確なリンク
2050
+ - 完了条件の明記
2051
+
2052
+ ❌ **避けるべき**:
2053
+ - 大きすぎるタスク(8時間超)
2054
+ - 要件リンクのないタスク
2055
+ - 曖昧な完了条件
2056
+
2057
+ ---
2058
+
2059
+ ## トラブルシューティング
2060
+
2061
+ ### よくある問題と解決策
2062
+
2063
+ #### 要件の検証エラー
2064
+
2065
+ ```
2066
+ エラー: EARS形式が検出されませんでした
2067
+ ```
2068
+
2069
+ **解決策**: 要件テキストにEARSパターンを含めてください。
2070
+
2071
+ ```typescript
2072
+ // 修正前
2073
+ const text = '認証機能を実装する';
2074
+
2075
+ // 修正後
2076
+ const text = 'ユーザーがログインしたとき、システムは認証を行わなければならない';
2077
+ ```
2078
+
2079
+ #### トレーサビリティの警告
2080
+
2081
+ ```
2082
+ 警告: 要件 REQ-001 に設計参照がありません
2083
+ ```
2084
+
2085
+ **解決策**: 設計ドキュメントを作成し、リンクしてください。
2086
+
2087
+ ```typescript
2088
+ requirementsService.linkDesign('REQ-001', 'DES-001');
2089
+ ```
2090
+
2091
+ #### MCPサーバー接続エラー
2092
+
2093
+ ```
2094
+ エラー: MCPサーバーに接続できません
2095
+ ```
2096
+
2097
+ **解決策**:
2098
+ 1. サーバーが起動しているか確認
2099
+ 2. ポート番号を確認
2100
+ 3. ファイアウォール設定を確認
2101
+
2102
+ ```bash
2103
+ # サーバーの状態確認
2104
+ ps aux | grep musubix
2105
+ ```
2106
+
2107
+ #### YATA接続エラー
2108
+
2109
+ ```
2110
+ エラー: YATAエンドポイントに接続できません
2111
+ ```
2112
+
2113
+ **解決策**:
2114
+ 1. エンドポイントURLを確認
2115
+ 2. APIキーを確認
2116
+ 3. ネットワーク設定を確認
2117
+
2118
+ ```typescript
2119
+ const client = createYATAClient({
2120
+ endpoint: 'http://localhost:8000', // 正しいURL
2121
+ apiKey: process.env.YATA_API_KEY // 環境変数を確認
2122
+ });
2123
+ ```
2124
+
2125
+ ---
2126
+
2127
+ ## 次のステップ
2128
+
2129
+ - 📚 [APIリファレンス](./API-REFERENCE.md)を参照
2130
+ - 💡 [サンプルプロジェクト](./examples/)を確認
2131
+ - 🤝 [コントリビューションガイド](./CONTRIBUTING.md)を読む
2132
+
2133
+ ---
2134
+
2135
+ ## 関連ドキュメント
2136
+
2137
+ | ドキュメント | 説明 |
2138
+ |-------------|------|
2139
+ | [INSTALL-GUIDE.ja.md](INSTALL-GUIDE.ja.md) | 詳細インストールガイド |
2140
+ | [API-REFERENCE.md](API-REFERENCE.md) | APIリファレンス |
2141
+ | [evolution-from-musubi-to-musubix.md](evolution-from-musubi-to-musubix.md) | MUSUBIからの進化 |
2142
+
2143
+ ---
2144
+
2145
+ **バージョン**: 1.8.0
2146
+ **最終更新**: 2026-01-06
2147
+ **MUSUBIX Project**