bluelamp 3.0.8 → 4.0.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.
Files changed (138) hide show
  1. package/README.md +68 -12
  2. package/bin/bluelamp-base +145 -330
  3. package/bin/bluelamp-hook +33 -0
  4. package/bin/bluelamp1 +2 -0
  5. package/bin/bluelamp10 +1 -373
  6. package/bin/bluelamp11 +1 -373
  7. package/bin/bluelamp12 +1 -373
  8. package/bin/bluelamp13 +1 -373
  9. package/bin/bluelamp14 +1 -373
  10. package/bin/bluelamp15 +1 -373
  11. package/bin/bluelamp16 +1 -373
  12. package/bin/bluelamp17 +1 -373
  13. package/bin/bluelamp18 +1 -373
  14. package/bin/bluelamp2 +1 -373
  15. package/bin/bluelamp3 +1 -373
  16. package/bin/bluelamp4 +1 -373
  17. package/bin/bluelamp5 +1 -373
  18. package/bin/bluelamp6 +1 -373
  19. package/bin/bluelamp7 +1 -373
  20. package/bin/bluelamp8 +1 -373
  21. package/bin/bluelamp9 +1 -373
  22. package/bin/docs/SCOPE_PROGRESS.md +222 -0
  23. package/lib/agents//343/203/226/343/203/253/343/203/274/343/203/251/343/203/263/343/203/227.md +106 -0
  24. package/lib/auth/InteractiveLogin.js +243 -0
  25. package/lib/auth/PortalAuthClient.js +187 -0
  26. package/lib/auth/TokenManager.js +258 -0
  27. package/lib/mcp-server/fetch-prompt.js +61 -0
  28. package/lib/mcp-server/index.cjs +164 -0
  29. package/lib/mcp-server/portal-api-client.cjs +210 -0
  30. package/package.json +24 -108
  31. package/scripts/build-release.js +426 -0
  32. package/scripts/generate-commands.js +40 -0
  33. package/scripts/setup-hook.js +98 -0
  34. package/bin/bluelamp +0 -374
  35. package/bin/bluelamp100 +0 -374
  36. package/bin/bluelamp19 +0 -374
  37. package/bin/bluelamp20 +0 -374
  38. package/bin/bluelamp21 +0 -374
  39. package/bin/bluelamp22 +0 -374
  40. package/bin/bluelamp23 +0 -374
  41. package/bin/bluelamp24 +0 -374
  42. package/bin/bluelamp25 +0 -374
  43. package/bin/bluelamp26 +0 -374
  44. package/bin/bluelamp27 +0 -374
  45. package/bin/bluelamp28 +0 -374
  46. package/bin/bluelamp29 +0 -374
  47. package/bin/bluelamp30 +0 -374
  48. package/bin/bluelamp31 +0 -374
  49. package/bin/bluelamp32 +0 -374
  50. package/bin/bluelamp33 +0 -374
  51. package/bin/bluelamp34 +0 -374
  52. package/bin/bluelamp35 +0 -374
  53. package/bin/bluelamp36 +0 -374
  54. package/bin/bluelamp37 +0 -374
  55. package/bin/bluelamp38 +0 -374
  56. package/bin/bluelamp39 +0 -374
  57. package/bin/bluelamp40 +0 -374
  58. package/bin/bluelamp41 +0 -374
  59. package/bin/bluelamp42 +0 -374
  60. package/bin/bluelamp43 +0 -374
  61. package/bin/bluelamp44 +0 -374
  62. package/bin/bluelamp45 +0 -374
  63. package/bin/bluelamp46 +0 -374
  64. package/bin/bluelamp47 +0 -374
  65. package/bin/bluelamp48 +0 -374
  66. package/bin/bluelamp49 +0 -374
  67. package/bin/bluelamp50 +0 -374
  68. package/bin/bluelamp51 +0 -374
  69. package/bin/bluelamp52 +0 -374
  70. package/bin/bluelamp53 +0 -374
  71. package/bin/bluelamp54 +0 -374
  72. package/bin/bluelamp55 +0 -374
  73. package/bin/bluelamp56 +0 -374
  74. package/bin/bluelamp57 +0 -374
  75. package/bin/bluelamp58 +0 -374
  76. package/bin/bluelamp59 +0 -374
  77. package/bin/bluelamp60 +0 -374
  78. package/bin/bluelamp61 +0 -374
  79. package/bin/bluelamp62 +0 -374
  80. package/bin/bluelamp63 +0 -374
  81. package/bin/bluelamp64 +0 -374
  82. package/bin/bluelamp65 +0 -374
  83. package/bin/bluelamp66 +0 -374
  84. package/bin/bluelamp67 +0 -374
  85. package/bin/bluelamp68 +0 -374
  86. package/bin/bluelamp69 +0 -374
  87. package/bin/bluelamp70 +0 -374
  88. package/bin/bluelamp71 +0 -374
  89. package/bin/bluelamp72 +0 -374
  90. package/bin/bluelamp73 +0 -374
  91. package/bin/bluelamp74 +0 -374
  92. package/bin/bluelamp75 +0 -374
  93. package/bin/bluelamp76 +0 -374
  94. package/bin/bluelamp77 +0 -374
  95. package/bin/bluelamp78 +0 -374
  96. package/bin/bluelamp79 +0 -374
  97. package/bin/bluelamp80 +0 -374
  98. package/bin/bluelamp81 +0 -374
  99. package/bin/bluelamp82 +0 -374
  100. package/bin/bluelamp83 +0 -374
  101. package/bin/bluelamp84 +0 -374
  102. package/bin/bluelamp85 +0 -374
  103. package/bin/bluelamp86 +0 -374
  104. package/bin/bluelamp87 +0 -374
  105. package/bin/bluelamp88 +0 -374
  106. package/bin/bluelamp89 +0 -374
  107. package/bin/bluelamp90 +0 -374
  108. package/bin/bluelamp91 +0 -374
  109. package/bin/bluelamp92 +0 -374
  110. package/bin/bluelamp93 +0 -374
  111. package/bin/bluelamp94 +0 -374
  112. package/bin/bluelamp95 +0 -374
  113. package/bin/bluelamp96 +0 -374
  114. package/bin/bluelamp97 +0 -374
  115. package/bin/bluelamp98 +0 -374
  116. package/bin/bluelamp99 +0 -374
  117. package/config/claude-config-template.json +0 -13
  118. package/lib/mcp-server/dist/InteractiveLogin.js +0 -27
  119. package/lib/mcp-server/dist/PortalAuthClient.js +0 -1
  120. package/lib/mcp-server/dist/TokenManager.js +0 -20
  121. package/lib/mcp-server/dist/bluelamp-system.js +0 -32
  122. package/lib/mcp-server/dist/crypto-utils.js +0 -27
  123. package/lib/mcp-server/dist/database-version.js +0 -33
  124. package/lib/mcp-server/dist/index.js +0 -62
  125. package/lib/mcp-server/dist/plugins/base-plugin.js +0 -24
  126. package/lib/mcp-server/dist/plugins/plugin-manager.js +0 -31
  127. package/lib/mcp-server/dist/plugins/services/leonardo-plugin.js +0 -95
  128. package/lib/mcp-server/dist/plugins/services/leonardo-prompt-parser.js +0 -36
  129. package/lib/mcp-server/dist/plugins/services/portal-api-client.js +0 -22
  130. package/lib/mcp-server/dist/plugins/services/portal-plugin.js +0 -52
  131. package/lib/mcp-server/dist/secure-mcp-server.js +0 -76
  132. package/lib/mcp-server/dist/security/ApiKeyManager.js +0 -24
  133. package/lib/mcp-server/dist/security/InteractiveLogin.js +0 -32
  134. package/lib/mcp-server/dist/security/PortalAuthClient.js +0 -1
  135. package/lib/mcp-server/dist/security/SimpleAuthManager.js +0 -1
  136. package/lib/mcp-server/dist/security/SlotAuthClient.js +0 -9
  137. package/lib/mcp-server/dist/security/TokenManager.js +0 -25
  138. package/lib/mcp-server/package.json +0 -21
