@nahisaho/katashiro 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/AGENTS.md +222 -144
  2. package/CLAUDE.md +164 -174
  3. package/package.json +1 -1
package/AGENTS.md CHANGED
@@ -1,198 +1,276 @@
1
1
  # KATASHIRO - AI Coding Agent Guide
2
2
 
3
- > **AI Coding Agent向け**: このファイルはAIエージェント(GitHub Copilot、Claude等)がKATASHIROサービスを自然言語で利用するためのガイドです。
3
+ > **AI Coding Agent向け**: このファイルはAIエージェント(GitHub Copilot、Claude等)がKATASHIROライブラリを利用するためのガイドです。
4
4
 
5
5
  ## 🎯 KATASHIROでできること
6
6
 
7
- KATASHIROは以下のタスクを自然言語で実行できます:
7
+ KATASHIROは情報収集・分析・生成のためのTypeScriptライブラリです。
8
8
 
9
- | やりたいこと | 自然言語での依頼例 |
10
- |-------------|-------------------|
11
- | **Web調査** | 「〜について調べて」「〜の最新情報を検索して」 |
12
- | **Webページ取得** | 「このURLの内容を取得して」「〜のサイトをスクレイピングして」 |
13
- | **テキスト分析** | 「この文章を分析して」「キーワードを抽出して」 |
14
- | **エンティティ抽出** | 「人名・組織名を抽出して」「固有表現を見つけて」 |
15
- | **レポート生成** | 「調査レポートを作成して」「分析結果をまとめて」 |
16
- | **要約作成** | 「この文章を要約して」「3行でまとめて」 |
17
- | **知識グラフ操作** | 「知識グラフに追加して」「関連情報を検索して」 |
9
+ | 機能 | 説明 |
10
+ |------|------|
11
+ | **Web収集** | Webスクレイピング、検索、RSSフィード取得 |
12
+ | **テキスト分析** | キーワード抽出、複雑度分析、構造解析 |
13
+ | **エンティティ抽出** | 人名・組織名・地名などの固有表現抽出 |
14
+ | **レポート生成** | Markdown/HTMLレポート、要約、引用生成 |
15
+ | **知識グラフ** | エンティティ・関係の保存・検索・可視化 |
16
+ | **フィードバック学習** | パターン検出、適応的推薦 |
18
17
 
19
18
  ---
20
19
 
21
- ## 🔧 MCPツール(自然言語で呼び出し可能)
20
+ ## 📦 インストール
22
21
 
