@nahisaho/shikigami 1.1.0
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/prompts/shikigami-deep-research.prompt.md +32 -0
- package/.github/prompts/shikigami-framework-analysis.prompt.md +40 -0
- package/.github/prompts/shikigami-full-research.prompt.md +54 -0
- package/.github/prompts/shikigami-purpose-discovery.prompt.md +32 -0
- package/.github/prompts/shikigami-report-writing.prompt.md +36 -0
- package/.github/skills/shikigami-consulting-framework/SKILL.md +403 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/README.md +173 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/customer/nps.md +164 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/customer/rfm.md +160 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/decision-making/cost-benefit.md +168 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/decision-making/decision-matrix.md +138 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/decision-making/pros-cons.md +162 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/decision-making/risk-matrix.md +159 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/general/5w1h.md +152 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/general/jtbd.md +176 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/general/kpt.md +149 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/general/okr.md +155 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/general/smart.md +130 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/innovation/aarrr.md +193 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/innovation/business-model-canvas.md +182 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/innovation/design-thinking.md +275 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/innovation/lean-canvas.md +199 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/innovation/scamper.md +188 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/innovation/tam-sam-som.md +231 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/innovation/value-proposition-canvas.md +194 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/marketing/4c.md +179 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/marketing/4p.md +161 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/marketing/aidma-aisas.md +146 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/marketing/customer-journey.md +155 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/marketing/persona.md +182 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/marketing/positioning-map.md +116 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/marketing/stp.md +177 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/organization/7s.md +154 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/organization/raci.md +147 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/problem-solving/5whys.md +142 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/problem-solving/as-is-to-be.md +186 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/problem-solving/fishbone.md +201 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/problem-solving/issue-tree.md +178 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/problem-solving/logic-tree.md +161 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/problem-solving/mece.md +127 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/problem-solving/sora-ame-kasa.md +176 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/process/ecrs.md +168 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/process/ooda.md +144 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/process/pdca.md +113 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/strategic/3c.md +118 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/strategic/5forces.md +135 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/strategic/ansoff-matrix.md +168 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/strategic/bcg-matrix.md +134 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/strategic/blue-ocean.md +184 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/strategic/ge-matrix.md +158 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/strategic/pest.md +106 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/strategic/swot.md +90 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/strategic/value-chain.md +192 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/strategic/vrio.md +163 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/thinking/prep.md +105 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/thinking/pyramid.md +171 -0
- package/.github/skills/shikigami-consulting-framework/frameworks/thinking/so-what-why-so.md +175 -0
- package/.github/skills/shikigami-deep-research/SKILL.md +395 -0
- package/.github/skills/shikigami-planner/SKILL.md +267 -0
- package/.github/skills/shikigami-writing/SKILL.md +782 -0
- package/.vscode/mcp.json +9 -0
- package/AGENTS.md +310 -0
- package/CHANGELOG.md +109 -0
- package/README.md +144 -0
- package/mcp-server/README.md +80 -0
- package/mcp-server/package-lock.json +2123 -0
- package/mcp-server/package.json +38 -0
- package/mcp-server/shikigami.config.example.yaml +93 -0
- package/mcp-server/src/config/index.ts +8 -0
- package/mcp-server/src/config/loader.ts +246 -0
- package/mcp-server/src/config/types.ts +184 -0
- package/mcp-server/src/index.ts +418 -0
- package/mcp-server/src/tools/embedding.ts +279 -0
- package/mcp-server/src/tools/file-parser.ts +332 -0
- package/mcp-server/src/tools/search.ts +181 -0
- package/mcp-server/src/tools/visit.ts +168 -0
- package/mcp-server/tsconfig.json +19 -0
- package/package.json +82 -0
- package/scripts/init.js +181 -0
- package/scripts/postinstall.js +129 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shikigami/mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SHIKIGAMI MCP Server - Deep Research tools with DuckDuckGo search",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"shikigami-mcp": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"dev": "tsx src/index.ts"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"shikigami",
|
|
18
|
+
"deep-research",
|
|
19
|
+
"duckduckgo",
|
|
20
|
+
"github-copilot"
|
|
21
|
+
],
|
|
22
|
+
"author": "nahisaho",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
26
|
+
"cheerio": "^1.0.0",
|
|
27
|
+
"node-fetch": "^3.3.2",
|
|
28
|
+
"yaml": "^2.7.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^20.10.0",
|
|
32
|
+
"tsx": "^4.7.0",
|
|
33
|
+
"typescript": "^5.3.2"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=20.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# SHIKIGAMI Configuration
|
|
2
|
+
# このファイルをプロジェクトルートに配置して設定をカスタマイズ
|
|
3
|
+
#
|
|
4
|
+
# ファイル名の優先順位:
|
|
5
|
+
# 1. shikigami.config.yaml
|
|
6
|
+
# 2. shikigami.config.yml
|
|
7
|
+
# 3. .shikigami.yaml
|
|
8
|
+
# 4. .shikigami.yml
|
|
9
|
+
#
|
|
10
|
+
# 探索場所(優先順):
|
|
11
|
+
# 1. カレントディレクトリ
|
|
12
|
+
# 2. ホームディレクトリ
|
|
13
|
+
#
|
|
14
|
+
# 環境変数で上書き可能(環境変数が最優先)
|
|
15
|
+
|
|
16
|
+
version: "1.0"
|
|
17
|
+
|
|
18
|
+
# ===== 検索プロバイダー設定 =====
|
|
19
|
+
search:
|
|
20
|
+
# プロバイダー選択
|
|
21
|
+
# - duckduckgo: API キー不要(デフォルト)
|
|
22
|
+
# - google: Google Custom Search API(要 API キー)
|
|
23
|
+
# - bing: Bing Search API(要 API キー)
|
|
24
|
+
# - tavily: Tavily Search API(要 API キー)
|
|
25
|
+
provider: duckduckgo
|
|
26
|
+
options:
|
|
27
|
+
# apiKey: "" # 環境変数 SHIKIGAMI_SEARCH_API_KEY で設定推奨
|
|
28
|
+
timeout: 30000 # タイムアウト(ms)
|
|
29
|
+
maxRetries: 3 # 最大リトライ回数
|
|
30
|
+
rateLimitMs: 1500 # リクエスト間隔(ms)
|
|
31
|
+
locale: ja-JP # 言語/地域設定
|
|
32
|
+
|
|
33
|
+
# ===== ページ取得プロバイダー設定 =====
|
|
34
|
+
pageFetcher:
|
|
35
|
+
# プロバイダー選択
|
|
36
|
+
# - jina: Jina AI Reader(無料枠あり、デフォルト)
|
|
37
|
+
# - firecrawl: Firecrawl(要 API キー)
|
|
38
|
+
# - browserbase: Browserbase(要 API キー)
|
|
39
|
+
provider: jina
|
|
40
|
+
options:
|
|
41
|
+
# apiKey: "" # 環境変数 JINA_API_KEY で設定推奨
|
|
42
|
+
timeout: 30000 # タイムアウト(ms)
|
|
43
|
+
rateLimitMs: 1000 # リクエスト間隔(ms)
|
|
44
|
+
format: markdown # 返却形式: markdown | text | html
|
|
45
|
+
waitForJS: false # JavaScript 実行を待つか
|
|
46
|
+
|
|
47
|
+
# ===== LLM プロバイダー設定 =====
|
|
48
|
+
# Deep Research のサマリー生成等で使用(オプション)
|
|
49
|
+
llm:
|
|
50
|
+
# プロバイダー選択
|
|
51
|
+
# - ollama: ローカル LLM(デフォルト)
|
|
52
|
+
# - openai: OpenAI API
|
|
53
|
+
# - anthropic: Anthropic Claude API
|
|
54
|
+
# - azure-openai: Azure OpenAI
|
|
55
|
+
provider: ollama
|
|
56
|
+
model: llama3.2 # 使用するモデル名
|
|
57
|
+
options:
|
|
58
|
+
endpoint: http://localhost:11434 # Ollama エンドポイント
|
|
59
|
+
# apiKey: "" # 環境変数 OPENAI_API_KEY 等で設定推奨
|
|
60
|
+
temperature: 0.7 # 生成の多様性(0.0-1.0)
|
|
61
|
+
maxTokens: 4096 # 最大トークン数
|
|
62
|
+
|
|
63
|
+
# ===== Embedding プロバイダー設定 =====
|
|
64
|
+
# セマンティック検索で使用(オプション)
|
|
65
|
+
embedding:
|
|
66
|
+
# プロバイダー選択
|
|
67
|
+
# - ollama: ローカル Embedding(デフォルト)
|
|
68
|
+
# - openai: OpenAI Embeddings API
|
|
69
|
+
# - huggingface: HuggingFace Inference API
|
|
70
|
+
provider: ollama
|
|
71
|
+
model: nomic-embed-text # 使用するモデル名
|
|
72
|
+
options:
|
|
73
|
+
endpoint: http://localhost:11434
|
|
74
|
+
dimensions: 768 # ベクトル次元数
|
|
75
|
+
|
|
76
|
+
# ===== キャッシュ設定 =====
|
|
77
|
+
cache:
|
|
78
|
+
enabled: true # キャッシュを有効にするか
|
|
79
|
+
ttlSeconds: 3600 # TTL(秒)= 1時間
|
|
80
|
+
maxSize: 1000 # 最大エントリ数
|
|
81
|
+
storage: memory # memory | file
|
|
82
|
+
# filePath: .shikigami-cache.json # file 使用時のパス
|
|
83
|
+
|
|
84
|
+
# ===== ログ設定 =====
|
|
85
|
+
log:
|
|
86
|
+
level: info # debug | info | warn | error
|
|
87
|
+
output: stderr # stderr | file
|
|
88
|
+
# filePath: shikigami.log # file 使用時のパス
|
|
89
|
+
|
|
90
|
+
# ===== カスタム設定 =====
|
|
91
|
+
# 拡張用(任意のキー・値を設定可能)
|
|
92
|
+
# custom:
|
|
93
|
+
# myKey: myValue
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHIKIGAMI Configuration Loader
|
|
3
|
+
*
|
|
4
|
+
* REQ-NF-007: プロバイダー設定ファイル対応
|
|
5
|
+
* shikigami.config.yaml を読み込み、設定をマージ
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
import * as yaml from 'yaml';
|
|
11
|
+
import { ShikigamiConfig, DEFAULT_CONFIG } from './types.js';
|
|
12
|
+
|
|
13
|
+
/** 設定ファイル名(優先順) */
|
|
14
|
+
const CONFIG_FILENAMES = [
|
|
15
|
+
'shikigami.config.yaml',
|
|
16
|
+
'shikigami.config.yml',
|
|
17
|
+
'.shikigami.yaml',
|
|
18
|
+
'.shikigami.yml',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 設定ファイルのパスを探索
|
|
23
|
+
* @param searchPaths 探索するディレクトリパス(デフォルト: カレント、ホーム)
|
|
24
|
+
* @returns 見つかった設定ファイルパス、または null
|
|
25
|
+
*/
|
|
26
|
+
export function findConfigFile(searchPaths?: string[]): string | null {
|
|
27
|
+
const paths = searchPaths ?? [
|
|
28
|
+
process.cwd(),
|
|
29
|
+
process.env.HOME ?? '',
|
|
30
|
+
].filter(Boolean);
|
|
31
|
+
|
|
32
|
+
for (const dir of paths) {
|
|
33
|
+
for (const filename of CONFIG_FILENAMES) {
|
|
34
|
+
const filePath = path.join(dir, filename);
|
|
35
|
+
if (fs.existsSync(filePath)) {
|
|
36
|
+
return filePath;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 深いマージを行う(配列は置換)
|
|
46
|
+
*/
|
|
47
|
+
function deepMerge<T extends object>(target: T, source: Partial<T>): T {
|
|
48
|
+
const result = { ...target } as T;
|
|
49
|
+
|
|
50
|
+
for (const key of Object.keys(source) as Array<keyof T>) {
|
|
51
|
+
const sourceValue = source[key];
|
|
52
|
+
const targetValue = target[key];
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
sourceValue !== null &&
|
|
56
|
+
sourceValue !== undefined &&
|
|
57
|
+
typeof sourceValue === 'object' &&
|
|
58
|
+
!Array.isArray(sourceValue) &&
|
|
59
|
+
targetValue !== null &&
|
|
60
|
+
targetValue !== undefined &&
|
|
61
|
+
typeof targetValue === 'object' &&
|
|
62
|
+
!Array.isArray(targetValue)
|
|
63
|
+
) {
|
|
64
|
+
// 両方がオブジェクトの場合、再帰マージ
|
|
65
|
+
result[key] = deepMerge(
|
|
66
|
+
targetValue as object,
|
|
67
|
+
sourceValue as object
|
|
68
|
+
) as T[keyof T];
|
|
69
|
+
} else if (sourceValue !== undefined) {
|
|
70
|
+
// それ以外は置換
|
|
71
|
+
result[key] = sourceValue as T[keyof T];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* YAML ファイルから設定を読み込み
|
|
80
|
+
* @param filePath 設定ファイルパス
|
|
81
|
+
* @returns パースされた設定
|
|
82
|
+
*/
|
|
83
|
+
export function loadConfigFile(filePath: string): Partial<ShikigamiConfig> {
|
|
84
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
85
|
+
const parsed = yaml.parse(content);
|
|
86
|
+
|
|
87
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
88
|
+
throw new Error(`Invalid config file: ${filePath}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return parsed as Partial<ShikigamiConfig>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 環境変数から設定を上書き
|
|
96
|
+
* SHIKIGAMI_* 形式の環境変数を読み込み
|
|
97
|
+
*/
|
|
98
|
+
export function loadEnvOverrides(): Partial<ShikigamiConfig> {
|
|
99
|
+
const overrides: Partial<ShikigamiConfig> = {};
|
|
100
|
+
|
|
101
|
+
// 検索プロバイダー
|
|
102
|
+
if (process.env.SHIKIGAMI_SEARCH_PROVIDER) {
|
|
103
|
+
overrides.search = {
|
|
104
|
+
provider: process.env.SHIKIGAMI_SEARCH_PROVIDER as 'duckduckgo' | 'google' | 'bing' | 'tavily',
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 検索 API キー
|
|
109
|
+
if (process.env.SHIKIGAMI_SEARCH_API_KEY) {
|
|
110
|
+
overrides.search = {
|
|
111
|
+
...overrides.search,
|
|
112
|
+
provider: overrides.search?.provider ?? 'duckduckgo',
|
|
113
|
+
options: {
|
|
114
|
+
...overrides.search?.options,
|
|
115
|
+
apiKey: process.env.SHIKIGAMI_SEARCH_API_KEY,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ページ取得プロバイダー
|
|
121
|
+
if (process.env.SHIKIGAMI_PAGE_FETCHER_PROVIDER) {
|
|
122
|
+
overrides.pageFetcher = {
|
|
123
|
+
provider: process.env.SHIKIGAMI_PAGE_FETCHER_PROVIDER as 'jina' | 'firecrawl' | 'browserbase',
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Jina API キー
|
|
128
|
+
if (process.env.JINA_API_KEY || process.env.SHIKIGAMI_JINA_API_KEY) {
|
|
129
|
+
overrides.pageFetcher = {
|
|
130
|
+
...overrides.pageFetcher,
|
|
131
|
+
provider: overrides.pageFetcher?.provider ?? 'jina',
|
|
132
|
+
options: {
|
|
133
|
+
...overrides.pageFetcher?.options,
|
|
134
|
+
apiKey: process.env.JINA_API_KEY || process.env.SHIKIGAMI_JINA_API_KEY,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// LLM プロバイダー
|
|
140
|
+
if (process.env.SHIKIGAMI_LLM_PROVIDER) {
|
|
141
|
+
overrides.llm = {
|
|
142
|
+
provider: process.env.SHIKIGAMI_LLM_PROVIDER as 'ollama' | 'openai' | 'anthropic' | 'azure-openai',
|
|
143
|
+
model: process.env.SHIKIGAMI_LLM_MODEL ?? 'default',
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// OpenAI API キー
|
|
148
|
+
if (process.env.OPENAI_API_KEY || process.env.SHIKIGAMI_OPENAI_API_KEY) {
|
|
149
|
+
overrides.llm = {
|
|
150
|
+
...overrides.llm,
|
|
151
|
+
provider: overrides.llm?.provider ?? 'openai',
|
|
152
|
+
model: overrides.llm?.model ?? 'gpt-4o-mini',
|
|
153
|
+
options: {
|
|
154
|
+
...overrides.llm?.options,
|
|
155
|
+
apiKey: process.env.OPENAI_API_KEY || process.env.SHIKIGAMI_OPENAI_API_KEY,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Ollama エンドポイント
|
|
161
|
+
if (process.env.OLLAMA_HOST || process.env.SHIKIGAMI_OLLAMA_ENDPOINT) {
|
|
162
|
+
overrides.llm = {
|
|
163
|
+
...overrides.llm,
|
|
164
|
+
provider: 'ollama',
|
|
165
|
+
model: overrides.llm?.model ?? 'llama3.2',
|
|
166
|
+
options: {
|
|
167
|
+
...overrides.llm?.options,
|
|
168
|
+
endpoint: process.env.OLLAMA_HOST || process.env.SHIKIGAMI_OLLAMA_ENDPOINT,
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Embedding プロバイダー
|
|
174
|
+
if (process.env.SHIKIGAMI_EMBEDDING_PROVIDER) {
|
|
175
|
+
overrides.embedding = {
|
|
176
|
+
provider: process.env.SHIKIGAMI_EMBEDDING_PROVIDER as 'ollama' | 'openai' | 'huggingface',
|
|
177
|
+
model: process.env.SHIKIGAMI_EMBEDDING_MODEL ?? 'default',
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// ログレベル
|
|
182
|
+
if (process.env.SHIKIGAMI_LOG_LEVEL) {
|
|
183
|
+
overrides.log = {
|
|
184
|
+
level: process.env.SHIKIGAMI_LOG_LEVEL as 'debug' | 'info' | 'warn' | 'error',
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return overrides;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 設定を読み込む(ファイル + 環境変数)
|
|
193
|
+
* 優先順位: 環境変数 > 設定ファイル > デフォルト
|
|
194
|
+
*
|
|
195
|
+
* @param configPath 明示的な設定ファイルパス(省略時は自動探索)
|
|
196
|
+
* @returns マージされた設定
|
|
197
|
+
*/
|
|
198
|
+
export function loadConfig(configPath?: string): ShikigamiConfig {
|
|
199
|
+
let fileConfig: Partial<ShikigamiConfig> = {};
|
|
200
|
+
|
|
201
|
+
// 設定ファイルを探索・読み込み
|
|
202
|
+
const foundPath = configPath ?? findConfigFile();
|
|
203
|
+
if (foundPath) {
|
|
204
|
+
try {
|
|
205
|
+
fileConfig = loadConfigFile(foundPath);
|
|
206
|
+
console.error(`[SHIKIGAMI] Loaded config from: ${foundPath}`);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
console.error(`[SHIKIGAMI] Failed to load config: ${error}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 環境変数の上書きを取得
|
|
213
|
+
const envOverrides = loadEnvOverrides();
|
|
214
|
+
|
|
215
|
+
// マージ: デフォルト < ファイル < 環境変数
|
|
216
|
+
const merged = deepMerge(
|
|
217
|
+
deepMerge(DEFAULT_CONFIG, fileConfig),
|
|
218
|
+
envOverrides
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
return merged;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** グローバル設定インスタンス(遅延初期化) */
|
|
225
|
+
let _config: ShikigamiConfig | null = null;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* グローバル設定を取得
|
|
229
|
+
* 初回呼び出し時に設定をロード
|
|
230
|
+
*/
|
|
231
|
+
export function getConfig(): ShikigamiConfig {
|
|
232
|
+
if (!_config) {
|
|
233
|
+
_config = loadConfig();
|
|
234
|
+
}
|
|
235
|
+
return _config;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* グローバル設定をリセット(テスト用)
|
|
240
|
+
*/
|
|
241
|
+
export function resetConfig(): void {
|
|
242
|
+
_config = null;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 型のエクスポート
|
|
246
|
+
export * from './types.js';
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHIKIGAMI Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* REQ-NF-007: プロバイダー設定ファイル対応
|
|
5
|
+
* shikigami.config.yaml で設定をカスタマイズ可能
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 検索プロバイダー設定
|
|
10
|
+
*/
|
|
11
|
+
export interface SearchProviderConfig {
|
|
12
|
+
/** プロバイダー名 */
|
|
13
|
+
provider: 'duckduckgo' | 'google' | 'bing' | 'tavily';
|
|
14
|
+
/** プロバイダー固有の設定 */
|
|
15
|
+
options?: {
|
|
16
|
+
/** API キー(必要な場合) */
|
|
17
|
+
apiKey?: string;
|
|
18
|
+
/** カスタムエンドポイント */
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
/** リクエストタイムアウト(ms) */
|
|
21
|
+
timeout?: number;
|
|
22
|
+
/** 最大リトライ回数 */
|
|
23
|
+
maxRetries?: number;
|
|
24
|
+
/** レート制限間隔(ms) */
|
|
25
|
+
rateLimitMs?: number;
|
|
26
|
+
/** 言語/地域設定 */
|
|
27
|
+
locale?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ページ取得プロバイダー設定
|
|
33
|
+
*/
|
|
34
|
+
export interface PageFetcherConfig {
|
|
35
|
+
/** プロバイダー名 */
|
|
36
|
+
provider: 'jina' | 'firecrawl' | 'browserbase';
|
|
37
|
+
/** プロバイダー固有の設定 */
|
|
38
|
+
options?: {
|
|
39
|
+
/** API キー(必要な場合) */
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
/** カスタムエンドポイント */
|
|
42
|
+
endpoint?: string;
|
|
43
|
+
/** リクエストタイムアウト(ms) */
|
|
44
|
+
timeout?: number;
|
|
45
|
+
/** レート制限間隔(ms) */
|
|
46
|
+
rateLimitMs?: number;
|
|
47
|
+
/** JavaScript 実行を待つか */
|
|
48
|
+
waitForJS?: boolean;
|
|
49
|
+
/** 返却形式 */
|
|
50
|
+
format?: 'markdown' | 'text' | 'html';
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* LLM プロバイダー設定
|
|
56
|
+
*/
|
|
57
|
+
export interface LLMProviderConfig {
|
|
58
|
+
/** プロバイダー名 */
|
|
59
|
+
provider: 'ollama' | 'openai' | 'anthropic' | 'azure-openai';
|
|
60
|
+
/** モデル名 */
|
|
61
|
+
model: string;
|
|
62
|
+
/** プロバイダー固有の設定 */
|
|
63
|
+
options?: {
|
|
64
|
+
/** API キー(必要な場合) */
|
|
65
|
+
apiKey?: string;
|
|
66
|
+
/** カスタムエンドポイント(Ollama等) */
|
|
67
|
+
endpoint?: string;
|
|
68
|
+
/** 生成時の温度パラメータ */
|
|
69
|
+
temperature?: number;
|
|
70
|
+
/** 最大トークン数 */
|
|
71
|
+
maxTokens?: number;
|
|
72
|
+
/** タイムアウト(ms) */
|
|
73
|
+
timeout?: number;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Embedding プロバイダー設定
|
|
79
|
+
*/
|
|
80
|
+
export interface EmbeddingProviderConfig {
|
|
81
|
+
/** プロバイダー名 */
|
|
82
|
+
provider: 'ollama' | 'openai' | 'huggingface';
|
|
83
|
+
/** モデル名 */
|
|
84
|
+
model: string;
|
|
85
|
+
/** プロバイダー固有の設定 */
|
|
86
|
+
options?: {
|
|
87
|
+
/** API キー(必要な場合) */
|
|
88
|
+
apiKey?: string;
|
|
89
|
+
/** カスタムエンドポイント */
|
|
90
|
+
endpoint?: string;
|
|
91
|
+
/** ベクトル次元数 */
|
|
92
|
+
dimensions?: number;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* キャッシュ設定
|
|
98
|
+
*/
|
|
99
|
+
export interface CacheConfig {
|
|
100
|
+
/** キャッシュを有効にするか */
|
|
101
|
+
enabled: boolean;
|
|
102
|
+
/** TTL(秒) */
|
|
103
|
+
ttlSeconds?: number;
|
|
104
|
+
/** 最大キャッシュサイズ(エントリ数) */
|
|
105
|
+
maxSize?: number;
|
|
106
|
+
/** キャッシュ保存場所 */
|
|
107
|
+
storage?: 'memory' | 'file';
|
|
108
|
+
/** ファイルキャッシュのパス */
|
|
109
|
+
filePath?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* ログ設定
|
|
114
|
+
*/
|
|
115
|
+
export interface LogConfig {
|
|
116
|
+
/** ログレベル */
|
|
117
|
+
level: 'debug' | 'info' | 'warn' | 'error';
|
|
118
|
+
/** 出力先 */
|
|
119
|
+
output?: 'stderr' | 'file';
|
|
120
|
+
/** ファイル出力時のパス */
|
|
121
|
+
filePath?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* SHIKIGAMI 設定全体
|
|
126
|
+
*/
|
|
127
|
+
export interface ShikigamiConfig {
|
|
128
|
+
/** 設定ファイルバージョン */
|
|
129
|
+
version: '1.0';
|
|
130
|
+
|
|
131
|
+
/** 検索プロバイダー設定 */
|
|
132
|
+
search?: SearchProviderConfig;
|
|
133
|
+
|
|
134
|
+
/** ページ取得プロバイダー設定 */
|
|
135
|
+
pageFetcher?: PageFetcherConfig;
|
|
136
|
+
|
|
137
|
+
/** LLM プロバイダー設定 */
|
|
138
|
+
llm?: LLMProviderConfig;
|
|
139
|
+
|
|
140
|
+
/** Embedding プロバイダー設定 */
|
|
141
|
+
embedding?: EmbeddingProviderConfig;
|
|
142
|
+
|
|
143
|
+
/** キャッシュ設定 */
|
|
144
|
+
cache?: CacheConfig;
|
|
145
|
+
|
|
146
|
+
/** ログ設定 */
|
|
147
|
+
log?: LogConfig;
|
|
148
|
+
|
|
149
|
+
/** カスタム設定(拡張用) */
|
|
150
|
+
custom?: Record<string, unknown>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* デフォルト設定
|
|
155
|
+
*/
|
|
156
|
+
export const DEFAULT_CONFIG: ShikigamiConfig = {
|
|
157
|
+
version: '1.0',
|
|
158
|
+
search: {
|
|
159
|
+
provider: 'duckduckgo',
|
|
160
|
+
options: {
|
|
161
|
+
maxRetries: 3,
|
|
162
|
+
rateLimitMs: 1500,
|
|
163
|
+
timeout: 30000,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
pageFetcher: {
|
|
167
|
+
provider: 'jina',
|
|
168
|
+
options: {
|
|
169
|
+
rateLimitMs: 1000,
|
|
170
|
+
timeout: 30000,
|
|
171
|
+
format: 'markdown',
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
cache: {
|
|
175
|
+
enabled: true,
|
|
176
|
+
ttlSeconds: 3600,
|
|
177
|
+
maxSize: 1000,
|
|
178
|
+
storage: 'memory',
|
|
179
|
+
},
|
|
180
|
+
log: {
|
|
181
|
+
level: 'info',
|
|
182
|
+
output: 'stderr',
|
|
183
|
+
},
|
|
184
|
+
};
|