musubix 3.6.1 → 3.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/.github/skills/build-fix/SKILL.md +124 -0
  2. package/.github/skills/checkpoint/SKILL.md +131 -0
  3. package/.github/skills/codemap/SKILL.md +120 -0
  4. package/.github/skills/codemap/templates/codemap-index.md +142 -0
  5. package/.github/skills/codemap/templates/package-codemap.md +160 -0
  6. package/.github/skills/context-optimizer/SKILL.md +109 -0
  7. package/.github/skills/context-optimizer/contexts/dev.md +40 -0
  8. package/.github/skills/context-optimizer/contexts/research.md +55 -0
  9. package/.github/skills/context-optimizer/contexts/review.md +49 -0
  10. package/.github/skills/e2e-runner/SKILL.md +145 -0
  11. package/.github/skills/eval-harness/SKILL.md +111 -0
  12. package/.github/skills/eval-harness/examples/capability-eval.md +158 -0
  13. package/.github/skills/eval-harness/examples/human-grader-template.md +326 -0
  14. package/.github/skills/eval-harness/examples/regression-eval.md +228 -0
  15. package/.github/skills/learning-hooks/SKILL.md +101 -0
  16. package/.github/skills/learning-hooks/templates/learned-skill-template.md +79 -0
  17. package/.github/skills/musubix-adr-generation/SKILL.md +33 -168
  18. package/.github/skills/musubix-best-practices/SKILL.md +46 -276
  19. package/.github/skills/musubix-c4-design/SKILL.md +48 -124
  20. package/.github/skills/musubix-code-generation/SKILL.md +46 -193
  21. package/.github/skills/musubix-domain-inference/SKILL.md +54 -168
  22. package/.github/skills/musubix-ears-validation/SKILL.md +49 -136
  23. package/.github/skills/musubix-sdd-workflow/SKILL.md +56 -178
  24. package/.github/skills/musubix-technical-writing/SKILL.md +45 -381
  25. package/.github/skills/musubix-test-generation/SKILL.md +52 -176
  26. package/.github/skills/musubix-traceability/SKILL.md +52 -99
  27. package/.github/skills/refactor-cleaner/SKILL.md +105 -0
  28. package/.github/skills/session-manager/SKILL.md +119 -0
  29. package/.github/skills/session-manager/scripts/session-end.sh +175 -0
  30. package/.github/skills/session-manager/scripts/session-start.sh +87 -0
  31. package/.github/skills/verification-loop/SKILL.md +111 -0
  32. package/.github/skills/verification-loop/scripts/verify.sh +305 -0
  33. package/AGENTS.md +231 -1034
  34. package/docs/CODEMAPS/CODEMAP.md +1 -0
  35. package/docs/adr/ADR-v3.7.0-001-everything-claude-code-integration.md +102 -0
  36. package/package.json +2 -2
package/AGENTS.md CHANGED
@@ -1,1136 +1,333 @@
1
- # MUSUBIX - Neuro-Symbolic AI Integration System
1
+ # AGENTS.md MUSUBIX v3.7.2
2
2
 
3
- > **AI Coding Agent向け**: このファイルはAIエージェント(GitHub Copilot、Claude等)がMUSUBIXプロジェクトを理解するためのガイドです。
3
+ > **AI Agent向け最適化ナレッジ** WHEN/DO構文で明確なトリガーとアクションを定義
4
4
 
5
- ## 🎯 プロジェクト概要
5
+ ## 🎯 クイックリファレンス
6
6
 
7
- **MUSUBIX**は、**Neural(LLM)** **Symbolic(Knowledge Graph)** 推論を統合した次世代AIコーディングシステムです。MUSUBI SDD方法論とオントロジー推論を組み合わせ、高品質なソフトウェア開発を支援します。
8
-
9
- | 項目 | 詳細 |
10
- |------|------|
11
- | **バージョン** | 3.5.0 (Assistant Axis Integration) |
12
- | **言語** | TypeScript |
13
- | **ランタイム** | Node.js >= 20.0.0 |
14
- | **パッケージマネージャ** | npm >= 10.0.0 |
15
- | **ビルドシステム** | モノレポ(npm workspaces) |
16
- | **テストフレームワーク** | Vitest |
17
- | **テスト数** | 5095+ (全合格) |
18
- | **パッケージ数** | 28 |
19
- | **MCPツール数** | 114 |
20
- | **Agent Skills** | 15 (Claude Code対応) |
7
+ | 項目 | |
8
+ |------|-----|
9
+ | バージョン | 3.7.2 |
10
+ | テストカバレッジ | 92%+ |
11
+ | パッケージ数 | 28 |
12
+ | MCP ツール | 114 |
13
+ | Agent Skills | 15 |
21
14
 
22
15
  ---
23
16
 