23
- ### 情報収集ツール
22
+ \`\`\`bash
23
+ npm install @nahisaho/katashiro
24
+ \`\`\`
24
25
 
25
- | ツール | 自然言語での呼び出し例 |
26
- |--------|----------------------|
27
- | `katashiro_scrape` | 「https://example.com の内容を取得して」 |
28
- | `katashiro_search` | 「TypeScript best practices について検索して」 |
29
- | `katashiro_feed` | 「このRSSフィードを読み込んで」 |
26
+ ---
30
27
 
31
- ### 分析ツール
28
+ ## 🔧 基本的な使い方
29
+
30
+ ### インポート
31
+
32
+ \`\`\`typescript
33
+ import {
34
+ // Collector - 情報収集
35
+ WebScraper,
36
+ WebSearchClient,
37
+ FeedReader,
38
+ ApiClient,
39
+
40
+ // Analyzer - テキスト分析
41
+ TextAnalyzer,
42
+ EntityExtractor,
43
+ TopicModeler,
44
+
45
+ // Generator - コンテンツ生成
46
+ ReportGenerator,
47
+ SummaryGenerator,
48
+ CitationGenerator,
49
+
50
+ // Knowledge - 知識グラフ
51
+ KnowledgeGraph,
52
+ GraphQuery,
53
+ GraphPersistence,
54
+
55
+ // Core - ユーティリティ
56
+ ok, err, isOk, isErr,
57
+ } from '@nahisaho/katashiro';
58
+ \`\`\`
32
59
 
33
- | ツール | 自然言語での呼び出し例 |
34
- |--------|----------------------|
35
- | `katashiro_analyze` | 「この文章のキーワードと複雑度を分析して」 |
36
- | `katashiro_extract_entities` | 「このテキストから人名と組織名を抽出して」 |
37
- | `katashiro_topics` | 「これらの文書のトピックを分析して」 |
60
+ ---
38
61
 
39
- ### 生成ツール
62
+ ## 📝 ユースケース別コード例
63
+
64
+ ### 1. Webページの取得と分析
65
+
66
+ \`\`\`typescript
67
+ import { WebScraper, TextAnalyzer, EntityExtractor, isOk } from '@nahisaho/katashiro';
68
+
69
+ // Webページを取得
70
+ const scraper = new WebScraper();
71
+ const pageResult = await scraper.scrape('https://example.com/article');
72
+
73
+ if (isOk(pageResult)) {
74
+ const { content, title } = pageResult.value;
75
+
76
+ // テキスト分析
77
+ const analyzer = new TextAnalyzer();
78
+ const analysis = await analyzer.analyze(content);
79
+ console.log('Keywords:', analysis.keywords);
80
+ console.log('Complexity:', analysis.complexity);
81
+
82
+ // エンティティ抽出
83
+ const extractor = new EntityExtractor();
84
+ const entities = await extractor.extract(content);
85
+ console.log('People:', entities.filter(e => e.type === 'PERSON'));
86
+ console.log('Organizations:', entities.filter(e => e.type === 'ORGANIZATION'));
87
+ }
88
+ \`\`\`
40
89
 
41
- | ツール | 自然言語での呼び出し例 |
42
- |--------|----------------------|
43
- | `katashiro_generate_report` | 「調査結果からレポートを生成して」 |
44
- | `katashiro_summarize` | 「この長文を300文字で要約して」 |
45
- | `katashiro_citation` | 「APA形式で引用を生成して」 |
90
+ ### 2. Web検索と情報収集
46
91
 
47
- ### 知識グラフツール
92
+ \`\`\`typescript
93
+ import { WebSearchClient, WebScraper, isOk } from '@nahisaho/katashiro';
48
94
 
49
- | ツール | 自然言語での呼び出し例 |
50
- |--------|----------------------|
51
- | `katashiro_knowledge_query` | 「知識グラフから〜に関連する情報を検索して」 |
52
- | `katashiro_knowledge_add` | 「この情報を知識グラフに追加して」 |
95
+ // 検索実行
96
+ const searchClient = new WebSearchClient({ apiKey: process.env.SEARCH_API_KEY });
97
+ const results = await searchClient.search('TypeScript best practices', { maxResults: 5 });
53
98
 
54
- ---
99
+ // 上位結果のページを取得
100
+ const scraper = new WebScraper();
101
+ for (const result of results) {
102
+ const page = await scraper.scrape(result.url);
103
+ if (isOk(page)) {
104
+ console.log(\`Title: \${page.value.title}\`);
105
+ console.log(\`Content: \${page.value.content.slice(0, 200)}...\`);
106
+ }
107
+ }
108
+ \`\`\`
55
109
 
56
- ## 📝 ユースケース別ワークフロー
110
+ ### 3. レポート生成
57
111
 
58
- ### 1. 競合調査レポート作成
112
+ \`\`\`typescript
113
+ import { ReportGenerator, SummaryGenerator } from '@nahisaho/katashiro';
59
114
 
60
- ```
61
- ユーザー: 「〇〇社について競合調査して、レポートにまとめて」
115
+ // 要約生成
116
+ const summarizer = new SummaryGenerator();
117
+ const summary = await summarizer.generate(longText, { maxLength: 300 });
62
118
 
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
- ```
119
+ // レポート生成
120
+ const reportGen = new ReportGenerator();
121
+ const report = await reportGen.generate({
122
+ title: '調査レポート',
123
+ sections: [
124
+ { heading: '概要', content: summary },
125
+ { heading: '詳細分析', content: analysisText },
126
+ { heading: '結論', content: conclusionText },
127
+ ],
128
+ format: 'markdown',
129
+ });
70
130
 
71
- ### 2. 技術トレンド分析
131
+ console.log(report);
132
+ \`\`\`
72
133
 
73
- ```
74
- ユーザー: 「2026年のAI技術トレンドを調べて分析して」
134
+ ### 4. 知識グラフの操作
75
135
 