package/README.md CHANGED
@@ -1,25 +1,81 @@
1
- # BlueLamp v3.0.0 Release Build
1
+ # BlueLamp VSCode MCP Integration
2
+
3
+ VSCode拡張機能専用の知識注入システム
4
+
5
+ ## 概要
6
+
7
+ BlueLamp VSCodeは、VSCode拡張機能から16種類の開発プロンプトを使用してClaude Desktopを起動するためのMCP(Model Context Protocol)統合パッケージです。
2
8
 
3
9
  ## インストール
4
10
 
11
+ ### グローバルインストール(推奨)
12
+
13
+ ```bash
14
+ npm install -g bluelamp-vscode
15
+ ```
16
+
17
+ ### ローカルインストール
18
+
5
19
  ```bash
6
- npm install -g .
20
+ npm install bluelamp-vscode
7
21
  ```
8
22
 
9
23
  ## 使用方法
10
24
 
25
+ ### コマンドラインから直接実行
26
+
11
27
  ```bash
12
- bluelamp
13
- # または
14
- bluelamp2, bluelamp3, ... bluelamp100
28
+ # 要件定義エンジニアとして起動
29
+ bluelamp-vscode1
30
+
31
+ # UI/UXデザイナーとして起動
32
+ bluelamp-vscode2
33
+
34
+ # ... など16種類のコマンド
15
35
  ```
