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,322 @@
|
|
|
1
|
+
# MUSUBIX CodeGraph v2.3.0
|
|
2
|
+
|
|
3
|
+
> **@nahisaho/musubix-codegraph** - コード知識グラフライブラリ
|
|
4
|
+
|
|
5
|
+
## 概要
|
|
6
|
+
|
|
7
|
+
CodeGraphは、ソースコードを知識グラフとして構造化し、GraphRAGベースのセマンティック検索を提供するライブラリです。AST解析、依存関係追跡、呼び出しグラフ分析など、コードベース全体を理解するための機能を提供します。
|
|
8
|
+
|
|
9
|
+
## 主要機能
|
|
10
|
+
|
|
11
|
+
### 1. AST解析・エンティティ抽出
|
|
12
|
+
|
|
13
|
+
複数言語のソースコードを解析し、関数、クラス、変数などのエンティティを抽出します。
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { createCodeGraph } from '@nahisaho/musubix-codegraph';
|
|
17
|
+
|
|
18
|
+
const codeGraph = await createCodeGraph({ storage: 'memory' });
|
|
19
|
+
const result = await codeGraph.index('/path/to/project');
|
|
20
|
+
|
|
21
|
+
console.log(`Entities: ${result.entitiesIndexed}`);
|
|
22
|
+
console.log(`Relations: ${result.relationsIndexed}`);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**対応言語:**
|
|
26
|
+
- TypeScript / JavaScript
|
|
27
|
+
- Python
|
|
28
|
+
- Rust
|
|
29
|
+
- Go
|
|
30
|
+
- Java
|
|
31
|
+
- PHP
|
|
32
|
+
- C# / C / C++
|
|
33
|
+
- Ruby
|
|
34
|
+
- Kotlin / Swift / Scala
|
|
35
|
+
- Lua
|
|
36
|
+
- HCL (Terraform)
|
|
37
|
+
|
|
38
|
+
### 2. グラフクエリ
|
|
39
|
+
|
|
40
|
+
エンティティをさまざまな条件で検索できます。
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// テキスト検索
|
|
44
|
+
const result = await codeGraph.query({ textSearch: 'authentication' });
|
|
45
|
+
|
|
46
|
+
// 型フィルタ
|
|
47
|
+
const classes = await codeGraph.query({ entityTypes: ['class'] });
|
|
48
|
+
|
|
49
|
+
// ファイルフィルタ
|
|
50
|
+
const entities = await codeGraph.query({ filePath: 'src/auth/' });
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. 依存関係分析
|
|
54
|
+
|
|
55
|
+
エンティティ間の依存関係を追跡します。
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// 依存先を検索
|
|
59
|
+
const deps = await codeGraph.findDependencies('UserService');
|
|
60
|
+
|
|
61
|
+
// インターフェースの実装を検索
|
|
62
|
+
const impls = await codeGraph.findImplementations('IRepository');
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 4. 呼び出しグラフ分析
|
|
66
|
+
|
|
67
|
+
関数・メソッドの呼び出し関係を分析します。
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
// 呼び出し元を検索
|
|
71
|
+
const callers = await codeGraph.findCallers('authenticate');
|
|
72
|
+
|
|
73
|
+
// 呼び出し先を検索
|
|
74
|
+
const callees = await codeGraph.findCallees('processRequest');
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 5. GraphRAGセマンティック検索
|
|
78
|
+
|
|
79
|
+
コミュニティ検出とセマンティック検索を組み合わせた高度な検索機能です。
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// グローバル検索(コードベース全体)
|
|
83
|
+
const results = await codeGraph.globalSearch('user authentication flow');
|
|
84
|
+
|
|
85
|
+
// ローカル検索(特定エンティティ周辺)
|
|
86
|
+
const local = await codeGraph.localSearch('validation', {
|
|
87
|
+
radius: 2,
|
|
88
|
+
limit: 10,
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## アーキテクチャ
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
96
|
+
│ CodeGraph API │
|
|
97
|
+
├─────────────────────────────────────────────────────────────┤
|
|
98
|
+
│ │
|
|
99
|
+
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌──────────┐ │
|
|
100
|
+
│ │ AST Parser│ │Graph Engine│ │ Indexer │ │ GraphRAG │ │
|
|
101
|
+
│ └─────┬─────┘ └─────┬─────┘ └─────┬─────┘ └────┬─────┘ │
|
|
102
|
+
│ │ │ │ │ │
|
|
103
|
+
│ ┌─────▼─────────────▼──────────────▼──────────────▼─────┐ │
|
|
104
|
+
│ │ Storage Adapter │ │
|
|
105
|
+
│ │ (Memory / SQLite / Custom) │ │
|
|
106
|
+
│ └───────────────────────────────────────────────────────┘ │
|
|
107
|
+
└─────────────────────────────────────────────────────────────┘
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### コンポーネント
|
|
111
|
+
|
|
112
|
+
| コンポーネント | 役割 |
|
|
113
|
+
|---------------|------|
|
|
114
|
+
| **AST Parser** | Tree-sitterベースの多言語AST解析 |
|
|
115
|
+
| **Graph Engine** | エンティティ・リレーション管理、クエリ処理 |
|
|
116
|
+
| **Indexer** | ファイルシステム走査、並列インデックス |
|
|
117
|
+
| **GraphRAG** | コミュニティ検出、セマンティック検索 |
|
|
118
|
+
| **Storage** | プラグイン可能なストレージバックエンド |
|
|
119
|
+
|
|
120
|
+
## CLI コマンド
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# ディレクトリをインデックス
|
|
124
|
+
npx musubix cg index <path>
|
|
125
|
+
|
|
126
|
+
# エンティティを検索
|
|
127
|
+
npx musubix cg query [name] [-t type] [-l limit]
|
|
128
|
+
|
|
129
|
+
# 依存関係を検索
|
|
130
|
+
npx musubix cg deps <name>
|
|
131
|
+
|
|
132
|
+
# 呼び出し元を検索
|
|
133
|
+
npx musubix cg callers <name>
|
|
134
|
+
|
|
135
|
+
# 呼び出し先を検索
|
|
136
|
+
npx musubix cg callees <name>
|
|
137
|
+
|
|
138
|
+
# セマンティック検索
|
|
139
|
+
npx musubix cg search <query> [-L local] [-c context]
|
|
140
|
+
|
|
141
|
+
# 統計を表示
|
|
142
|
+
npx musubix cg stats
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## MCP ツール
|
|
146
|
+
|
|
147
|
+
MCPサーバー経由で以下のツールが利用可能です:
|
|
148
|
+
|
|
149
|
+
| ツール名 | 説明 |
|
|
150
|
+
|---------|------|
|
|
151
|
+
| `codegraph_index` | リポジトリ/ディレクトリをインデックス |
|
|
152
|
+
| `codegraph_query` | エンティティをクエリ |
|
|
153
|
+
| `codegraph_find_dependencies` | 依存関係を検索 |
|
|
154
|
+
| `codegraph_find_callers` | 関数の呼び出し元を検索 |
|
|
155
|
+
| `codegraph_find_callees` | 関数の呼び出し先を検索 |
|
|
156
|
+
| `codegraph_global_search` | GraphRAGセマンティック検索 |
|
|
157
|
+
| `codegraph_local_search` | ローカルコンテキスト検索 |
|
|
158
|
+
| `codegraph_stats` | グラフ統計を取得 |
|
|
159
|
+
|
|
160
|
+
## 設定オプション
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
interface CodeGraphOptions {
|
|
164
|
+
// ストレージバックエンド
|
|
165
|
+
storage?: 'memory' | 'sqlite' | StorageAdapter;
|
|
166
|
+
sqlitePath?: string;
|
|
167
|
+
|
|
168
|
+
// パーサー設定
|
|
169
|
+
parser?: {
|
|
170
|
+
languages?: Language[]; // 対象言語
|
|
171
|
+
includeComments?: boolean; // コメント含む
|
|
172
|
+
extractDocstrings?: boolean; // docstring抽出
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// グラフエンジン設定
|
|
176
|
+
graph?: {
|
|
177
|
+
maxDepth?: number; // 最大探索深度
|
|
178
|
+
enableCaching?: boolean; // キャッシュ有効化
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// インデクサー設定
|
|
182
|
+
indexer?: {
|
|
183
|
+
ignorePatterns?: string[]; // 除外パターン
|
|
184
|
+
maxFileSize?: number; // 最大ファイルサイズ
|
|
185
|
+
parallelism?: number; // 並列処理数
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// GraphRAG設定
|
|
189
|
+
graphrag?: {
|
|
190
|
+
communityAlgorithm?: 'louvain' | 'label_propagation';
|
|
191
|
+
minCommunitySize?: number;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## エンティティタイプ
|
|
197
|
+
|
|
198
|
+
| タイプ | 説明 |
|
|
199
|
+
|--------|------|
|
|
200
|
+
| `function` | 関数・メソッド |
|
|
201
|
+
| `class` | クラス |
|
|
202
|
+
| `interface` | インターフェース |
|
|
203
|
+
| `type` | 型エイリアス |
|
|
204
|
+
| `variable` | 変数・定数 |
|
|
205
|
+
| `module` | モジュール・名前空間 |
|
|
206
|
+
| `enum` | 列挙型 |
|
|
207
|
+
| `property` | プロパティ |
|
|
208
|
+
| `parameter` | パラメータ |
|
|
209
|
+
|
|
210
|
+
## リレーションタイプ
|
|
211
|
+
|
|
212
|
+
| タイプ | 説明 |
|
|
213
|
+
|--------|------|
|
|
214
|
+
| `calls` | 関数呼び出し |
|
|
215
|
+
| `imports` | インポート |
|
|
216
|
+
| `extends` | 継承 |
|
|
217
|
+
| `implements` | インターフェース実装 |
|
|
218
|
+
| `uses` | 使用(変数参照等) |
|
|
219
|
+
| `defines` | 定義(クラス→メソッド等) |
|
|
220
|
+
| `returns` | 戻り値の型 |
|
|
221
|
+
| `parameter_of` | パラメータ関係 |
|
|
222
|
+
|
|
223
|
+
## イベント
|
|
224
|
+
|
|
225
|
+
CodeGraphはイベントエミッターとして動作し、処理の進捗を監視できます。
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
const codeGraph = await createCodeGraph();
|
|
229
|
+
|
|
230
|
+
codeGraph.onIndexingStart((path) => {
|
|
231
|
+
console.log(`Indexing started: ${path}`);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
codeGraph.onIndexingProgress((processed, total, file) => {
|
|
235
|
+
console.log(`Progress: ${processed}/${total} - ${file}`);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
codeGraph.onIndexingComplete((result) => {
|
|
239
|
+
console.log(`Complete: ${result.entitiesIndexed} entities`);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
codeGraph.onIndexingError((error, file) => {
|
|
243
|
+
console.error(`Error in ${file}: ${error.message}`);
|
|
244
|
+
});
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## 使用例
|
|
248
|
+
|
|
249
|
+
### プロジェクト分析
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
import { createCodeGraph } from '@nahisaho/musubix-codegraph';
|
|
253
|
+
|
|
254
|
+
async function analyzeProject(projectPath: string) {
|
|
255
|
+
const cg = await createCodeGraph({ storage: 'sqlite', sqlitePath: '.codegraph.db' });
|
|
256
|
+
|
|
257
|
+
// インデックス作成
|
|
258
|
+
const result = await cg.index(projectPath);
|
|
259
|
+
console.log(`Indexed ${result.filesProcessed} files`);
|
|
260
|
+
|
|
261
|
+
// 統計取得
|
|
262
|
+
const stats = await cg.getStats();
|
|
263
|
+
console.log(`Entities: ${stats.entityCount}`);
|
|
264
|
+
console.log(`Relations: ${stats.relationCount}`);
|
|
265
|
+
console.log(`Languages: ${stats.languages.join(', ')}`);
|
|
266
|
+
|
|
267
|
+
// クラス一覧
|
|
268
|
+
const classes = await cg.query({ entityTypes: ['class'] });
|
|
269
|
+
console.log(`Classes: ${classes.entities.length}`);
|
|
270
|
+
|
|
271
|
+
// 依存関係分析
|
|
272
|
+
for (const cls of classes.entities.slice(0, 5)) {
|
|
273
|
+
const deps = await cg.findDependencies(cls.name);
|
|
274
|
+
console.log(`${cls.name} depends on: ${deps.map(d => d.name).join(', ')}`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### コードナビゲーション
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
// 関数の呼び出し関係を可視化
|
|
283
|
+
async function traceCallGraph(functionName: string) {
|
|
284
|
+
const cg = await createCodeGraph();
|
|
285
|
+
await cg.index('./src');
|
|
286
|
+
|
|
287
|
+
const callers = await cg.findCallers(functionName);
|
|
288
|
+
const callees = await cg.findCallees(functionName);
|
|
289
|
+
|
|
290
|
+
console.log(`=== ${functionName} ===`);
|
|
291
|
+
console.log('Called by:');
|
|
292
|
+
callers.forEach(c => console.log(` <- ${c.from.name}`));
|
|
293
|
+
console.log('Calls:');
|
|
294
|
+
callees.forEach(c => console.log(` -> ${c.to.name}`));
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## 要件トレーサビリティ
|
|
299
|
+
|
|
300
|
+
| 要件ID | 説明 |
|
|
301
|
+
|--------|------|
|
|
302
|
+
| REQ-CG-API-001 | 独立ライブラリとして動作 |
|
|
303
|
+
| REQ-CG-API-002 | プログラマティックAPI提供 |
|
|
304
|
+
| REQ-CG-API-003 | CLI統合 |
|
|
305
|
+
| REQ-CG-AST-001 | 多言語AST解析 |
|
|
306
|
+
| REQ-CG-GRF-001 | エンティティ・リレーション管理 |
|
|
307
|
+
| REQ-CG-GRF-003 | グラフクエリ |
|
|
308
|
+
| REQ-CG-GRF-004 | 依存関係分析 |
|
|
309
|
+
| REQ-CG-GRF-005 | 呼び出しグラフ分析 |
|
|
310
|
+
| REQ-CG-RAG-001 | コミュニティ検出 |
|
|
311
|
+
| REQ-CG-RAG-002 | セマンティック検索 |
|
|
312
|
+
|
|
313
|
+
## 関連ドキュメント
|
|
314
|
+
|
|
315
|
+
- [MUSUBIX Overview](MUSUBIX-Overview.md)
|
|
316
|
+
- [MUSUBIX Core](MUSUBIX-Core.md)
|
|
317
|
+
- [MUSUBIX MCP Server](MUSUBIX-MCP-Server.md)
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
**バージョン**: 2.3.0
|
|
322
|
+
**最終更新**: 2026-01-09
|