76
- AIエージェントの動作:
77
- 1. katashiro_search で「AI trends 2026」を検索
78
- 2. katashiro_scrape で技術ブログを取得
79
- 3. katashiro_topics でトピック分析
80
- 4. katashiro_summarize で要点をまとめ
81
- ```
136
+ \`\`\`typescript
137
+ import { KnowledgeGraph, GraphQuery, GraphPersistence } from '@nahisaho/katashiro';
82
138
 
83
- ### 3. 論文・記事の要約
139
+ // 知識グラフを作成
140
+ const kg = new KnowledgeGraph();
84
141
 
85
- ```
86
- ユーザー: 「このURLの論文を要約して、重要なポイントを箇条書きにして」
142
+ // ノードを追加
143
+ kg.addNode({ id: 'company-1', type: 'Organization', properties: { name: 'TechCorp' } });
144
+ kg.addNode({ id: 'person-1', type: 'Person', properties: { name: '山田太郎' } });
87
145
 
88
- AIエージェントの動作:
89
- 1. katashiro_scrape でページ内容を取得
90
- 2. katashiro_analyze で構造分析
91
- 3. katashiro_summarize で要約生成
92
- 4. katashiro_citation で引用情報を生成
93
- ```
146
+ // エッジ(関係)を追加
147
+ kg.addEdge({ source: 'person-1', target: 'company-1', type: 'WORKS_FOR' });
94
148
 
95
- ### 4. 知識ベース構築
149
+ // クエリ実行
150
+ const query = new GraphQuery(kg);
151
+ const employees = query.findByRelation('company-1', 'WORKS_FOR', 'incoming');
96
152
 
97
- ```
98
- ユーザー: 「このプロジェクトの情報を知識グラフに登録して」
153
+ // 永続化
154
+ const persistence = new GraphPersistence();
155
+ await persistence.save(kg, './knowledge-graph.json');
99
156
 
100
- AIエージェントの動作:
101
- 1. katashiro_extract_entities でエンティティ抽出
102
- 2. katashiro_knowledge_add でノード追加
103
- 3. katashiro_knowledge_query で関連性確認
104
- ```
157
+ // 読み込み
158
+ const loadedKg = await persistence.load('./knowledge-graph.json');
159
+ \`\`\`
105
160
 
106
- ---
161
+ ### 5. RSSフィードの購読
107
162
 
108
- ## 💡 自然言語プロンプト例
109
-
110
- ### 調査系
111
- - 「〜について調べて」
112
- - 「〜の最新ニュースを検索して」
113
- - 「〜に関する情報を集めて」
114
- - 「このURLの内容を取得して分析して」
115
-
116
- ### 分析系
117
- - 「この文章を分析して」
118
- - 「キーワードを抽出して」
119
- - 「人名・組織名をリストアップして」
120
- - 「トピックを分類して」
121
- - 「感情分析して」
122
-
123
- ### 生成系
124
- - 「レポートにまとめて」
125
- - 「要約して」
126
- - 「〜文字でまとめて」
127
- - 「プレゼン資料を作って」
128
- - 「引用を生成して」
129
-
130
- ### 知識グラフ系
131
- - 「知識グラフに追加して」
132
- - 「関連情報を検索して」
133
- - 「この情報を保存して」
163
+ \`\`\`typescript
164
+ import { FeedReader, isOk } from '@nahisaho/katashiro';
134
165
 
135
- ---
166
+ const reader = new FeedReader();
167
+ const feed = await reader.read('https://blog.example.com/rss.xml');
136
168
 
137
- ## 📦 npmパッケージ
169
+ if (isOk(feed)) {
170
+ for (const item of feed.value.items) {
171
+ console.log(\`\${item.title} - \${item.pubDate}\`);
172
+ console.log(\` \${item.description}\`);
173
+ }
174
+ }
175
+ \`\`\`
138
176
 
139
- ```bash
140
- # オールインワン(推奨)
141
- npm install @nahisaho/katashiro
177
+ ### 6. 引用生成
142
178
 