24
- ## 📦 アーキテクチャ
25
-
26
- ### パッケージ構成
27
-
28
- ```
29
- packages/
30
- ├── core/ # @nahisaho/musubix-core
31
- ├── mcp-server/ # @nahisaho/musubix-mcp-server
32
- ├── security/ # @nahisaho/musubix-security
33
- ├── formal-verify/ # @nahisaho/musubix-formal-verify
34
- ├── pattern-mcp/ # @nahisaho/musubix-pattern-mcp
35
- ├── ontology-mcp/ # @nahisaho/musubix-ontology-mcp
36
- ├── wake-sleep/ # @nahisaho/musubix-wake-sleep
37
- ├── sdd-ontology/ # @nahisaho/musubix-sdd-ontology
38
- ├── dfg/ # @nahisaho/musubix-dfg
39
- ├── lean/ # @nahisaho/musubix-lean
40
- ├── library-learner/# @nahisaho/musubix-library-learner
41
- ├── neural-search/ # @nahisaho/musubix-neural-search
42
- ├── synthesis/ # @nahisaho/musubix-synthesis
43
- ├── agent-orchestrator/ # @nahisaho/musubix-agent-orchestrator
44
- ├── workflow-engine/ # @nahisaho/musubix-workflow-engine
45
- ├── skill-manager/ # @nahisaho/musubix-skill-manager
46
- ├── codegraph/ # @nahisaho/musubix-codegraph
47
- ├── expert-delegation/ # @nahisaho/musubix-expert-delegation (v3.2.0 NEW!)
48
- ├── deep-research/ # @nahisaho/musubix-deep-research (v3.4.0 NEW!)
49
- ├── assistant-axis/ # @nahisaho/musubix-assistant-axis (v3.5.0 NEW!)
50
- ├── knowledge/ # @musubix/knowledge (v3.0.0 NEW!)
51
- ├── policy/ # @musubix/policy (v3.0.0 NEW!)
52
- └── decisions/ # @musubix/decisions (v3.0.0 NEW!)
53
- ```
54
-
55
- | パッケージ | npm | 役割 |
56
- |-----------|-----|------|
57
- | `packages/core/` | `@nahisaho/musubix-core` | コアライブラリ - CLI、EARS検証、コード生成、設計パターン |
58
- | `packages/mcp-server/` | `@nahisaho/musubix-mcp-server` | MCPサーバー - 114ツール、5プロンプト |
59
- | `packages/security/` | `@nahisaho/musubix-security` | セキュリティ分析 - 脆弱性検出、シークレット検出、テイント解析 |
60
- | `packages/formal-verify/` | `@nahisaho/musubix-formal-verify` | 形式検証 - Z3統合、Hoare検証、EARS→SMT変換 |
61
- | `packages/pattern-mcp/` | `@nahisaho/musubix-pattern-mcp` | パターン学習 - 抽出・圧縮・ライブラリ |
62
- | `packages/ontology-mcp/` | `@nahisaho/musubix-ontology-mcp` | オントロジー - N3Store・推論エンジン |
63
- | `packages/wake-sleep/` | `@nahisaho/musubix-wake-sleep` | Wake-Sleep学習サイクル |
64
- | `packages/sdd-ontology/` | `@nahisaho/musubix-sdd-ontology` | SDD方法論オントロジー |
65
- | `packages/dfg/` | `@nahisaho/musubix-dfg` | **DFG/CFG抽出** - データフロー・制御フロー解析 |
66
- | `packages/lean/` | `@nahisaho/musubix-lean` | **Lean 4統合** - 定理証明・EARS変換 |
67
- | `packages/library-learner/` | `@nahisaho/musubix-library-learner` | **ライブラリ学習** - APIパターン抽出、メトリクスエクスポート |
68
- | `packages/knowledge/` | `@musubix/knowledge` | **知識ストア (v3.0.0 NEW!)** - Git-friendly JSON知識グラフ |
69
- | `packages/policy/` | `@musubix/policy` | **ポリシーエンジン (v3.0.0 NEW!)** - 10憲法条項検証 |
70
- | `packages/decisions/` | `@musubix/decisions` | **ADRマネージャー (v3.0.0 NEW!)** - Architecture Decision Records |
71
- | `packages/neural-search/` | `@nahisaho/musubix-neural-search` | **ニューラル検索** - 意味的コード検索、軌跡ロギング |
72
- | `packages/synthesis/` | `@nahisaho/musubix-synthesis` | **プログラム合成** - ニューラル誘導合成、説明生成 |
73
- | `packages/agent-orchestrator/` | `@nahisaho/musubix-agent-orchestrator` | **エージェント調整** - サブエージェント分散・複雑度分析 |
74
- | `packages/workflow-engine/` | `@nahisaho/musubix-workflow-engine` | **ワークフロー制御** - 5フェーズ制御・品質ゲート |
75
- | `packages/skill-manager/` | `@nahisaho/musubix-skill-manager` | **スキル管理** - スキル登録・実行・検証 |
76
- | `packages/codegraph/` | `@nahisaho/musubix-codegraph` | **コードグラフ** - コード構造解析・依存関係追跡 |
77
- | `packages/expert-delegation/` | `@nahisaho/musubix-expert-delegation` | **エキスパート委譲 (v3.2.0 NEW!)** - 7種AI専門家・VS Code LM API統合 |
78
- | `packages/deep-research/` | `@nahisaho/musubix-deep-research` | **Deep Research (v3.4.0 NEW!)** - AI駆動型深層リサーチ・6統合機能・433テスト |
79
- | `packages/assistant-axis/` | `@nahisaho/musubix-assistant-axis` | **Assistant Axis (v3.5.0 NEW!)** - ペルソナドリフト検出・129テスト |
80
-
81
- ### 非推奨パッケージ(Deprecated) ⚠️
82
-
83
- 以下のYATA関連パッケージはv3.0.0で非推奨となりました。`@musubix/knowledge`へ移行してください。
84
-
85
- | パッケージ | 状態 | 移行先 |
86
- |-----------|------|--------|
87
- | `packages/yata-client/` | ⚠️ Deprecated | `@musubix/knowledge` |
88
- | `packages/yata-global/` | ⚠️ Deprecated | `@musubix/knowledge` |
89
- | `packages/yata-local/` | ⚠️ Deprecated | `@musubix/knowledge` |
90
- | `packages/yata-scale/` | ⚠️ Deprecated | `@musubix/knowledge` |
91
- | `packages/yata-ui/` | ⚠️ Deprecated | `@musubix/knowledge` |
92
-
93
- **移行ガイド**: [docs/MIGRATION-v3.0.md](docs/MIGRATION-v3.0.md)
94
-
95
- ### Core パッケージモジュール
96
-
97
- ```
98
- packages/core/src/
99
- ├── auth/ # 認証・認可
100
- ├── cli/ # CLIインターフェース
101
- │ └── generators/ # スキャフォールドジェネレーター (v3.3.0 NEW!)
102
- ├── codegen/ # コード生成・解析
103
- ├── design/ # 設計パターン・C4モデル
104
- ├── error/ # エラーハンドリング
105
- ├── explanation/ # 説明生成・可視化
106
- ├── learning/ # 自己学習システム
107
- ├── requirements/ # 要件分析・分解
108
- ├── symbolic/ # シンボリック推論(v1.2.0 NEW!)
109
- ├── traceability/ # トレーサビリティ
110
- ├── types/ # 型定義
111
- ├── utils/ # ユーティリティ
112
- └── validators/ # EARS検証
113
- ```
17
+ ## 📦 パッケージ構成
18
+
19
+ | カテゴリ | パッケージ | 用途 |
20
+ |----------|------------|------|
21
+ | **Core** | `@musubix/core` | エンティティ・値オブジェクト |
22
+ | | `@musubix/knowledge` | ナレッジグラフ CRUD |
23
+ | | `@musubix/musubi` | AI要約(300字以内) |
24
+ | | `@musubix/codegraph` | コード解析・依存関係抽出 |
25
+ | **SDD** | `@musubix/sdd-ontology` | オントロジー管理 |
26
+ | | `@musubix/decisions` | ADR管理・トレーサビリティ |
27
+ | | `@musubix/synthesis` | 情報統合 |
28
+ | **Verification** | `@musubix/formal-verify` | Lean4形式検証 |
29
+ | | `@musubix/lean` | Lean4連携 |
30
+ | | `@musubix/policy` | ルール駆動検証 |
31
+ | **Agent** | `@musubix/assistant-axis` | マルチモーダル統合 |
32
+ | | `@musubix/expert-delegation` | 専門家委譲 |
33
+ | | `@musubix/skill-manager` | スキル動的ロード |
34
+ | | `@musubix/agent-orchestrator` | 階層的オーケストレーション |
35
+ | **Learning** | `@musubix/wake-sleep` | 自律学習 |
36
+ | | `@musubix/deep-research` | 深層調査 |
37
+ | | `@musubix/library-learner` | ライブラリ学習 |
38
+ | **Search** | `@musubix/neural-search` | ベクトル・ハイブリッド検索 |
39
+ | **Workflow** | `@musubix/workflow-engine` | DAGワークフロー |
40
+ | | `@musubix/dfg` | データフローグラフ |
41
+ | **MCP** | `@musubix/mcp-server` | MCP統合サーバー |
42
+ | | `@musubix/ontology-mcp` | オントロジーMCP |
43
+ | | `@musubix/pattern-mcp` | パターンMCP |
114
44
 
115
45
  ---
116
46
 
117
47
  ## 🛠️ CLI コマンド
118
48
 
119
- ```bash
120
- # プロジェクト初期化
121
- npx musubix init [path] [--name <name>] [--force]
122
-
123
- # 要件分析(EARS形式)
124
- npx musubix requirements analyze <file> # 自然言語 → EARS変換
125
- npx musubix requirements validate <file> # EARS構文検証
126
- npx musubix requirements map <file> # オントロジーマッピング
127
- npx musubix requirements search <query> # 関連要件検索
128
-
129
- # 設計生成
130
- npx musubix design generate <file> # 要件から設計生成
131
- npx musubix design patterns <context> # パターン検出
132
- npx musubix design validate <file> # SOLID準拠検証
133
- npx musubix design c4 <file> # C4ダイアグラム生成
134
- npx musubix design adr <decision> # ADR生成
135
- npx musubix design traceability # REQ↔DESトレーサビリティ検証 (v3.1.0 NEW!)
136
- npx musubix design traceability --min-coverage 80 # カバレッジ閾値指定
137
-
138
- # コード生成
139
- npx musubix codegen generate <file> # 設計からコード生成
140
- npx musubix codegen generate <file> --full-skeleton # 4ファイル生成 (v3.3.10 NEW!)
141
- npx musubix codegen generate <file> --with-tests # テストファイル付き (v3.3.10 NEW!)
142
- npx musubix codegen analyze <file> # 静的解析
143
- npx musubix codegen security <path> # セキュリティスキャン
144
- npx musubix codegen status <spec> # ステータス遷移コード生成 (v3.1.0 NEW!)
145
- npx musubix codegen status <spec> --enum # enum型で生成
146
-
147
- # テスト
148
- npx musubix test generate <file> # テスト生成
149
- npx musubix test coverage <dir> # カバレッジ測定
150
-
151
- # トレーサビリティ
152
- npx musubix trace matrix # トレーサビリティマトリクス
153
- npx musubix trace matrix -p <project> # 指定プロジェクトのマトリクス
154
- npx musubix trace impact <id> # 影響分析
155
- npx musubix trace validate # リンク検証
156
- npx musubix trace sync # トレースマトリクス自動更新 (v1.6.7 NEW!)
157
- npx musubix trace sync --dry-run # プレビューのみ
158
-
159
- # 説明生成
160
- npx musubix explain why <id> # 決定理由の説明
161
- npx musubix explain graph <id> # 推論グラフ生成
162
-
163
- # 自己学習システム
164
- npx musubix learn status # 学習状態ダッシュボード
165
- npx musubix learn feedback <id> # フィードバック記録
166
- npx musubix learn patterns # パターン一覧表示
167
- npx musubix learn add-pattern <name> # パターン手動登録
168
- npx musubix learn remove-pattern <id> # パターン削除
169
- npx musubix learn recommend # コンテキストベースの推奨
170
- npx musubix learn decay # 未使用パターンの減衰
171
- npx musubix learn export # 学習データエクスポート
172
- # オプション: --output <file>, --privacy-filter, --patterns-only, --feedback-only, --min-confidence <n>
173
- npx musubix learn import <file> # 学習データインポート
174
- # オプション: --merge-strategy <skip|overwrite|merge>, --dry-run, --patterns-only, --feedback-only
175
-
176
- # オントロジー操作 (v1.4.1 NEW!)
177
- npx musubix ontology validate -f <file> # 知識グラフ整合性検証
178
- npx musubix ontology check-circular -f <file> # 循環依存チェック
179
- npx musubix ontology stats -f <file> # 統計表示
180
-
181
- # Interactive REPL (v1.5.0 NEW!)
182
- npx musubix repl # 対話的シェルを起動
183
- npx musubix repl --history <file> # カスタム履歴ファイル
184
- npx musubix repl --no-color # 色なしモード
185
-
186
- # KGPR - Knowledge Graph Pull Request (v1.6.4 - DEPRECATED)
187
- # KGPRは廃止されました。通常のGit PRワークフローを使用してください。
188
-
189
- # SDDプロジェクトスキャフォールド (v1.6.7 NEW!, v3.3.0 Enhanced!)
190
- npx musubix scaffold domain-model <name> # DDDプロジェクト生成
191
- npx musubix scaffold domain-model <name> -e "Entity1,Entity2" # エンティティ指定
192
- npx musubix scaffold domain-model <name> -d DOMAIN # ドメイン接頭辞指定
193
- npx musubix scaffold domain-model <name> -v "Price,Email" # Value Object生成 (v3.1.0 NEW!)
194
- npx musubix scaffold domain-model <name> -s "Order,Task" # ステータス遷移生成 (v3.1.0 NEW!)
195
- npx musubix scaffold domain-model <name> -s "Order=pending,Task=open" # 初期状態指定 (v3.3.0 NEW!)
196
- npx musubix scaffold minimal <name> # 最小構成プロジェクト
197
-
198
- # プログラム合成 (v2.2.0 NEW!)
199
- npx musubix synthesize <examples.json> # 例からプログラム合成
200
- npx musubix synthesize pbe <examples.json> # PBE特化合成
201
- npx musubix syn <examples.json> # エイリアス
202
-
203
- # パターンライブラリ管理 (v2.2.0 NEW!)
204
- npx musubix library learn <file> # コードからパターン学習
205
- npx musubix library query <query> # パターン検索
206
- npx musubix library stats # 統計表示
207
- npx musubix lib stats # エイリアス
208
-
209
- # ヘルプ
210
- npx musubix --help
211
- npx musubix help <command>
212
- ```
213
-
214
- ---
215
-
216
- ## 🔌 MCP Server
217
-
218
- ### 起動方法
49
+ ### 基本操作
219
50
 
