bluelamp 4.0.7 → 4.0.11

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 (46) hide show
  1. package/README.md +53 -56
  2. package/bin/bluelamp-vscode-base +1 -257
  3. package/bin/bluelamp-vscode1 +2 -0
  4. package/bin/bluelamp-vscode10 +2 -0
  5. package/bin/bluelamp-vscode11 +2 -0
  6. package/bin/bluelamp-vscode12 +2 -0
  7. package/bin/bluelamp-vscode13 +2 -0
  8. package/bin/bluelamp-vscode14 +2 -0
  9. package/bin/bluelamp-vscode15 +2 -0
  10. package/bin/bluelamp-vscode16 +2 -0
  11. package/bin/bluelamp-vscode2 +2 -0
  12. package/bin/bluelamp-vscode3 +2 -0
  13. package/bin/bluelamp-vscode4 +2 -0
  14. package/bin/bluelamp-vscode5 +2 -0
  15. package/bin/bluelamp-vscode6 +2 -0
  16. package/bin/bluelamp-vscode7 +2 -0
  17. package/bin/bluelamp-vscode8 +2 -0
  18. package/bin/bluelamp-vscode9 +2 -0
  19. package/bin/bluelamp1 +0 -0
  20. package/bin/bluelamp10 +0 -0
  21. package/bin/bluelamp11 +0 -0
  22. package/bin/bluelamp12 +0 -0
  23. package/bin/bluelamp13 +0 -0
  24. package/bin/bluelamp14 +0 -0
  25. package/bin/bluelamp15 +0 -0
  26. package/bin/bluelamp16 +0 -0
  27. package/bin/bluelamp17 +0 -0
  28. package/bin/bluelamp18 +0 -0
  29. package/bin/bluelamp2 +0 -0
  30. package/bin/bluelamp3 +0 -0
  31. package/bin/bluelamp4 +0 -0
  32. package/bin/bluelamp5 +0 -0
  33. package/bin/bluelamp6 +0 -0
  34. package/bin/bluelamp7 +0 -0
  35. package/bin/bluelamp8 +0 -0
  36. package/bin/bluelamp9 +0 -0
  37. package/lib/auth/InteractiveLogin.js +1 -243
  38. package/lib/auth/PortalAuthClient.js +1 -187
  39. package/lib/auth/TokenManager.js +1 -258
  40. package/lib/mcp-server/index.cjs +1 -195
  41. package/lib/mcp-server/portal-api-client.cjs +1 -237
  42. package/lib/utils/logger.js +1 -83
  43. package/package.json +5 -17
  44. package/bin/docs/SCOPE_PROGRESS.md +0 -222
  45. package/scripts/build-release.js +0 -426
  46. package/scripts/generate-commands.js +0 -35
@@ -1,196 +1,2 @@
1
1
  #!/usr/bin/env node
