bluelamp-vscode 2.0.2 → 2.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.
@@ -1,2 +1,203 @@
1
1
  #!/usr/bin/env node
2
- const {spawn}=require('child_process'),path=require('path'),fs=require('fs'),os=require('os'),packageRoot=path['dirname'](__dirname),dotenvPath=path['join'](packageRoot,'.env');fs['existsSync'](dotenvPath)&&require('dotenv')['config']({'path':dotenvPath});const PROMPT_MAPPING={'bluelamp-vscode1':'@要件定義','bluelamp-vscode2':'@Git管理','bluelamp-vscode3':'@フロントエンド基盤','bluelamp-vscode4':'@ページ実装オーケストレーター','bluelamp-vscode5':'@環境構築オーケストレーター','bluelamp-vscode6':'@バックエンド計画オーケストレーター','bluelamp-vscode7':'@バックエンド実装オーケストレーター','bluelamp-vscode8':'@フロントエンド実装オーケストレーター','bluelamp-vscode9':'@E2Eテストオーケストレーター','bluelamp-vscode10':'@デプロイオーケストレーター','bluelamp-vscode11':'@機能拡張','bluelamp-vscode12':'@デバッグ技術','bluelamp-vscode13':'@TypeScript型システム','bluelamp-vscode14':'@リファクタリング','bluelamp-vscode15':'@ドキュメント生成','bluelamp-vscode16':'@相談'};function getKeywordFromCommand(){const a=process['argv'][0x1],b=path['basename'](a);return!PROMPT_MAPPING[b]&&(console['error']('❌\x20未定義のコマンド:\x20'+b),process['exit'](0x1)),PROMPT_MAPPING[b];}function createMCPConfig(a,b){const c=path['join'](packageRoot,'lib/mcp-server/index.cjs'),d=path['join'](os['tmpdir'](),'bluelamp-vscode-'+Date['now']()+'.json'),e={'mcpServers':{'bluelamp-vscode':{'command':'node','args':[c],'env':{'BLUELAMP_KEYWORD':a,'BLUELAMP_TOKEN':b,'PORTAL_URL':'http://localhost:8080'}}}};return fs['writeFileSync'](d,JSON['stringify'](e,null,0x2)),d;}async function performPortalAuth(){try{const {InteractiveLogin:a}=require('../lib/auth/InteractiveLogin'),b=await a['performLogin']();return a['displayLoginSuccess'](b),b['token'];}catch(c){console['error']('❌\x20Portal認証エラー:',c['message']),console['error'](''),console['error']('解決方法:'),console['error']('1.\x20インターネット接続を確認してください'),console['error']('2.\x20Portal認証情報が正しいか確認してください'),console['error']('3.\x20http://localhost:8080\x20にアクセスできるか確認してください'),process['exit'](0x1);}}async function main(){const a=getKeywordFromCommand();console['log']('🔵\x20BlueLamp\x20VSCode\x20MCP\x20Integration'),console['log']('📚\x20プロンプト:\x20'+a),console['log']('');const b=await performPortalAuth(),c=createMCPConfig(a,b),d='>\x20拡張モードで起動\x0a\x0a🔵\x20BlueLamp\x20統合認証システム\x20が有効化されました\x0a\x0a\x1b[34m╭─────────────────────────────────────────────────────────────────╮\x1b[0m\x0a\x1b[34m│\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20│\x1b[0m\x0a\x1b[34m│\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20B\x20l\x20u\x20e\x20L\x20a\x20m\x20p\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20│\x1b[0m\x0a\x1b[34m│\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20─────────────────\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20│\x1b[0m\x0a\x1b[34m│\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20さあ始めましょう\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20│\x1b[0m\x0a\x1b[34m│\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20│\x1b[0m\x0a\x1b[34m╰─────────────────────────────────────────────────────────────────╯\x1b[0m\x0a\x0a**最初に必ず専門知識を注入してください**\x0ainject_knowledge\x20ツールで\x20keyword:\x20\x22'+a+'\x22\x20を実行してから開始してください。(初回必須)\x0a\x0a重要:キーワードは\x20\x22'+a+'\x22\x20をそのまま使用してください。変換や推測は不要です。\x0a\x0a準備完了です。まず知識注入を実行してから、タスクを開始してください。';console['log']('🚀\x20Claude\x20起動中...'),console['log']('\x20\x20\x20-\x20MCP\x20Server:\x20BlueLamp\x20VSCode'),console['log']('\x20\x20\x20-\x20Knowledge:\x20'+a),console['log']('');const e=[d,'--dangerously-skip-permissions','--mcp-config',c],f=spawn('claude',e,{'stdio':'inherit','env':{...process['env'],'BLUELAMP_VSCODE_KEYWORD':a}});f['on']('error',g=>{console['error']('❌\x20Claude\x20起動エラー:',g['message']);try{fs['unlinkSync'](c);}catch(h){}process['exit'](0x1);}),f['on']('exit',g=>{console['log'](''),console['log']('🔵\x20BlueLamp\x20VSCode\x20セッション終了');try{fs['unlinkSync'](c);}catch(h){}process['exit'](g||0x0);}),process['on']('SIGINT',()=>{console['log']('\x0a🔵\x20BlueLamp\x20VSCode\x20を終了しています...'),f['kill']('SIGINT');});}main()['catch'](a=>{console['error']('❌\x20予期しないエラー:',a['message']),process['exit'](0x1);});
2
+
3
+ /**
4
+ * BlueLamp VSCode MCP Integration
5
+ * Base script for VSCode extension prompt injection
6
+ */
7
+
8
+ const { spawn } = require('child_process');
9
+ const path = require('path');
10
+ const fs = require('fs');
11
+ const os = require('os');
12
+
13
+ // パッケージのルートディレクトリを取得
14
+ const packageRoot = path.dirname(__dirname);
15
+
16
+ // .envファイルを読み込み(存在する場合)
17
+ const dotenvPath = path.join(packageRoot, '.env');
18
+ if (fs.existsSync(dotenvPath)) {
19
+ require('dotenv').config({ path: dotenvPath });
20
+ }
21
+
22
+ // コマンドマッピング(15個のプロンプト - 新BlueLamp 15エージェント体制)
23
+ const PROMPT_MAPPING = {
24
+ 'bluelamp-vscode1': '@要件定義', // Phase @1: 要件定義エンジニア
25
+ 'bluelamp-vscode2': '@Git管理', // Phase @2: Git/GitHub管理
26
+ 'bluelamp-vscode3': '@フロントエンド基盤', // Phase @3: フロントエンド基盤オーケストレーター
27
+ 'bluelamp-vscode4': '@ページ実装オーケストレーター', // Phase @4: ページ実装統括
28
+ 'bluelamp-vscode5': '@環境構築オーケストレーター', // Phase @5: 環境構築
29
+ 'bluelamp-vscode6': '@バックエンド計画オーケストレーター', // Phase @6: バックエンド実装計画
30
+ 'bluelamp-vscode7': '@バックエンド実装オーケストレーター', // Phase @7: バックエンド実装統括
31
+ 'bluelamp-vscode8': '@フロントエンド実装オーケストレーター', // Phase @8: API統合統括
32
+ 'bluelamp-vscode9': '@E2Eテストオーケストレーター', // Phase @9: E2Eテスト統括
33
+ 'bluelamp-vscode10': '@デプロイオーケストレーター', // Phase @10: デプロイメント統括
34
+ 'bluelamp-vscode11': '@機能拡張', // Phase @11: 機能拡張オーケストレーター
35
+ 'bluelamp-vscode12': '@デバッグ技術', // Tools @12: 自己完結型デバッグマスター
36
+ 'bluelamp-vscode13': '@TypeScript型システム', // Tools @13: 並列TypeScript型エラー解消
37
+ 'bluelamp-vscode14': '@リファクタリング', // Tools @14: 超並列リファクタリング
38
+ 'bluelamp-vscode15': '@ドキュメント生成', // Tools @15: ドキュメント生成統括
39
+ 'bluelamp-vscode16': '@相談' // Tools @16: 相談対応
40
+ };
41
+
42
+ /**
43
+ * コマンド名から対応するキーワードを取得
44
+ */
45
+ function getKeywordFromCommand() {
46
+ const commandPath = process.argv[1];
47
+ const commandName = path.basename(commandPath);
48
+
49
+ if (!PROMPT_MAPPING[commandName]) {
50
+ console.error(`❌ 未定義のコマンド: ${commandName}`);
51
+ process.exit(1);
52
+ }
53
+
54
+ return PROMPT_MAPPING[commandName];
55
+ }
56
+
57
+ /**
58
+ * MCPサーバー設定を作成
59
+ */
60
+ function createMCPConfig(keyword, cliToken) {
61
+ const mcpServerPath = path.join(packageRoot, 'lib/mcp-server/index.cjs');
62
+ const tempConfigPath = path.join(os.tmpdir(), `bluelamp-vscode-${Date.now()}.json`);
63
+
64
+ const config = {
65
+ mcpServers: {
66
+ "bluelamp-vscode": {
67
+ command: "node",
68
+ args: [mcpServerPath],
69
+ env: {
70
+ BLUELAMP_KEYWORD: keyword,
71
+ BLUELAMP_TOKEN: cliToken,
72
+ PORTAL_URL: "https://bluelamp-235426778039.asia-northeast1.run.app" // 本番Portalサーバー
73
+ }
74
+ }
75
+ }
76
+ };
77
+
78
+ fs.writeFileSync(tempConfigPath, JSON.stringify(config, null, 2));
79
+ return tempConfigPath;
80
+ }
81
+
82
+ /**
83
+ * Portal認証の実行(BlueLamp VSCode独自の認証システム)
84
+ */
85
+ async function performPortalAuth() {
86
+ try {
87
+ // BlueLamp VSCode用の認証モジュールを使用
88
+ const { InteractiveLogin } = require('../lib/auth/InteractiveLogin');
89
+
90
+ const authResult = await InteractiveLogin.performLogin();
91
+
92
+ InteractiveLogin.displayLoginSuccess(authResult);
93
+
94
+ return authResult.token;
95
+
96
+ } catch (error) {
97
+ console.error('❌ Portal認証エラー:', error.message);
98
+ console.error('');
99
+ console.error('解決方法:');
100
+ console.error('1. インターネット接続を確認してください');
101
+ console.error('2. Portal認証情報が正しいか確認してください');
102
+ console.error('3. https://bluelamp-235426778039.asia-northeast1.run.app にアクセスできるか確認してください');
103
+ process.exit(1);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * メイン処理
109
+ */
110
+ async function main() {
111
+ const keyword = getKeywordFromCommand();
112
+
113
+ console.log('🔵 BlueLamp VSCode MCP Integration');
114
+ console.log(`📚 プロンプト: ${keyword}`);
115
+ console.log('');
116
+
117
+ // Portal認証の実行
118
+ const cliToken = await performPortalAuth();
119
+
120
+ // MCP設定ファイルを作成(認証トークンを含む)
121
+ const configPath = createMCPConfig(keyword, cliToken);
122
+
123
+ // 初期プロンプトメッセージ
124
+ const initialPrompt = `> 拡張モードで起動
125
+
126
+ 🔵 BlueLamp 統合認証システム が有効化されました
127
+
128
+ \x1b[34m╭─────────────────────────────────────────────────────────────────╮\x1b[0m
129
+ \x1b[34m│ │\x1b[0m
130
+ \x1b[34m│ B l u e L a m p │\x1b[0m
131
+ \x1b[34m│ ───────────────── │\x1b[0m
132
+ \x1b[34m│ さあ始めましょう │\x1b[0m
133
+ \x1b[34m│ │\x1b[0m
134
+ \x1b[34m╰─────────────────────────────────────────────────────────────────╯\x1b[0m
135
+
136
+ **最初に必ず専門知識を注入してください**
137
+ inject_knowledge ツールで keyword: "${keyword}" を実行してから開始してください。(初回必須)
138
+
139
+ 重要:キーワードは "${keyword}" をそのまま使用してください。変換や推測は不要です。
140
+
141
+ 準備完了です。まず知識注入を実行してから、タスクを開始してください。`;
142
+
143
+ // Claude を起動
144
+ console.log('🚀 Claude 起動中...');
145
+ console.log(' - MCP Server: BlueLamp VSCode');
146
+ console.log(` - Knowledge: ${keyword}`);
147
+ console.log('');
148
+
149
+ const claudeArgs = [
150
+ initialPrompt,
151
+ '--dangerously-skip-permissions', // bypassPermissionを有効化
152
+ '--mcp-config', configPath
153
+ ];
154
+
155
+ const child = spawn('claude', claudeArgs, {
156
+ stdio: 'inherit',
157
+ env: {
158
+ ...process.env,
159
+ BLUELAMP_VSCODE_KEYWORD: keyword
160
+ }
161
+ });
162
+
163
+ // エラーハンドリング
164
+ child.on('error', (error) => {
165
+ console.error('❌ Claude 起動エラー:', error.message);
166
+
167
+ // 一時ファイルをクリーンアップ
168
+ try {
169
+ fs.unlinkSync(configPath);
170
+ } catch (e) {
171
+ // ignore
172
+ }
173
+
174
+ process.exit(1);
175
+ });
176
+
177
+ // 終了時のクリーンアップ
178
+ child.on('exit', (code) => {
179
+ console.log('');
180
+ console.log('🔵 BlueLamp VSCode セッション終了');
181
+
182
+ // 一時ファイルをクリーンアップ
183
+ try {
184
+ fs.unlinkSync(configPath);
185
+ } catch (e) {
186
+ // ignore
187
+ }
188
+
189
+ process.exit(code || 0);
190
+ });
191
+
192
+ // SIGINT (Ctrl+C) ハンドリング
193
+ process.on('SIGINT', () => {
194
+ console.log('\n🔵 BlueLamp VSCode を終了しています...');
195
+ child.kill('SIGINT');
196
+ });
197
+ }
198
+
199
+ // メイン処理の実行
200
+ main().catch((error) => {
201
+ console.error('❌ 予期しないエラー:', error.message);
202
+ process.exit(1);
203
+ });