143
- # MCPサーバー
144
- npm install @nahisaho/katashiro-mcp-server
145
- ```
179
+ \`\`\`typescript
180
+ import { CitationGenerator } from '@nahisaho/katashiro';
146
181
 
147
- ### VS Code MCP設定
182
+ const citationGen = new CitationGenerator();
183
+ const citation = citationGen.generate({
184
+ title: 'TypeScript Best Practices',
185
+ author: 'John Doe',
186
+ url: 'https://example.com/article',
187
+ date: '2026-01-10',
188
+ }, { style: 'APA' });
148
189
 
149
- ```json
150
- {
151
- "mcp.servers": {
152
- "katashiro": {
153
- "command": "npx",
154
- "args": ["@nahisaho/katashiro-mcp-server"]
155
- }
156
- }
157
- }
158
- ```
190
+ console.log(citation);
191
+ // Doe, J. (2026). TypeScript Best Practices. Retrieved from https://example.com/article
192
+ \`\`\`
193
+
194
+ ---
195
+
196
+ ## 📚 モジュール一覧
197
+
198
+ ### Collector(情報収集)
199
+
200
+ | クラス | 機能 |
201
+ |--------|------|
202
+ | \`WebScraper\` | Webページのスクレイピング |
203
+ | \`WebSearchClient\` | Web検索API連携 |
204
+ | \`FeedReader\` | RSS/Atomフィード読み込み |
205
+ | \`ApiClient\` | REST API呼び出し |
206
+ | \`MediaExtractor\` | 画像・動画URL抽出 |
207
+ | \`YouTubeTranscript\` | YouTube字幕取得 |
208
+
209
+ ### Analyzer(テキスト分析)
210
+
211
+ | クラス | 機能 |
212
+ |--------|------|
213
+ | \`TextAnalyzer\` | キーワード・複雑度・感情分析 |
214
+ | \`EntityExtractor\` | 固有表現抽出(人名・組織名・地名) |
215
+ | \`TopicModeler\` | トピック分類 |
216
+ | \`StructureAnalyzer\` | 文書構造解析 |
217
+ | \`RelationAnalyzer\` | エンティティ間関係分析 |
218
+ | \`QualityScorer\` | テキスト品質スコアリング |
219
+
220
+ ### Generator(コンテンツ生成)
221
+
222
+ | クラス | 機能 |
223
+ |--------|------|
224
+ | \`ReportGenerator\` | Markdown/HTMLレポート生成 |
225
+ | \`SummaryGenerator\` | テキスト要約 |
226
+ | \`CitationGenerator\` | 引用生成(APA/MLA/Chicago) |
227
+ | \`PresentationGenerator\` | プレゼン資料生成 |
228
+ | \`TemplateEngine\` | テンプレートベース生成 |
229
+ | \`ExportService\` | 各種フォーマットへのエクスポート |
230
+
231
+ ### Knowledge(知識グラフ)
232
+
233
+ | クラス | 機能 |
234
+ |--------|------|
235
+ | \`KnowledgeGraph\` | グラフ構造の管理 |
236
+ | \`GraphQuery\` | グラフ検索・クエリ |
237
+ | \`GraphPersistence\` | JSON/SQLite永続化 |
238
+ | \`GraphSync\` | グラフ同期 |
239
+ | \`GraphVisualization\` | D3.js/Mermaid可視化 |
240
+
241
+ ### Core(ユーティリティ)
242
+
243
+ | 関数/クラス | 機能 |
244
+ |-------------|------|
245
+ | \`ok()\`, \`err()\` | Result型の生成 |
246
+ | \`isOk()\`, \`isErr()\` | Result型の判定 |
247
+ | \`Logger\` | ログ出力 |
248
+ | \`generateId()\` | ユニークID生成 |
159
249
 
160
250
  ---
161
251
 
162
252
  ## 🏗️ プロジェクト構造
163
253
 
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
179
- ```
254
+ \`\`\`
255
+ @nahisaho/katashiro
256
+ ├── Collector # 情報収集モジュール
257
+ ├── Analyzer # テキスト分析モジュール
258
+ ├── Generator # コンテンツ生成モジュール
259
+ ├── Knowledge # 知識グラフモジュール
260
+ ├── Feedback # フィードバック学習モジュール
261
+ └── Core # ユーティリティ
262
+ \`\`\`
180
263
 
181
264
  ---
182
265
 
183
- ## 🛠️ 開発コマンド
266
+ ## 🔗 関連リンク
184
267
 
185
- ```bash
186
- npm install # 依存関係インストール
187
- npm run build # 全パッケージビルド
188
- npm run test # テスト実行(448テスト)
189
- npm run lint # ESLint
190
- npm run typecheck # TypeScript型チェック
191
- ```
268
+ - **npm**: https://www.npmjs.com/package/@nahisaho/katashiro
269
+ - **GitHub**: https://github.com/nahisaho/katashiro
192
270
 
193
271
  ---
194
272
 
195
273
  **Project**: KATASHIRO
196
274
  **npm**: @nahisaho/katashiro
197
275
  **Last Updated**: 2026-01-10
198
- **Version**: 0.1.0
276
+ **Version**: 0.1.3
package/CLAUDE.md CHANGED
@@ -1,221 +1,211 @@
1
- # KATASHIRO - Claude Code専用ガイド
1
+ # KATASHIRO - Claude向けガイド
2
2
 
3
- > このファイルはClaude CodeKATASHIROサービスを自然言語で利用するためのガイドです。
3
+ > このファイルはClaude(Claude Code、Claude Desktop等)向けのKATASHIROライブラリ利用ガイドです。
4
4
 
5
- ## 🎯 KATASHIROとは
5
+ ## 🎯 概要
6
6
 
7
- KATASHIROは情報収集・分析・コンテンツ生成を行うMCPサーバーです。ユーザーから以下のような依頼があった場合、KATASHIROのツールを使用してください。
7
+ KATASHIROは情報収集・分析・生成のためのTypeScriptライブラリです。
8
+ ユーザーからの調査・分析リクエストに対して、適切なモジュールを使用してタスクを実行できます。
8
9
 
9
10
  ---
10
11
 
11
- ## 📝 自然言語 → ツール対応表
12
-
13
- ### 「〜について調べて」「検索して」
14
-
15
- ```
16
- katashiro_search を使用
17
- ```
18
-
19
- 例:
20
- - 「TypeScriptのベストプラクティスについて調べて」
21
- - 「2026年のAIトレンドを検索して」
22
- - 「〇〇社の最新ニュースを調べて」
23
-
24
- ### 「このURLの内容を取得して」「スクレイピングして」
25
-
26
- ```
27
- katashiro_scrape を使用
28
- ```
29
-
30
- 例:
31
- - 「https://example.com の内容を取得して」
32
- - 「このページの本文を抽出して」
33
-
34
- ### 「分析して」「キーワードを抽出して」
35
-
36
- ```
37
- katashiro_analyze を使用
38
- ```
39
-
40
- 例:
41
- - 「この文章を分析して」
42
- - 「テキストの複雑度を調べて」
43
- - 「重要なキーワードを抽出して」
44
-
45
- ### 「人名・組織名を抽出して」「固有表現を見つけて」
46
-
47
- ```
48
- katashiro_extract_entities を使用
49
- ```
50
-
51
- 例:
52
- - 「この記事に出てくる人名をリストアップして」
53
- - 「組織名と地名を抽出して」
54
-
55
- ### 「レポートを作成して」「まとめて」
56
-
57
- ```
58
- katashiro_generate_report を使用
59
- ```
60
-
61
- 例:
62
- - 「調査結果をレポートにまとめて」
63
- - 「分析結果からレポートを生成して」
64
-
65
- ### 「要約して」「〜文字でまとめて」
66
-
67
- ```
68
- katashiro_summarize を使用
69
- ```
70
-
71
- 例:
72
- - 「この長文を要約して」
73
- - 「300文字以内でまとめて」
74
- - 「3行で要点をまとめて」
75
-
76
- ### 「知識グラフに追加して」「保存して」
77
-
78
- ```
79
- katashiro_knowledge_add を使用
80
- ```
81
-
82
- 例:
83
- - 「この情報を知識グラフに登録して」
84
- - 「エンティティを保存して」
85
-
86
- ### 「知識グラフから検索して」「関連情報を探して」
12
+ ## 📦 インストール
87
13
 
14
+ ```bash
15
+ npm install @nahisaho/katashiro
88
16
  ```
89
- katashiro_knowledge_query を使用
90
- ```
91
-
92
- 例:
93
- - 「〇〇に関連する情報を知識グラフから検索して」
94
- - 「保存した情報を検索して」
95
17
 