16
36
 
17
- ## 特徴
37
+ ### VSCode拡張機能から自動実行
38
+
39
+ VSCode拡張機能のプロンプトカードをクリックすると、対応するコマンドが自動的に実行されます。
40
+
41
+ ## コマンド一覧
42
+
43
+ | コマンド | キーワード | 役割 |
44
+ |---------|----------|------|
45
+ | `bluelamp-vscode1` | BL-要件定義 | 要件定義エンジニア |
46
+ | `bluelamp-vscode2` | BL-UIUXデザイン | UI/UXデザイナー |
47
+ | `bluelamp-vscode3` | BL-データモデル | データモデリングエンジニア |
48
+ | `bluelamp-vscode4` | BL-システム設計 | システムアーキテクト |
49
+ | `bluelamp-vscode5` | BL-実装計画 | 実装プランナー |
50
+ | `bluelamp-vscode6` | BL-環境構築 | 環境構築エンジニア |
51
+ | `bluelamp-vscode7` | BL-プロトタイプ | プロトタイプ開発者 |
52
+ | `bluelamp-vscode8` | BL-バックエンド | バックエンドエンジニア |
53
+ | `bluelamp-vscode9` | BL-テスト検証 | QAエンジニア |
54
+ | `bluelamp-vscode10` | BL-API統合 | API統合スペシャリスト |
55
+ | `bluelamp-vscode11` | BL-デプロイ | デプロイメントエンジニア |
56
+ | `bluelamp-vscode12` | BL-GitHub | GitHub運用エキスパート |
57
+ | `bluelamp-vscode13` | BL-TypeScript | TypeScriptエキスパート |
58
+ | `bluelamp-vscode14` | BL-デバッグ | デバッグスペシャリスト |
59
+ | `bluelamp-vscode15` | BL-機能拡張 | 機能拡張エンジニア |
60
+ | `bluelamp-vscode16` | BL-リファクタリング | リファクタリングエキスパート |
61
+
62
+ ## 仕組み
63
+
64
+ 1. コマンド実行時にMCPサーバーが自動起動
65
+ 2. Claude Desktopが起動し、MCPサーバーに接続
66
+ 3. 初回プロンプトで知識注入(inject_knowledge)を実行
67
+ 4. 選択したロールの専門知識が注入され、開発支援開始
68
+
69
+ ## 必要要件
70
+
71
+ - Node.js 18以上
72
+ - Claude Desktop(インストール済み)
73
+ - VSCode BlueLamp拡張機能(オプション)
74
+
75
+ ## ライセンス
76
+
77
+ MIT
18
78
 
19
- - 高度な難読化によるセキュリティ保護
20
- - Portal統合機能
21
- - Leonardo AI連携
22
- - 最適化されたパフォーマンス
79
+ ## サポート
23
80
 