2
-
3
- /**
4
- * BlueLamp VSCode MCP Server
5
- * VSCode拡張機能専用のMCPサーバー実装
6
- */
7
-
8
- const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
9
- const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
10
- const {
11
- CallToolRequestSchema,
12
- ListToolsRequestSchema,
13
- } = require('@modelcontextprotocol/sdk/types.js');
14
- const { getPromptFromPortal } = require('./portal-api-client.cjs');
15
- const { logger } = require('../utils/logger');
16
- const path = require('path');
17
- const fs = require('fs');
18
- const os = require('os');
19
-
20
- // .envファイルを読み込み(.env.localを優先)
21
- const dotenvLocalPath = path.join(__dirname, '../../.env.local');
22
- const dotenvPath = path.join(__dirname, '../../.env');
23
-
24
- if (fs.existsSync(dotenvLocalPath)) {
25
- require('dotenv').config({ path: dotenvLocalPath });
26
- logger.debug('[MCP Server] Loaded .env.local');
27
- } else if (fs.existsSync(dotenvPath)) {
28
- require('dotenv').config({ path: dotenvPath });
29
- logger.debug('[MCP Server] Loaded .env');
30
- }
31
-
32
- // 環境変数から取得
33
- const KEYWORD = process.env.BLUELAMP_KEYWORD || 'BL-要件定義';
34
- const TOKEN = process.env.BLUELAMP_TOKEN;
35
- const PORTAL_URL = process.env.PORTAL_URL || 'https://bluelamp-6clpzmy5pa-an.a.run.app';
36
-
37
- // ログファイル設定(ユーザーホームディレクトリに保存)
38
- const LOG_DIR = path.join(os.homedir(), '.bluelamp-vscode', 'logs');
39
- const LOG_FILE = path.join(LOG_DIR, 'mcp.log');
40
-
41
- // ログディレクトリが存在しない場合は作成
42
- if (!fs.existsSync(LOG_DIR)) {
43
- fs.mkdirSync(LOG_DIR, { recursive: true });
44
- }
45
-
46
- /**
47
- * ファイルとコンソールにログを出力
48
- * @param {string} message - ログメッセージ
49
- */
50
- function log(message) {
51
- const timestamp = new Date().toISOString();
52
- const logMessage = `[${timestamp}] ${message}\n`;
53
- fs.appendFileSync(LOG_FILE, logMessage);
54
- logger.info(`[MCP Server] ${message}`);
55
- }
56
-
57
- log(`MCP Server started - Log file: ${LOG_FILE}`);
58
- log(`Environment variables:`);
59
- log(` KEYWORD: ${KEYWORD}`);
60
- log(` TOKEN: ${TOKEN ? TOKEN.substring(0, 20) + '...' : 'NOT SET'}`);
61
- log(` PORTAL_URL: ${PORTAL_URL}`);
62
- log(` .env file exists: ${fs.existsSync(dotenvPath)}`);
63
-
64
- /**
65
- * BlueLamp VSCode MCPサーバークラス
66
- * @class BlueLampVSCodeServer
67
- */
68
- class BlueLampVSCodeServer {
69
- constructor() {
70
- this.server = new Server(
71
- {
72
- name: 'bluelamp-vscode',
73
- version: '1.0.0',
74
- },
75
- {
76
- capabilities: {
77
- tools: {},
78
- },
79
- }
80
- );
81
-
82
- this.setupHandlers();
83
- }
84
-
85
- setupHandlers() {
86
- // ツール一覧を返す
87
- this.server.setRequestHandler(ListToolsRequestSchema, async () => {
88
- log('[MCP Server] ListTools request received');
89
- return {
90
- tools: [
91
- {
92
- name: 'inject_knowledge',
93
- description: 'BlueLamp VSCode開発プロンプトの知識を注入',
94
- inputSchema: {
95
- type: 'object',
96
- properties: {
97
- keyword: {
98
- type: 'string',
99
- description: 'キーワード(@相談 など、そのまま指定してください。プレフィックスの追加は不要です)',
100
- },
101
- },
102
- required: ['keyword'],
103
- },
104
- },
105
- ],
106
- };
107
- });
108
-
109
- // ツール実行
110
- this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
111
- if (request.params.name === 'inject_knowledge') {
112
- const { keyword } = request.params.arguments;
113
-
114
- log(`[MCP Server] inject_knowledge called with keyword: ${keyword}`);
115
- log(`[MCP Server] TOKEN: ${TOKEN ? TOKEN.substring(0, 20) + '...' : 'missing'}`);
116
- log(`[MCP Server] PORTAL_URL: ${PORTAL_URL}`);
117
-
118
- try {
119
- // Portal APIから認証付きで知識を取得
120
- const result = await getPromptFromPortal(keyword, TOKEN);
121
-
122
- if (!result || !result.success) {
123
- const errorMessage = result?.error || `キーワード "${keyword}" に対応する知識が見つかりませんでした`;
124
- log(`[MCP Server] Knowledge injection failed: ${errorMessage}`);
125
- return {
126
- content: [
127
- {
128
- type: 'text',
129
- text: `❌ Portal APIから知識を取得できませんでした: ${errorMessage}`,
130
- },
131
- ],
132
- isError: true,
133
- };
134
- }
135
-
136
- // 知識注入メッセージを返す
137
- return {
138
- content: [
139
- {
140
- type: 'text',
141
- text: `✅ BlueLamp VSCode 知識注入完了
142
-
143
- ${result.knowledge}
144
-
145
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
146
- 専門知識が注入されました。このロールで支援を開始します。`,
147
- },
148
- ],
149
- };
150
- } catch (error) {
151
- log(`[MCP Server] Exception in inject_knowledge: ${error.message}`);
152
- return {
153
- content: [
154
- {
155
- type: 'text',
156
- text: `❌ 知識注入中にエラーが発生しました: ${error.message}`,
157
- },
158
- ],
159
- isError: true,
160
- };
161
- }
162
- }
163
-
164
- return {
165
- content: [
166
- {
167
- type: 'text',
168
- text: `Unknown tool: ${request.params.name}`,
169
- },
170
- ],
171
- isError: true,
172
- };
173
- });
174
- }
175
-
176
- async run() {
177
- const transport = new StdioServerTransport();
178
- await this.server.connect(transport);
179
- logger.info('BlueLamp VSCode MCP server started');
180
-
181
- // 起動時に自動的に知識を注入(環境変数で指定されたキーワード)
182
- if (KEYWORD && TOKEN) {
183
- log(`[MCP Server] Auto-injecting knowledge for keyword: ${KEYWORD}`);
184
- const result = await getPromptFromPortal(KEYWORD, TOKEN);
185
- if (result && result.success) {
186
- log(`[MCP Server] Auto-injection successful: ${result.title}`);
187
- } else {
188
- log(`[MCP Server] Auto-injection failed for keyword: ${KEYWORD}`);
189
- }
190
- }
191
- }
192
- }
193
-
194
- // サーバー起動
195
- const server = new BlueLampVSCodeServer();
196
- server.run().catch((err) => logger.error(err.message));
2
+ const{Server:Server}=require("@modelcontextprotocol/sdk/server/index.js"),{StdioServerTransport:StdioServerTransport}=require("@modelcontextprotocol/sdk/server/stdio.js"),{CallToolRequestSchema:CallToolRequestSchema,ListToolsRequestSchema:ListToolsRequestSchema}=require("@modelcontextprotocol/sdk/types.js"),{getPromptFromPortal:getPromptFromPortal}=require("./portal-api-client.cjs"),{logger:logger}=require("../utils/logger"),path=require("path"),fs=require("fs"),os=require("os"),dotenvLocalPath=path.join(__dirname,"../../.env.local"),dotenvPath=path.join(__dirname,"../../.env");fs.existsSync(dotenvLocalPath)?(require("dotenv").config({path:dotenvLocalPath}),logger.debug("[MCP Server] Loaded .env.local")):fs.existsSync(dotenvPath)&&(require("dotenv").config({path:dotenvPath}),logger.debug("[MCP Server] Loaded .env"));const KEYWORD=process.env.BLUELAMP_KEYWORD||"BL-要件定義",TOKEN=process.env.BLUELAMP_TOKEN,PORTAL_URL=process.env.PORTAL_URL||"https://bluelamp-6clpzmy5pa-an.a.run.app",LOG_DIR=path.join(os.homedir(),".bluelamp-vscode","logs"),LOG_FILE=path.join(LOG_DIR,"mcp.log");function log(e){const r=`[${(new Date).toISOString()}] ${e}\n`;fs.appendFileSync(LOG_FILE,r),logger.info(`[MCP Server] ${e}`)}fs.existsSync(LOG_DIR)||fs.mkdirSync(LOG_DIR,{recursive:!0}),log(`MCP Server started - Log file: ${LOG_FILE}`),log("Environment variables:"),log(` KEYWORD: ${KEYWORD}`),log(" TOKEN: "+(TOKEN?TOKEN.substring(0,20)+"...":"NOT SET")),log(` PORTAL_URL: ${PORTAL_URL}`),log(` .env file exists: ${fs.existsSync(dotenvPath)}`);class BlueLampVSCodeServer{constructor(){this.server=new Server({name:"bluelamp-vscode",version:"1.0.0"},{capabilities:{tools:{}}}),this.setupHandlers()}setupHandlers(){this.server.setRequestHandler(ListToolsRequestSchema,async()=>(log("[MCP Server] ListTools request received"),{tools:[{name:"inject_knowledge",description:"BlueLamp VSCode開発プロンプトの知識を注入",inputSchema:{type:"object",properties:{keyword:{type:"string",description:"キーワード(@相談 など、そのまま指定してください。プレフィックスの追加は不要です)"}},required:["keyword"]}}]})),this.server.setRequestHandler(CallToolRequestSchema,async e=>{if("inject_knowledge"===e.params.name){const{keyword:r}=e.params.arguments;log(`[MCP Server] inject_knowledge called with keyword: ${r}`),log("[MCP Server] TOKEN: "+(TOKEN?TOKEN.substring(0,20)+"...":"missing")),log(`[MCP Server] PORTAL_URL: ${PORTAL_URL}`);try{const e=await getPromptFromPortal(r,TOKEN);if(!e||!e.success){const t=e?.error||`キーワード "${r}" に対応する知識が見つかりませんでした`;return log(`[MCP Server] Knowledge injection failed: ${t}`),{content:[{type:"text",text:`❌ Portal APIから知識を取得できませんでした: ${t}`}],isError:!0}}return{content:[{type:"text",text:`✅ BlueLamp VSCode 知識注入完了\n\n${e.knowledge}\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n専門知識が注入されました。このロールで支援を開始します。`}]}}catch(e){return log(`[MCP Server] Exception in inject_knowledge: ${e.message}`),{content:[{type:"text",text:`❌ 知識注入中にエラーが発生しました: ${e.message}`}],isError:!0}}}return{content:[{type:"text",text:`Unknown tool: ${e.params.name}`}],isError:!0}})}async run(){const e=new StdioServerTransport;if(await this.server.connect(e),logger.info("BlueLamp VSCode MCP server started"),KEYWORD&&TOKEN){log(`[MCP Server] Auto-injecting knowledge for keyword: ${KEYWORD}`);const e=await getPromptFromPortal(KEYWORD,TOKEN);e&&e.success?log(`[MCP Server] Auto-injection successful: ${e.title}`):log(`[MCP Server] Auto-injection failed for keyword: ${KEYWORD}`)}}}const server=new BlueLampVSCodeServer;server.run().catch(e=>logger.error(e.message));