220
51
  ```bash
221
- npx @nahisaho/musubix-mcp-server
222
- npx musubix-mcp --transport stdio
223
- ```
224
-
225
- ### ツール一覧(61ツール)
226
-
227
- #### SDD基本ツール(7ツール)
228
-
229
- | ツール名 | 説明 |
230
- |---------|------|
231
- | `sdd_create_requirements` | EARS形式の要件ドキュメント作成 |
232
- | `sdd_validate_requirements` | 要件のEARS検証・憲法準拠チェック |
233
- | `sdd_create_design` | C4モデル設計ドキュメント作成 |
234
- | `sdd_validate_design` | 設計の要件トレーサビリティ検証 |
235
- | `sdd_create_tasks` | 設計から実装タスク生成 |
236
- | `sdd_validate_constitution` | 10憲法条項への準拠検証 |
237
- | `sdd_validate_traceability` | 要件↔設計↔タスクのトレーサビリティ検証 |
238
-
239
- #### パターン統合ツール(7ツール)- v1.3.0 NEW!
240
-
241
- | ツール名 | 説明 |
242
- |---------|------|
243
- | `pattern_extract` | コードからパターンを抽出 |
244
- | `pattern_compress` | パターンの抽象化・圧縮 |
245
- | `pattern_store` | パターンライブラリへの保存 |
246
- | `pattern_query` | パターンの検索・取得 |
247
- | `pattern_consolidate` | 類似パターンの統合 |
248
- | `ontology_query` | オントロジーグラフへのクエリ |
249
- | `ontology_infer` | オントロジーによる推論実行 |
250
-
251
- #### オントロジー検証ツール(3ツール)- v1.4.1 NEW!
252
-
253
- | ツール名 | 説明 |
254
- |---------|------|
255
- | `consistency_validate` | 知識グラフの整合性検証 |
256
- | `validate_triple` | 単一トリプルの事前検証 |
257
- | `check_circular` | 循環依存の検出 |
258
-
259
- #### Synthesisツール(5ツール)- v2.2.0 NEW!
260
-
261
- | ツール名 | 説明 |
262
- |---------|------|
263
- | `synthesis_from_examples` | 例からプログラム合成 |
264
- | `synthesis_analyze_examples` | 例題品質分析 |
265
- | `synthesis_learn_patterns` | パターン学習 |
266
- | `synthesis_query_patterns` | パターン検索 |
267
- | `synthesis_get_stats` | 統計取得 |
268
-
269
- #### Agent Orchestratorツール(4ツール)- v2.4.0 NEW!
270
-
271
- | ツール名 | 説明 |
272
- |---------|------|
273
- | `agent_analyze_complexity` | タスク複雑度分析・サブエージェント分散判定 |
274
- | `agent_dispatch` | サブエージェントへのタスクディスパッチ |
275
- | `agent_collect_results` | サブエージェント結果の収集・統合 |
276
- | `agent_get_status` | エージェント実行状態の取得 |
277
-
278
- #### Workflow Engineツール(5ツール)- v2.4.0 NEW!
279
-
280
- | ツール名 | 説明 |
281
- |---------|------|
282
- | `workflow_create` | 新規ワークフロー作成(5フェーズ制御) |
283
- | `workflow_advance_phase` | 次フェーズへの遷移(品質ゲート検証付き) |
284
- | `workflow_set_approval` | ユーザー承認状態の設定 |
285
- | `workflow_get_status` | ワークフロー現在状態の取得 |
286
- | `workflow_validate_transition` | フェーズ遷移の事前検証 |
287
-
288
- #### Skill Managerツール(5ツール)- v2.4.0 NEW!
289
-
290
- | ツール名 | 説明 |
291
- |---------|------|
292
- | `skill_register` | 新規スキルの登録 |
293
- | `skill_execute` | スキルの実行 |
294
- | `skill_list` | 登録済みスキル一覧の取得 |
295
- | `skill_get_info` | スキル詳細情報の取得 |
296
- | `skill_validate` | スキル定義の検証 |
297
-
298
- #### Knowledge Storeツール(6ツール)- v3.0.0 NEW!
299
-
300
- | ツール名 | 説明 |
301
- |---------|------|
302
- | `knowledge_put_entity` | エンティティの作成・更新 |
303
- | `knowledge_get_entity` | エンティティの取得 |
304
- | `knowledge_delete_entity` | エンティティの削除 |
305
- | `knowledge_add_relation` | リレーションの追加 |
306
- | `knowledge_query` | グラフクエリによる検索 |
307
- | `knowledge_traverse` | グラフ走査による関連エンティティ探索 |
308
-
309
- #### Policy Engineツール(4ツール)- v3.0.0 NEW!
310
-
311
- | ツール名 | 説明 |
312
- |---------|------|
313
- | `policy_validate` | プロジェクトのポリシー検証 |
314
- | `policy_list` | 登録済みポリシー一覧 |
315
- | `policy_get` | ポリシー詳細取得 |
316
- | `policy_check_file` | 単一ファイルのポリシー検証 |
317
-
318
- #### Decision Recordsツール(8ツール)- v3.0.0 NEW!
319
-
320
- | ツール名 | 説明 |
321
- |---------|------|
322
- | `decision_create` | ADRの作成 |
323
- | `decision_list` | ADR一覧取得 |
324
- | `decision_get` | ADR詳細取得 |
325
- | `decision_accept` | ADRの承認 |
326
- | `decision_deprecate` | ADRの廃止 |
327
- | `decision_search` | ADRのキーワード検索 |
328
- | `decision_find_by_requirement` | 要件からADR検索 |
329
- | `decision_generate_index` | ADRインデックス生成 |
330
-
331
- ### プロンプト一覧(5プロンプト)
332
-
333
- | プロンプト名 | 説明 |
334
- |-------------|------|
335
- | `sdd_requirements_analysis` | 機能説明からEARS形式要件を生成 |
336
- | `sdd_requirements_review` | 要件の完全性・憲法準拠レビュー |
337
- | `sdd_design_generation` | 要件からC4モデル設計を生成 |
338
- | `synthesis_guidance` | 合成ガイダンス (v2.2.0 NEW!) |
339
- | `synthesis_explain_pattern` | パターン説明 (v2.2.0 NEW!) |
340
-
341
- ---
342
-
343
- ## 📋 10憲法条項(Constitutional Articles)
344
-
345
- すべての開発活動を統治する不変のルールです。
346
-
347
- | 条項 | 名称 | 概要 |
348
- |-----|------|------|
349
- | **I** | Library-First | 機能は独立ライブラリとして開始 |
350
- | **II** | CLI Interface | すべてのライブラリはCLI公開必須 |
351
- | **III** | Test-First | Red-Green-Blueサイクルでテスト先行 |
352
- | **IV** | EARS Format | 要件はEARS形式で記述 |
353
- | **V** | Traceability | 要件↔設計↔コード↔テストの100%追跡 |
354
- | **VI** | Project Memory | steering/を参照してから決定 |
355
- | **VII** | Design Patterns | 設計パターン適用の文書化 |
356
- | **VIII** | Decision Records | すべての決定をADRで記録 |
357
- | **IX** | Quality Gates | フェーズ移行前の品質検証 |
358
- | **X** | **Implementation Prerequisites** | **要件・設計・タスクなしの実装禁止** |
359
-
360
- ### ⛔ Article X: Implementation Prerequisites (v3.0.9)
52
+ # プロジェクト全体
53
+ pnpm i && pnpm build && pnpm test
361
54
 
