@nahisaho/katashiro 0.1.3 → 0.1.5
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/AGENTS.md +303 -145
- package/CLAUDE.md +212 -155
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -1,198 +1,356 @@
|
|
|
1
1
|
# KATASHIRO - AI Coding Agent Guide
|
|
2
2
|
|
|
3
|
-
> **AI Coding Agent向け**:
|
|
3
|
+
> **AI Coding Agent向け**: このファイルを読み込んだAIエージェントは、ユーザーの課題を解決するためにKATASHIROライブラリの機能を自動的に活用できます。
|
|
4
4
|
|
|
5
|
-
## 🎯
|
|
5
|
+
## 🎯 このガイドの目的
|
|
6
6
|
|
|
7
|
-
KATASHIRO
|
|
8
|
-
|
|
9
|
-
| やりたいこと | 自然言語での依頼例 |
|
|
10
|
-
|-------------|-------------------|
|
|
11
|
-
| **Web調査** | 「〜について調べて」「〜の最新情報を検索して」 |
|
|
12
|
-
| **Webページ取得** | 「このURLの内容を取得して」「〜のサイトをスクレイピングして」 |
|
|
13
|
-
| **テキスト分析** | 「この文章を分析して」「キーワードを抽出して」 |
|
|
14
|
-
| **エンティティ抽出** | 「人名・組織名を抽出して」「固有表現を見つけて」 |
|
|
15
|
-
| **レポート生成** | 「調査レポートを作成して」「分析結果をまとめて」 |
|
|
16
|
-
| **要約作成** | 「この文章を要約して」「3行でまとめて」 |
|
|
17
|
-
| **知識グラフ操作** | 「知識グラフに追加して」「関連情報を検索して」 |
|
|
7
|
+
ユーザーが自然言語で入力した課題に対して、KATASHIROの機能を適切に組み合わせて解決策を提供します。
|
|
18
8
|
|
|
19
9
|
---
|
|
20
10
|
|
|
21
|
-
##
|
|
22
|
-
|
|
23
|
-
### 情報収集ツール
|
|
24
|
-
|
|
25
|
-
| ツール | 自然言語での呼び出し例 |
|
|
26
|
-
|--------|----------------------|
|
|
27
|
-
| `katashiro_scrape` | 「https://example.com の内容を取得して」 |
|
|
28
|
-
| `katashiro_search` | 「TypeScript best practices について検索して」 |
|
|
29
|
-
| `katashiro_feed` | 「このRSSフィードを読み込んで」 |
|
|
11
|
+
## 📋 課題タイプ別の解決アプローチ
|
|
30
12
|
|
|
31
|
-
###
|
|
13
|
+
### 課題タイプの判定
|
|
32
14
|
|
|
33
|
-
|
|
34
|
-
|--------|----------------------|
|
|
35
|
-
| `katashiro_analyze` | 「この文章のキーワードと複雑度を分析して」 |
|
|
36
|
-
| `katashiro_extract_entities` | 「このテキストから人名と組織名を抽出して」 |
|
|
37
|
-
| `katashiro_topics` | 「これらの文書のトピックを分析して」 |
|
|
15
|
+
ユーザーの入力から以下のタイプを判定してください:
|
|
38
16
|
|
|
39
|
-
|
|
17
|
+
| 課題タイプ | キーワード例 | 使用する機能 |
|
|
18
|
+
|-----------|-------------|-------------|
|
|
19
|
+
| **調査・リサーチ** | 調べて、検索、情報収集、〜について | Collector → Analyzer → Generator |
|
|
20
|
+
| **分析・解析** | 分析して、解析、キーワード、傾向 | Analyzer |
|
|
21
|
+
| **要約・まとめ** | 要約、まとめて、短くして | Generator (SummaryGenerator) |
|
|
22
|
+
| **レポート作成** | レポート、報告書、文書化 | Generator (ReportGenerator) |
|
|
23
|
+
| **データ抽出** | 抽出、取り出して、リストアップ | Analyzer (EntityExtractor) |
|
|
24
|
+
| **知識管理** | 保存、記録、覚えておいて | Knowledge |
|
|
25
|
+
| **比較・評価** | 比較、評価、どちらが | Collector → Analyzer → Generator |
|
|
40
26
|
|
|
41
|
-
|
|
42
|
-
|--------|----------------------|
|
|
43
|
-
| `katashiro_generate_report` | 「調査結果からレポートを生成して」 |
|
|
44
|
-
| `katashiro_summarize` | 「この長文を300文字で要約して」 |
|
|
45
|
-
| `katashiro_citation` | 「APA形式で引用を生成して」 |
|
|
27
|
+
---
|
|
46
28
|
|
|
47
|
-
|
|
29
|
+
## 🔄 課題解決ワークフロー
|
|
30
|
+
|
|
31
|
+
### ステップ1: 課題の分析
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// ユーザー入力から課題タイプを判定
|
|
35
|
+
function analyzeProblem(userInput: string): ProblemType {
|
|
36
|
+
const keywords = {
|
|
37
|
+
research: ['調べ', '検索', '情報', 'について', '知りたい'],
|
|
38
|
+
analyze: ['分析', '解析', 'キーワード', '傾向', '特徴'],
|
|
39
|
+
summarize: ['要約', 'まとめ', '短く', '簡潔'],
|
|
40
|
+
report: ['レポート', '報告', '文書', 'ドキュメント'],
|
|
41
|
+
extract: ['抽出', '取り出', 'リスト', '一覧'],
|
|
42
|
+
knowledge: ['保存', '記録', '覚え', '登録'],
|
|
43
|
+
compare: ['比較', '評価', 'どちら', '違い'],
|
|
44
|
+
};
|
|
45
|
+
// キーワードマッチングで判定
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
### ステップ2: 必要な機能の選択
|
|
50
|
+
|
|
51
|
+
課題タイプに応じて以下のクラスを使用:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import {
|
|
55
|
+
// 情報収集(URLや検索クエリがある場合)
|
|
56
|
+
WebScraper, // URL指定のページ取得
|
|
57
|
+
WebSearchClient, // キーワード検索
|
|
58
|
+
FeedReader, // RSSフィード
|
|
59
|
+
ApiClient, // API呼び出し
|
|
60
|
+
|
|
61
|
+
// テキスト分析(テキストデータがある場合)
|
|
62
|
+
TextAnalyzer, // キーワード・複雑度分析
|
|
63
|
+
EntityExtractor, // 人名・組織名抽出
|
|
64
|
+
TopicModeler, // トピック分類
|
|
65
|
+
StructureAnalyzer, // 文書構造解析
|
|
66
|
+
QualityScorer, // 品質スコアリング
|
|
67
|
+
|
|
68
|
+
// コンテンツ生成(出力が必要な場合)
|
|
69
|
+
ReportGenerator, // レポート生成
|
|
70
|
+
SummaryGenerator, // 要約生成
|
|
71
|
+
CitationGenerator, // 引用生成
|
|
72
|
+
TemplateEngine, // テンプレート処理
|
|
73
|
+
|
|
74
|
+
// 知識管理(情報を蓄積・検索する場合)
|
|
75
|
+
KnowledgeGraph, // グラフ管理
|
|
76
|
+
GraphQuery, // 検索
|
|
77
|
+
GraphPersistence, // 永続化
|
|
78
|
+
|
|
79
|
+
// ユーティリティ
|
|
80
|
+
ok, err, isOk, isErr,
|
|
81
|
+
} from '@nahisaho/katashiro';
|
|
82
|
+
```
|
|
53
83
|
|
|
54
84
|
---
|
|
55
85
|
|
|
56
|
-
## 📝
|
|
57
|
-
|
|
58
|
-
### 1. 競合調査レポート作成
|
|
86
|
+
## 📝 課題タイプ別の実装パターン
|
|
59
87
|
|
|
60
|
-
|
|
61
|
-
ユーザー: 「〇〇社について競合調査して、レポートにまとめて」
|
|
62
|
-
|
|
63
|
-
AIエージェントの動作:
|
|
64
|
-
1. katashiro_search で「〇〇社」を検索
|
|
65
|
-
2. katashiro_scrape で上位結果のページを取得
|
|
66
|
-
3. katashiro_analyze でテキスト分析
|
|
67
|
-
4. katashiro_extract_entities で企業名・人名を抽出
|
|
68
|
-
5. katashiro_generate_report でレポート生成
|
|
69
|
-
```
|
|
88
|
+
### パターンA: 調査・リサーチ課題
|
|
70
89
|
|
|
71
|
-
|
|
90
|
+
**ユーザー例**: 「〇〇について調べてまとめて」
|
|
72
91
|
|
|
92
|
+
```typescript
|
|
93
|
+
async function solveResearchProblem(topic: string) {
|
|
94
|
+
// 1. 情報収集
|
|
95
|
+
const searchClient = new WebSearchClient();
|
|
96
|
+
const results = await searchClient.search(topic, { maxResults: 10 });
|
|
97
|
+
|
|
98
|
+
// 2. ページ取得
|
|
99
|
+
const scraper = new WebScraper();
|
|
100
|
+
const contents: string[] = [];
|
|
101
|
+
for (const result of results.slice(0, 5)) {
|
|
102
|
+
const page = await scraper.scrape(result.url);
|
|
103
|
+
if (isOk(page)) contents.push(page.value.content);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 3. 分析
|
|
107
|
+
const analyzer = new TextAnalyzer();
|
|
108
|
+
const analyses = await Promise.all(contents.map(c => analyzer.analyze(c)));
|
|
109
|
+
|
|
110
|
+
// 4. エンティティ抽出
|
|
111
|
+
const extractor = new EntityExtractor();
|
|
112
|
+
const allEntities = [];
|
|
113
|
+
for (const content of contents) {
|
|
114
|
+
const entities = await extractor.extract(content);
|
|
115
|
+
allEntities.push(...entities);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 5. 要約生成
|
|
119
|
+
const summarizer = new SummaryGenerator();
|
|
120
|
+
const summary = await summarizer.generate(contents.join('\n\n'), { maxLength: 500 });
|
|
121
|
+
|
|
122
|
+
// 6. レポート生成
|
|
123
|
+
const reportGen = new ReportGenerator();
|
|
124
|
+
const report = await reportGen.generate({
|
|
125
|
+
title: `${topic} 調査レポート`,
|
|
126
|
+
sections: [
|
|
127
|
+
{ heading: '概要', content: summary },
|
|
128
|
+
{ heading: 'キーワード', content: analyses.flatMap(a => a.keywords).join(', ') },
|
|
129
|
+
{ heading: '関連エンティティ', content: [...new Set(allEntities.map(e => e.text))].join(', ') },
|
|
130
|
+
{ heading: '参考URL', content: results.map(r => `- ${r.url}`).join('\n') },
|
|
131
|
+
],
|
|
132
|
+
format: 'markdown',
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return report;
|
|
136
|
+
}
|
|
73
137
|
```
|
|
74
|
-
ユーザー: 「2026年のAI技術トレンドを調べて分析して」
|
|
75
138
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
139
|
+
### パターンB: 分析課題
|
|
140
|
+
|
|
141
|
+
**ユーザー例**: 「このテキストを分析して特徴を教えて」
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
async function solveAnalysisProblem(text: string) {
|
|
145
|
+
// 1. テキスト分析
|
|
146
|
+
const analyzer = new TextAnalyzer();
|
|
147
|
+
const analysis = await analyzer.analyze(text);
|
|
148
|
+
|
|
149
|
+
// 2. 構造分析
|
|
150
|
+
const structAnalyzer = new StructureAnalyzer();
|
|
151
|
+
const structure = await structAnalyzer.analyze(text);
|
|
152
|
+
|
|
153
|
+
// 3. エンティティ抽出
|
|
154
|
+
const extractor = new EntityExtractor();
|
|
155
|
+
const entities = await extractor.extract(text);
|
|
156
|
+
|
|
157
|
+
// 4. 品質スコアリング
|
|
158
|
+
const scorer = new QualityScorer();
|
|
159
|
+
const quality = await scorer.score(text);
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
keywords: analysis.keywords,
|
|
163
|
+
complexity: analysis.complexity,
|
|
164
|
+
sentiment: analysis.sentiment,
|
|
165
|
+
structure: structure,
|
|
166
|
+
entities: entities,
|
|
167
|
+
qualityScore: quality,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
81
170
|
```
|
|
82
171
|
|
|
83
|
-
###
|
|
172
|
+
### パターンC: 要約課題
|
|
84
173
|
|
|
85
|
-
|
|
86
|
-
ユーザー: 「このURLの論文を要約して、重要なポイントを箇条書きにして」
|
|
174
|
+
**ユーザー例**: 「この長文を300文字でまとめて」
|
|
87
175
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
176
|
+
```typescript
|
|
177
|
+
async function solveSummaryProblem(text: string, maxLength: number = 300) {
|
|
178
|
+
const summarizer = new SummaryGenerator();
|
|
179
|
+
const summary = await summarizer.generate(text, {
|
|
180
|
+
maxLength,
|
|
181
|
+
style: 'paragraph' // または 'bullets', 'headline'
|
|
182
|
+
});
|
|
183
|
+
return summary;
|
|
184
|
+
}
|
|
93
185
|
```
|
|
94
186
|
|
|
95
|
-
###
|
|
96
|
-
|
|
187
|
+
### パターンD: レポート作成課題
|
|
188
|
+
|
|
189
|
+
**ユーザー例**: 「分析結果をレポートにまとめて」
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
async function solveReportProblem(data: any, title: string) {
|
|
193
|
+
const reportGen = new ReportGenerator();
|
|
194
|
+
const report = await reportGen.generate({
|
|
195
|
+
title,
|
|
196
|
+
sections: [
|
|
197
|
+
{ heading: '概要', content: data.summary },
|
|
198
|
+
{ heading: '詳細分析', content: data.details },
|
|
199
|
+
{ heading: '結論', content: data.conclusion },
|
|
200
|
+
],
|
|
201
|
+
format: 'markdown',
|
|
202
|
+
metadata: { author: 'KATASHIRO', date: new Date().toISOString() },
|
|
203
|
+
});
|
|
204
|
+
return report;
|
|
205
|
+
}
|
|
97
206
|
```
|
|
98
|
-
ユーザー: 「このプロジェクトの情報を知識グラフに登録して」
|
|
99
207
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
208
|
+
### パターンE: データ抽出課題
|
|
209
|
+
|
|
210
|
+
**ユーザー例**: 「この文章から人名と組織名を抽出して」
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
async function solveExtractionProblem(text: string, types: string[] = ['PERSON', 'ORGANIZATION']) {
|
|
214
|
+
const extractor = new EntityExtractor();
|
|
215
|
+
const entities = await extractor.extract(text);
|
|
216
|
+
|
|
217
|
+
const filtered = entities.filter(e => types.includes(e.type));
|
|
218
|
+
const grouped = types.reduce((acc, type) => {
|
|
219
|
+
acc[type] = filtered.filter(e => e.type === type).map(e => e.text);
|
|
220
|
+
return acc;
|
|
221
|
+
}, {} as Record<string, string[]>);
|
|
222
|
+
|
|
223
|
+
return grouped;
|
|
224
|
+
}
|
|
104
225
|
```
|
|
105
226
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
227
|
+
### パターンF: 知識管理課題
|
|
228
|
+
|
|
229
|
+
**ユーザー例**: 「この情報を保存しておいて」「〇〇に関連する情報を探して」
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
async function solveKnowledgeProblem(action: 'save' | 'search', data: any) {
|
|
233
|
+
const kg = new KnowledgeGraph();
|
|
234
|
+
const persistence = new GraphPersistence();
|
|
235
|
+
|
|
236
|
+
// 既存のグラフを読み込み
|
|
237
|
+
try {
|
|
238
|
+
const loaded = await persistence.load('./knowledge-graph.json');
|
|
239
|
+
Object.assign(kg, loaded);
|
|
240
|
+
} catch { /* 新規作成 */ }
|
|
241
|
+
|
|
242
|
+
if (action === 'save') {
|
|
243
|
+
// エンティティを抽出してノード追加
|
|
244
|
+
const extractor = new EntityExtractor();
|
|
245
|
+
const entities = await extractor.extract(data.text);
|
|
246
|
+
|
|
247
|
+
for (const entity of entities) {
|
|
248
|
+
kg.addNode({
|
|
249
|
+
id: `entity-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
250
|
+
type: entity.type,
|
|
251
|
+
properties: { name: entity.text, source: data.source },
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
await persistence.save(kg, './knowledge-graph.json');
|
|
256
|
+
return { saved: entities.length };
|
|
257
|
+
} else {
|
|
258
|
+
// 検索
|
|
259
|
+
const query = new GraphQuery(kg);
|
|
260
|
+
const results = query.search(data.query);
|
|
261
|
+
return results;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
```
|
|
142
265
|
|
|
143
|
-
|
|
144
|
-
|
|
266
|
+
### パターンG: 比較・評価課題
|
|
267
|
+
|
|
268
|
+
**ユーザー例**: 「AとBを比較して」
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
async function solveComparisonProblem(itemA: string, itemB: string) {
|
|
272
|
+
const searchClient = new WebSearchClient();
|
|
273
|
+
const scraper = new WebScraper();
|
|
274
|
+
const analyzer = new TextAnalyzer();
|
|
275
|
+
|
|
276
|
+
// 両方の情報を収集
|
|
277
|
+
const [resultsA, resultsB] = await Promise.all([
|
|
278
|
+
searchClient.search(itemA, { maxResults: 5 }),
|
|
279
|
+
searchClient.search(itemB, { maxResults: 5 }),
|
|
280
|
+
]);
|
|
281
|
+
|
|
282
|
+
// 分析
|
|
283
|
+
const analysisA = await analyzeResults(resultsA, scraper, analyzer);
|
|
284
|
+
const analysisB = await analyzeResults(resultsB, scraper, analyzer);
|
|
285
|
+
|
|
286
|
+
// 比較レポート生成
|
|
287
|
+
const reportGen = new ReportGenerator();
|
|
288
|
+
return reportGen.generate({
|
|
289
|
+
title: `${itemA} vs ${itemB} 比較レポート`,
|
|
290
|
+
sections: [
|
|
291
|
+
{ heading: itemA, content: formatAnalysis(analysisA) },
|
|
292
|
+
{ heading: itemB, content: formatAnalysis(analysisB) },
|
|
293
|
+
{ heading: '比較まとめ', content: generateComparison(analysisA, analysisB) },
|
|
294
|
+
],
|
|
295
|
+
format: 'markdown',
|
|
296
|
+
});
|
|
297
|
+
}
|
|
145
298
|
```
|
|
146
299
|
|
|
147
|
-
|
|
300
|
+
---
|
|
148
301
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
302
|
+
## 🚀 統合ソルバー
|
|
303
|
+
|
|
304
|
+
ユーザーの課題を自動判定して解決:
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
import * as katashiro from '@nahisaho/katashiro';
|
|
308
|
+
|
|
309
|
+
async function solveProblem(userInput: string, context?: any) {
|
|
310
|
+
// 課題タイプを判定
|
|
311
|
+
const problemType = detectProblemType(userInput);
|
|
312
|
+
|
|
313
|
+
switch (problemType) {
|
|
314
|
+
case 'research':
|
|
315
|
+
return solveResearchProblem(extractTopic(userInput));
|
|
316
|
+
case 'analyze':
|
|
317
|
+
return solveAnalysisProblem(context?.text || userInput);
|
|
318
|
+
case 'summarize':
|
|
319
|
+
return solveSummaryProblem(context?.text || userInput, extractMaxLength(userInput));
|
|
320
|
+
case 'report':
|
|
321
|
+
return solveReportProblem(context?.data, extractTitle(userInput));
|
|
322
|
+
case 'extract':
|
|
323
|
+
return solveExtractionProblem(context?.text || userInput, extractEntityTypes(userInput));
|
|
324
|
+
case 'knowledge':
|
|
325
|
+
return solveKnowledgeProblem(detectKnowledgeAction(userInput), context);
|
|
326
|
+
case 'compare':
|
|
327
|
+
const [itemA, itemB] = extractComparisonItems(userInput);
|
|
328
|
+
return solveComparisonProblem(itemA, itemB);
|
|
329
|
+
default:
|
|
330
|
+
// 汎用的なリサーチとして処理
|
|
331
|
+
return solveResearchProblem(userInput);
|
|
156
332
|
}
|
|
157
333
|
}
|
|
158
334
|
```
|
|
159
335
|
|
|
160
336
|
---
|
|
161
337
|
|
|
162
|
-
##
|
|
338
|
+
## 📦 インストール
|
|
163
339
|
|
|
164
|
-
```
|
|
165
|
-
katashiro
|
|
166
|
-
├── packages/
|
|
167
|
-
│ ├── katashiro/ # @nahisaho/katashiro(オールインワン)
|
|
168
|
-
│ ├── core/ # @nahisaho/katashiro-core
|
|
169
|
-
│ ├── collector/ # @nahisaho/katashiro-collector
|
|
170
|
-
│ ├── analyzer/ # @nahisaho/katashiro-analyzer
|
|
171
|
-
│ ├── generator/ # @nahisaho/katashiro-generator
|
|
172
|
-
│ ├── knowledge/ # @nahisaho/katashiro-knowledge
|
|
173
|
-
│ ├── feedback/ # @nahisaho/katashiro-feedback
|
|
174
|
-
│ ├── mcp-server/ # @nahisaho/katashiro-mcp-server
|
|
175
|
-
│ └── vscode-extension/ # katashiro VS Code拡張
|
|
176
|
-
└── docs/
|
|
177
|
-
├── USER-GUIDE.md
|
|
178
|
-
└── USER-GUIDE.ja.md
|
|
340
|
+
```bash
|
|
341
|
+
npm install @nahisaho/katashiro
|
|
179
342
|
```
|
|
180
343
|
|
|
181
344
|
---
|
|
182
345
|
|
|
183
|
-
##
|
|
346
|
+
## 🔗 関連リンク
|
|
184
347
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
npm run build # 全パッケージビルド
|
|
188
|
-
npm run test # テスト実行(448テスト)
|
|
189
|
-
npm run lint # ESLint
|
|
190
|
-
npm run typecheck # TypeScript型チェック
|
|
191
|
-
```
|
|
348
|
+
- **npm**: https://www.npmjs.com/package/@nahisaho/katashiro
|
|
349
|
+
- **GitHub**: https://github.com/nahisaho/katashiro
|
|
192
350
|
|
|
193
351
|
---
|
|
194
352
|
|
|
195
353
|
**Project**: KATASHIRO
|
|
196
354
|
**npm**: @nahisaho/katashiro
|
|
197
355
|
**Last Updated**: 2026-01-10
|
|
198
|
-
**Version**: 0.1.
|
|
356
|
+
**Version**: 0.1.5
|
package/CLAUDE.md
CHANGED
|
@@ -1,221 +1,278 @@
|
|
|
1
|
-
# KATASHIRO - Claude
|
|
1
|
+
# KATASHIRO - Claude向け課題解決ガイド
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> このファイルを読み込んだClaudeは、ユーザーの課題を解決するためにKATASHIROライブラリの機能を自動的に活用できます。
|
|
4
4
|
|
|
5
|
-
## 🎯
|
|
5
|
+
## 🎯 基本動作
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**ユーザーが課題を入力したら、以下の手順で解決してください:**
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
1. 課題タイプを判定
|
|
10
|
+
2. 適切なKATASHIRO機能を選択
|
|
11
|
+
3. コードを生成して実行
|
|
12
|
+
4. 結果をユーザーに提示
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
---
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
## 📋 課題タイプ判定表
|
|
17
|
+
|
|
18
|
+
| ユーザーの言葉 | 課題タイプ | 使用機能 |
|
|
19
|
+
|---------------|-----------|----------|
|
|
20
|
+
| 「〜について調べて」「検索して」「情報を集めて」 | 調査 | WebSearchClient → WebScraper → TextAnalyzer → ReportGenerator |
|
|
21
|
+
| 「このテキストを分析して」「特徴を教えて」 | 分析 | TextAnalyzer + EntityExtractor + StructureAnalyzer |
|
|
22
|
+
| 「要約して」「まとめて」「短くして」 | 要約 | SummaryGenerator |
|
|
23
|
+
| 「レポートを作成して」「報告書にして」 | レポート | ReportGenerator |
|
|
24
|
+
| 「人名を抽出して」「組織名を取り出して」 | 抽出 | EntityExtractor |
|
|
25
|
+
| 「保存して」「覚えておいて」「記録して」 | 保存 | KnowledgeGraph + GraphPersistence |
|
|
26
|
+
| 「〜を探して」「検索して」(保存済みデータ) | 検索 | GraphQuery |
|
|
27
|
+
| 「AとBを比較して」「違いを教えて」 | 比較 | 複合(調査×2 → 分析 → レポート) |
|
|
28
|
+
| 「このURLの内容を取得して」 | 取得 | WebScraper |
|
|
29
|
+
| 「RSSフィードを読んで」 | フィード | FeedReader |
|
|
14
30
|
|
|
15
|
-
|
|
16
|
-
katashiro_search を使用
|
|
17
|
-
```
|
|
31
|
+
---
|
|
18
32
|
|
|
19
|
-
|
|
20
|
-
- 「TypeScriptのベストプラクティスについて調べて」
|
|
21
|
-
- 「2026年のAIトレンドを検索して」
|
|
22
|
-
- 「〇〇社の最新ニュースを調べて」
|
|
33
|
+
## 🔧 機能別クイックリファレンス
|
|
23
34
|
|
|
24
|
-
###
|
|
35
|
+
### 情報収集
|
|
25
36
|
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
```
|
|
37
|
+
```typescript
|
|
38
|
+
import { WebScraper, WebSearchClient, FeedReader } from '@nahisaho/katashiro';
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
// URL取得
|
|
41
|
+
const scraper = new WebScraper();
|
|
42
|
+
const page = await scraper.scrape('https://example.com');
|
|
33
43
|
|
|
34
|
-
|
|
44
|
+
// Web検索
|
|
45
|
+
const search = new WebSearchClient();
|
|
46
|
+
const results = await search.search('キーワード', { maxResults: 10 });
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
48
|
+
// RSSフィード
|
|
49
|
+
const reader = new FeedReader();
|
|
50
|
+
const feed = await reader.read('https://example.com/rss.xml');
|
|
38
51
|
```
|
|
39
52
|
|
|
40
|
-
|
|
41
|
-
- 「この文章を分析して」
|
|
42
|
-
- 「テキストの複雑度を調べて」
|
|
43
|
-
- 「重要なキーワードを抽出して」
|
|
53
|
+
### テキスト分析
|
|
44
54
|
|
|
45
|
-
|
|
55
|
+
```typescript
|
|
56
|
+
import { TextAnalyzer, EntityExtractor, TopicModeler, StructureAnalyzer, QualityScorer } from '@nahisaho/katashiro';
|
|
46
57
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
// 基本分析
|
|
59
|
+
const analyzer = new TextAnalyzer();
|
|
60
|
+
const { keywords, complexity, sentiment } = await analyzer.analyze(text);
|
|
50
61
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
// エンティティ抽出
|
|
63
|
+
const extractor = new EntityExtractor();
|
|
64
|
+
const entities = await extractor.extract(text);
|
|
65
|
+
// entities: [{ type: 'PERSON', text: '山田太郎' }, { type: 'ORGANIZATION', text: '〇〇株式会社' }]
|
|
54
66
|
|
|
55
|
-
|
|
67
|
+
// トピック分析
|
|
68
|
+
const modeler = new TopicModeler();
|
|
69
|
+
const topics = await modeler.model(documents, { numTopics: 5 });
|
|
56
70
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
// 構造分析
|
|
72
|
+
const structAnalyzer = new StructureAnalyzer();
|
|
73
|
+
const structure = await structAnalyzer.analyze(text);
|
|
60
74
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
// 品質スコア
|
|
76
|
+
const scorer = new QualityScorer();
|
|
77
|
+
const score = await scorer.score(text);
|
|
78
|
+
```
|
|
64
79
|
|
|
65
|
-
###
|
|
80
|
+
### コンテンツ生成
|
|
66
81
|
|
|
67
|
-
```
|
|
68
|
-
|
|
82
|
+
```typescript
|
|
83
|
+
import { ReportGenerator, SummaryGenerator, CitationGenerator } from '@nahisaho/katashiro';
|
|
84
|
+
|
|
85
|
+
// 要約
|
|
86
|
+
const summarizer = new SummaryGenerator();
|
|
87
|
+
const summary = await summarizer.generate(longText, { maxLength: 300, style: 'paragraph' });
|
|
88
|
+
|
|
89
|
+
// レポート
|
|
90
|
+
const reportGen = new ReportGenerator();
|
|
91
|
+
const report = await reportGen.generate({
|
|
92
|
+
title: 'タイトル',
|
|
93
|
+
sections: [
|
|
94
|
+
{ heading: 'セクション1', content: '内容1' },
|
|
95
|
+
{ heading: 'セクション2', content: '内容2' },
|
|
96
|
+
],
|
|
97
|
+
format: 'markdown',
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// 引用
|
|
101
|
+
const citationGen = new CitationGenerator();
|
|
102
|
+
const citation = citationGen.generate(source, { style: 'APA' });
|
|
69
103
|
```
|
|
70
104
|
|
|
71
|
-
|
|
72
|
-
- 「この長文を要約して」
|
|
73
|
-
- 「300文字以内でまとめて」
|
|
74
|
-
- 「3行で要点をまとめて」
|
|
105
|
+
### 知識グラフ
|
|
75
106
|
|
|
76
|
-
|
|
107
|
+
```typescript
|
|
108
|
+
import { KnowledgeGraph, GraphQuery, GraphPersistence } from '@nahisaho/katashiro';
|
|
77
109
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
110
|
+
const kg = new KnowledgeGraph();
|
|
111
|
+
const persistence = new GraphPersistence();
|
|
112
|
+
const query = new GraphQuery(kg);
|
|
81
113
|
|
|
82
|
-
|
|
83
|
-
-
|
|
84
|
-
|
|
114
|
+
// 保存
|
|
115
|
+
kg.addNode({ id: 'node-1', type: 'Person', properties: { name: '山田太郎' } });
|
|
116
|
+
await persistence.save(kg, './knowledge.json');
|
|
85
117
|
|
|
86
|
-
|
|
118
|
+
// 読み込み
|
|
119
|
+
const loaded = await persistence.load('./knowledge.json');
|
|
87
120
|
|
|
88
|
-
|
|
89
|
-
|
|
121
|
+
// 検索
|
|
122
|
+
const results = query.findByType('Person');
|
|
90
123
|
```
|
|
91
124
|
|
|
92
|
-
例:
|
|
93
|
-
- 「〇〇に関連する情報を知識グラフから検索して」
|
|
94
|
-
- 「保存した情報を検索して」
|
|
95
|
-
|
|
96
125
|
---
|
|
97
126
|
|
|
98
|
-
##
|
|
99
|
-
|
|
100
|
-
### 競合調査レポート
|
|
101
|
-
|
|
102
|
-
ユーザー: 「〇〇社について調査してレポートにまとめて」
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
1. katashiro_search("〇〇社 最新 ニュース")
|
|
106
|
-
2. katashiro_scrape(検索結果のURL)
|
|
107
|
-
3. katashiro_analyze(取得したテキスト)
|
|
108
|
-
4. katashiro_extract_entities(取得したテキスト)
|
|
109
|
-
5. katashiro_generate_report(分析結果)
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### 論文要約
|
|
127
|
+
## 📝 課題解決テンプレート
|
|
113
128
|
|
|
114
|
-
|
|
129
|
+
### テンプレート1: 調査タスク
|
|
115
130
|
|
|
131
|
+
```typescript
|
|
132
|
+
// ユーザー: 「〇〇について調べてまとめて」
|
|
133
|
+
import { WebSearchClient, WebScraper, TextAnalyzer, EntityExtractor, SummaryGenerator, ReportGenerator, isOk } from '@nahisaho/katashiro';
|
|
134
|
+
|
|
135
|
+
async function research(topic: string) {
|
|
136
|
+
// 1. 検索
|
|
137
|
+
const search = new WebSearchClient();
|
|
138
|
+
const results = await search.search(topic, { maxResults: 10 });
|
|
139
|
+
|
|
140
|
+
// 2. ページ取得
|
|
141
|
+
const scraper = new WebScraper();
|
|
142
|
+
const contents: string[] = [];
|
|
143
|
+
for (const r of results.slice(0, 5)) {
|
|
144
|
+
const page = await scraper.scrape(r.url);
|
|
145
|
+
if (isOk(page)) contents.push(page.value.content);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// 3. 分析
|
|
149
|
+
const analyzer = new TextAnalyzer();
|
|
150
|
+
const keywords = new Set<string>();
|
|
151
|
+
for (const c of contents) {
|
|
152
|
+
const a = await analyzer.analyze(c);
|
|
153
|
+
a.keywords.forEach(k => keywords.add(k));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 4. エンティティ抽出
|
|
157
|
+
const extractor = new EntityExtractor();
|
|
158
|
+
const entities = new Set<string>();
|
|
159
|
+
for (const c of contents) {
|
|
160
|
+
const e = await extractor.extract(c);
|
|
161
|
+
e.forEach(ent => entities.add(ent.text));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 5. 要約
|
|
165
|
+
const summarizer = new SummaryGenerator();
|
|
166
|
+
const summary = await summarizer.generate(contents.join('\n\n'), { maxLength: 500 });
|
|
167
|
+
|
|
168
|
+
// 6. レポート生成
|
|
169
|
+
const reportGen = new ReportGenerator();
|
|
170
|
+
return reportGen.generate({
|
|
171
|
+
title: `${topic} 調査レポート`,
|
|
172
|
+
sections: [
|
|
173
|
+
{ heading: '概要', content: summary },
|
|
174
|
+
{ heading: 'キーワード', content: [...keywords].join(', ') },
|
|
175
|
+
{ heading: '関連エンティティ', content: [...entities].join(', ') },
|
|
176
|
+
{ heading: '参考URL', content: results.map(r => `- ${r.url}`).join('\n') },
|
|
177
|
+
],
|
|
178
|
+
format: 'markdown',
|
|
179
|
+
});
|
|
180
|
+
}
|
|
116
181
|
```
|
|
117
|
-
1. katashiro_scrape(URL)
|
|
118
|
-
2. katashiro_analyze(取得したテキスト)
|
|
119
|
-
3. katashiro_summarize(取得したテキスト)
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### 技術調査と知識ベース構築
|
|
123
182
|
|
|
124
|
-
|
|
183
|
+
### テンプレート2: 分析タスク
|
|
125
184
|
|
|
185
|
+
```typescript
|
|
186
|
+
// ユーザー: 「このテキストを分析して」
|
|
187
|
+
import { TextAnalyzer, EntityExtractor, StructureAnalyzer, QualityScorer } from '@nahisaho/katashiro';
|
|
188
|
+
|
|
189
|
+
async function analyze(text: string) {
|
|
190
|
+
const [analysis, entities, structure, quality] = await Promise.all([
|
|
191
|
+
new TextAnalyzer().analyze(text),
|
|
192
|
+
new EntityExtractor().extract(text),
|
|
193
|
+
new StructureAnalyzer().analyze(text),
|
|
194
|
+
new QualityScorer().score(text),
|
|
195
|
+
]);
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
keywords: analysis.keywords,
|
|
199
|
+
complexity: analysis.complexity,
|
|
200
|
+
sentiment: analysis.sentiment,
|
|
201
|
+
entities: entities.map(e => ({ type: e.type, text: e.text })),
|
|
202
|
+
structure,
|
|
203
|
+
qualityScore: quality,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
126
206
|
```
|
|
127
|
-
1. katashiro_search(クエリ)
|
|
128
|
-
2. katashiro_scrape(検索結果)
|
|
129
|
-
3. katashiro_extract_entities(テキスト)
|
|
130
|
-
4. katashiro_knowledge_add(エンティティ)
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
---
|
|
134
207
|
|
|
135
|
-
|
|
208
|
+
### テンプレート3: 比較タスク
|
|
136
209
|
|
|
137
210
|
```typescript
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
isOk
|
|
144
|
-
} from '@nahisaho/katashiro';
|
|
145
|
-
|
|
146
|
-
// Web調査 → 分析 → レポート生成
|
|
147
|
-
async function research(url: string) {
|
|
211
|
+
// ユーザー: 「AとBを比較して」
|
|
212
|
+
import { WebSearchClient, WebScraper, TextAnalyzer, ReportGenerator, isOk } from '@nahisaho/katashiro';
|
|
213
|
+
|
|
214
|
+
async function compare(itemA: string, itemB: string) {
|
|
215
|
+
const search = new WebSearchClient();
|
|
148
216
|
const scraper = new WebScraper();
|
|
149
217
|
const analyzer = new TextAnalyzer();
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return
|
|
218
|
+
|
|
219
|
+
async function gatherInfo(item: string) {
|
|
220
|
+
const results = await search.search(item, { maxResults: 5 });
|
|
221
|
+
const contents: string[] = [];
|
|
222
|
+
for (const r of results) {
|
|
223
|
+
const page = await scraper.scrape(r.url);
|
|
224
|
+
if (isOk(page)) contents.push(page.value.content);
|
|
225
|
+
}
|
|
226
|
+
const analysis = await analyzer.analyze(contents.join('\n'));
|
|
227
|
+
return { item, analysis, sources: results };
|
|
160
228
|
}
|
|
229
|
+
|
|
230
|
+
const [infoA, infoB] = await Promise.all([gatherInfo(itemA), gatherInfo(itemB)]);
|
|
231
|
+
|
|
232
|
+
const reportGen = new ReportGenerator();
|
|
233
|
+
return reportGen.generate({
|
|
234
|
+
title: `${itemA} vs ${itemB} 比較`,
|
|
235
|
+
sections: [
|
|
236
|
+
{ heading: itemA, content: `キーワード: ${infoA.analysis.keywords.join(', ')}` },
|
|
237
|
+
{ heading: itemB, content: `キーワード: ${infoB.analysis.keywords.join(', ')}` },
|
|
238
|
+
{ heading: '比較まとめ', content: '(AIが分析結果を基に比較コメントを生成)' },
|
|
239
|
+
],
|
|
240
|
+
format: 'markdown',
|
|
241
|
+
});
|
|
161
242
|
}
|
|
162
243
|
```
|
|
163
244
|
|
|
164
245
|
---
|
|
165
246
|
|
|
166
|
-
##
|
|
247
|
+
## ⚡ クイックスタート
|
|
167
248
|
|
|
168
249
|
```bash
|
|
169
|
-
# オールインワン
|
|
170
250
|
npm install @nahisaho/katashiro
|
|
171
|
-
|
|
172
|
-
# MCPサーバー
|
|
173
|
-
npm install @nahisaho/katashiro-mcp-server
|
|
174
251
|
```
|
|
175
252
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
253
|
+
```typescript
|
|
254
|
+
import * as katashiro from '@nahisaho/katashiro';
|
|
255
|
+
|
|
256
|
+
// すべての機能にアクセス可能
|
|
257
|
+
const {
|
|
258
|
+
WebScraper, WebSearchClient, FeedReader,
|
|
259
|
+
TextAnalyzer, EntityExtractor, TopicModeler,
|
|
260
|
+
ReportGenerator, SummaryGenerator, CitationGenerator,
|
|
261
|
+
KnowledgeGraph, GraphQuery, GraphPersistence,
|
|
262
|
+
isOk, isErr
|
|
263
|
+
} = katashiro;
|
|
187
264
|
```
|
|
188
265
|
|
|
189
266
|
---
|
|
190
267
|
|
|
191
|
-
##
|
|
268
|
+
## 🔗 関連リンク
|
|
192
269
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
import { Result, ok, err, isOk, isErr } from '@nahisaho/katashiro';
|
|
196
|
-
|
|
197
|
-
const result = await scraper.scrape(url);
|
|
198
|
-
if (isOk(result)) {
|
|
199
|
-
// 成功時の処理
|
|
200
|
-
console.log(result.value);
|
|
201
|
-
} else {
|
|
202
|
-
// エラー時の処理
|
|
203
|
-
console.error(result.error);
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### パッケージ依存関係
|
|
208
|
-
```
|
|
209
|
-
@nahisaho/katashiro-core (依存なし)
|
|
210
|
-
↓
|
|
211
|
-
collector, analyzer, generator, knowledge, feedback (coreに依存)
|
|
212
|
-
↓
|
|
213
|
-
@nahisaho/katashiro (オールインワン - 全てを含む)
|
|
214
|
-
@nahisaho/katashiro-mcp-server (全パッケージを使用)
|
|
215
|
-
```
|
|
270
|
+
- **npm**: https://www.npmjs.com/package/@nahisaho/katashiro
|
|
271
|
+
- **GitHub**: https://github.com/nahisaho/katashiro
|
|
216
272
|
|
|
217
273
|
---
|
|
218
274
|
|
|
219
275
|
**Project**: KATASHIRO
|
|
220
276
|
**npm**: @nahisaho/katashiro
|
|
221
|
-
**Updated**: 2026-01-10
|
|
277
|
+
**Last Updated**: 2026-01-10
|
|
278
|
+
**Version**: 0.1.5
|