96
18
  ---
97
19
 
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
- ### 論文要約
113
-
114
- ユーザー: 「このURLの論文を要約して」
115
-
116
- ```
117
- 1. katashiro_scrape(URL)
118
- 2. katashiro_analyze(取得したテキスト)
119
- 3. katashiro_summarize(取得したテキスト)
120
- ```
121
-
122
- ### 技術調査と知識ベース構築
123
-
124
- ユーザー: 「〜について調べて知識グラフに保存して」
125
-
126
- ```
127
- 1. katashiro_search(クエリ)
128
- 2. katashiro_scrape(検索結果)
129
- 3. katashiro_extract_entities(テキスト)
130
- 4. katashiro_knowledge_add(エンティティ)
131
- ```
20
+ ## 🔧 モジュール対応表
21
+
22
+ | ユーザーのリクエスト | 使用するモジュール | クラス |
23
+ |---------------------|-------------------|--------|
24
+ | 「URLの内容を取得して」 | Collector | `WebScraper` |
25
+ | 「〜について検索して」 | Collector | `WebSearchClient` |
26
+ | 「RSSフィードを読んで」 | Collector | `FeedReader` |
27
+ | 「テキストを分析して」 | Analyzer | `TextAnalyzer` |
28
+ | 「人名・組織名を抽出して」 | Analyzer | `EntityExtractor` |
29
+ | 「トピックを分類して」 | Analyzer | `TopicModeler` |
30
+ | 「レポートを作成して」 | Generator | `ReportGenerator` |
31
+ | 「要約して」 | Generator | `SummaryGenerator` |
32
+ | 「引用を生成して」 | Generator | `CitationGenerator` |
33
+ | 「知識グラフに追加して」 | Knowledge | `KnowledgeGraph` |
34
+ | 「関連情報を検索して」 | Knowledge | `GraphQuery` |
132
35
 