24
- ---
25
- Generated by BlueLamp Build System v3.0.0
81
+ 問題が発生した場合は、[GitHubリポジトリ](https://github.com/bluelamp/bluelamp-vscode)でIssueを作成してください。
package/bin/bluelamp-base CHANGED
@@ -1,16 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * BlueLamp - AI Agent Orchestration System with Portal Authentication
5
- * Base script that handles slot-based command routing
6
- *
7
- * Features:
8
- * - Portal統合認証システム
9
- * - 3箇所分散保存によるセキュリティ強化
10
- * - bypassmode=true (--dangerously-skip-permissions)
11
- * - orchestrator Knowledge Injection
12
- * - 24 AI Agents available as sub-agents
13
- * - Auto slot detection from command name
4
+ * BlueLamp MCP Integration
5
+ * Fast startup version using SessionStart Hook
14
6
  */
15
7
 
16
8
  const { spawn } = require('child_process');
@@ -20,355 +12,178 @@ const os = require('os');
20
12
 
21
13
  // パッケージのルートディレクトリを取得
22
14
  const packageRoot = path.dirname(__dirname);
23
- const mcpServerPath = path.join(packageRoot, 'lib/mcp-server/dist/secure-mcp-server.js');
24
15
 
25
- // Portal認証モジュールのインポート(ES Modules対応)
26
- const securityPath = path.join(packageRoot, 'lib/mcp-server/dist/security');
16
+ // .envファイルを読み込み(.env.localを優先)
17
+ const dotenvLocalPath = path.join(packageRoot, '.env.local');
18
+ const dotenvPath = path.join(packageRoot, '.env');
27
19
 
28
- /**
29
- * コマンド名からスロット番号を自動判定
30
- */
31
- function detectSlotNumber() {
32
- try {
33
- // process.argv[1] から実行されたコマンドのパスを取得
34
- const commandPath = process.argv[1];
35
- const commandName = path.basename(commandPath);
36
-
37
- // コマンド名から数字部分を抽出
38
- if (commandName === 'bluelamp') {
39
- return 1; // デフォルトはスロット1
40
- }
41
-
42
- const match = commandName.match(/^bluelamp(\d+)$/);
43
- if (match) {
44
- const slotNumber = parseInt(match[1], 10);
45
- if (slotNumber >= 1 && slotNumber <= 100) {
46
- return slotNumber;
47
- }
48
- }
49
-
50
- throw new Error(`Invalid command name: ${commandName}. Expected format: bluelamp or bluelamp[1-100]`);
51
-
52
- } catch (error) {
53
- console.error('❌ スロット番号の自動判定に失敗しました:', error.message);
54
- console.error('');
55
- console.error('有効なコマンド名:');
56
- console.error('- bluelamp (スロット1)');
57
- console.error('- bluelamp2〜bluelamp100');
58
- process.exit(1);
59
- }
20
+ if (fs.existsSync(dotenvLocalPath)) {
21
+ require('dotenv').config({ path: dotenvLocalPath });
22
+ } else if (fs.existsSync(dotenvPath)) {
23
+ require('dotenv').config({ path: dotenvPath });
60
24
  }
61
25
 
62
- // スロット番号を取得
63
- const SLOT_NUMBER = detectSlotNumber();
64
-
65
- console.log(`🔵 BlueLamp - AIエージェント統合システム (スロット${SLOT_NUMBER})`);
66
- console.log(' ポータル統合認証 + 知識注入 + 24種類のAIエージェント');
67
- console.log('');
26
+ // コマンドマッピング(18個のプロンプト - BlueLamp 18エージェント体制)
27
+ const PROMPT_MAPPING = {
28
+ 'bluelamp1': '@要件定義',
29
+ 'bluelamp2': '@Git管理',
30
+ 'bluelamp3': '@フロントエンド基盤',
31
+ 'bluelamp4': '@ページ実装オーケストレーター',
32
+ 'bluelamp5': '@環境構築オーケストレーター',
33
+ 'bluelamp6': '@バックエンド計画オーケストレーター',
34
+ 'bluelamp7': '@バックエンド実装オーケストレーター',
35
+ 'bluelamp8': '@フロントエンド実装オーケストレーター',
36
+ 'bluelamp9': '@E2Eテストオーケストレーター',
37
+ 'bluelamp10': '@本番運用診断オーケストレーター',
38
+ 'bluelamp11': '@デプロイオーケストレーター',
39
+ 'bluelamp12': '@拡張要件定義',
40
+ 'bluelamp13': '@拡張機能実装',
41
+ 'bluelamp14': '@デバッグ技術',
42
+ 'bluelamp15': '@リファクタリング',
43
+ 'bluelamp16': '@ドキュメント生成',
44
+ 'bluelamp17': '@相談',
45
+ 'bluelamp18': '@MCP追加'
46
+ };
68
47
 
69
48
  /**
70
- * Portal認証の実行
49
+ * コマンド名から対応するキーワードを取得
71
50
  */
72
- async function performPortalAuth() {
73
- try {
74
- // 動的インポートでES Modulesを読み込み(遅延評価を保証)
75
- console.log('🔐 Portal認証を開始します...');
76
-
77
- // macOS対応のfile URLで InteractiveLogin を読み込み
78
- const { InteractiveLogin } = await import(`file://localhost${securityPath}/InteractiveLogin.js`);
79
-
80
- const authResult = await InteractiveLogin.performLogin();
81
-
82
- InteractiveLogin.displayLoginSuccess(authResult);
83
-
84
- return authResult.token;
85
-
86
- } catch (error) {
87
- console.error('❌ Portal認証エラー:', error.message);
88
- console.error('');
89
- console.error('解決方法:');
90
- console.error('1. インターネット接続を確認してください');
91
- console.error('2. Portal認証情報が正しいか確認してください');
92
- console.error('3. https://geniemon.vercel.app にアクセスできるか確認してください');
93
- process.exit(1);
94
- }
95
- }
51
+ function getKeywordFromCommand() {
52
+ const commandPath = process.argv[1];
53
+ const commandName = path.basename(commandPath);
96
54
 
97
- /**
98
- * シンプル保存システムの実行
99
- */
100
- async function performDistributedStorage(cliToken) {
101
- try {
102
- // SimpleAuthManagerを読み込み(dynamic import使用)
103
- const { SimpleAuthManager } = await import(`file://${securityPath}/SimpleAuthManager.js`);
104
-
105
- console.log('🔒 APIキーを安全に保存中...');
106
- const success = SimpleAuthManager.saveApiKey(cliToken);
107
-
108
- if (success) {
109
- console.log('✅ APIキー保存完了');
110
- console.log('🛡️ セキュリティレベル: 高');
111
- }
112
-
113
- return {
114
- success: success,
115
- distributionTime: 1
116
- };
117
-
118
- } catch (error) {
119
- console.error('❌ APIキー保存エラー:', error.message);
120
- return {
121
- success: false,
122
- error: error.message
123
- };
124
- }
55
+ if (!PROMPT_MAPPING[commandName]) {
56
+ console.error(`❌ 未定義のコマンド: ${commandName}`);
57
+ process.exit(1);
58
+ }
59
+
60
+ return PROMPT_MAPPING[commandName];
125
61
  }
126
62
 
127
63
  /**
128
- * エージェントセットアップの確認と実行
64
+ * MCPサーバー設定を作成
129
65
  */
130
- function ensureAgentsSetup() {
131
- const agentsDir = path.join(os.homedir(), '.claude/agents');
132
- const blueLampAgent = path.join(agentsDir, 'ブルーランプ.md');
133
-
134
- // ブルーランプエージェントが存在しない場合はセットアップを実行
135
- if (!fs.existsSync(blueLampAgent)) {
136
- console.log('🔧 エージェントセットアップが必要です...');
137
-
138
- try {
139
- const setupScript = path.join(packageRoot, 'scripts/setup-agents.js');
140
- if (fs.existsSync(setupScript)) {
141
- require(setupScript);
142
- console.log('✅ エージェントセットアップ完了');
143
- } else {
144
- console.log('⚠️ セットアップスクリプトが見つかりません。スキップします。');
145
- }
146
- } catch (error) {
147
- console.warn('⚠️ エージェント自動セットアップに失敗しました:', error.message);
148
- console.warn('手動でセットアップを実行してください: npm run postinstall');
66
+ function createMCPConfig(keyword, cliToken) {
67
+ const mcpServerPath = path.join(packageRoot, 'lib/mcp-server/index.cjs');
68
+ const tempConfigPath = path.join(os.tmpdir(), `bluelamp-${Date.now()}.json`);
69
+
70
+ const portalUrl = process.env.PORTAL_URL || "https://bluelamp-6clpzmy5pa-an.a.run.app";
71
+
72
+ const config = {
73
+ mcpServers: {
74
+ "bluelamp": {
75
+ command: "node",
76
+ args: [mcpServerPath],
77
+ env: {
78
+ BLUELAMP_KEYWORD: keyword,
79
+ BLUELAMP_TOKEN: cliToken,
80
+ PORTAL_URL: portalUrl
149
81
  }
82
+ }
150
83
  }
84
+ };
85
+
86
+ fs.writeFileSync(tempConfigPath, JSON.stringify(config, null, 2));
87
+ return tempConfigPath;
151
88
  }
152
89
 
153
90
  /**
154
- * スロット認証の実行
91
+ * Portal認証の実行
155
92
  */
156
- async function performSlotAuth(token) {
157
- try {
158
- const fetch = (await import('node-fetch')).default;
159
-
160
- console.log(`🎯 スロット${SLOT_NUMBER}の認証を実行中...`);
161
-
162
- const response = await fetch(`https://bluelamp-portal-6clpzmy5pa-an.a.run.app/api/slots/${SLOT_NUMBER}`, {
163
- method: 'GET',
164
- headers: {
165
- 'Content-Type': 'application/json',
166
- 'X-CLI-Token': token
167
- }
168
- });
169
-
170
- if (!response.ok) {
171
- throw new Error(`スロット認証失敗 (${response.status}): ${response.statusText}`);
172
- }
173
-
174
- const result = await response.json();
175
- console.log(`✅ スロット${SLOT_NUMBER}認証完了`);
176
-
177
- return result;
178
-
179
- } catch (error) {
180
- console.error(`❌ スロット${SLOT_NUMBER}認証エラー:`, error.message);
181
- console.error('');
182
- console.error('解決方法:');
183
- console.error('1. インターネット接続を確認してください');
184
- console.error('2. Portalでスロット権限があることを確認してください');
185
- console.error('3. しばらく待ってから再試行してください');
186
- process.exit(1);
187
- }
93
+ async function performPortalAuth() {
94
+ try {
95
+ const { InteractiveLogin } = require('../lib/auth/InteractiveLogin');
96
+ const authResult = await InteractiveLogin.performLogin();
97
+ InteractiveLogin.displayLoginSuccess(authResult);
98
+ return authResult.token;
99
+ } catch (error) {
100
+ console.error('❌ Portal認証エラー:', error.message);
101
+ console.error('');
102
+ console.error('解決方法:');
103
+ console.error('1. インターネット接続を確認してください');
104
+ console.error('2. Portal認証情報が正しいか確認してください');
105
+ process.exit(1);
106
+ }
188
107
  }
189
108
 
190
109
  /**
191
110
  * メイン処理
192
111
  */
193
112
  async function main() {
194
- // コマンドライン引数の処理
195
- const args = process.argv.slice(2);
196
-
197
- // ログアウトコマンド
198
- if (args.includes('--logout')) {
199
- try {
200
- const { InteractiveLogin } = await import(`file://${securityPath}/InteractiveLogin.js`);
201
- await InteractiveLogin.logout();
202
- process.exit(0);
203
- } catch (error) {
204
- console.error('❌ ログアウトエラー:', error.message);
205
- process.exit(1);
206
- }
207
- }
208
-
209
- // ログイン状態確認コマンド
210
- if (args.includes('--status')) {
211
- try {
212
- const { InteractiveLogin } = await import(`file://${securityPath}/InteractiveLogin.js`);
213
- await InteractiveLogin.checkLoginStatus();
214
- process.exit(0);
215
- } catch (error) {
216
- console.error('❌ ステータス確認エラー:', error.message);
217
- process.exit(1);
218
- }
219
- }
220
-
221
- // エージェントセットアップの確認
222
- ensureAgentsSetup();
223
-
224
- // Portal認証の実行
225
- const cliToken = await performPortalAuth();
226
-
227
- // スロット認証の実行
228
- await performSlotAuth(cliToken);
229
-
230
- // シンプル保存システムの実行
231
- console.log('🔒 APIキーを保存中...');
232
- const distributed = await performDistributedStorage(cliToken);
233
-
234
- if (!distributed.success) {
235
- console.error('❌ APIキー保存に失敗しました:', distributed.error);
236
- console.error('フォールバックモードで起動します...');
237
- }
238
-
239
- // TTY検出とフォールバック処理
240
- const isTTY = process.stdout.isTTY && process.stdin.isTTY;
241
- if (!isTTY) {
242
- console.warn('⚠️ TTY環境が検出されませんでした。互換モードで起動します。');
243
- }
244
-
245
- // 環境変数の設定(スロット番号を追加)
246
- const env = {
247
- ...process.env,
248
- BLUELAMP_ENCRYPTION_KEY: process.env.BLUELAMP_ENCRYPTION_KEY || 'bluelamp-default-key-2024',
249
- BLUELAMP_TOKEN: cliToken, // Portal認証で取得した実際のCLIトークンを使用
250
- BLUELAMP_DISTRIBUTED: distributed.success ? 'true' : 'false',
251
- BLUELAMP_SLOT_NUMBER: SLOT_NUMBER.toString(), // スロット番号を環境変数として設定
252
- NODE_ENV: 'production'
253
- };
254
-
255
- // MCP設定ファイルの作成
256
- const tempConfigPath = path.join(os.tmpdir(), `bluelamp-mcp-slot${SLOT_NUMBER}-${Date.now()}.json`);
257
-
258
- const mcpConfig = {
259
- mcpServers: {
260
- "bluelamp-secure": {
261
- command: "node",
262
- args: [mcpServerPath],
263
- env: {
264
- BLUELAMP_ENCRYPTION_KEY: env.BLUELAMP_ENCRYPTION_KEY,
265
- BLUELAMP_TOKEN: env.BLUELAMP_TOKEN,
266
- BLUELAMP_SLOT_NUMBER: env.BLUELAMP_SLOT_NUMBER
267
- }
268
- }
269
- }
270
- // 自動フックは削除 - 起動プロンプトで手動実行を指示
271
- };
272
-
273
- fs.writeFileSync(tempConfigPath, JSON.stringify(mcpConfig, null, 2));
274
-
275
- // オーケストレーター起動プロンプト(スロット情報を追加)
276
- const orchestratorPrompt = `> オーケストレーターモードで起動 (スロット${SLOT_NUMBER})
277
-
278
- 🔵 BlueLamp 統合認証システム が有効化されました
279
-
280
- \x1b[34m╭─────────────────────────────────────────────────────────────────╮\x1b[0m
281
- \x1b[34m│ │\x1b[0m
282
- \x1b[34m│ B l u e L a m p │\x1b[0m
283
- \x1b[34m│ ───────────────── │\x1b[0m
284
- \x1b[34m│ スロット${SLOT_NUMBER.toString().padStart(2, ' ')} でお待ちしています │\x1b[0m
285
- \x1b[34m│ │\x1b[0m
286
- \x1b[34m╰─────────────────────────────────────────────────────────────────╯\x1b[0m
287
-
288
- **最初に必ずオーケストレーター専門知識を注入してください**
289
- inject_knowledge ツールで "オーケストレーター" を実行してから開始してください。(初回必須)
290
-
291
- 準備完了です。まず知識注入を実行してから、何を実装するか教えてください。`;
292
-
293
- // 一時プロンプトファイルの作成
294
- const tempPromptPath = path.join(os.tmpdir(), `bluelamp-prompt-slot${SLOT_NUMBER}-${Date.now()}.txt`);
295
- fs.writeFileSync(tempPromptPath, orchestratorPrompt);
296
-
297
- console.log('🚀 Claude Code起動中...');
298
- console.log(` - スロット番号: ${SLOT_NUMBER}`);
299
- console.log(' - Portal認証: ON');
300
- console.log(' - 単一ファイル保存: ON');
301
- console.log(' - bypassmode: ON (--dangerously-skip-permissions)');
302
- console.log(' - Knowledge Injection: ON');
303
- console.log(' - MCP Server: BlueLamp Secure');
304
- console.log(' - TTY互換モード: ON');
305
- console.log('');
306
-
307
- // Claude Codeを起動(claude-flow方式: プロンプト引数渡し + TTY維持)
308
- const claudeArgs = [
309
- orchestratorPrompt, // 初期プロンプトを第1引数で渡す(claude-flow方式)
310
- '--dangerously-skip-permissions', // bypassmode=true(開発モード)
311
- '--mcp-config', tempConfigPath, // MCP設定ファイル
113
+ const keyword = getKeywordFromCommand();
114
+ const isDebugMode = process.argv.includes('--debug');
115
+
116
+ console.log('🔵 BlueLamp MCP Integration (Fast Mode)');
117
+ console.log(`📚 プロンプト: ${keyword}`);
118
+ console.log('');
119
+
120
+ // Portal認証の実行
121
+ const cliToken = await performPortalAuth();
122
+
123
+ // MCP設定ファイルを作成
124
+ const configPath = createMCPConfig(keyword, cliToken);
125
+
126
+ console.log('🚀 Claude 起動中...');
127
+ console.log('');
128
+
129
+ // Windows対応
130
+ const isWindows = process.platform === 'win32';
131
+ let claudeCommand, claudeArgs;
132
+
133
+ if (isWindows) {
134
+ claudeCommand = 'powershell.exe';
135
+ claudeArgs = [
136
+ '-NoProfile',
137
+ '-Command',
138
+ 'claude',
139
+ '--dangerously-skip-permissions',
140
+ '--mcp-config', configPath
312
141
  ];
142
+ } else {
143
+ claudeCommand = 'claude';
144
+ // initialPrompt を渡さない = 高速起動
145
+ claudeArgs = [
146
+ '--dangerously-skip-permissions',
147
+ '--mcp-config', configPath
148
+ ];
149
+ }
313
150
 
314
- const child = spawn('claude', claudeArgs, {
315
- stdio: 'inherit', // TTY完全維持(claude-flow方式)
316
- env: env,
317
-
318
- // プロセス設定
319
- detached: false, // プロセスグループ分離を無効
320
- windowsHide: false, // Windows環境でのウィンドウ表示
321
- shell: false // シェル経由実行を無効化
322
- });
323
-
324
- // TTY維持によりsetRawMode不要(問題の原因を完全除去)
325
- // stdin操作も不要(引数でプロンプト渡し済み)
151
+ if (isDebugMode) {
152
+ console.log('🐛 デバッグ情報:');
153
+ console.log(` コマンド: ${claudeCommand}`);
154
+ console.log(` 引数: ${JSON.stringify(claudeArgs)}`);
155
+ console.log(` MCP設定: ${configPath}`);
156
+ console.log('');
157
+ }
326
158
 
327
- // エラーハンドリング
328
- child.on('error', (error) => {
329
- console.error('❌ Claude Code起動エラー:', error.message);
330
- console.error('');
331
- console.error('解決方法:');
332
- console.error('1. Claude Codeがインストールされているか確認');
333
- console.error('2. PATHにclaudeコマンドが含まれているか確認');
334
- console.error('3. Claude Codeのバージョンが最新か確認');
335
-
336
- // 一時ファイルをクリーンアップ
337
- try {
338
- fs.unlinkSync(tempConfigPath);
339
- fs.unlinkSync(tempPromptPath);
340
- } catch (e) {
341
- // ignore cleanup errors
342
- }
343
-
344
- process.exit(1);
345
- });
159
+ const child = spawn(claudeCommand, claudeArgs, {
160
+ stdio: 'inherit',
161
+ env: {
162
+ ...process.env,
163
+ BLUELAMP_KEYWORD: keyword
164
+ }
165
+ });
346
166
 
347
- // 終了時のクリーンアップ
348
- child.on('exit', (code) => {
349
- console.log('');
350
- console.log(`🔵 BlueLamp セッション終了 (スロット${SLOT_NUMBER})`);
351
-
352
- // 一時ファイルをクリーンアップ
353
- try {
354
- fs.unlinkSync(tempConfigPath);
355
- fs.unlinkSync(tempPromptPath);
356
- } catch (e) {
357
- // ignore cleanup errors
358
- }
359
-
360
- process.exit(code || 0);
361
- });
167
+ child.on('error', (error) => {
168
+ console.error('❌ Claude 起動エラー:', error.message);
169
+ try { fs.unlinkSync(configPath); } catch (e) {}
170
+ process.exit(1);
171
+ });
362
172
 
363
- // SIGINT (Ctrl+C) ハンドリング
364
- process.on('SIGINT', () => {
365
- console.log(`\n🔵 BlueLamp を終了しています... (スロット${SLOT_NUMBER})`);
366
- child.kill('SIGINT');
367
- });
173
+ child.on('exit', (code) => {
174
+ console.log('');
175
+ console.log('🔵 BlueLamp セッション終了');
176
+ try { fs.unlinkSync(configPath); } catch (e) {}
177
+ process.exit(code || 0);
178
+ });
179
+
180
+ process.on('SIGINT', () => {
181
+ console.log('\n🔵 BlueLamp を終了しています...');
182
+ child.kill('SIGINT');
183
+ });
368
184
  }
369
185
 
370
- // メイン処理の実行
371
186
  main().catch((error) => {
372
- console.error('❌ 予期しないエラーが発生しました:', error.message);
373
- process.exit(1);
374
- });
187
+ console.error('❌ 予期しないエラー:', error.message);
188
+ process.exit(1);
189
+ });
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * BlueLamp SessionStart Hook
5
+ * Claude Code の SessionStart Hook として実行され、
6
+ * 環境変数 BLUELAMP_KEYWORD に基づいてプロンプトを出力する
7
+ */
8
+
9
+ const keyword = process.env.BLUELAMP_KEYWORD;
10
+
11
+ // BLUELAMP_KEYWORD が設定されている場合のみ出力
12
+ if (keyword) {
13
+ const prompt = `> 拡張モードで起動
14
+
15
+ 🔵 BlueLamp 統合認証システム が有効化されました
16
+
17
+ ╭─────────────────────────────────────────────────────────────────╮
18
+ │ │
19
+ │ B l u e L a m p │
20
+ │ ───────────────── │
21
+ │ さあ始めましょう │
22
+ │ │
23
+ ╰─────────────────────────────────────────────────────────────────╯
24
+
25
+ **最初に必ず専門知識を注入してください**
26
+ inject_knowledge ツールで keyword: "${keyword}" を実行してから開始してください。(初回必須)
27
+
28
+ 重要:キーワードは "${keyword}" をそのまま使用してください。変換や推測は不要です。
29
+
30
+ 準備完了です。まず知識注入を実行してから、タスクを開始してください。`;
31
+
32
+ console.log(prompt);
33
+ }
package/bin/bluelamp1 ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('./bluelamp-base');