362
- **絶対ルール**: 要件定義書・設計書・タスク分解が承認されていない限り、実装を開始してはならない。
363
-
364
- ```
365
- ⛔ 禁止: Phase 2 (設計) → Phase 4 (実装) の直接遷移
366
- ✅ 必須: Phase 1 → Phase 2 → Phase 3 → Phase 4 の順序遵守
55
+ # 個別パッケージ
56
+ pnpm --filter @musubix/core test
57
+ pnpm --filter @musubix/knowledge test
367
58
  ```
368
59
 
369
- 実装開始前に`workflow-engine`が自動検証:
370
- - ✅ Phase 1 (要件定義) が承認済みかつ成果物あり
371
- - ✅ Phase 2 (設計) が承認済みかつ成果物あり
372
- - ✅ Phase 3 (タスク分解) が承認済みかつ成果物あり
373
-
374
- **詳細**: [steering/rules/constitution.md](steering/rules/constitution.md)
375
-
376
- ---
377
-
378
- ## 📁 プロジェクトメモリ(Steering)
379
-
380
- AIエージェントは決定前に必ずこれらのファイルを参照してください。
381
-
382
- | ファイル | 内容 |
383
- |---------|------|
384
- | `steering/structure.ja.md` | アーキテクチャパターン、レイヤー構造 |
385
- | `steering/tech.ja.md` | 技術スタック(TypeScript, Node.js 20+) |
386
- | `steering/product.ja.md` | プロダクトコンテキスト |
387
- | `steering/rules/constitution.md` | 10憲法条項 |
388
- | `steering/project.yml` | プロジェクト設定 |
389
-
390
- ---
391
-
392
- ## 📂 ストレージ構造
393
-
394
- | パス | 内容 |
395
- |-----|------|
396
- | `storage/specs/` | 要件(REQ-*)、設計(DES-*)、タスク(TSK-*) |
397
- | `storage/design/` | 設計ドキュメント、C4ダイアグラム |
398
- | `storage/traceability/` | トレーサビリティマトリクス |
399
- | `storage/reviews/` | コードレビュー、検証結果 |
400
- | `storage/changes/` | 変更履歴 |
401
- | `storage/archive/` | アーカイブ |
402
-
403
- ---
404
-
405
- ## 🧪 開発コマンド
60
+ ### ナレッジ操作
406
61
 
407
62
  ```bash
408
- # 依存関係インストール
409
- npm install
63
+ # 追加・検索
64
+ musubix knowledge add --source ./src --output ./knowledge.json
65
+ musubix knowledge search "認証" --semantic --top-k 5
410
66
 
411
- # 全パッケージビルド
412
- npm run build
413
-
414
- # テスト実行
415
- npm run test # 全テスト
416
- npm run test:unit # ユニットテスト
417
- npm run test:integration # 統合テスト
418
- npm run test:coverage # カバレッジ計測
419
-
420
- # コード品質
421
- npm run lint # ESLint
422
- npm run lint:fix # ESLint 自動修正
423
- npm run typecheck # TypeScript型チェック
424
-
425
- # クリーンアップ
426
- npm run clean
67
+ # コードグラフ
68
+ musubix codegraph analyze ./src --include-dependencies
69
+ musubix codegraph query "関数 -> 依存関係"
427
70
  ```
428
71
 
429
- ---
72
+ ### SDD ワークフロー
430
73
 
431
- ## 🔑 主要機能
432
-
433
- ### 1. Neuro-Symbolic統合(REQ-INT-001〜003準拠)
434
- - **Neural(LLM)**: 創造的なコード生成、自然言語理解
435
- - **Symbolic(Ontology)**: オントロジーによる精密な推論、一貫性検証
436
- - **信頼度評価ルール** (REQ-INT-002):
437
- | シンボリック結果 | ニューラル信頼度 | 最終決定 |
438
- |-----------------|-----------------|---------|
439
- | invalid | - | ニューラル結果を棄却 |
440
- | valid | ≥0.8 | ニューラル結果を採用 |
441
- | valid | <0.8 | シンボリック結果を優先 |
442
-
443
- ### 2. EARS要件分析
444
- 5つのEARSパターンで要件を形式化(REQ-RA-001準拠):
445
-
446
- | パターン | 構文 | 用途 |
447
- |---------|------|------|
448
- | Ubiquitous | `THE [system] SHALL [requirement]` | システムが常に満たすべき要件 |
449
- | Event-driven | `WHEN [event], THE [system] SHALL [response]` | 特定イベント発生時の要件 |
450
- | State-driven | `WHILE [state], THE [system] SHALL [response]` | 特定状態における要件 |
451
- | Unwanted | `THE [system] SHALL NOT [behavior]` | 回避すべき動作の要件 |
452
- | Optional | `IF [condition], THEN THE [system] SHALL [response]` | 条件付き要件 |
453
-
454
- **要件総数**: 41要件(REQ-MUSUBIX-001定義)
455
- **優先度**: P0(必須)、P1(重要)、P2(任意)
456
-
457
- ### 3. C4モデル設計
458
- 4つのレベルで設計を構造化:
459
- - **Context**: システム境界と外部アクター
460
- - **Container**: 技術選択とコンテナ構成
461
- - **Component**: コンテナ内部構造
462
- - **Code**: 実装詳細
463
-
464
- **C4コード生成** (v1.0.12 NEW!):
465
74
  ```bash
466
- # C4設計ドキュメントからTypeScriptスケルトンコードを自動生成
467
- npx musubix codegen generate <design.md> --output src/
75
+ # 仕様駆動開発
76
+ musubix sdd init --domain "Eコマース" --output ./specs
77
+ musubix sdd validate ./specs --strict
78
+ musubix sdd generate ./specs --output ./src
468
79
  ```
469
- - 設計パターン(Repository, Service, Factory等)を自動検出
470
- - コンポーネントごとにTypeScriptファイル生成
471
- - 設計との完全なトレーサビリティを維持
472
80
 
473
- ### 4. 完全なトレーサビリティ
474
- ```
475
- 要件(REQ-*) → 設計(DES-*) → タスク(TSK-*) → コード → テスト
476
- ```
81
+ ### MCP サーバー
477
82
 