133
36
  ---
134
37
 
135
- ## 💻 コード例(TypeScript)
38
+ ## 📝 実装パターン
39
+
40
+ ### パターン1: Webページ取得→分析→レポート
136
41
 
137
42
  ```typescript
138
43
  import {
139
44
  WebScraper,
140
45
  TextAnalyzer,
46
+ EntityExtractor,
141
47
  ReportGenerator,
142
- KnowledgeGraph,
143
48
  isOk
144
49
  } from '@nahisaho/katashiro';
145
50
 
146
- // Web調査 分析 → レポート生成
147
- async function research(url: string) {
51
+ async function analyzeWebPage(url: string) {
52
+ // 1. Webページ取得
148
53
  const scraper = new WebScraper();
149
- const analyzer = new TextAnalyzer();
150
- const generator = new ReportGenerator();
151
-
152
- const page = await scraper.scrape(url);
153
- if (isOk(page)) {
154
- const analysis = await analyzer.analyze(page.value.text);
155
- const report = await generator.generate({
156
- title: '調査レポート',
157
- sections: [{ heading: '分析結果', content: analysis.value.summary }]
158
- });
159
- return report;
54
+ const pageResult = await scraper.scrape(url);
55
+
56
+ if (!isOk(pageResult)) {
57
+ return { error: 'Failed to scrape page' };
160
58
  }
59
+
60
+ const { content, title } = pageResult.value;
61
+
62
+ // 2. テキスト分析
63
+ const analyzer = new TextAnalyzer();
64
+ const analysis = await analyzer.analyze(content);
65
+
66
+ // 3. エンティティ抽出
67
+ const extractor = new EntityExtractor();
68
+ const entities = await extractor.extract(content);
69
+
70
+ // 4. レポート生成
71
+ const reportGen = new ReportGenerator();
72
+ const report = await reportGen.generate({
73
+ title: `Analysis: ${title}`,
74
+ sections: [
75
+ { heading: 'Summary', content: analysis.summary },
76
+ { heading: 'Keywords', content: analysis.keywords.join(', ') },
77
+ { heading: 'Entities', content: entities.map(e => e.text).join(', ') },
78
+ ],
79
+ format: 'markdown',
80
+ });
81
+
82
+ return { report, analysis, entities };
161
83
  }
162
84
  ```
