bluelamp 4.0.4 → 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 +34 -114
- package/package.json +3 -4
package/bin/bluelamp-base
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* BlueLamp MCP Integration
|
|
5
|
-
* Fast startup with
|
|
6
|
-
* Fallback to spawn if pty fails
|
|
5
|
+
* Fast startup with short initial prompt
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
const { spawn } = require('child_process');
|
|
@@ -107,111 +106,14 @@ async function performPortalAuth() {
|
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
/**
|
|
111
|
-
* node-ptyを使用してClaudeを起動(自動トリガー付き)
|
|
112
|
-
*/
|
|
113
|
-
function startWithPty(claudeCommand, claudeArgs, configPath, keyword) {
|
|
114
|
-
const pty = require('node-pty');
|
|
115
|
-
|
|
116
|
-
// 疑似端末を作成
|
|
117
|
-
const ptyProcess = pty.spawn(claudeCommand, claudeArgs, {
|
|
118
|
-
name: 'xterm-256color',
|
|
119
|
-
cols: process.stdout.columns || 80,
|
|
120
|
-
rows: process.stdout.rows || 24,
|
|
121
|
-
cwd: process.cwd(),
|
|
122
|
-
env: {
|
|
123
|
-
...process.env,
|
|
124
|
-
BLUELAMP_KEYWORD: keyword
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// Claudeが起動完了したら自動で「開始」を送信
|
|
129
|
-
let triggered = false;
|
|
130
|
-
let buffer = '';
|
|
131
|
-
|
|
132
|
-
// 出力をそのまま標準出力に転送 + 起動完了検知
|
|
133
|
-
ptyProcess.onData((data) => {
|
|
134
|
-
process.stdout.write(data);
|
|
135
|
-
buffer += data;
|
|
136
|
-
|
|
137
|
-
// Claudeの起動完了を検知(プロンプトが表示されたら)
|
|
138
|
-
if (!triggered && (buffer.includes('> ') || buffer.includes('╰─'))) {
|
|
139
|
-
triggered = true;
|
|
140
|
-
// 少し待ってから「開始」を送信
|
|
141
|
-
setTimeout(() => {
|
|
142
|
-
ptyProcess.write('開始\r');
|
|
143
|
-
}, 500);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
// 標準入力をptyに転送
|
|
148
|
-
if (process.stdin.isTTY) {
|
|
149
|
-
process.stdin.setRawMode(true);
|
|
150
|
-
}
|
|
151
|
-
process.stdin.resume();
|
|
152
|
-
process.stdin.on('data', (data) => {
|
|
153
|
-
ptyProcess.write(data.toString());
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
// ターミナルサイズの変更を検知
|
|
157
|
-
process.stdout.on('resize', () => {
|
|
158
|
-
ptyProcess.resize(process.stdout.columns, process.stdout.rows);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// プロセス終了時の処理
|
|
162
|
-
ptyProcess.onExit(({ exitCode }) => {
|
|
163
|
-
console.log('');
|
|
164
|
-
console.log('🔵 BlueLamp セッション終了');
|
|
165
|
-
try { fs.unlinkSync(configPath); } catch (e) {}
|
|
166
|
-
process.exit(exitCode || 0);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// Ctrl+C などのシグナル処理
|
|
170
|
-
process.on('SIGINT', () => {
|
|
171
|
-
ptyProcess.write('\x03');
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* 通常のspawnでClaudeを起動(フォールバック)
|
|
177
|
-
*/
|
|
178
|
-
function startWithSpawn(claudeCommand, claudeArgs, configPath, keyword) {
|
|
179
|
-
const child = spawn(claudeCommand, claudeArgs, {
|
|
180
|
-
stdio: 'inherit',
|
|
181
|
-
env: {
|
|
182
|
-
...process.env,
|
|
183
|
-
BLUELAMP_KEYWORD: keyword
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
child.on('error', (error) => {
|
|
188
|
-
console.error('❌ Claude 起動エラー:', error.message);
|
|
189
|
-
try { fs.unlinkSync(configPath); } catch (e) {}
|
|
190
|
-
process.exit(1);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
child.on('exit', (code) => {
|
|
194
|
-
console.log('');
|
|
195
|
-
console.log('🔵 BlueLamp セッション終了');
|
|
196
|
-
try { fs.unlinkSync(configPath); } catch (e) {}
|
|
197
|
-
process.exit(code || 0);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
process.on('SIGINT', () => {
|
|
201
|
-
console.log('\n🔵 BlueLamp を終了しています...');
|
|
202
|
-
child.kill('SIGINT');
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
109
|
/**
|
|
207
110
|
* メイン処理
|
|
208
111
|
*/
|
|
209
112
|
async function main() {
|
|
210
113
|
const keyword = getKeywordFromCommand();
|
|
211
114
|
const isDebugMode = process.argv.includes('--debug');
|
|
212
|
-
const useSpawn = process.argv.includes('--no-auto');
|
|
213
115
|
|
|
214
|
-
console.log('🔵 BlueLamp MCP Integration
|
|
116
|
+
console.log('🔵 BlueLamp MCP Integration');
|
|
215
117
|
console.log(`📚 プロンプト: ${keyword}`);
|
|
216
118
|
console.log('');
|
|
217
119
|
|
|
@@ -224,11 +126,14 @@ async function main() {
|
|
|
224
126
|
console.log('🚀 Claude 起動中...');
|
|
225
127
|
console.log('');
|
|
226
128
|
|
|
227
|
-
//
|
|
129
|
+
// システムプロンプトに追加する指示(inject_knowledgeを自動実行させる)
|
|
228
130
|
const systemPromptAddition = `【重要】セッション開始時に必ず inject_knowledge ツールを実行してください。
|
|
229
131
|
keyword: "${keyword}" を指定して、専門知識を注入してから作業を開始してください。
|
|
230
132
|
ユーザーが何か質問や指示をした場合でも、まず inject_knowledge を実行してから回答してください。`;
|
|
231
133
|
|
|
134
|
+
// 短い初期プロンプト(これがトリガーになる)
|
|
135
|
+
const initialPrompt = '開始';
|
|
136
|
+
|
|
232
137
|
// Windows対応
|
|
233
138
|
const isWindows = process.platform === 'win32';
|
|
234
139
|
let claudeCommand, claudeArgs;
|
|
@@ -241,14 +146,16 @@ keyword: "${keyword}" を指定して、専門知識を注入してから作業
|
|
|
241
146
|
'claude',
|
|
242
147
|
'--dangerously-skip-permissions',
|
|
243
148
|
'--mcp-config', configPath,
|
|
244
|
-
'--append-system-prompt', systemPromptAddition
|
|
149
|
+
'--append-system-prompt', systemPromptAddition,
|
|
150
|
+
'-p', initialPrompt
|
|
245
151
|
];
|
|
246
152
|
} else {
|
|
247
153
|
claudeCommand = 'claude';
|
|
248
154
|
claudeArgs = [
|
|
249
155
|
'--dangerously-skip-permissions',
|
|
250
156
|
'--mcp-config', configPath,
|
|
251
|
-
'--append-system-prompt', systemPromptAddition
|
|
157
|
+
'--append-system-prompt', systemPromptAddition,
|
|
158
|
+
'-p', initialPrompt
|
|
252
159
|
];
|
|
253
160
|
}
|
|
254
161
|
|
|
@@ -260,18 +167,31 @@ keyword: "${keyword}" を指定して、専門知識を注入してから作業
|
|
|
260
167
|
console.log('');
|
|
261
168
|
}
|
|
262
169
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
try {
|
|
269
|
-
startWithPty(claudeCommand, claudeArgs, configPath, keyword);
|
|
270
|
-
} catch (e) {
|
|
271
|
-
console.log('⚠️ 自動モード利用不可、通常モードで起動します...');
|
|
272
|
-
startWithSpawn(claudeCommand, claudeArgs, configPath, keyword);
|
|
170
|
+
const child = spawn(claudeCommand, claudeArgs, {
|
|
171
|
+
stdio: 'inherit',
|
|
172
|
+
env: {
|
|
173
|
+
...process.env,
|
|
174
|
+
BLUELAMP_KEYWORD: keyword
|
|
273
175
|
}
|
|
274
|
-
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
child.on('error', (error) => {
|
|
179
|
+
console.error('❌ Claude 起動エラー:', error.message);
|
|
180
|
+
try { fs.unlinkSync(configPath); } catch (e) {}
|
|
181
|
+
process.exit(1);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
child.on('exit', (code) => {
|
|
185
|
+
console.log('');
|
|
186
|
+
console.log('🔵 BlueLamp セッション終了');
|
|
187
|
+
try { fs.unlinkSync(configPath); } catch (e) {}
|
|
188
|
+
process.exit(code || 0);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
process.on('SIGINT', () => {
|
|
192
|
+
console.log('\n🔵 BlueLamp を終了しています...');
|
|
193
|
+
child.kill('SIGINT');
|
|
194
|
+
});
|
|
275
195
|
}
|
|
276
196
|
|
|
277
197
|
main().catch((error) => {
|
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"
|