478
- ### 5. 自己学習システム(REQ-LEARN-001〜006準拠)
479
- - **フィードバック収集**: accept/reject/modifyの記録と分析
480
- - **パターン抽出**: 繰り返しパターンの自動検出・登録
481
- - **適応的推論**: 学習済みパターンに基づく推論調整
482
- - **プライバシー保護**: 機密情報の自動フィルタリング(ローカルストレージのみ)
483
-
484
- ```
485
- フィードバック → パターン候補 → 閾値超過 → パターン登録 → 推論に適用
83
+ ```bash
84
+ # 起動
85
+ musubix-mcp serve
86
+ musubix-mcp serve --port 3000 --skills-dir ./skills
486
87
  ```
487
88
 
488
- ### 6. Wake-Sleep学習サイクル(v1.3.0 NEW!)
489
-
490
- Wake-Sleepアルゴリズムに基づいた継続的学習システム:
491
-
492
- | フェーズ | 処理内容 |
493
- |---------|----------|
494
- | **Wake** | コード観察 → パターン抽出 → 知識グラフ更新 |
495
- | **Sleep** | パターン統合 → 類似パターン圧縮 → メモリ最適化 |
496
-
497
- ```
498
- Wake Phase: observe() → extractPatterns() → updateKnowledge()
499
- Sleep Phase: consolidate() → compress() → optimize()
500
- ```
89
+ ---
501
90
 
502
- **主要コンポーネント**:
503
- - `WakeSleepCycle`: 学習サイクル全体の制御
504
- - `PatternLibrary`: 学習済みパターンの永続化管理
505
- - `PatternOntologyBridge`: パターン↔オントロジー相互変換
506
- - `N3Store`: RDF/OWLベースの知識グラフストレージ
91
+ ## 🔌 MCP ツール(主要)
507
92
 
508
- ### 7. Git-Native Knowledge System(v3.0.0 NEW!)
93
+ | カテゴリ | ツール | 用途 |
94
+ |----------|--------|------|
95
+ | **Knowledge** | `knowledge_add`, `knowledge_search`, `knowledge_import`, `knowledge_export` | ナレッジ CRUD |
96
+ | **CodeGraph** | `codegraph_analyze`, `codegraph_query`, `codegraph_visualize` | コード解析 |
97
+ | **SDD** | `sdd_init`, `sdd_validate`, `sdd_generate`, `sdd_trace` | 仕様駆動開発 |
98
+ | **Wake-Sleep** | `wake_observe`, `wake_optimize`, `sleep_consolidate`, `sleep_generate` | 自律学習 |
99
+ | **Formal** | `formal_translate`, `formal_verify`, `formal_prove` | 形式検証 |
100
+ | **Search** | `neural_search`, `hybrid_search`, `graph_search` | 検索 |
509
101
 
510
- サーバーレス・Git-friendlyな知識グラフシステム:
102
+ **全114ツール**: `musubix-mcp list-tools` で確認
511
103
 
512
- | 特徴 | 説明 |
513
- |------|------|
514
- | **サーバーレス** | データベース不要、JSONファイルで完結 |
515
- | **Git-friendly** | diff/merge/PR対応、バージョン管理可能 |
516
- | **軽量** | ゼロ依存(外部ライブラリ不要) |
517
- | **階層型ID** | `requirement:REQ-001`、`design:DES-001` |
104
+ ---
518
105
 
519
- ```
520
- .knowledge/
521
- └── graph.json # 全エンティティ・リレーション
522
- ```
106
+ ## 📜 10憲法条項
107
+
108
+ | # | 条項 | ルール |
109
+ |---|------|--------|
110
+ | 1 | コンテキスト最優先 | Steering/product.ja.md, structure.ja.md を必ず参照 |
111
+ | 2 | ナレッジ駆動 | 既存知識を検索・活用してから回答 |
112
+ | 3 | 仕様駆動 (SDD) | 要件→設計→実装→検証の順序厳守 |
113
+ | 4 | トレーサビリティ | 決定事項は ADR として記録 |
114
+ | 5 | 段階的詳細化 | 抽象から具体へ、一度に1レベル |
115
+ | 6 | 自律学習 | Wake-Sleepサイクルで継続的改善 |
116
+ | 7 | 形式検証 | 重要ロジックはLean4で証明 |
117
+ | 8 | パターン適用 | 学習済みベストプラクティスを活用 |
118
+ | 9 | 明示的コミュニケーション | 不明点は確認、仮定を明示 |
119
+ | 10 | 品質最優先 | テスト・レビュー・検証を省略しない |
523
120
 
524
- **主要API**:
525
- ```typescript
526
- import { createKnowledgeStore } from '@musubix/knowledge';
527
-
528
- const store = createKnowledgeStore('.knowledge');
529
-
530
- // エンティティ操作
531
- await store.putEntity({
532
- id: 'requirement:REQ-001',
533
- type: 'requirement',
534
- name: 'User Authentication',
535
- properties: { ears: 'WHEN user logs in...' },
536
- tags: ['security', 'auth'],
537
- });
538
-
539
- const req = await store.getEntity('requirement:REQ-001');
540
-
541
- // リレーション追加
542
- await store.addRelation({
543
- source: 'requirement:REQ-001',
544
- target: 'design:DES-001',
545
- type: 'tracesTo',
546
- properties: { confidence: 0.95 },
547
- });
548
-
549
- // クエリ
550
- const entities = await store.query({ type: 'requirement', tags: ['security'] });
551
-
552
- // グラフ走査
553
- const related = await store.traverse('requirement:REQ-001', {
554
- direction: 'outgoing',
555
- relationTypes: ['tracesTo'],
556
- maxDepth: 2,
557
- });
558
- ```
559
-
560
- **関連パッケージ**:
561
- - `@musubix/policy`: 10憲法条項の自動検証
562
- - `@musubix/decisions`: Architecture Decision Records管理
121
+ ---
563
122
 
564
- **ドキュメント**: [docs/packages/knowledge.md](docs/packages/knowledge.md)
123
+ ## 🧭 Project Memory(Steering)
565
124
 
566
- ### 8. Advanced Learning Enhancement(v2.2.0 NEW!)
125
+ | ファイル | 用途 | 参照タイミング |
126
+ |----------|------|----------------|
127
+ | `steering/product.ja.md` | 製品ビジョン・ゴール | プロジェクト理解時 |
128
+ | `steering/structure.ja.md` | アーキテクチャ構造 | 設計・実装時 |
129
+ | `steering/tech.ja.md` | 技術スタック・制約 | 技術選定時 |
130
+ | `steering/project.yml` | プロジェクトメタデータ | CI/CD設定時 |
131
+ | `steering/rules/*.md` | ドメイン固有ルール | コード生成時 |
567
132
 
568
- 3パッケージに高度な学習機能を追加:
133
+ ---
569
134
 
570
- #### Neural Search強化
571
- ```typescript
572
- import {
573
- ContextAwareEmbedder, // コンテキスト認識埋め込み
574
- HybridRanker, // BM25 + ベクトル類似度
575
- EmbeddingCache, // LRU + TTL キャッシュ
576
- createTrajectoryLogger, // 検索軌跡ロギング
577
- } from '@nahisaho/musubix-neural-search';
578
-
579
- const logger = createTrajectoryLogger();
580
- logger.logBranch({ depth: 1, score: 0.85, action: 'expand' });
581
- const parquet = logger.export('parquet');
582
- ```
135
+ ## 🔬 主要機能
583
136
 
584
- #### Library Learner強化
585
- ```typescript
586
- import {
587
- SemanticChunker, // AST境界認識チャンキング
588
- PatternVersionManager, // Git風バージョン管理
589
- createMetricsExporter, // メトリクスエクスポート
590
- } from '@nahisaho/musubix-library-learner';
591
-
592
- const exporter = createMetricsExporter(library);
593
- const markdown = exporter.export('markdown');
594
- const summary = exporter.getSummary(); // { healthStatus: 'good' }
595
- ```
137
+ ### 1. Wake-Sleep 自律学習
596
138
 
597
- #### Synthesis強化
598
139
  ```typescript
599
- import {
600
- createMetaLearningEngine, // メタ学習エンジン
601
- createExampleAnalyzer, // 例題品質分析
602
- createExplanationGenerator, // 説明生成
603
- } from '@nahisaho/musubix-synthesis';
604
-
605
- const explainer = createExplanationGenerator();
606
- const explanation = explainer.generate(program);
607
- const summary = explainer.summarize(program);
608
- // "Converts to uppercase"
140
+ // WHEN: パターン学習が必要
141
+ // DO: Wake-Sleepサイクルを実行
142
+ const result = await wakeSleep.observe("./src/**/*.ts");
143
+ const patterns = await wakeSleep.consolidate(result);
144
+ await wakeSleep.apply(patterns);
609
145
  ```
610
146
 
611
- ### 9. Performance Optimization(v3.1.0 NEW!)
612
-
613
- CLI・パターン処理の性能最適化ユーティリティ:
147
+ ### 2. Knowledge Graph
614
148
 
615
- #### 性能計測
616
149
  ```typescript
617
- import {
618
- PerformanceTimer,
619
- measureAsync,
620
- measureSync,
621
- PerformanceCollector,
622
- createPerformanceCollector,
623
- formatPerformanceReport,
624
- } from '@nahisaho/musubix-core/cli';
625
-
626
- // 非同期処理の計測
627
- const { result, performance } = await measureAsync('api-call', async () => {
628
- return await fetchData();
629
- });
630
- console.log(`Duration: ${performance.durationMs}ms`);
631
-
632
- // 性能レポート生成
633
- const collector = createPerformanceCollector();
634
- collector.addResult(performance);
635
- const report = collector.generateReport();
636
- console.log(formatPerformanceReport(report));
150
+ // WHEN: 情報の関連付けが必要
151
+ // DO: エンティティとリレーションを追加
152
+ await knowledge.addEntity({ type: "Function", name: "auth" });
153
+ await knowledge.addRelation("auth", "uses", "jwt-library");
154
+ const related = await knowledge.search("認証", { semantic: true });
637
155
  ```
638
156
 
639
- #### 遅延読み込み
640
- ```typescript
641
- import {
642
- createLazyLoader,
643
- LazyModuleRegistry,
644
- globalLazyRegistry,
645
- BatchLoader,
646
- } from '@nahisaho/musubix-core/cli';
647
-
648
- // モジュールの遅延読み込み
649
- const heavyModule = createLazyLoader(() => import('./heavy-module'));
650
- const module = await heavyModule(); // 初回アクセス時にのみ読み込み
651
-
652
- // バッチ読み込み
653
- const loader = new BatchLoader(async (keys) => {
654
- const results = await fetchMany(keys);
655
- return new Map(keys.map((k, i) => [k, results[i]]));
656
- });
657
- const [a, b, c] = await Promise.all([
658
- loader.load('a'),
659
- loader.load('b'),
660
- loader.load('c'),
661
- ]); // 1回のバッチリクエストで取得
662
- ```
157
+ ### 3. CodeGraph 解析
663
158
 
664
- #### パターンキャッシュ
665
159
  ```typescript
666
- import {
667
- LRUCache,
668
- PatternCache,
669
- globalPatternCache,
670
- memoize,
671
- memoizeAsync,
672
- } from '@nahisaho/musubix-core/learning';
673
-
674
- // LRUキャッシュ(TTL対応)
675
- const cache = new LRUCache<string, Pattern>({
676
- maxSize: 100,
677
- ttlMs: 60000, // 1分
678
- });
679
- cache.set('pattern-1', patternData);
680
- const pattern = cache.get('pattern-1');
681
-
682
- // 関数メモ化
683
- const expensiveFn = memoize((x: number) => {
684
- // 重い計算
685
- return x * 2;
686
- });
687
-
688
- // 非同期関数メモ化
689
- const fetchUser = memoizeAsync(async (id: string) => {
690
- return await api.getUser(id);
691
- });
160
+ // WHEN: コード依存関係の把握が必要
161
+ // DO: 解析してクエリ実行
162
+ const graph = await codegraph.analyze("./src");
163
+ const deps = await codegraph.query("Function -> Dependency");
692
164
  ```
693
165
 
694
- ### 10. Scaffold Enhancement & Pattern Learning Integration(v3.3.0 NEW!)
166
+ ### 4. SDD ワークフロー
695
167
 
696
- スキャフォールドコマンドとパターン学習システムの統合強化:
697
-
698
- #### Value Object Generator
699
168
  ```typescript