163
85
 
164
- ---
165
-
166
- ## 📦 インストール
86
+ ### パターン2: 検索→収集→要約
167
87
 
168
- ```bash
169
- # オールインワン
170
- npm install @nahisaho/katashiro
88
+ ```typescript
89
+ import {
90
+ WebSearchClient,
91
+ WebScraper,
92
+ SummaryGenerator,
93
+ isOk
94
+ } from '@nahisaho/katashiro';
171
95
 
172
- # MCPサーバー
173
- npm install @nahisaho/katashiro-mcp-server
96
+ async function researchTopic(topic: string) {
97
+ // 1. 検索
98
+ const searchClient = new WebSearchClient({ apiKey: process.env.SEARCH_API_KEY });
99
+ const results = await searchClient.search(topic, { maxResults: 5 });
100
+
101
+ // 2. 上位結果を収集
102
+ const scraper = new WebScraper();
103
+ const contents: string[] = [];
104
+
105
+ for (const result of results) {
106
+ const page = await scraper.scrape(result.url);
107
+ if (isOk(page)) {
108
+ contents.push(page.value.content);
109
+ }
110
+ }
111
+
112
+ // 3. 全体を要約
113
+ const summarizer = new SummaryGenerator();
114
+ const combinedText = contents.join('\n\n---\n\n');
115
+ const summary = await summarizer.generate(combinedText, { maxLength: 500 });
116
+
117
+ return { summary, sources: results };
118
+ }
174
119
  ```
175
120
 
176
- ## VS Code MCP設定
121
+ ### パターン3: 知識グラフ構築
122
+
123
+ ```typescript
124
+ import {
125
+ KnowledgeGraph,
126
+ GraphQuery,
127
+ GraphPersistence,
128
+ EntityExtractor
129
+ } from '@nahisaho/katashiro';
177
130
 
