bluelamp 4.0.2 → 4.0.3
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 +61 -26
- package/package.json +3 -2
package/bin/bluelamp-base
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* BlueLamp MCP Integration
|
|
5
|
-
* Fast startup
|
|
5
|
+
* Fast startup with auto-trigger using node-pty
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
const { spawn } = require('child_process');
|
|
9
8
|
const path = require('path');
|
|
10
9
|
const fs = require('fs');
|
|
11
10
|
const os = require('os');
|
|
@@ -113,7 +112,7 @@ async function main() {
|
|
|
113
112
|
const keyword = getKeywordFromCommand();
|
|
114
113
|
const isDebugMode = process.argv.includes('--debug');
|
|
115
114
|
|
|
116
|
-
console.log('🔵 BlueLamp MCP Integration (
|
|
115
|
+
console.log('🔵 BlueLamp MCP Integration (Auto Mode)');
|
|
117
116
|
console.log(`📚 プロンプト: ${keyword}`);
|
|
118
117
|
console.log('');
|
|
119
118
|
|
|
@@ -126,18 +125,28 @@ async function main() {
|
|
|
126
125
|
console.log('🚀 Claude 起動中...');
|
|
127
126
|
console.log('');
|
|
128
127
|
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
// node-ptyを使用して疑似端末でClaudeを起動
|
|
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
|
+
}
|
|
132
137
|
|
|
133
138
|
// システムプロンプトに追加する指示
|
|
134
139
|
const systemPromptAddition = `【重要】セッション開始時に必ず inject_knowledge ツールを実行してください。
|
|
135
140
|
keyword: "${keyword}" を指定して、専門知識を注入してから作業を開始してください。
|
|
136
141
|
ユーザーが何か質問や指示をした場合でも、まず inject_knowledge を実行してから回答してください。`;
|
|
137
142
|
|
|
143
|
+
// Windows対応
|
|
144
|
+
const isWindows = process.platform === 'win32';
|
|
145
|
+
const shell = isWindows ? 'powershell.exe' : 'claude';
|
|
146
|
+
|
|
147
|
+
let shellArgs;
|
|
138
148
|
if (isWindows) {
|
|
139
|
-
|
|
140
|
-
claudeArgs = [
|
|
149
|
+
shellArgs = [
|
|
141
150
|
'-NoProfile',
|
|
142
151
|
'-Command',
|
|
143
152
|
'claude',
|
|
@@ -146,8 +155,7 @@ keyword: "${keyword}" を指定して、専門知識を注入してから作業
|
|
|
146
155
|
'--append-system-prompt', systemPromptAddition
|
|
147
156
|
];
|
|
148
157
|
} else {
|
|
149
|
-
|
|
150
|
-
claudeArgs = [
|
|
158
|
+
shellArgs = [
|
|
151
159
|
'--dangerously-skip-permissions',
|
|
152
160
|
'--mcp-config', configPath,
|
|
153
161
|
'--append-system-prompt', systemPromptAddition
|
|
@@ -156,40 +164,67 @@ keyword: "${keyword}" を指定して、専門知識を注入してから作業
|
|
|
156
164
|
|
|
157
165
|
if (isDebugMode) {
|
|
158
166
|
console.log('🐛 デバッグ情報:');
|
|
159
|
-
console.log(` コマンド: ${
|
|
160
|
-
console.log(` 引数: ${JSON.stringify(
|
|
167
|
+
console.log(` コマンド: ${shell}`);
|
|
168
|
+
console.log(` 引数: ${JSON.stringify(shellArgs)}`);
|
|
161
169
|
console.log(` MCP設定: ${configPath}`);
|
|
162
170
|
console.log('');
|
|
163
171
|
}
|
|
164
172
|
|
|
165
|
-
//
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
173
|
+
// 疑似端末を作成
|
|
174
|
+
const ptyProcess = pty.spawn(shell, shellArgs, {
|
|
175
|
+
name: 'xterm-256color',
|
|
176
|
+
cols: process.stdout.columns || 80,
|
|
177
|
+
rows: process.stdout.rows || 24,
|
|
178
|
+
cwd: process.cwd(),
|
|
171
179
|
env: {
|
|
172
180
|
...process.env,
|
|
173
181
|
BLUELAMP_KEYWORD: keyword
|
|
174
182
|
}
|
|
175
183
|
});
|
|
176
184
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
// Claudeが起動完了したら自動で「開始」を送信
|
|
186
|
+
let triggered = false;
|
|
187
|
+
let buffer = '';
|
|
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);
|
|
181
215
|
});
|
|
182
216
|
|
|
183
|
-
|
|
217
|
+
// プロセス終了時の処理
|
|
218
|
+
ptyProcess.onExit(({ exitCode }) => {
|
|
184
219
|
console.log('');
|
|
185
220
|
console.log('🔵 BlueLamp セッション終了');
|
|
186
221
|
try { fs.unlinkSync(configPath); } catch (e) {}
|
|
187
|
-
process.exit(
|
|
222
|
+
process.exit(exitCode || 0);
|
|
188
223
|
});
|
|
189
224
|
|
|
225
|
+
// Ctrl+C などのシグナル処理
|
|
190
226
|
process.on('SIGINT', () => {
|
|
191
|
-
|
|
192
|
-
child.kill('SIGINT');
|
|
227
|
+
ptyProcess.write('\x03'); // Ctrl+C を送信
|
|
193
228
|
});
|
|
194
229
|
}
|
|
195
230
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bluelamp",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "BlueLamp MCP Integration - Fast Startup with SessionStart Hook",
|
|
5
5
|
"main": "lib/mcp-server/index.cjs",
|
|
6
6
|
"bin": {
|
|
@@ -41,7 +41,8 @@
|
|
|
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"
|
|
44
|
+
"node-fetch": "^3.3.2",
|
|
45
|
+
"node-pty": "^1.1.0"
|
|
45
46
|
},
|
|
46
47
|
"engines": {
|
|
47
48
|
"node": ">=18"
|