musubix 3.5.1 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +1136 -0
- package/LICENSE +21 -0
- package/README.ja.md +313 -0
- package/README.md +315 -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/adr/ADR-v3.4.0-001-deep-research-architecture.md +217 -0
- package/docs/adr/ADR-v3.4.0-002-search-provider-selection.md +308 -0
- package/docs/adr/ADR-v3.4.0-003-lm-api-integration.md +475 -0
- package/docs/enterprise-knowledge-management.md +1737 -0
- package/docs/evolution-from-musubi-to-musubix.md +2170 -0
- package/docs/experiments/EXPERIMENT-ASSISTANT-AXIS-DRIFT-DETECTION.md +155 -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/musubix-v3.6.0-fastrender-insights.md +625 -0
- package/docs/qiita-linux-kernel-knowledge-graph.md +596 -0
- package/docs/qiita-musubix-assistant-axis.md +380 -0
- package/package.json +58 -52
- package/scripts/generate-quality-gate-report.ts +106 -0
- package/scripts/postinstall.js +94 -0
- package/scripts/register-release-knowledge.ts +127 -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,594 @@
|
|
|
1
|
+
# @musubix/knowledge マニュアル
|
|
2
|
+
|
|
3
|
+
> Git-Native Knowledge Store - ファイルベースの知識グラフ管理
|
|
4
|
+
|
|
5
|
+
| 項目 | 内容 |
|
|
6
|
+
|------|------|
|
|
7
|
+
| **パッケージ名** | `@musubix/knowledge` |
|
|
8
|
+
| **バージョン** | 3.0.0 |
|
|
9
|
+
| **導入バージョン** | MUSUBIX v3.0.0 |
|
|
10
|
+
| **ストレージ形式** | JSON (`.knowledge/graph.json`) |
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 概要
|
|
15
|
+
|
|
16
|
+
`@musubix/knowledge` は、MUSUBIX v3.0.0で導入されたGit-Nativeな知識グラフ管理パッケージです。要件(REQ)、設計(DES)、タスク(TSK)、コード、決定事項などのエンティティとその関係を、Gitで管理可能なJSONファイルとして保存します。
|
|
17
|
+
|
|
18
|
+
### 特徴
|
|
19
|
+
|
|
20
|
+
- **Git-Friendly**: JSON形式で差分管理が容易
|
|
21
|
+
- **軽量**: 外部データベース不要、ファイルシステムのみで動作
|
|
22
|
+
- **型安全**: TypeScriptで完全な型定義
|
|
23
|
+
- **トレーサビリティ**: REQ→DES→TSK→Codeの追跡が可能
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## インストール
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @musubix/knowledge
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## クイックスタート
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { createKnowledgeStore } from '@musubix/knowledge';
|
|
39
|
+
|
|
40
|
+
// 1. Knowledge Store を作成
|
|
41
|
+
const store = createKnowledgeStore('.knowledge');
|
|
42
|
+
|
|
43
|
+
// 2. エンティティを追加
|
|
44
|
+
await store.putEntity({
|
|
45
|
+
id: 'REQ-001',
|
|
46
|
+
type: 'requirement',
|
|
47
|
+
name: 'ユーザー認証',
|
|
48
|
+
description: 'ユーザーがログインできること',
|
|
49
|
+
properties: { priority: 'P0' },
|
|
50
|
+
tags: ['security', 'auth'],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
await store.putEntity({
|
|
54
|
+
id: 'DES-001',
|
|
55
|
+
type: 'design',
|
|
56
|
+
name: '認証設計',
|
|
57
|
+
description: 'JWT認証を使用',
|
|
58
|
+
properties: { pattern: 'Token-Based Auth' },
|
|
59
|
+
tags: ['security'],
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// 3. リレーションを作成
|
|
63
|
+
await store.addRelation({
|
|
64
|
+
id: 'rel-001',
|
|
65
|
+
source: 'DES-001',
|
|
66
|
+
target: 'REQ-001',
|
|
67
|
+
type: 'implements',
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// 4. 保存(永続化)
|
|
71
|
+
await store.save();
|
|
72
|
+
|
|
73
|
+
// 5. 取得
|
|
74
|
+
const req = await store.getEntity('REQ-001');
|
|
75
|
+
console.log(req?.name); // => 'ユーザー認証'
|
|
76
|
+
|
|
77
|
+
// 6. クエリ
|
|
78
|
+
const requirements = await store.query({ type: 'requirement' });
|
|
79
|
+
console.log(requirements.length); // => 1
|
|
80
|
+
|
|
81
|
+
// 7. グラフ走査
|
|
82
|
+
const chain = await store.traverse('REQ-001', { depth: 2 });
|
|
83
|
+
console.log(chain.map(e => e.id)); // => ['REQ-001', 'DES-001']
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## API リファレンス
|
|
89
|
+
|
|
90
|
+
### `createKnowledgeStore(basePath: string): KnowledgeStore`
|
|
91
|
+
|
|
92
|
+
Knowledge Store のファクトリ関数。
|
|
93
|
+
|
|
94
|
+
| パラメータ | 型 | 説明 |
|
|
95
|
+
|-----------|---|------|
|
|
96
|
+
| `basePath` | `string` | ストレージディレクトリのパス(例: `.knowledge`) |
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const store = createKnowledgeStore('.knowledge');
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## エンティティ操作
|
|
105
|
+
|
|
106
|
+
### `putEntity(entity: Entity): Promise<void>`
|
|
107
|
+
|
|
108
|
+
エンティティを追加または更新します。
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
await store.putEntity({
|
|
112
|
+
id: 'REQ-001',
|
|
113
|
+
type: 'requirement',
|
|
114
|
+
name: 'ユーザー認証',
|
|
115
|
+
description: 'ユーザーがログインできること',
|
|
116
|
+
properties: { priority: 'P0', stakeholder: 'セキュリティチーム' },
|
|
117
|
+
tags: ['security', 'auth', 'P0'],
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Entity インターフェース
|
|
122
|
+
|
|
123
|
+
| フィールド | 型 | 必須 | 説明 |
|
|
124
|
+
|-----------|---|------|------|
|
|
125
|
+
| `id` | `string` | ✅ | 一意識別子(例: `REQ-001`, `DES-001`) |
|
|
126
|
+
| `type` | `EntityType` | ✅ | エンティティタイプ |
|
|
127
|
+
| `name` | `string` | ✅ | 表示名 |
|
|
128
|
+
| `description` | `string` | - | 説明文 |
|
|
129
|
+
| `properties` | `Record<string, unknown>` | ✅ | カスタムプロパティ(空オブジェクト可) |
|
|
130
|
+
| `tags` | `string[]` | ✅ | タグ配列(空配列可) |
|
|
131
|
+
| `createdAt` | `string` | 自動 | 作成日時(ISO 8601) |
|
|
132
|
+
| `updatedAt` | `string` | 自動 | 更新日時(ISO 8601) |
|
|
133
|
+
|
|
134
|
+
#### EntityType
|
|
135
|
+
|
|
136
|
+
| 値 | 説明 | 例 |
|
|
137
|
+
|---|------|---|
|
|
138
|
+
| `requirement` | 要件 | `REQ-001` |
|
|
139
|
+
| `design` | 設計 | `DES-001` |
|
|
140
|
+
| `task` | タスク | `TSK-001` |
|
|
141
|
+
| `code` | コード | `func:UserService.login` |
|
|
142
|
+
| `decision` | 決定事項 | `ADR-001` |
|
|
143
|
+
| `pattern` | パターン | `pattern:Repository` |
|
|
144
|
+
| `constraint` | 制約 | `const:MaxUsers` |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### `getEntity(id: string): Promise<Entity | undefined>`
|
|
149
|
+
|
|
150
|
+
IDでエンティティを取得します。
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
const entity = await store.getEntity('REQ-001');
|
|
154
|
+
if (entity) {
|
|
155
|
+
console.log(entity.name);
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### `deleteEntity(id: string): Promise<boolean>`
|
|
162
|
+
|
|
163
|
+
エンティティを削除します。関連するリレーションも自動的に削除されます。
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
const deleted = await store.deleteEntity('REQ-001');
|
|
167
|
+
console.log(deleted); // => true
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## リレーション操作
|
|
173
|
+
|
|
174
|
+
### `addRelation(relation: Relation): Promise<void>`
|
|
175
|
+
|
|
176
|
+
エンティティ間のリレーションを追加します。
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
await store.addRelation({
|
|
180
|
+
id: 'rel-001',
|
|
181
|
+
source: 'DES-001', // 設計
|
|
182
|
+
target: 'REQ-001', // 要件
|
|
183
|
+
type: 'implements',
|
|
184
|
+
properties: { coverage: '100%' },
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### Relation インターフェース
|
|
189
|
+
|
|
190
|
+
| フィールド | 型 | 必須 | 説明 |
|
|
191
|
+
|-----------|---|------|------|
|
|
192
|
+
| `id` | `string` | ✅ | 一意識別子 |
|
|
193
|
+
| `source` | `string` | ✅ | ソースエンティティID |
|
|
194
|
+
| `target` | `string` | ✅ | ターゲットエンティティID |
|
|
195
|
+
| `type` | `RelationType` | ✅ | リレーションタイプ |
|
|
196
|
+
| `properties` | `Record<string, unknown>` | - | カスタムプロパティ |
|
|
197
|
+
|
|
198
|
+
#### RelationType
|
|
199
|
+
|
|
200
|
+
| 値 | 説明 | 例 |
|
|
201
|
+
|---|------|---|
|
|
202
|
+
| `implements` | 実装する | DES → REQ |
|
|
203
|
+
| `depends_on` | 依存する | TSK → TSK |
|
|
204
|
+
| `traces_to` | 追跡する | Code → REQ |
|
|
205
|
+
| `related_to` | 関連する | 汎用 |
|
|
206
|
+
| `derives_from` | 派生する | REQ → REQ |
|
|
207
|
+
| `conflicts_with` | 競合する | REQ ↔ REQ |
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### `getRelations(entityId: string, direction?: 'in' | 'out' | 'both'): Promise<Relation[]>`
|
|
212
|
+
|
|
213
|
+
エンティティに関連するリレーションを取得します。
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
// すべてのリレーション(デフォルト)
|
|
217
|
+
const allRels = await store.getRelations('REQ-001');
|
|
218
|
+
|
|
219
|
+
// 出ていくリレーションのみ(source = REQ-001)
|
|
220
|
+
const outRels = await store.getRelations('REQ-001', 'out');
|
|
221
|
+
|
|
222
|
+
// 入ってくるリレーションのみ(target = REQ-001)
|
|
223
|
+
const inRels = await store.getRelations('REQ-001', 'in');
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### `removeRelation(id: string): Promise<boolean>`
|
|
229
|
+
|
|
230
|
+
リレーションを削除します。
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
const removed = await store.removeRelation('rel-001');
|
|
234
|
+
console.log(removed); // => true
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## クエリ操作
|
|
240
|
+
|
|
241
|
+
### `query(filter: QueryFilter): Promise<Entity[]>`
|
|
242
|
+
|
|
243
|
+
フィルタ条件でエンティティを検索します。
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
// タイプでフィルタ
|
|
247
|
+
const requirements = await store.query({ type: 'requirement' });
|
|
248
|
+
|
|
249
|
+
// 複数タイプでフィルタ
|
|
250
|
+
const reqAndDes = await store.query({ type: ['requirement', 'design'] });
|
|
251
|
+
|
|
252
|
+
// タグでフィルタ(AND条件)
|
|
253
|
+
const securityItems = await store.query({ tags: ['security'] });
|
|
254
|
+
|
|
255
|
+
// テキスト検索(name, descriptionで部分一致)
|
|
256
|
+
const authItems = await store.query({ text: '認証' });
|
|
257
|
+
|
|
258
|
+
// ページネーション
|
|
259
|
+
const page1 = await store.query({ type: 'requirement', limit: 10, offset: 0 });
|
|
260
|
+
const page2 = await store.query({ type: 'requirement', limit: 10, offset: 10 });
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
#### QueryFilter インターフェース
|
|
264
|
+
|
|
265
|
+
| フィールド | 型 | 説明 |
|
|
266
|
+
|-----------|---|------|
|
|
267
|
+
| `type` | `EntityType \| EntityType[]` | タイプフィルタ |
|
|
268
|
+
| `tags` | `string[]` | タグフィルタ(AND条件) |
|
|
269
|
+
| `text` | `string` | テキスト検索(name, description) |
|
|
270
|
+
| `limit` | `number` | 最大件数 |
|
|
271
|
+
| `offset` | `number` | オフセット |
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### `search(text: string, options?: SearchOptions): Promise<Entity[]>`
|
|
276
|
+
|
|
277
|
+
テキストでエンティティを検索します。
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
// 基本検索(name, description, tagsを検索)
|
|
281
|
+
const results = await store.search('認証');
|
|
282
|
+
|
|
283
|
+
// 特定フィールドのみ検索
|
|
284
|
+
const nameOnly = await store.search('認証', { fields: ['name'] });
|
|
285
|
+
|
|
286
|
+
// 大文字小文字を区別
|
|
287
|
+
const caseSensitive = await store.search('AUTH', { caseSensitive: true });
|
|
288
|
+
|
|
289
|
+
// 結果数を制限
|
|
290
|
+
const limited = await store.search('認証', { limit: 5 });
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## グラフ操作
|
|
296
|
+
|
|
297
|
+
### `traverse(startId: string, options?: TraverseOptions): Promise<Entity[]>`
|
|
298
|
+
|
|
299
|
+
指定したエンティティから関連エンティティを走査します。
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
// 基本走査(深さ3、双方向)
|
|
303
|
+
const chain = await store.traverse('REQ-001');
|
|
304
|
+
|
|
305
|
+
// 深さ指定
|
|
306
|
+
const shallow = await store.traverse('REQ-001', { depth: 1 });
|
|
307
|
+
|
|
308
|
+
// 特定のリレーションタイプのみ
|
|
309
|
+
const implements = await store.traverse('REQ-001', {
|
|
310
|
+
relationTypes: ['implements']
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
// 方向指定
|
|
314
|
+
const downstream = await store.traverse('REQ-001', { direction: 'out' });
|
|
315
|
+
const upstream = await store.traverse('DES-001', { direction: 'in' });
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
#### TraverseOptions インターフェース
|
|
319
|
+
|
|
320
|
+
| フィールド | 型 | デフォルト | 説明 |
|
|
321
|
+
|-----------|---|----------|------|
|
|
322
|
+
| `depth` | `number` | `3` | 最大深さ |
|
|
323
|
+
| `relationTypes` | `RelationType[]` | すべて | 走査するリレーションタイプ |
|
|
324
|
+
| `direction` | `'in' \| 'out' \| 'both'` | `'both'` | 走査方向 |
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
### `getSubgraph(rootId: string, depth: number): Promise<KnowledgeGraph>`
|
|
329
|
+
|
|
330
|
+
指定したエンティティを中心としたサブグラフを取得します。
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
const subgraph = await store.getSubgraph('REQ-001', 2);
|
|
334
|
+
console.log(subgraph.metadata.entityCount);
|
|
335
|
+
console.log(subgraph.metadata.relationCount);
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## 永続化
|
|
341
|
+
|
|
342
|
+
### `save(): Promise<void>`
|
|
343
|
+
|
|
344
|
+
現在のグラフを `.knowledge/graph.json` に保存します。
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
await store.putEntity({ /* ... */ });
|
|
348
|
+
await store.addRelation({ /* ... */ });
|
|
349
|
+
await store.save(); // 必ず呼び出す
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### `load(): Promise<void>`
|
|
353
|
+
|
|
354
|
+
`.knowledge/graph.json` からグラフを読み込みます。通常は自動的に呼び出されます。
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
await store.load(); // 明示的に再読み込み
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## 統計
|
|
363
|
+
|
|
364
|
+
### `getStats(): Stats`
|
|
365
|
+
|
|
366
|
+
グラフの統計情報を取得します。
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
const stats = store.getStats();
|
|
370
|
+
console.log(stats.entityCount); // => 10
|
|
371
|
+
console.log(stats.relationCount); // => 15
|
|
372
|
+
console.log(stats.types.requirement); // => 5
|
|
373
|
+
console.log(stats.types.design); // => 3
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## ストレージ形式
|
|
379
|
+
|
|
380
|
+
### ディレクトリ構造
|
|
381
|
+
|
|
382
|
+
```
|
|
383
|
+
.knowledge/
|
|
384
|
+
└── graph.json # メインのナレッジグラフ
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### graph.json スキーマ
|
|
388
|
+
|
|
389
|
+
```json
|
|
390
|
+
{
|
|
391
|
+
"version": "1.0.0",
|
|
392
|
+
"metadata": {
|
|
393
|
+
"lastModified": "2026-01-11T12:00:00.000Z",
|
|
394
|
+
"entityCount": 10,
|
|
395
|
+
"relationCount": 15
|
|
396
|
+
},
|
|
397
|
+
"entities": {
|
|
398
|
+
"REQ-001": {
|
|
399
|
+
"id": "REQ-001",
|
|
400
|
+
"type": "requirement",
|
|
401
|
+
"name": "ユーザー認証",
|
|
402
|
+
"description": "ユーザーがログインできること",
|
|
403
|
+
"properties": { "priority": "P0" },
|
|
404
|
+
"tags": ["security", "auth"],
|
|
405
|
+
"createdAt": "2026-01-11T10:00:00.000Z",
|
|
406
|
+
"updatedAt": "2026-01-11T12:00:00.000Z"
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
"relations": [
|
|
410
|
+
{
|
|
411
|
+
"id": "rel-001",
|
|
412
|
+
"source": "DES-001",
|
|
413
|
+
"target": "REQ-001",
|
|
414
|
+
"type": "implements"
|
|
415
|
+
}
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## トレーサビリティの例
|
|
423
|
+
|
|
424
|
+
MUSUBIX SDDワークフローにおけるトレーサビリティチェーンの例:
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
// 要件 → 設計 → タスク → コード のチェーンを作成
|
|
428
|
+
|
|
429
|
+
// 1. 要件
|
|
430
|
+
await store.putEntity({
|
|
431
|
+
id: 'REQ-AUTH-001',
|
|
432
|
+
type: 'requirement',
|
|
433
|
+
name: 'ユーザーログイン',
|
|
434
|
+
properties: { priority: 'P0' },
|
|
435
|
+
tags: ['auth'],
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
// 2. 設計
|
|
439
|
+
await store.putEntity({
|
|
440
|
+
id: 'DES-AUTH-001',
|
|
441
|
+
type: 'design',
|
|
442
|
+
name: 'JWT認証設計',
|
|
443
|
+
properties: { pattern: 'Token-Based' },
|
|
444
|
+
tags: ['auth'],
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
await store.addRelation({
|
|
448
|
+
id: 'rel-des-req',
|
|
449
|
+
source: 'DES-AUTH-001',
|
|
450
|
+
target: 'REQ-AUTH-001',
|
|
451
|
+
type: 'implements',
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
// 3. タスク
|
|
455
|
+
await store.putEntity({
|
|
456
|
+
id: 'TSK-AUTH-001',
|
|
457
|
+
type: 'task',
|
|
458
|
+
name: 'AuthService実装',
|
|
459
|
+
properties: { estimate: '4h' },
|
|
460
|
+
tags: ['auth'],
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
await store.addRelation({
|
|
464
|
+
id: 'rel-tsk-des',
|
|
465
|
+
source: 'TSK-AUTH-001',
|
|
466
|
+
target: 'DES-AUTH-001',
|
|
467
|
+
type: 'implements',
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
// 4. コード
|
|
471
|
+
await store.putEntity({
|
|
472
|
+
id: 'code:AuthService.login',
|
|
473
|
+
type: 'code',
|
|
474
|
+
name: 'AuthService.login()',
|
|
475
|
+
properties: { file: 'src/auth/AuthService.ts', line: 42 },
|
|
476
|
+
tags: ['auth'],
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
await store.addRelation({
|
|
480
|
+
id: 'rel-code-tsk',
|
|
481
|
+
source: 'code:AuthService.login',
|
|
482
|
+
target: 'TSK-AUTH-001',
|
|
483
|
+
type: 'implements',
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
await store.save();
|
|
487
|
+
|
|
488
|
+
// トレーサビリティチェーンを確認
|
|
489
|
+
const chain = await store.traverse('REQ-AUTH-001', {
|
|
490
|
+
direction: 'in', // 要件に向かって来るもの
|
|
491
|
+
depth: 10
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
console.log('トレーサビリティチェーン:');
|
|
495
|
+
chain.forEach(e => console.log(` ${e.type}: ${e.id}`));
|
|
496
|
+
// => requirement: REQ-AUTH-001
|
|
497
|
+
// => design: DES-AUTH-001
|
|
498
|
+
// => task: TSK-AUTH-001
|
|
499
|
+
// => code: code:AuthService.login
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
504
|
+
## MCP ツール連携
|
|
505
|
+
|
|
506
|
+
`@musubix/knowledge` は以下のMCPツールから利用されます:
|
|
507
|
+
|
|
508
|
+
| ツール名 | 説明 |
|
|
509
|
+
|---------|------|
|
|
510
|
+
| `knowledge_put_entity` | エンティティ作成/更新 |
|
|
511
|
+
| `knowledge_get_entity` | エンティティ取得 |
|
|
512
|
+
| `knowledge_delete_entity` | エンティティ削除 |
|
|
513
|
+
| `knowledge_add_relation` | リレーション追加 |
|
|
514
|
+
| `knowledge_query` | クエリ実行 |
|
|
515
|
+
| `knowledge_traverse` | グラフ走査 |
|
|
516
|
+
|
|
517
|
+
---
|
|
518
|
+
|
|
519
|
+
## CLI コマンド連携
|
|
520
|
+
|
|
521
|
+
```bash
|
|
522
|
+
# エンティティ追加
|
|
523
|
+
npx musubix knowledge put REQ-001 requirement "ユーザー認証"
|
|
524
|
+
|
|
525
|
+
# エンティティ取得
|
|
526
|
+
npx musubix knowledge get REQ-001
|
|
527
|
+
|
|
528
|
+
# エンティティ削除
|
|
529
|
+
npx musubix knowledge delete REQ-001
|
|
530
|
+
|
|
531
|
+
# リレーション追加
|
|
532
|
+
npx musubix knowledge link DES-001 REQ-001 implements
|
|
533
|
+
|
|
534
|
+
# クエリ
|
|
535
|
+
npx musubix knowledge query --type requirement
|
|
536
|
+
|
|
537
|
+
# グラフ走査
|
|
538
|
+
npx musubix knowledge traverse REQ-001 --depth 3
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|
|
543
|
+
## ベストプラクティス
|
|
544
|
+
|
|
545
|
+
### 1. ID命名規則
|
|
546
|
+
|
|
547
|
+
```typescript
|
|
548
|
+
// ✅ 推奨: プレフィックス + 連番
|
|
549
|
+
'REQ-001', 'DES-001', 'TSK-001'
|
|
550
|
+
|
|
551
|
+
// ✅ 推奨: コードは関数パス形式
|
|
552
|
+
'code:UserService.create'
|
|
553
|
+
'code:auth/login.ts:42'
|
|
554
|
+
|
|
555
|
+
// ❌ 非推奨: 意味のないID
|
|
556
|
+
'entity1', 'xyz123'
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
### 2. 定期的な save() 呼び出し
|
|
560
|
+
|
|
561
|
+
```typescript
|
|
562
|
+
// ✅ 推奨: 操作後にsave
|
|
563
|
+
await store.putEntity({ /* ... */ });
|
|
564
|
+
await store.save();
|
|
565
|
+
|
|
566
|
+
// ✅ 推奨: バッチ操作後にsave
|
|
567
|
+
for (const entity of entities) {
|
|
568
|
+
await store.putEntity(entity);
|
|
569
|
+
}
|
|
570
|
+
await store.save(); // まとめてsave
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### 3. タグの活用
|
|
574
|
+
|
|
575
|
+
```typescript
|
|
576
|
+
// ✅ 推奨: 意味のあるタグ
|
|
577
|
+
tags: ['security', 'auth', 'P0', 'sprint-1']
|
|
578
|
+
|
|
579
|
+
// ❌ 非推奨: 曖昧なタグ
|
|
580
|
+
tags: ['important', 'todo']
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
---
|
|
584
|
+
|
|
585
|
+
## 関連ドキュメント
|
|
586
|
+
|
|
587
|
+
- [MIGRATION-v3.0.md](../MIGRATION-v3.0.md) - v2.x からの移行ガイド
|
|
588
|
+
- [@musubix/policy マニュアル](./policy.md) - ポリシーエンジン
|
|
589
|
+
- [@musubix/decisions マニュアル](./decisions.md) - ADR管理
|
|
590
|
+
|
|
591
|
+
---
|
|
592
|
+
|
|
593
|
+
**作成日**: 2026-01-11
|
|
594
|
+
**バージョン**: 3.0.0
|