700
- import {
701
- generators,
702
- type generators.ValueObjectSpec,
703
- } from '@nahisaho/musubix-core';
704
-
705
- const generator = generators.createValueObjectGenerator();
706
- const spec: generators.ValueObjectSpec = {
707
- name: 'Price',
708
- fields: [
709
- { name: 'amount', type: 'number', validation: { min: 100, max: 1000000 } },
710
- { name: 'currency', type: 'string', validation: { pattern: 'JPY|USD|EUR' } }
711
- ],
712
- domainPrefix: 'SHOP'
713
- };
714
-
715
- const files = generator.generate(spec);
716
- // → [{ path: 'price.ts', content: '...' }, { path: 'price.test.ts', content: '...' }]
169
+ // WHEN: 新機能の仕様策定
170
+ // DO: init → validate → generate
171
+ await sdd.init({ domain: "Payment", output: "./specs" });
172
+ await sdd.validate("./specs", { strict: true });
173
+ await sdd.generate("./specs", { output: "./src" });
717
174
  ```
718
175
 
719
- #### Status Machine Generator
720
- ```typescript
721
- import {
722
- generators,
723
- type generators.StatusMachineSpec,
724
- } from '@nahisaho/musubix-core';
725
-
726
- const generator = generators.createStatusMachineGenerator();
727
- const spec: generators.StatusMachineSpec = {
728
- name: 'Order',
729
- statuses: ['pending', 'confirmed', 'shipped', 'delivered', 'cancelled'],
730
- initialStatus: 'pending', // v3.3.0: 初期状態を明示指定可能
731
- transitions: [
732
- { from: 'pending', to: 'confirmed' },
733
- { from: 'pending', to: 'cancelled' },
734
- { from: 'confirmed', to: 'shipped' },
735
- // ...
736
- ],
737
- domainPrefix: 'SHOP'
738
- };
739
-
740
- const files = generator.generate(spec);
741
- // → [{ path: 'order-status.ts', content: '...' }, { path: 'order-status.test.ts', content: '...' }]
742
- ```
176
+ ### 5. Formal Verification
743
177
 
744
- #### Pattern Learning Service(新規)
745
178
  ```typescript
746
- import { generators } from '@nahisaho/musubix-core';
747
-
748
- // スキャフォールド生成結果からパターンを学習
749
- const service = generators.createPatternLearningService();
750
-
751
- // コードからパターン抽出
752
- await service.learnFromCode(generatedCode);
753
-
754
- // 学習したパターンを次回生成に活用
755
- const suggestions = await service.getSuggestions(context);
756
- // → [{ pattern: 'ValueObject+ResultType', confidence: 0.95 }]
757
-
758
- // 学習状況のサマリー
759
- const summary = await service.getSummary();
760
- // → { totalPatterns: 15, healthStatus: 'good' }
179
+ // WHEN: 重要ロジックの証明が必要
180
+ // DO: Lean4に変換して検証
181
+ const leanCode = await formal.translate(tsCode);
182
+ const proof = await formal.verify(leanCode);
761
183
  ```
762
184
 
763
- #### Expert Integration(AIエキスパート委譲統合)
764
- ```typescript
765
- import { generators } from '@nahisaho/musubix-core';
766
-
767
- const expert = generators.createExpertIntegration({
768
- ...generators.DEFAULT_EXPERT_CONFIG,
769
- timeout: 30000, // ADR-v3.3.0-002: 30秒タイムアウト
770
- fallbackEnabled: true, // タイムアウト時フォールバック有効
771
- });
772
-
773
- // スキャフォールド生成にAIエキスパートを活用
774
- const recommendation = await expert.consultForScaffold({
775
- type: 'value-object',
776
- spec: valueObjectSpec,
777
- context: projectContext,
778
- });
779
- // → { validationRules: [...], suggestedPatterns: [...] }
780
- ```
781
-
782
- #### CLI使用例(v3.3.0強化)
783
- ```bash
784
- # 初期状態を明示指定してステータスマシンを生成
785
- npx musubix scaffold domain-model shop -s "Order=pending,Task=open"
185
+ ---
786
186
 
787
- # 上記コマンドで生成されるファイル:
788
- # - order-status.ts (初期状態: 'pending')
789
- # - task-status.ts (初期状態: 'open')
790
- # - *.test.ts (対応テスト)
791
- ```
187
+ ## 📚 学習済みベストプラクティス
188
+
189
+ | パターン | 適用条件 | 効果 |
190
+ |----------|----------|------|
191
+ | Result型 | エラーハンドリング | 型安全なエラー処理 |
192
+ | Repository | データアクセス | 永続化層の抽象化 |
193
+ | ValueObject | 不変データ | 値の整合性保証 |
194
+ | AggregateRoot | 整合性境界 | トランザクション境界の明確化 |
195
+ | CQRS | 読み書き分離 | パフォーマンス最適化 |
196
+ | EventSourcing | 状態追跡 | 完全な監査証跡 |
197
+ | DomainEvent | 疎結合通知 | モジュール間の依存削減 |
198
+ | Specification | 条件カプセル化 | 再利用可能なビジネスルール |
199
+ | Factory | 生成ロジック | 複雑なオブジェクト生成の隠蔽 |
200
+ | Strategy | アルゴリズム切替 | 実行時の振る舞い変更 |
792
201
 
793
202
  ---
794
203
 
795
- ## 📚 学習済みベストプラクティス(v1.1.10 Updated!)
204
+ ## 🤖 Agent Skills(15スキル)
796
205
 
797
- Project-07〜14の実装から学習したパターンです。
206
+ ### Core Skills
798
207
 
799
- ### コードパターン
208
+ | スキル | トリガー | 機能 |
209
+ |--------|----------|------|
210
+ | `knowledge-capture` | 新情報入力時 | エンティティ抽出・関係構築 |
211
+ | `knowledge-integration` | 統合要求時 | 複数ソースの知識統合 |
212
+ | `structured-summary` | 要約要求時 | 構造化300字要約 |
213
+ | `deep-research` | 調査要求時 | 多段階深層調査 |
214
+ | `learning-extraction` | パターン発見時 | ベストプラクティス抽出 |
800
215
 
801
- | ID | 名称 | 概要 | 信頼度 |
802
- |----|------|------|--------|
803
- | BP-CODE-001 | Entity Input DTO | エンティティ作成にInput DTOオブジェクトを使用 | 95% |
804
- | BP-CODE-002 | Date-based ID Format | PREFIX-YYYYMMDD-NNN形式でIDを生成 | 90% |
805
- | BP-CODE-003 | Value Objects | ドメイン概念にValue Objectを使用 | 90% |
806
- | BP-CODE-004 | Function-based Value Objects | クラスではなくinterface+factory関数でVO実装 | 95% |
807
- | BP-CODE-005 | Result Type | 失敗可能な操作にResult<T, E>を使用 | 95% |
216
+ ### SDD Skills
808
217
 
809
- **Function-based Value Object例**:
810
- ```typescript
811
- // 推奨: Interface + Factory Function
812
- interface Price {
813
- readonly amount: number;
814
- readonly currency: 'JPY';
815
- }
816
-
817
- function createPrice(amount: number): Result<Price, ValidationError> {
818
- if (amount < 100 || amount > 1_000_000) {
819
- return err(new ValidationError('Price must be between 100 and 1,000,000 JPY'));
820
- }
821
- return ok({ amount, currency: 'JPY' });
822
- }
823
-
824
- // ❌ 非推奨: クラスベース(構造的型付けと相性が悪い)
825
- class Price {
826
- private constructor(readonly amount: number) {}
827
- static create(amount: number): Price { ... }
828
- }
829
- ```
218
+ | スキル | トリガー | 機能 |
219
+ |--------|----------|------|
220
+ | `musubix-domain-inference` | 要件分析時 | ドメインモデル推論 |
221
+ | `musubix-sdd-workflow` | SDD開始時 | 仕様駆動開発ガイド |
222
+ | `musubix-code-generation` | コード生成時 | SDD準拠コード生成 |
223
+ | `musubix-test-generation` | テスト生成時 | 仕様ベーステスト生成 |
224
+ | `musubix-traceability` | 追跡確認時 | 要件-実装追跡 |
830
225
 
831
- ### 設計パターン
226
+ ### Documentation Skills
832
227
 
833
- | ID | 名称 | 概要 | 信頼度 |
834
- |----|------|------|--------|
835
- | BP-DESIGN-001 | Status Transition Map | 有効なステータス遷移をMapで定義 | 95% |
836
- | BP-DESIGN-002 | Repository Async Pattern | 将来のDB移行に備えてasync化 | 85% |
837
- | BP-DESIGN-003 | Service Layer with DI | リポジトリをDIしたService層 | 90% |
838
- | BP-DESIGN-004 | Optimistic Locking | 同時編集検出のためのversion管理 | 90% |
839
- | BP-DESIGN-005 | AuditService | データ変更の監査ログ記録 | 85% |
840
- | BP-DESIGN-006 | Entity Counter Reset | テスト用のresetXxxCounter()関数を提供 | 95% |
841
- | BP-DESIGN-007 | Expiry Time Logic | 有効期限をexpiresAtフィールドで明示管理 | 90% |
228
+ | スキル | トリガー | 機能 |
229
+ |--------|----------|------|
230
+ | `musubix-adr-generation` | 決定記録時 | ADR自動生成 |
231
+ | `musubix-c4-design` | 設計図作成時 | C4モデル生成 |
232
+ | `musubix-technical-writing` | 文書作成時 | 技術文書生成 |
233
+ | `musubix-best-practices` | ノウハウ整理時 | ベストプラクティス文書化 |
234
+ | `musubix-ears-validation` | 要件検証時 | EARS構文検証 |
842
235
 
843
- **Status Transition Map例**:
844
- ```typescript
845
- const validStatusTransitions: Record<Status, Status[]> = {
846
- draft: ['active', 'cancelled'],
847
- active: ['completed', 'cancelled'],
848
- completed: [],
849
- cancelled: [],
850
- };
851
- ```
236
+ ---
852
237
 
853
- ### テストパターン
238
+ ## 📋 AI Agent ガイドライン
854
239
 
855
- | ID | 名称 | 概要 | 信頼度 |
856
- |----|------|------|--------|
857
- | BP-TEST-001 | Test Counter Reset | beforeEachでIDカウンターをリセット | 95% |
858
- | BP-TEST-002 | Verify API Before Test | テスト前にAPIシグネチャを確認 | 80% |
859
- | BP-TEST-003 | Vitest ESM Configuration | Vitest + TypeScript ESM構成 | 85% |
860
- | BP-TEST-004 | Result Type Test Pattern | isOk()/isErr()で両方のケースをテスト | 95% |
861
- | BP-TEST-005 | Status Transition Testing | 有効・無効な遷移を網羅的にテスト | 90% |
240
+ ### WHEN: 新規タスク開始
862
241
 
863
- **Result Type Test例**:
864
- ```typescript
865
- describe('createPrice', () => {
866
- it('should create valid price', () => {
867
- const result = createPrice(1000);
868
- expect(result.isOk()).toBe(true);
869
- if (result.isOk()) {
870
- expect(result.value.amount).toBe(1000);
871
- }
872
- });
873
-
874
- it('should reject price below minimum', () => {
875
- const result = createPrice(50);
876
- expect(result.isErr()).toBe(true);
877
- if (result.isErr()) {
878
- expect(result.error.message).toContain('100');
879
- }
880
- });
881
- });
882
242
  ```
883
-
884
- ### CLIでベストプラクティスを表示
885
-
886
- ```bash
887
- # 全ベストプラクティス表示
888
- npx musubix learn best-practices
889
-
890
- # カテゴリ別フィルタ
891
- npx musubix learn best-practices --category code
892
- npx musubix learn best-practices --category design
893
- npx musubix learn best-practices --category test
894
-
895
- # 高信頼度パターンのみ
896
- npx musubix learn best-practices --high-confidence
897
-
898
- # Markdown出力
899
- npx musubix learn best-practices --format markdown
243
+ DO:
244
+ 1. steering/ を読んでコンテキスト把握
245
+ 2. knowledge search で既存知識確認
246
+ 3. 関連 ADR を確認
247
+ 4. 必要なスキルを特定
900
248
  ```
901
249
 
902
- ---
903
-
904
- ## �📚 ドキュメント
905
-
906
- | ドキュメント | 説明 |
907
- |-------------|------|
908
- | [docs/INSTALL-GUIDE.md](docs/INSTALL-GUIDE.md) | インストールガイド |
909
- | [docs/USER-GUIDE.md](docs/USER-GUIDE.md) | ユーザーガイド |
910
- | [docs/API-REFERENCE.md](docs/API-REFERENCE.md) | APIリファレンス |
911
- | [README.md](README.md) | 英語版README |
912
- | [README.ja.md](README.ja.md) | 日本語版README |
913
-
914
- ---
915
-
916
- ## 🤝 AI Agent向けガイドライン
917
-
918
- ### コード生成時の注意点
919
-
920
- 1. **憲法条項の遵守**: 9条項を必ず確認
921
- 2. **steering/参照**: 決定前にproject memoryを確認
922
- 3. **EARS形式**: 要件は必ずEARS形式で記述
923
- 4. **トレーサビリティ**: コードコメントに要件IDを記載
924
- 5. **テスト先行**: Red-Green-Blueサイクルを遵守
925
- 6. **モノレポ構造**: パッケージ間の依存関係に注意
926
-
927
- ### 要件定義時の自動ヒアリング(v3.3.9 NEW!)
928
-
929
- 「○○の要件定義を開始」と依頼された場合、コンテキストが不足しているときは自動的にヒアリングを行います。
930
-
931
- #### ヒアリングフロー
250
+ ### WHEN: コード生成
932
251
 
933
252
  ```
