musubix 3.3.4 → 3.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/AGENTS.md +949 -0
- package/.github/prompts/sdd-change-apply.prompt.md +283 -0
- package/.github/prompts/sdd-change-archive.prompt.md +241 -0
- package/.github/prompts/sdd-change-init.prompt.md +269 -0
- package/.github/prompts/sdd-design.prompt.md +250 -0
- package/.github/prompts/sdd-implement.prompt.md +387 -0
- package/.github/prompts/sdd-requirements.prompt.md +193 -0
- package/.github/prompts/sdd-review.prompt.md +155 -0
- package/.github/prompts/sdd-security.prompt.md +228 -0
- package/.github/prompts/sdd-steering.prompt.md +269 -0
- package/.github/prompts/sdd-tasks.prompt.md +255 -0
- package/.github/prompts/sdd-test.prompt.md +230 -0
- package/.github/prompts/sdd-validate.prompt.md +304 -0
- package/.github/skills/musubix-adr-generation/SKILL.md +209 -0
- package/.github/skills/musubix-best-practices/SKILL.md +315 -0
- package/.github/skills/musubix-c4-design/SKILL.md +162 -0
- package/.github/skills/musubix-code-generation/SKILL.md +237 -0
- package/.github/skills/musubix-domain-inference/SKILL.md +196 -0
- package/.github/skills/musubix-ears-validation/SKILL.md +161 -0
- package/.github/skills/musubix-sdd-workflow/SKILL.md +217 -0
- package/.github/skills/musubix-technical-writing/SKILL.md +444 -0
- package/.github/skills/musubix-test-generation/SKILL.md +212 -0
- package/.github/skills/musubix-traceability/SKILL.md +141 -0
- package/AGENTS.md +1065 -0
- package/LICENSE +21 -0
- package/README.ja.md +296 -0
- package/README.md +305 -50
- package/bin/musubix-mcp.js +15 -0
- package/bin/musubix.js +9 -1
- package/docs/API-REFERENCE.md +1425 -0
- package/docs/GITHUB-ACTIONS-NPM-SETUP.md +132 -0
- package/docs/INSTALL-GUIDE.ja.md +459 -0
- package/docs/INSTALL-GUIDE.md +459 -0
- package/docs/MIGRATION-v3.0.md +324 -0
- package/docs/MUSUBI-enhancement_roadmap_20260105.md +651 -0
- package/docs/MUSUBIX-v3.0-User-Guide.md +1357 -0
- package/docs/MUSUBIXv2.2.0-Manual-outline.md +136 -0
- package/docs/MUSUBIXv2.2.0-Manual.md +3123 -0
- package/docs/MUSUBIXv2.3.5-Refactering.md +1310 -0
- package/docs/MUSUBIv1.6.1-enhancement_roadmap_20260105.md +291 -0
- package/docs/MUSUBIv2.2.0-USERGUIDE.md +2079 -0
- package/docs/ROADMAP-v1.5.md +116 -0
- package/docs/SwarmCoding.md +1284 -0
- package/docs/Test-prompt.md +105 -0
- package/docs/USER-GUIDE-v1.8.0.md +2371 -0
- package/docs/USER-GUIDE.ja.md +2147 -0
- package/docs/USER-GUIDE.md +3022 -0
- package/docs/YATA-GLOBAL-GUIDE.ja.md +750 -0
- package/docs/YATA-GLOBAL-GUIDE.md +595 -0
- package/docs/YATA-LOCAL-GUIDE.ja.md +989 -0
- package/docs/YATA-LOCAL-GUIDE.md +730 -0
- package/docs/adr/0001-real-time-pattern-learning-architecture-for-v1-5-0.md +75 -0
- package/docs/adr/0002-pattern-sharing-protocol-for-cross-team-collaborat.md +79 -0
- package/docs/adr/0003-owl-2-rl-implementation-strategy-for-advanced-infe.md +90 -0
- package/docs/enterprise-knowledge-management.md +1737 -0
- package/docs/evolution-from-musubi-to-musubix.md +2170 -0
- package/docs/getting-started-with-sdd.md +1602 -0
- package/docs/moodle-refactering-codegraph-musubix.md +391 -0
- package/docs/moodle-refactering-codegraph.md +278 -0
- package/docs/overview/MUSUBIX-CodeGraph.md +322 -0
- package/docs/overview/MUSUBIX-Core.md +671 -0
- package/docs/overview/MUSUBIX-Decisions.md +494 -0
- package/docs/overview/MUSUBIX-FormalVerify.md +566 -0
- package/docs/overview/MUSUBIX-Knowledge.md +1231 -0
- package/docs/overview/MUSUBIX-Learning.md +837 -0
- package/docs/overview/MUSUBIX-MCP-Server.md +535 -0
- package/docs/overview/MUSUBIX-Overview.md +264 -0
- package/docs/overview/MUSUBIX-Phase1-Complete.md +271 -0
- package/docs/overview/MUSUBIX-Phase2-Complete.md +310 -0
- package/docs/overview/MUSUBIX-Policy.md +477 -0
- package/docs/overview/MUSUBIX-Roadmap-v2.md +399 -0
- package/docs/overview/MUSUBIX-Security-Plan.md +939 -0
- package/docs/overview/MUSUBIX-Security-v2.1.md +668 -0
- package/docs/overview/MUSUBIX-Security.md +891 -0
- package/docs/overview/MUSUBIX-YATA.md +666 -0
- package/docs/overview/MUSUBIX-v2.2.0-Advanced-Learning.md +513 -0
- package/docs/overview/Neuro-SymbolicAI.md +159 -0
- package/docs/packages/knowledge.md +594 -0
- package/docs/qiita-linux-kernel-knowledge-graph.md +596 -0
- package/package.json +55 -51
- package/scripts/generate-quality-gate-report.ts +106 -0
- package/scripts/postinstall.js +94 -0
- package/steering/.musubi-version +1 -0
- package/steering/product.ja.md +572 -0
- package/steering/project.yml +66 -0
- package/steering/rules/constitution.md +491 -0
- package/steering/structure.ja.md +503 -0
- package/steering/tech.ja.md +208 -0
- package/dist/index.d.ts +0 -25
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -74
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
# MUSUBIX Core パッケージ
|
|
2
|
+
|
|
3
|
+
**パッケージ名**: `@nahisaho/musubix-core`
|
|
4
|
+
**バージョン**: 1.7.5
|
|
5
|
+
**最終更新**: 2026-01-06
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. 概要
|
|
10
|
+
|
|
11
|
+
`@nahisaho/musubix-core` は、MUSUBIXシステムの中核となるライブラリです。CLI、EARS検証、コード生成、設計パターン検出、トレーサビリティ管理、シンボリック推論など、すべての基本機能を提供します。
|
|
12
|
+
|
|
13
|
+
### 1.1 モジュール構成
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
packages/core/src/
|
|
17
|
+
├── auth/ # 認証・認可
|
|
18
|
+
├── cli/ # CLIインターフェース
|
|
19
|
+
├── codegen/ # コード生成・解析
|
|
20
|
+
├── design/ # 設計パターン・C4モデル
|
|
21
|
+
├── error/ # エラーハンドリング
|
|
22
|
+
├── explanation/ # 説明生成・可視化
|
|
23
|
+
├── learning/ # 自己学習システム
|
|
24
|
+
├── perf/ # パフォーマンス最適化
|
|
25
|
+
├── requirements/ # 要件分析・分解
|
|
26
|
+
├── symbolic/ # シンボリック推論
|
|
27
|
+
├── testing/ # テスト支援
|
|
28
|
+
├── traceability/ # トレーサビリティ
|
|
29
|
+
├── types/ # 型定義
|
|
30
|
+
├── utils/ # ユーティリティ
|
|
31
|
+
└── validators/ # EARS検証
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 2. auth/ - 認証・認可モジュール
|
|
37
|
+
|
|
38
|
+
### 2.1 概要
|
|
39
|
+
|
|
40
|
+
ユーザー認証・認可管理を提供します。マルチプロバイダ対応で、エンタープライズ環境での利用を想定しています。
|
|
41
|
+
|
|
42
|
+
### 2.2 主要機能
|
|
43
|
+
|
|
44
|
+
| 機能 | 説明 |
|
|
45
|
+
|------|------|
|
|
46
|
+
| **マルチプロバイダ** | local, OAuth, SAML, LDAP, API-key |
|
|
47
|
+
| **トークン管理** | access, refresh, api-key |
|
|
48
|
+
| **セッション管理** | 有効期限、自動更新 |
|
|
49
|
+
| **MFA対応** | 二要素認証 |
|
|
50
|
+
| **RBAC** | ロールベースアクセス制御 |
|
|
51
|
+
|
|
52
|
+
### 2.3 主要な型
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// 認証プロバイダ
|
|
56
|
+
type AuthProvider = 'local' | 'oauth' | 'saml' | 'ldap' | 'api-key';
|
|
57
|
+
|
|
58
|
+
// ユーザー情報
|
|
59
|
+
interface User {
|
|
60
|
+
id: string;
|
|
61
|
+
email: string;
|
|
62
|
+
roles: string[];
|
|
63
|
+
permissions: string[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// トークン
|
|
67
|
+
interface Token {
|
|
68
|
+
accessToken: string;
|
|
69
|
+
refreshToken?: string;
|
|
70
|
+
expiresAt: Date;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 認可チェック
|
|
74
|
+
interface AuthorizationCheck {
|
|
75
|
+
resource: string;
|
|
76
|
+
action: 'read' | 'write' | 'delete' | 'admin';
|
|
77
|
+
allowed: boolean;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 2.4 トレーサビリティ
|
|
82
|
+
|
|
83
|
+
- **REQ-SEC-002**: 認証・認可要件
|
|
84
|
+
- **Article VIII**: Decision Records(認証方式の決定記録)
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 3. cli/ - CLIモジュール
|
|
89
|
+
|
|
90
|
+
### 3.1 概要
|
|
91
|
+
|
|
92
|
+
Commander.jsベースのCLIフレームワークを提供します。すべてのMUSUBIX機能にコマンドラインからアクセスできます。
|
|
93
|
+
|
|
94
|
+
### 3.2 主要コマンド
|
|
95
|
+
|
|
96
|
+
#### 初期化
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npx musubix init [path] [--name <name>] [--force]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### 要件分析
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npx musubix requirements analyze <file> # 自然言語 → EARS変換
|
|
106
|
+
npx musubix requirements validate <file> # EARS構文検証
|
|
107
|
+
npx musubix requirements map <file> # オントロジーマッピング
|
|
108
|
+
npx musubix requirements search <query> # 関連要件検索
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### 設計生成
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npx musubix design generate <file> # 要件から設計生成
|
|
115
|
+
npx musubix design patterns <context> # パターン検出
|
|
116
|
+
npx musubix design validate <file> # SOLID準拠検証
|
|
117
|
+
npx musubix design c4 <file> # C4ダイアグラム生成
|
|
118
|
+
npx musubix design adr <decision> # ADR生成
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### コード生成
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npx musubix codegen generate <file> # 設計からコード生成
|
|
125
|
+
npx musubix codegen analyze <file> # 静的解析
|
|
126
|
+
npx musubix codegen security <path> # セキュリティスキャン
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### テスト
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npx musubix test generate <file> # テスト生成
|
|
133
|
+
npx musubix test coverage <dir> # カバレッジ測定
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### トレーサビリティ
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npx musubix trace matrix # トレーサビリティマトリクス
|
|
140
|
+
npx musubix trace impact <id> # 影響分析
|
|
141
|
+
npx musubix trace validate # リンク検証
|
|
142
|
+
npx musubix trace sync # 自動更新
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### 自己学習
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npx musubix learn status # 学習状態ダッシュボード
|
|
149
|
+
npx musubix learn feedback <id> # フィードバック記録
|
|
150
|
+
npx musubix learn patterns # パターン一覧
|
|
151
|
+
npx musubix learn recommend # 推奨パターン
|
|
152
|
+
npx musubix learn export # エクスポート
|
|
153
|
+
npx musubix learn import <file> # インポート
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### REPL
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npx musubix repl # 対話的シェル
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### KGPR(Knowledge Graph Pull Request)
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npx musubix kgpr create -t "title" # KGPR作成
|
|
166
|
+
npx musubix kgpr diff # 差分プレビュー
|
|
167
|
+
npx musubix kgpr list # 一覧
|
|
168
|
+
npx musubix kgpr submit <id> # 送信
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 3.3 グローバルオプション
|
|
172
|
+
|
|
173
|
+
| オプション | 説明 |
|
|
174
|
+
|-----------|------|
|
|
175
|
+
| `--verbose, -v` | 詳細出力 |
|
|
176
|
+
| `--json` | JSON形式出力 |
|
|
177
|
+
| `--config <file>` | 設定ファイル指定 |
|
|
178
|
+
| `--quiet, -q` | 静音モード |
|
|
179
|
+
|
|
180
|
+
### 3.4 終了コード
|
|
181
|
+
|
|
182
|
+
| コード | 意味 |
|
|
183
|
+
|--------|------|
|
|
184
|
+
| 0 | 成功 |
|
|
185
|
+
| 1 | 一般エラー |
|
|
186
|
+
| 2 | 検証エラー |
|
|
187
|
+
| 3 | 設定エラー |
|
|
188
|
+
| 4 | 入出力エラー |
|
|
189
|
+
| 5 | 内部エラー |
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 4. codegen/ - コード生成モジュール
|
|
194
|
+
|
|
195
|
+
### 4.1 概要
|
|
196
|
+
|
|
197
|
+
設計ドキュメントからマルチ言語対応のコードを自動生成します。静的解析、品質メトリクス、セキュリティスキャン機能も提供します。
|
|
198
|
+
|
|
199
|
+
### 4.2 対応言語
|
|
200
|
+
|
|
201
|
+
| 言語 | ファイル拡張子 |
|
|
202
|
+
|------|---------------|
|
|
203
|
+
| TypeScript | `.ts` |
|
|
204
|
+
| JavaScript | `.js` |
|
|
205
|
+
| Python | `.py` |
|
|
206
|
+
| Java | `.java` |
|
|
207
|
+
| C# | `.cs` |
|
|
208
|
+
| Go | `.go` |
|
|
209
|
+
| Rust | `.rs` |
|
|
210
|
+
|
|
211
|
+
### 4.3 主要クラス
|
|
212
|
+
|
|
213
|
+
#### CodeGenerator
|
|
214
|
+
|
|
215
|
+
メインのコード生成器。
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
import { CodeGenerator } from '@nahisaho/musubix-core';
|
|
219
|
+
|
|
220
|
+
const generator = new CodeGenerator({
|
|
221
|
+
language: 'typescript',
|
|
222
|
+
outputDir: './src',
|
|
223
|
+
patterns: ['repository', 'service', 'factory'],
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const result = await generator.generate(designDocument);
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### StaticAnalyzer
|
|
230
|
+
|
|
231
|
+
コードの静的解析を実行。
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
import { StaticAnalyzer } from '@nahisaho/musubix-core';
|
|
235
|
+
|
|
236
|
+
const analyzer = new StaticAnalyzer();
|
|
237
|
+
const issues = await analyzer.analyze('./src');
|
|
238
|
+
// 複雑度、デッドコード、未使用変数などを検出
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
#### SecurityScanner
|
|
242
|
+
|
|
243
|
+
セキュリティ脆弱性をスキャン。
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
import { SecurityScanner } from '@nahisaho/musubix-core';
|
|
247
|
+
|
|
248
|
+
const scanner = new SecurityScanner();
|
|
249
|
+
const vulnerabilities = await scanner.scan('./src');
|
|
250
|
+
// SQLインジェクション、XSS、ハードコードされた秘密情報などを検出
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### QualityMetrics
|
|
254
|
+
|
|
255
|
+
コード品質メトリクスを計算。
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
import { QualityMetrics } from '@nahisaho/musubix-core';
|
|
259
|
+
|
|
260
|
+
const metrics = new QualityMetrics();
|
|
261
|
+
const report = await metrics.calculate('./src');
|
|
262
|
+
// 循環的複雑度、行数、テストカバレッジなど
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### 4.4 テスト生成
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
import { UnitTestGenerator, IntegrationTestGenerator } from '@nahisaho/musubix-core';
|
|
269
|
+
|
|
270
|
+
// ユニットテスト生成
|
|
271
|
+
const unitGen = new UnitTestGenerator();
|
|
272
|
+
const unitTests = await unitGen.generate(sourceFile);
|
|
273
|
+
|
|
274
|
+
// 統合テスト生成
|
|
275
|
+
const intGen = new IntegrationTestGenerator();
|
|
276
|
+
const integrationTests = await intGen.generate(componentSpec);
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 5. design/ - 設計モジュール
|
|
282
|
+
|
|
283
|
+
### 5.1 概要
|
|
284
|
+
|
|
285
|
+
C4モデル図の自動生成、デザインパターン検出、ADR生成、SOLID原則検証を提供します。
|
|
286
|
+
|
|
287
|
+
### 5.2 C4モデル生成
|
|
288
|
+
|
|
289
|
+
4つのレベルでシステム設計を構造化します。
|
|
290
|
+
|
|
291
|
+
| レベル | 説明 |
|
|
292
|
+
|--------|------|
|
|
293
|
+
| **Context** | システム境界と外部アクター |
|
|
294
|
+
| **Container** | 技術選択とコンテナ構成 |
|
|
295
|
+
| **Component** | コンテナ内部構造 |
|
|
296
|
+
| **Code** | 実装詳細 |
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
import { C4Generator } from '@nahisaho/musubix-core';
|
|
300
|
+
|
|
301
|
+
const generator = new C4Generator();
|
|
302
|
+
const diagram = await generator.generate(requirements, {
|
|
303
|
+
level: 'component',
|
|
304
|
+
format: 'mermaid', // 'structurizr' | 'plantuml' | 'mermaid' | 'json'
|
|
305
|
+
});
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### 5.3 デザインパターン検出
|
|
309
|
+
|
|
310
|
+
```typescript
|
|
311
|
+
import { PatternDetector } from '@nahisaho/musubix-core';
|
|
312
|
+
|
|
313
|
+
const detector = new PatternDetector();
|
|
314
|
+
const patterns = await detector.detect(codebase);
|
|
315
|
+
// Repository, Service, Factory, Singleton, Observer など
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### 5.4 ADR生成
|
|
319
|
+
|
|
320
|
+
Architecture Decision Record(アーキテクチャ決定記録)を生成。
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
import { AdrGenerator } from '@nahisaho/musubix-core';
|
|
324
|
+
|
|
325
|
+
const generator = new AdrGenerator();
|
|
326
|
+
const adr = await generator.generate({
|
|
327
|
+
title: 'Use PostgreSQL for persistence',
|
|
328
|
+
context: 'Need a reliable database...',
|
|
329
|
+
decision: 'Use PostgreSQL...',
|
|
330
|
+
consequences: ['Pro: ACID compliance', 'Con: More complex setup'],
|
|
331
|
+
});
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### 5.5 SOLID検証
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
import { SolidValidator } from '@nahisaho/musubix-core';
|
|
338
|
+
|
|
339
|
+
const validator = new SolidValidator();
|
|
340
|
+
const violations = await validator.validate('./src');
|
|
341
|
+
// SRP, OCP, LSP, ISP, DIP の違反を検出
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## 6. symbolic/ - シンボリック推論モジュール
|
|
347
|
+
|
|
348
|
+
### 6.1 概要
|
|
349
|
+
|
|
350
|
+
ニューロシンボリックAI統合の中核モジュール。LLM出力の検証、ハルシネーション検出、憲法ルール施行、形式検証を提供します。
|
|
351
|
+
|
|
352
|
+
### 6.2 セマンティックフィルタ
|
|
353
|
+
|
|
354
|
+
LLMが生成したコードをシンボリック検証でフィルタリング。
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
import { SemanticCodeFilterPipeline } from '@nahisaho/musubix-core';
|
|
358
|
+
|
|
359
|
+
const pipeline = new SemanticCodeFilterPipeline({
|
|
360
|
+
projectContext: { /* プロジェクト情報 */ },
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
const result = await pipeline.filter({
|
|
364
|
+
code: generatedCode,
|
|
365
|
+
prompt: originalPrompt,
|
|
366
|
+
});
|
|
367
|
+
// valid/invalid/warning を返す
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### 6.3 ハルシネーション検出
|
|
371
|
+
|
|
372
|
+
存在しないAPIやインポートを検出。
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
import { HallucinationDetector, ProjectSymbolIndex } from '@nahisaho/musubix-core';
|
|
376
|
+
|
|
377
|
+
const index = new ProjectSymbolIndex();
|
|
378
|
+
await index.buildFromDirectory('./src');
|
|
379
|
+
|
|
380
|
+
const detector = new HallucinationDetector(index);
|
|
381
|
+
const hallucinations = await detector.detect(code);
|
|
382
|
+
// 存在しない関数、クラス、モジュールを報告
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### 6.4 憲法ルールチェック
|
|
386
|
+
|
|
387
|
+
9条憲法への準拠を検証。
|
|
388
|
+
|
|
389
|
+
```typescript
|
|
390
|
+
import { ConstitutionRuleRegistry, DEFAULT_CONSTITUTION_RULES } from '@nahisaho/musubix-core';
|
|
391
|
+
|
|
392
|
+
const registry = new ConstitutionRuleRegistry(DEFAULT_CONSTITUTION_RULES);
|
|
393
|
+
const report = await registry.checkAll({
|
|
394
|
+
code: sourceCode,
|
|
395
|
+
design: designDoc,
|
|
396
|
+
requirements: reqDoc,
|
|
397
|
+
});
|
|
398
|
+
// 各条項の準拠状況を報告
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### 6.5 信頼度ルーティング
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
import { ConfidenceEstimator, ConfidenceBasedRouter } from '@nahisaho/musubix-core';
|
|
405
|
+
|
|
406
|
+
const estimator = new ConfidenceEstimator();
|
|
407
|
+
const confidence = await estimator.estimate(llmOutput);
|
|
408
|
+
|
|
409
|
+
const router = new ConfidenceBasedRouter();
|
|
410
|
+
const decision = router.route({
|
|
411
|
+
symbolicResult: 'valid',
|
|
412
|
+
neuralConfidence: confidence.score,
|
|
413
|
+
});
|
|
414
|
+
// 'accept' | 'reject' | 'prefer_symbolic'
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### 6.6 形式検証(Z3)
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
import { Z3Adapter, EarsToFormalSpecConverter } from '@nahisaho/musubix-core';
|
|
421
|
+
|
|
422
|
+
// EARS→SMT変換
|
|
423
|
+
const converter = new EarsToFormalSpecConverter();
|
|
424
|
+
const smtSpec = converter.convert(earsRequirement);
|
|
425
|
+
|
|
426
|
+
// Z3で検証
|
|
427
|
+
const z3 = new Z3Adapter();
|
|
428
|
+
const result = await z3.verify(smtSpec);
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
---
|
|
432
|
+
|
|
433
|
+
## 7. traceability/ - トレーサビリティモジュール
|
|
434
|
+
|
|
435
|
+
### 7.1 概要
|
|
436
|
+
|
|
437
|
+
要件・設計・コード・テスト間の双方向トレーサビリティを管理します。
|
|
438
|
+
|
|
439
|
+
### 7.2 リンクタイプ
|
|
440
|
+
|
|
441
|
+
| タイプ | 説明 |
|
|
442
|
+
|--------|------|
|
|
443
|
+
| `derives` | 派生関係 |
|
|
444
|
+
| `implements` | 実装関係 |
|
|
445
|
+
| `satisfies` | 充足関係 |
|
|
446
|
+
| `verifies` | 検証関係 |
|
|
447
|
+
| `decomposes` | 分解関係 |
|
|
448
|
+
| `relates` | 関連関係 |
|
|
449
|
+
| `conflicts` | 競合関係 |
|
|
450
|
+
|
|
451
|
+
### 7.3 使用例
|
|
452
|
+
|
|
453
|
+
```typescript
|
|
454
|
+
import { TraceabilityManager } from '@nahisaho/musubix-core';
|
|
455
|
+
|
|
456
|
+
const manager = new TraceabilityManager();
|
|
457
|
+
|
|
458
|
+
// リンク追加
|
|
459
|
+
await manager.addLink({
|
|
460
|
+
source: 'REQ-001',
|
|
461
|
+
target: 'DES-001',
|
|
462
|
+
type: 'implements',
|
|
463
|
+
confidence: 0.95,
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
// 影響分析
|
|
467
|
+
const impact = await manager.analyzeImpact('REQ-001');
|
|
468
|
+
|
|
469
|
+
// マトリクス生成
|
|
470
|
+
const matrix = await manager.generateMatrix();
|
|
471
|
+
|
|
472
|
+
// ギャップ検出
|
|
473
|
+
const gaps = await manager.detectGaps();
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
---
|
|
477
|
+
|
|
478
|
+
## 8. validators/ - EARS検証モジュール
|
|
479
|
+
|
|
480
|
+
### 8.1 概要
|
|
481
|
+
|
|
482
|
+
EARS(Easy Approach to Requirements Syntax)形式の要件を検証します。
|
|
483
|
+
|
|
484
|
+
### 8.2 パターン
|
|
485
|
+
|
|
486
|
+
| パターン | キーワード | 例 |
|
|
487
|
+
|---------|-----------|-----|
|
|
488
|
+
| **Ubiquitous** | `THE ... SHALL` | THE system SHALL encrypt data |
|
|
489
|
+
| **Event-driven** | `WHEN ... THE ... SHALL` | WHEN user logs in, THE system SHALL... |
|
|
490
|
+
| **State-driven** | `WHILE ... THE ... SHALL` | WHILE in maintenance, THE system SHALL... |
|
|
491
|
+
| **Unwanted** | `SHALL NOT` | THE system SHALL NOT expose... |
|
|
492
|
+
| **Optional** | `IF ... THEN ... SHALL` | IF admin, THEN THE system SHALL... |
|
|
493
|
+
|
|
494
|
+
### 8.3 使用例
|
|
495
|
+
|
|
496
|
+
```typescript
|
|
497
|
+
import { EarsValidator } from '@nahisaho/musubix-core';
|
|
498
|
+
|
|
499
|
+
const validator = new EarsValidator();
|
|
500
|
+
const result = await validator.validate(
|
|
501
|
+
'WHEN a user submits login form, THE system SHALL validate credentials.'
|
|
502
|
+
);
|
|
503
|
+
|
|
504
|
+
console.log(result.pattern); // 'event-driven'
|
|
505
|
+
console.log(result.confidence); // 0.95
|
|
506
|
+
console.log(result.isValid); // true
|
|
507
|
+
console.log(result.suggestions); // 改善提案(もしあれば)
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## 9. learning/ - 自己学習モジュール
|
|
513
|
+
|
|
514
|
+
### 9.1 概要
|
|
515
|
+
|
|
516
|
+
フィードバック収集、パターン抽出、適応的推論を提供します。
|
|
517
|
+
|
|
518
|
+
### 9.2 フィードバックタイプ
|
|
519
|
+
|
|
520
|
+
| タイプ | 説明 |
|
|
521
|
+
|--------|------|
|
|
522
|
+
| `accept` | 生成結果を受け入れ |
|
|
523
|
+
| `reject` | 生成結果を拒否 |
|
|
524
|
+
| `modify` | 修正して使用 |
|
|
525
|
+
|
|
526
|
+
### 9.3 使用例
|
|
527
|
+
|
|
528
|
+
```typescript
|
|
529
|
+
import { LearningEngine, FeedbackCollector } from '@nahisaho/musubix-core';
|
|
530
|
+
|
|
531
|
+
const collector = new FeedbackCollector();
|
|
532
|
+
|
|
533
|
+
// フィードバック収集
|
|
534
|
+
await collector.record({
|
|
535
|
+
generationId: 'gen-001',
|
|
536
|
+
type: 'accept',
|
|
537
|
+
context: { language: 'typescript', pattern: 'repository' },
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
// 学習エンジン
|
|
541
|
+
const engine = new LearningEngine();
|
|
542
|
+
await engine.learn();
|
|
543
|
+
|
|
544
|
+
// パターン推奨
|
|
545
|
+
const recommendations = await engine.recommend(currentContext);
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
---
|
|
549
|
+
|
|
550
|
+
## 10. error/ - エラーハンドリングモジュール
|
|
551
|
+
|
|
552
|
+
### 10.1 概要
|
|
553
|
+
|
|
554
|
+
グレースフルデグラデーションとマルチ戦略フォールバックを提供します。
|
|
555
|
+
|
|
556
|
+
### 10.2 サービスモード
|
|
557
|
+
|
|
558
|
+
| モード | 説明 |
|
|
559
|
+
|--------|------|
|
|
560
|
+
| `full` | 全機能利用可能 |
|
|
561
|
+
| `reduced` | 一部機能制限 |
|
|
562
|
+
| `minimal` | 最小限の機能 |
|
|
563
|
+
| `offline` | オフライン動作 |
|
|
564
|
+
| `emergency` | 緊急モード |
|
|
565
|
+
|
|
566
|
+
### 10.3 フォールバック戦略
|
|
567
|
+
|
|
568
|
+
| 戦略 | 説明 |
|
|
569
|
+
|------|------|
|
|
570
|
+
| `use-cache` | キャッシュを利用 |
|
|
571
|
+
| `default-value` | デフォルト値を返す |
|
|
572
|
+
| `retry` | リトライ(バックオフ付き) |
|
|
573
|
+
| `alternative` | 代替サービスを使用 |
|
|
574
|
+
| `skip` | スキップ |
|
|
575
|
+
| `manual` | 手動介入要求 |
|
|
576
|
+
|
|
577
|
+
---
|
|
578
|
+
|
|
579
|
+
## 11. perf/ - パフォーマンスモジュール
|
|
580
|
+
|
|
581
|
+
### 11.1 概要
|
|
582
|
+
|
|
583
|
+
遅延ローディング、キャッシュ、並列実行、メモリ監視を提供します。
|
|
584
|
+
|
|
585
|
+
### 11.2 主要機能
|
|
586
|
+
|
|
587
|
+
```typescript
|
|
588
|
+
import {
|
|
589
|
+
LazyLoader,
|
|
590
|
+
LRUCache,
|
|
591
|
+
ParallelExecutor,
|
|
592
|
+
MemoryMonitor
|
|
593
|
+
} from '@nahisaho/musubix-core';
|
|
594
|
+
|
|
595
|
+
// 遅延ローディング
|
|
596
|
+
const loader = new LazyLoader();
|
|
597
|
+
const heavyModule = await loader.load(() => import('./heavy-module'));
|
|
598
|
+
|
|
599
|
+
// LRUキャッシュ
|
|
600
|
+
const cache = new LRUCache<string, Result>({ maxSize: 1000 });
|
|
601
|
+
cache.set('key', result);
|
|
602
|
+
|
|
603
|
+
// 並列実行
|
|
604
|
+
const executor = new ParallelExecutor({ concurrency: 4 });
|
|
605
|
+
const results = await executor.map(items, processItem);
|
|
606
|
+
|
|
607
|
+
// メモリ監視
|
|
608
|
+
const monitor = new MemoryMonitor();
|
|
609
|
+
monitor.onThreshold(0.8, () => {
|
|
610
|
+
console.log('Memory usage above 80%');
|
|
611
|
+
});
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## 12. testing/ - テスト支援モジュール
|
|
617
|
+
|
|
618
|
+
### 12.1 概要
|
|
619
|
+
|
|
620
|
+
E2Eテストフレームワーク、テストフィクスチャ管理、CLIランナーを提供します。
|
|
621
|
+
|
|
622
|
+
### 12.2 主要機能
|
|
623
|
+
|
|
624
|
+
```typescript
|
|
625
|
+
import {
|
|
626
|
+
TestContext,
|
|
627
|
+
TestProject,
|
|
628
|
+
TestFixtures,
|
|
629
|
+
CLIRunner,
|
|
630
|
+
assertEarsValid,
|
|
631
|
+
assertDesignComplete
|
|
632
|
+
} from '@nahisaho/musubix-core';
|
|
633
|
+
|
|
634
|
+
// テストコンテキスト
|
|
635
|
+
const ctx = new TestContext();
|
|
636
|
+
await ctx.setup();
|
|
637
|
+
|
|
638
|
+
// テストプロジェクト
|
|
639
|
+
const project = new TestProject('test-project');
|
|
640
|
+
await project.scaffold();
|
|
641
|
+
|
|
642
|
+
// CLIランナー
|
|
643
|
+
const runner = new CLIRunner();
|
|
644
|
+
const result = await runner.run('musubix', ['requirements', 'validate', 'req.md']);
|
|
645
|
+
|
|
646
|
+
// カスタムアサーション
|
|
647
|
+
assertEarsValid(requirement);
|
|
648
|
+
assertDesignComplete(design);
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
---
|
|
652
|
+
|
|
653
|
+
## 13. API リファレンス
|
|
654
|
+
|
|
655
|
+
詳細なAPIリファレンスは [API-REFERENCE.md](API-REFERENCE.md) を参照してください。
|
|
656
|
+
|
|
657
|
+
---
|
|
658
|
+
|
|
659
|
+
## 14. 関連ドキュメント
|
|
660
|
+
|
|
661
|
+
| ドキュメント | 説明 |
|
|
662
|
+
|-------------|------|
|
|
663
|
+
| [MUSUBIX-Overview.md](MUSUBIX-Overview.md) | 全体概要 |
|
|
664
|
+
| [MUSUBIX-FormalVerify.md](MUSUBIX-FormalVerify.md) | 形式検証 |
|
|
665
|
+
| [MUSUBIX-MCP-Server.md](MUSUBIX-MCP-Server.md) | MCPサーバー |
|
|
666
|
+
| [MUSUBIX-YATA.md](MUSUBIX-YATA.md) | YATA知識グラフ |
|
|
667
|
+
| [MUSUBIX-Learning.md](MUSUBIX-Learning.md) | 学習システム |
|
|
668
|
+
|
|
669
|
+
---
|
|
670
|
+
|
|
671
|
+
**© 2026 MUSUBIX Project**
|