bluelamp 4.0.3 → 4.0.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/bin/bluelamp-base +28 -62
- package/package.json +3 -4
package/bin/bluelamp-base
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* BlueLamp MCP Integration
|
|
5
|
-
* Fast startup with
|
|
5
|
+
* Fast startup with short initial prompt
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
const { spawn } = require('child_process');
|
|
8
9
|
const path = require('path');
|
|
9
10
|
const fs = require('fs');
|
|
10
11
|
const os = require('os');
|
|
@@ -112,7 +113,7 @@ async function main() {
|
|
|
112
113
|
const keyword = getKeywordFromCommand();
|
|
113
114
|
const isDebugMode = process.argv.includes('--debug');
|
|
114
115
|
|
|
115
|
-
console.log('🔵 BlueLamp MCP Integration
|
|
116
|
+
console.log('🔵 BlueLamp MCP Integration');
|
|
116
117
|
console.log(`📚 プロンプト: ${keyword}`);
|
|
117
118
|
console.log('');
|
|
118
119
|
|
|
@@ -125,106 +126,71 @@ async function main() {
|
|
|
125
126
|
console.log('🚀 Claude 起動中...');
|
|
126
127
|
console.log('');
|
|
127
128
|
|
|
128
|
-
//
|
|
129
|
-
let pty;
|
|
130
|
-
try {
|
|
131
|
-
pty = require('node-pty');
|
|
132
|
-
} catch (e) {
|
|
133
|
-
console.error('❌ node-pty が見つかりません。再インストールしてください:');
|
|
134
|
-
console.error(' npm install -g bluelamp');
|
|
135
|
-
process.exit(1);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// システムプロンプトに追加する指示
|
|
129
|
+
// システムプロンプトに追加する指示(inject_knowledgeを自動実行させる)
|
|
139
130
|
const systemPromptAddition = `【重要】セッション開始時に必ず inject_knowledge ツールを実行してください。
|
|
140
131
|
keyword: "${keyword}" を指定して、専門知識を注入してから作業を開始してください。
|
|
141
132
|
ユーザーが何か質問や指示をした場合でも、まず inject_knowledge を実行してから回答してください。`;
|
|
142
133
|
|
|
134
|
+
// 短い初期プロンプト(これがトリガーになる)
|
|
135
|
+
const initialPrompt = '開始';
|
|
136
|
+
|
|
143
137
|
// Windows対応
|
|
144
138
|
const isWindows = process.platform === 'win32';
|
|
145
|
-
|
|
139
|
+
let claudeCommand, claudeArgs;
|
|
146
140
|
|
|
147
|
-
let shellArgs;
|
|
148
141
|
if (isWindows) {
|
|
149
|
-
|
|
142
|
+
claudeCommand = 'powershell.exe';
|
|
143
|
+
claudeArgs = [
|
|
150
144
|
'-NoProfile',
|
|
151
145
|
'-Command',
|
|
152
146
|
'claude',
|
|
153
147
|
'--dangerously-skip-permissions',
|
|
154
148
|
'--mcp-config', configPath,
|
|
155
|
-
'--append-system-prompt', systemPromptAddition
|
|
149
|
+
'--append-system-prompt', systemPromptAddition,
|
|
150
|
+
'-p', initialPrompt
|
|
156
151
|
];
|
|
157
152
|
} else {
|
|
158
|
-
|
|
153
|
+
claudeCommand = 'claude';
|
|
154
|
+
claudeArgs = [
|
|
159
155
|
'--dangerously-skip-permissions',
|
|
160
156
|
'--mcp-config', configPath,
|
|
161
|
-
'--append-system-prompt', systemPromptAddition
|
|
157
|
+
'--append-system-prompt', systemPromptAddition,
|
|
158
|
+
'-p', initialPrompt
|
|
162
159
|
];
|
|
163
160
|
}
|
|
164
161
|
|
|
165
162
|
if (isDebugMode) {
|
|
166
163
|
console.log('🐛 デバッグ情報:');
|
|
167
|
-
console.log(` コマンド: ${
|
|
168
|
-
console.log(` 引数: ${JSON.stringify(
|
|
164
|
+
console.log(` コマンド: ${claudeCommand}`);
|
|
165
|
+
console.log(` 引数: ${JSON.stringify(claudeArgs)}`);
|
|
169
166
|
console.log(` MCP設定: ${configPath}`);
|
|
170
167
|
console.log('');
|
|
171
168
|
}
|
|
172
169
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
name: 'xterm-256color',
|
|
176
|
-
cols: process.stdout.columns || 80,
|
|
177
|
-
rows: process.stdout.rows || 24,
|
|
178
|
-
cwd: process.cwd(),
|
|
170
|
+
const child = spawn(claudeCommand, claudeArgs, {
|
|
171
|
+
stdio: 'inherit',
|
|
179
172
|
env: {
|
|
180
173
|
...process.env,
|
|
181
174
|
BLUELAMP_KEYWORD: keyword
|
|
182
175
|
}
|
|
183
176
|
});
|
|
184
177
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
// 出力をそのまま標準出力に転送 + 起動完了検知
|
|
190
|
-
ptyProcess.onData((data) => {
|
|
191
|
-
process.stdout.write(data);
|
|
192
|
-
buffer += data;
|
|
193
|
-
|
|
194
|
-
// Claudeの起動完了を検知(プロンプトが表示されたら)
|
|
195
|
-
// ">" または "╰" が含まれていたら起動完了と判断
|
|
196
|
-
if (!triggered && (buffer.includes('> ') || buffer.includes('╰─'))) {
|
|
197
|
-
triggered = true;
|
|
198
|
-
// 少し待ってから「開始」を送信
|
|
199
|
-
setTimeout(() => {
|
|
200
|
-
ptyProcess.write('開始\r');
|
|
201
|
-
}, 500);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
// 標準入力をptyに転送
|
|
206
|
-
process.stdin.setRawMode(true);
|
|
207
|
-
process.stdin.resume();
|
|
208
|
-
process.stdin.on('data', (data) => {
|
|
209
|
-
ptyProcess.write(data.toString());
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
// ターミナルサイズの変更を検知
|
|
213
|
-
process.stdout.on('resize', () => {
|
|
214
|
-
ptyProcess.resize(process.stdout.columns, process.stdout.rows);
|
|
178
|
+
child.on('error', (error) => {
|
|
179
|
+
console.error('❌ Claude 起動エラー:', error.message);
|
|
180
|
+
try { fs.unlinkSync(configPath); } catch (e) {}
|
|
181
|
+
process.exit(1);
|
|
215
182
|
});
|
|
216
183
|
|
|
217
|
-
|
|
218
|
-
ptyProcess.onExit(({ exitCode }) => {
|
|
184
|
+
child.on('exit', (code) => {
|
|
219
185
|
console.log('');
|
|
220
186
|
console.log('🔵 BlueLamp セッション終了');
|
|
221
187
|
try { fs.unlinkSync(configPath); } catch (e) {}
|
|
222
|
-
process.exit(
|
|
188
|
+
process.exit(code || 0);
|
|
223
189
|
});
|
|
224
190
|
|
|
225
|
-
// Ctrl+C などのシグナル処理
|
|
226
191
|
process.on('SIGINT', () => {
|
|
227
|
-
|
|
192
|
+
console.log('\n🔵 BlueLamp を終了しています...');
|
|
193
|
+
child.kill('SIGINT');
|
|
228
194
|
});
|
|
229
195
|
}
|
|
230
196
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bluelamp",
|
|
3
|
-
"version": "4.0.
|
|
4
|
-
"description": "BlueLamp MCP Integration -
|
|
3
|
+
"version": "4.0.5",
|
|
4
|
+
"description": "BlueLamp MCP Integration - Auto Knowledge Injection",
|
|
5
5
|
"main": "lib/mcp-server/index.cjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"bluelamp1": "./bin/bluelamp1",
|
|
@@ -41,8 +41,7 @@
|
|
|
41
41
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
42
42
|
"dotenv": "^16.6.1",
|
|
43
43
|
"jsonwebtoken": "^9.0.2",
|
|
44
|
-
"node-fetch": "^3.3.2"
|
|
45
|
-
"node-pty": "^1.1.0"
|
|
44
|
+
"node-fetch": "^3.3.2"
|
|
46
45
|
},
|
|
47
46
|
"engines": {
|
|
48
47
|
"node": ">=18"
|