934
- ユーザー: 「ログイン機能の要件定義を開始」
935
-
936
- AIエージェント: sdd_create_requirements(featureName: "login") を呼び出し
937
-
938
- MCPサーバー: needsClarification: true を返却
939
-
940
- AIエージェント: 以下の質問をユーザーに提示
253
+ DO:
254
+ 1. SDD ワークフローに従う
255
+ 2. 学習済みパターンを適用
256
+ 3. テストを同時生成
257
+ 4. トレーサビリティを維持
941
258
  ```
942
259
 
943
- #### 5つの核心質問
944
-
945
- | # | 観点 | 質問 |
946
- |---|------|------|
947
- | 1 | **WHY** | この機能で解決したい「本当の課題」は何ですか? |
948
- | 2 | **WHO** | この機能を最も必要としているのは誰ですか? |
949
- | 3 | **WHAT-IF** | もしこの機能が完璧に動作したら、何が変わりますか? |
950
- | 4 | **CONSTRAINT** | この機能で「絶対にやってはいけないこと」はありますか? |
951
- | 5 | **SUCCESS** | この機能が「成功した」と言えるのはどんな状態ですか? |
952
-
953
- #### 質問提示フォーマット
260
+ ### WHEN: エラー発生
954
261
 
955
262
  ```
956
- 📋 要件を明確にするため、いくつか質問させてください:
957
-
958
- 1. この機能で解決したい「本当の課題」は何ですか?
959
- 2. この機能を最も必要としているのは誰ですか?
960
- 3. もしこの機能が完璧に動作したら、何が変わりますか?
961
- 4. この機能で「絶対にやってはいけないこと」はありますか?
962
- 5. この機能が「成功した」と言えるのはどんな状態ですか?
963
-
964
- 回答をお願いします。
263
+ DO:
264
+ 1. Result型でエラーをラップ
265
+ 2. コンテキスト情報を付加
266
+ 3. リカバリー戦略を検討
267
+ 4. 学習データとして記録
965
268
  ```
966
269
 
967
- #### コンテキスト収集後の再呼び出し
270
+ ### WHEN: 不明点がある
968
271
 
969
- ```typescript
970
- // ユーザーが回答を提供した後
971
- sdd_create_requirements({
972
- projectName: "MyProject",
973
- featureName: "login",
974
- context: {
975
- purpose: "ログイン処理を簡素化し、UXを向上させる",
976
- targetUser: "一般ユーザー(技術レベル:初〜中級)",
977
- successState: "2秒以内にログイン完了、エラー率1%未満",
978
- constraints: "パスワードを平文で保存しない、ログイン試行回数制限",
979
- successCriteria: "ログイン成功率99%以上、平均ログイン時間2秒以下",
980
- },
981
- })
272
+ ```
273
+ DO:
274
+ 1. 仮定を明示して確認を求める
275
+ 2. 複数の選択肢を提示
276
+ 3. 決定事項は ADR に記録
982
277
  ```
983
278
 
984
- #### コンテキスト充足度レベル
985
-
986
- | レベル | 条件 | アクション |
987
- |--------|------|-----------|
988
- | **complete** | 5つの質問すべてに回答あり | 要件生成を開始 |
989
- | **partial** | 2-4つの質問に回答あり | 不足分の質問を返す |
990
- | **minimal** | 0-1つの質問に回答あり | 5つの核心質問すべてを返す |
991
-
992
- ### 推奨ワークフロー
279
+ ---
993
280
 
994
- > **⚠️ 重要ルール**: Phase 1〜3(要件定義・設計・タスク分解)は、**レビュー結果をユーザーに表示し、修正か次ステップかを確認すること**。ユーザーから明示的な承認を得るまで次フェーズに進んではならない。
995
- >
996
- > **🚫 絶対禁止**: **設計(Phase 2)から直接実装(Phase 4)に進むことは禁止**。必ずタスク分解(Phase 3)を経ること。タスク分解なしでの実装開始は憲法違反とみなす。
281
+ ## 🔄 推奨ワークフロー
997
282
 