178
- ```json
179
- {
180
- "mcp.servers": {
181
- "katashiro": {
182
- "command": "npx",
183
- "args": ["@nahisaho/katashiro-mcp-server"]
131
+ async function buildKnowledgeGraph(texts: string[]) {
132
+ const kg = new KnowledgeGraph();
133
+ const extractor = new EntityExtractor();
134
+
135
+ for (const text of texts) {
136
+ // エンティティ抽出
137
+ const entities = await extractor.extract(text);
138
+
139
+ // ノード追加
140
+ for (const entity of entities) {
141
+ kg.addNode({
142
+ id: `entity-${entity.text.toLowerCase().replace(/\s+/g, '-')}`,
143
+ type: entity.type,
144
+ properties: { name: entity.text },
145
+ });
184
146
  }
185
147
  }
148
+
149
+ // 永続化
150
+ const persistence = new GraphPersistence();
151
+ await persistence.save(kg, './knowledge-graph.json');
152
+
153
+ // クエリ
154
+ const query = new GraphQuery(kg);
155
+ const allNodes = query.getAllNodes();
156
+
157
+ return { nodeCount: allNodes.length, nodes: allNodes };
186
158
  }
187
159
  ```
188
160
 
189
161
  ---
190
162
 
191
- ## 🔧 開発時の注意
163
+ ## 📚 クラスリファレンス
192
164
 
193
- ### Result型パターン
194
- ```typescript
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
- ```
165
+ ### Collector
206
166
 
207
- ### パッケージ依存関係
208
- ```
209
- @nahisaho/katashiro-core (依存なし)
210
-
211
- collector, analyzer, generator, knowledge, feedback (coreに依存)
212
-
213
- @nahisaho/katashiro (オールインワン - 全てを含む)
214
- @nahisaho/katashiro-mcp-server (全パッケージを使用)
215
- ```
167
+ | クラス | メソッド | 説明 |
168
+ |--------|---------|------|
169
+ | `WebScraper` | `scrape(url)` | URLからコンテンツを取得 |
170
+ | `WebSearchClient` | `search(query, options)` | Web検索を実行 |
171
+ | `FeedReader` | `read(url)` | RSS/Atomフィードを読み込み |
172
+ | `ApiClient` | `get(url)`, `post(url, data)` | REST API呼び出し |
173
+
174
+ ### Analyzer
175
+
176
+ | クラス | メソッド | 説明 |
177
+ |--------|---------|------|
178
+ | `TextAnalyzer` | `analyze(text)` | キーワード、複雑度、感情を分析 |
179
+ | `EntityExtractor` | `extract(text)` | 固有表現を抽出 |
180
+ | `TopicModeler` | `model(documents)` | トピックを分類 |
181
+ | `StructureAnalyzer` | `analyze(text)` | 文書構造を解析 |
182
+
183
+ ### Generator
184
+
185
+ | クラス | メソッド | 説明 |
186
+ |--------|---------|------|
187
+ | `ReportGenerator` | `generate(options)` | レポートを生成 |
188
+ | `SummaryGenerator` | `generate(text, options)` | 要約を生成 |
189
+ | `CitationGenerator` | `generate(source, options)` | 引用を生成 |
190
+
191
+ ### Knowledge
192
+
193
+ | クラス | メソッド | 説明 |
194
+ |--------|---------|------|
195
+ | `KnowledgeGraph` | `addNode()`, `addEdge()` | グラフを構築 |
196
+ | `GraphQuery` | `find()`, `findByRelation()` | グラフを検索 |
197
+ | `GraphPersistence` | `save()`, `load()` | 永続化 |
198
+
199
+ ---
200
+
201
+ ## 🔗 関連リンク
202
+
203
+ - **npm**: https://www.npmjs.com/package/@nahisaho/katashiro
204
+ - **GitHub**: https://github.com/nahisaho/katashiro
216
205
 
217
206
  ---
218
207
 
219
208
  **Project**: KATASHIRO
220
209
  **npm**: @nahisaho/katashiro
221
- **Updated**: 2026-01-10
210
+ **Last Updated**: 2026-01-10
211
+ **Version**: 0.1.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nahisaho/katashiro",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "KATASHIRO - VS Code Agent Mode向け情報収集・分析・生成システム(オールインワンパッケージ)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",