998
283
  ```
999
- Phase 1: 要件定義】
1000
- ┌─────────────────────────────────────────────────────────────┐
1001
- 1. steering/ を読む │
1002
- │ 2. 要件定義書を作成(EARS形式) │
1003
- 3. ユーザーに提示
1004
- │ │
1005
- 4. セルフレビュー実施
1006
- │ - 既存実装との整合性チェック │
1007
- - EARS形式の検証 │
1008
- │ - 要件の網羅性・完全性確認 │
1009
- │ │
1010
- │ 5. レビュー結果を表示 │
1011
- │ ┌───────────────────────────────────────────────────────┐│
1012
- │ │ 📋 レビュー結果: ││
1013
- │ │ ✅ EARS形式: 準拠 ││
1014
- │ │ ✅ 優先度設定: 完了 ││
1015
- │ │ ⚠️ 整合性: 既存REQ-XXXと重複の可能性あり ││
1016
- │ │ ││
1017
- │ │ 👉 修正しますか?それとも次に進みますか? ││
1018
- │ │ - 「修正」→ 指摘箇所を修正して再提示 ││
1019
- │ │ - 「承認」→ Phase 2(設計)へ進む ││
1020
- │ └───────────────────────────────────────────────────────┘│
1021
- │ │
1022
- │ 6. ユーザー応答待ち │
1023
- │ - 修正指示 → 修正して3へ戻る │
1024
- │ - 承認 → Phase 2へ │
1025
- └─────────────────────────────────────────────────────────────┘
1026
-
1027
- 【Phase 2: 設計】
1028
- ┌─────────────────────────────────────────────────────────────┐
1029
- │ 1. 設計書を作成(C4モデル) │
1030
- │ 2. ユーザーに提示 │
1031
- │ │
1032
- │ 3. セルフレビュー実施 │
1033
- │ - 既存実装との型・インターフェース整合性 │
1034
- │ - 要件トレーサビリティ(REQ-* → DES-*) │
1035
- │ - 設計パターン・SOLID原則の適用確認 │
1036
- │ - 後方互換性・移行パスの確認 │
1037
- │ │
1038
- │ 4. レビュー結果を表示 │
1039
- │ ┌───────────────────────────────────────────────────────┐│
1040
- │ │ 📋 レビュー結果: ││
1041
- │ │ ✅ トレーサビリティ: REQ-001→DES-001 完了 ││
1042
- │ │ ✅ 型整合性: 既存インターフェースと互換 ││
1043
- │ │ ✅ 設計パターン: Repository, Service適用 ││
1044
- │ │ ││
1045
- │ │ 👉 修正しますか?それとも次に進みますか? ││
1046
- │ │ - 「修正」→ 指摘箇所を修正して再提示 ││
1047
- │ │ - 「承認」→ Phase 3(タスク分解)へ進む ││
1048
- │ │ ⚠️ 実装への直接遷移は禁止!必ずタスク分解を経る ││
1049
- │ └───────────────────────────────────────────────────────┘│
1050
- │ │
1051
- │ 5. ユーザー応答待ち │
1052
- │ - 修正指示 → 修正して2へ戻る │
1053
- │ - 承認 → Phase 3へ(※Phase 4への直接遷移は禁止) │
1054
- └─────────────────────────────────────────────────────────────┘
1055
-
1056
- 【Phase 3: タスク分解】⚠️ 必須フェーズ - スキップ禁止
1057
- ┌─────────────────────────────────────────────────────────────┐
1058
- │ 1. タスク分解書を作成(設計→実装タスク) │
1059
- │ 2. ユーザーに提示 │
1060
- │ │
1061
- │ 3. セルフレビュー実施 │
1062
- │ - 設計との対応確認(DES-* → TSK-*) │
1063
- │ - タスクサイズの適切性 │
1064
- │ - 依存関係・実行順序の妥当性 │
1065
- │ - 工数見積もりの現実性 │
1066
- │ │
1067
- │ 4. レビュー結果を表示 │
1068
- │ ┌───────────────────────────────────────────────────────┐│
1069
- │ │ 📋 レビュー結果: ││
1070
- │ │ ✅ トレーサビリティ: DES-001→TSK-001〜003 完了 ││
1071
- │ │ ✅ タスクサイズ: 各2-4時間で適切 ││
1072
- │ │ ✅ 依存関係: TSK-001→TSK-002→TSK-003 明確 ││
1073
- │ │ ││
1074
- │ │ 👉 修正しますか?それとも実装に進みますか? ││
1075
- │ │ - 「修正」→ 指摘箇所を修正して再提示 ││
1076
- │ │ - 「承認」→ Phase 4(実装)へ進む ││
1077
- │ └───────────────────────────────────────────────────────┘│
1078
- │ │
1079
- │ 5. ユーザー応答待ち │
1080
- │ - 修正指示 → 修正して2へ戻る │
1081
- │ - 承認 → Phase 4へ │
1082
- └─────────────────────────────────────────────────────────────┘
1083
-
1084
- 【Phase 4: 実装】⚠️ 前提条件: Phase 3(タスク分解)の承認が必須
1085
- ┌─────────────────────────────────────────────────────────────┐
1086
- │ ⛔ 開始前チェック: │
1087
- │ □ Phase 3(タスク分解)が完了し、ユーザー承認済みか? │
1088
- │ □ TSK-* が定義されているか? │
1089
- │ → 未完了の場合、Phase 3に戻ること │
1090
- │ │
1091
- │ タスクごとに: │
1092
- │ 1. テスト作成(Red) │
1093
- │ 2. 実装(Green) │
1094
- │ 3. リファクタリング(Blue) │
1095
- │ 4. ユニットテスト実行・合格確認 │
1096
- │ 5. 必要に応じて統合テスト │
1097
- └─────────────────────────────────────────────────────────────┘
1098
-
1099
- 【Phase 5: 完了】
1100
- ┌─────────────────────────────────────────────────────────────┐
1101
- │ 1. CHANGELOG.md を更新 │
1102
- │ 2. 必要に応じてその他ドキュメント更新 │
1103
- │ 3. Git コミット・プッシュ │
1104
- └─────────────────────────────────────────────────────────────┘
284
+ Phase 1: Context │ steering/ 読込 → knowledge search → ADR確認
285
+
286
+ Phase 2: Plan スキル選定 タスク分解 → 依存関係整理
287
+
288
+ Phase 3: Execute SDD準拠実装 → パターン適用 → テスト生成
289
+
290
+ Phase 4: Verify 形式検証 → トレーサビリティ確認 → レビュー
291
+
292
+ Phase 5: Learn Wake-Sleep → パターン抽出 → ナレッジ更新
1105
293
  ```
1106
294
 
1107
- ### レビュー結果の表示フォーマット
295
+ ---
1108
296
 
1109
- 各フェーズ終了時に以下の形式でレビュー結果を表示:
297
+ ## 📁 ストレージ構造
1110
298
 
1111
- ```
1112
- 📋 **レビュー結果**
299
+ | ディレクトリ | 用途 |
300
+ |--------------|------|
301
+ | `storage/learning/` | 学習データ |
302
+ | `storage/specs/` | SDD仕様 |
303
+ | `storage/design/` | 設計文書 |
304
+ | `storage/changes/` | 変更履歴 |
305
+ | `storage/reviews/` | レビュー記録 |
306
+ | `storage/dashboard/` | メトリクス |
1113
307
 
1114
- | 観点 | 状態 | 詳細 |
1115
- |------|------|------|
1116
- | チェック項目1 | ✅ OK | 説明 |
1117
- | チェック項目2 | ⚠️ 警告 | 要確認事項 |
1118
- | チェック項目3 | ❌ NG | 修正が必要 |
308
+ ---
1119
309
 
1120
- 👉 **次のアクションを選択してください:**
1121
- - 「修正」/ 具体的な修正指示 → 修正して再提示
1122
- - 「承認」/「OK」/「進める」 → 次フェーズへ
1123
- ```
310
+ ## 🚨 重要な制約
1124
311
 
1125
- ### 承認キーワード
312
+ | 制約 | 理由 |
313
+ |------|------|
314
+ | Node.js 20+ | ESM・最新API |
315
+ | TypeScript strict | 型安全性 |
316
+ | pnpm workspace | モノレポ管理 |
317
+ | Vitest | 高速テスト |
318
+ | ESLint flat config | 統一リント |
1126
319
 
1127
- ユーザーが以下のキーワードを使用した場合、次フェーズへ進む:
1128
- - `承認` / `approve` / `LGTM` / `進める` / `OK` / `実装`
320
+ ---
321
+
322
+ ## 📞 トラブルシューティング
1129
323
 
1130
- > **⚠️ 注意**: 「実装」キーワードが使われても、**現在のフェーズがPhase 2(設計)の場合は、必ずPhase 3(タスク分解)を先に実行すること**。タスク分解をスキップして実装に進むことは禁止されている。
324
+ | 症状 | 対処 |
325
+ |------|------|
326
+ | 依存解決エラー | `pnpm i --force` |
327
+ | 型エラー | `pnpm build` で再ビルド |
328
+ | テスト失敗 | `pnpm --filter <pkg> test` で個別実行 |
329
+ | MCP接続失敗 | ポート確認、`--debug` オプション |
1131
330
 
1132
331
  ---
1133
332
 
1134
- **Agent**: GitHub Copilot / Claude
1135
- **Last Updated**: 2026-01-11
1136
- **Version**: 3.0.0
333
+ **最終更新**: 2025-01-29 | **バージョン**: 3.7.2