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/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "bluelamp",
3
- "version": "3.0.8",
4
- "description": "BlueLamp - AI Agent Orchestration System with Production Portal Integration (Release Build)",
5
- "main": "lib/mcp-server/dist/index.js",
3
+ "version": "4.0.0",
4
+ "description": "BlueLamp MCP Integration - Fast Startup with SessionStart Hook",
5
+ "main": "lib/mcp-server/index.cjs",
6
6
  "bin": {
7
- "bluelamp": "./bin/bluelamp",
7
+ "bluelamp1": "./bin/bluelamp1",
8
8
  "bluelamp2": "./bin/bluelamp2",
9
9
  "bluelamp3": "./bin/bluelamp3",
10
10
  "bluelamp4": "./bin/bluelamp4",
@@ -22,123 +22,39 @@
22
22
  "bluelamp16": "./bin/bluelamp16",
23
23
  "bluelamp17": "./bin/bluelamp17",
24
24
  "bluelamp18": "./bin/bluelamp18",
25
- "bluelamp19": "./bin/bluelamp19",
26
- "bluelamp20": "./bin/bluelamp20",
27
- "bluelamp21": "./bin/bluelamp21",
28
- "bluelamp22": "./bin/bluelamp22",
29
- "bluelamp23": "./bin/bluelamp23",
30
- "bluelamp24": "./bin/bluelamp24",
31
- "bluelamp25": "./bin/bluelamp25",
32
- "bluelamp26": "./bin/bluelamp26",
33
- "bluelamp27": "./bin/bluelamp27",
34
- "bluelamp28": "./bin/bluelamp28",
35
- "bluelamp29": "./bin/bluelamp29",
36
- "bluelamp30": "./bin/bluelamp30",
37
- "bluelamp31": "./bin/bluelamp31",
38
- "bluelamp32": "./bin/bluelamp32",
39
- "bluelamp33": "./bin/bluelamp33",
40
- "bluelamp34": "./bin/bluelamp34",
41
- "bluelamp35": "./bin/bluelamp35",
42
- "bluelamp36": "./bin/bluelamp36",
43
- "bluelamp37": "./bin/bluelamp37",
44
- "bluelamp38": "./bin/bluelamp38",
45
- "bluelamp39": "./bin/bluelamp39",
46
- "bluelamp40": "./bin/bluelamp40",
47
- "bluelamp41": "./bin/bluelamp41",
48
- "bluelamp42": "./bin/bluelamp42",
49
- "bluelamp43": "./bin/bluelamp43",
50
- "bluelamp44": "./bin/bluelamp44",
51
- "bluelamp45": "./bin/bluelamp45",
52
- "bluelamp46": "./bin/bluelamp46",
53
- "bluelamp47": "./bin/bluelamp47",
54
- "bluelamp48": "./bin/bluelamp48",
55
- "bluelamp49": "./bin/bluelamp49",
56
- "bluelamp50": "./bin/bluelamp50",
57
- "bluelamp51": "./bin/bluelamp51",
58
- "bluelamp52": "./bin/bluelamp52",
59
- "bluelamp53": "./bin/bluelamp53",
60
- "bluelamp54": "./bin/bluelamp54",
61
- "bluelamp55": "./bin/bluelamp55",
62
- "bluelamp56": "./bin/bluelamp56",
63
- "bluelamp57": "./bin/bluelamp57",
64
- "bluelamp58": "./bin/bluelamp58",
65
- "bluelamp59": "./bin/bluelamp59",
66
- "bluelamp60": "./bin/bluelamp60",
67
- "bluelamp61": "./bin/bluelamp61",
68
- "bluelamp62": "./bin/bluelamp62",
69
- "bluelamp63": "./bin/bluelamp63",
70
- "bluelamp64": "./bin/bluelamp64",
71
- "bluelamp65": "./bin/bluelamp65",
72
- "bluelamp66": "./bin/bluelamp66",
73
- "bluelamp67": "./bin/bluelamp67",
74
- "bluelamp68": "./bin/bluelamp68",
75
- "bluelamp69": "./bin/bluelamp69",
76
- "bluelamp70": "./bin/bluelamp70",
77
- "bluelamp71": "./bin/bluelamp71",
78
- "bluelamp72": "./bin/bluelamp72",
79
- "bluelamp73": "./bin/bluelamp73",
80
- "bluelamp74": "./bin/bluelamp74",
81
- "bluelamp75": "./bin/bluelamp75",
82
- "bluelamp76": "./bin/bluelamp76",
83
- "bluelamp77": "./bin/bluelamp77",
84
- "bluelamp78": "./bin/bluelamp78",
85
- "bluelamp79": "./bin/bluelamp79",
86
- "bluelamp80": "./bin/bluelamp80",
87
- "bluelamp81": "./bin/bluelamp81",
88
- "bluelamp82": "./bin/bluelamp82",
89
- "bluelamp83": "./bin/bluelamp83",
90
- "bluelamp84": "./bin/bluelamp84",
91
- "bluelamp85": "./bin/bluelamp85",
92
- "bluelamp86": "./bin/bluelamp86",
93
- "bluelamp87": "./bin/bluelamp87",
94
- "bluelamp88": "./bin/bluelamp88",
95
- "bluelamp89": "./bin/bluelamp89",
96
- "bluelamp90": "./bin/bluelamp90",
97
- "bluelamp91": "./bin/bluelamp91",
98
- "bluelamp92": "./bin/bluelamp92",
99
- "bluelamp93": "./bin/bluelamp93",
100
- "bluelamp94": "./bin/bluelamp94",
101
- "bluelamp95": "./bin/bluelamp95",
102
- "bluelamp96": "./bin/bluelamp96",
103
- "bluelamp97": "./bin/bluelamp97",
104
- "bluelamp98": "./bin/bluelamp98",
105
- "bluelamp99": "./bin/bluelamp99",
106
- "bluelamp100": "./bin/bluelamp100"
25
+ "bluelamp-hook": "./bin/bluelamp-hook"
26
+ },
27
+ "scripts": {
28
+ "postinstall": "node scripts/generate-commands.js && node scripts/setup-hook.js",
29
+ "test": "node test-mcp.js"
107
30
  },
108
31
  "keywords": [
109
- "ai",
110
- "claude",
32
+ "bluelamp",
111
33
  "mcp",
112
- "agents",
113
- "orchestration",
114
- "knowledge-injection"
34
+ "claude",
35
+ "knowledge-injection",
36
+ "fast-startup"
115
37
  ],
116
38
  "author": "BlueLamp Team",
117
39
  "license": "MIT",
118
- "engines": {
119
- "node": ">=18"
120
- },
121
40
  "dependencies": {
122
- "@leonardo-ai/sdk": "^4.20.0",
123
41
  "@modelcontextprotocol/sdk": "^1.0.0",
42
+ "dotenv": "^16.6.1",
124
43
  "jsonwebtoken": "^9.0.2",
125
- "node-fetch": "^3.3.2",
126
- "sharp": "^0.33.0",
127
- "zod": "^3.22.4"
128
- },
129
- "preferGlobal": true,
130
- "repository": {
131
- "type": "git",
132
- "url": "https://github.com/bluelamp/bluelamp.git"
44
+ "node-fetch": "^3.3.2"
133
45
  },
134
- "bugs": {
135
- "url": "https://github.com/bluelamp/bluelamp/issues"
46
+ "engines": {
47
+ "node": ">=18"
136
48
  },
137
- "homepage": "https://github.com/bluelamp/bluelamp#readme",
138
49
  "files": [
139
50
  "bin/",
140
51
  "lib/",
141
- "config/",
52
+ "scripts/",
142
53
  "README.md"
143
- ]
54
+ ],
55
+ "preferGlobal": true,
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "https://github.com/bluelamp/bluelamp.git"
59
+ }
144
60
  }
@@ -0,0 +1,426 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * BlueLamp VSCode Extension - Release Build Script with Advanced Obfuscation
4
+ *
5
+ * 高度難読化を適用したリリースビルドを生成
6
+ *
7
+ * 主要機能:
8
+ * - JavaScript Obfuscatorによる高度難読化
9
+ * - クリーンな出力ディレクトリ構造の維持
10
+ * - 配布用package.jsonの最適化
11
+ * - エラーハンドリングと進行状況表示
12
+ */
13
+
14
+ const fs = require('fs').promises;
15
+ const path = require('path');
16
+
17
+ // 設定定数
18
+ const PROJECT_ROOT = path.dirname(__dirname);
19
+ const VERSION = '2.2.5';
20
+ const RELEASE_DIR = path.join(PROJECT_ROOT, 'release');
21
+ const OUTPUT_DIR = path.join(RELEASE_DIR, `bluelamp-vscode-v${VERSION}`);
22
+
23
+ // 高度難読化設定(全ファイル用 - ログ出力保護)
24
+ const HIGH_OBFUSCATION_OPTIONS = {
25
+ compact: true,
26
+ controlFlowFlattening: true,
27
+ controlFlowFlatteningThreshold: 0.75,
28
+ deadCodeInjection: true,
29
+ deadCodeInjectionThreshold: 0.4,
30
+ debugProtection: true,
31
+ debugProtectionInterval: 4000,
32
+ disableConsoleOutput: false, // ログ出力を保護
33
+ identifierNamesGenerator: 'hexadecimal',
34
+ log: false,
35
+ numbersToExpressions: true,
36
+ renameGlobals: true,
37
+ selfDefending: true,
38
+ simplify: true,
39
+ splitStrings: true,
40
+ splitStringsChunkLength: 5,
41
+ stringArray: true,
42
+ stringArrayCallsTransform: true,
43
+ stringArrayCallsTransformThreshold: 0.8,
44
+ stringArrayEncoding: ['base64'],
45
+ stringArrayIndexShift: true,
46
+ stringArrayRotate: true,
47
+ stringArrayShuffle: true,
48
+ stringArrayWrappersCount: 2,
49
+ stringArrayWrappersChainedCalls: true,
50
+ stringArrayWrappersParametersMaxCount: 4,
51
+ stringArrayWrappersType: 'function',
52
+ stringArrayThreshold: 0.8,
53
+ transformObjectKeys: true,
54
+ unicodeEscapeSequence: false
55
+ };
56
+
57
+ // 軽度難読化設定(現在未使用 - 全て高度難読化に変更済み)
58
+ const LIGHT_OBFUSCATION_OPTIONS = {
59
+ compact: true,
60
+ controlFlowFlattening: false,
61
+ deadCodeInjection: false,
62
+ debugProtection: false,
63
+ disableConsoleOutput: false, // console.logを保護
64
+ identifierNamesGenerator: 'mangled',
65
+ log: false,
66
+ renameGlobals: false,
67
+ selfDefending: false,
68
+ simplify: true,
69
+ stringArray: false, // 文字列配列を無効化(日本語保護)
70
+ stringArrayEncoding: [],
71
+ stringArrayThreshold: 0, // 文字列変換を完全に無効化
72
+ transformObjectKeys: false,
73
+ unicodeEscapeSequence: false
74
+ };
75
+
76
+ // 対象ファイルパターン
77
+ const TARGET_PATTERNS = {
78
+ lib: {
79
+ auth: ['*.js'],
80
+ 'mcp-server': ['*.cjs', '*.js']
81
+ },
82
+ bin: ['bluelamp-vscode-base'],
83
+ scripts: ['*.js']
84
+ };
85
+
86
+ /**
87
+ * コンソール出力ユーティリティ
88
+ */
89
+ class Logger {
90
+ static info(message) {
91
+ console.log(`\x1b[36m[INFO]\x1b[0m ${message}`);
92
+ }
93
+
94
+ static success(message) {
95
+ console.log(`\x1b[32m[SUCCESS]\x1b[0m ${message}`);
96
+ }
97
+
98
+ static warn(message) {
99
+ console.log(`\x1b[33m[WARN]\x1b[0m ${message}`);
100
+ }
101
+
102
+ static error(message) {
103
+ console.log(`\x1b[31m[ERROR]\x1b[0m ${message}`);
104
+ }
105
+
106
+ static step(step, total, message) {
107
+ console.log(`\x1b[34m[${step}/${total}]\x1b[0m ${message}`);
108
+ }
109
+ }
110
+
111
+ /**
112
+ * ディレクトリの作成
113
+ */
114
+ async function ensureDirectory(dirPath) {
115
+ try {
116
+ await fs.access(dirPath);
117
+ } catch {
118
+ await fs.mkdir(dirPath, { recursive: true });
119
+ }
120
+ }
121
+
122
+ /**
123
+ * ディレクトリの完全削除
124
+ */
125
+ async function removeDirectory(dirPath) {
126
+ try {
127
+ await fs.access(dirPath);
128
+ await fs.rm(dirPath, { recursive: true, force: true });
129
+ } catch {
130
+ // ディレクトリが存在しない場合は無視
131
+ }
132
+ }
133
+
134
+ /**
135
+ * JavaScript Obfuscatorのロード
136
+ */
137
+ function loadObfuscator() {
138
+ try {
139
+ return require('javascript-obfuscator');
140
+ } catch (error) {
141
+ Logger.error('javascript-obfuscator package not found. Installing...');
142
+ console.log('Run: npm install javascript-obfuscator --save-dev');
143
+ process.exit(1);
144
+ }
145
+ }
146
+
147
+ /**
148
+ * ファイルの難読化
149
+ */
150
+ async function obfuscateFile(inputPath, outputPath, obfuscationType = 'high') {
151
+ const JavaScriptObfuscator = loadObfuscator();
152
+ try {
153
+ const sourceCode = await fs.readFile(inputPath, 'utf8');
154
+
155
+ // shebang行を保持
156
+ let shebang = '';
157
+ let codeToObfuscate = sourceCode;
158
+
159
+ if (sourceCode.startsWith('#!')) {
160
+ const firstNewline = sourceCode.indexOf('\n');
161
+ shebang = sourceCode.substring(0, firstNewline + 1);
162
+ codeToObfuscate = sourceCode.substring(firstNewline + 1);
163
+ }
164
+
165
+ // 難読化オプションを選択
166
+ const obfuscationOptions = obfuscationType === 'light'
167
+ ? LIGHT_OBFUSCATION_OPTIONS
168
+ : HIGH_OBFUSCATION_OPTIONS;
169
+
170
+ // 難読化実行
171
+ const obfuscatedCode = JavaScriptObfuscator.obfuscate(codeToObfuscate, obfuscationOptions);
172
+
173
+ // shebang + 難読化コードを結合
174
+ const finalCode = shebang + obfuscatedCode.getObfuscatedCode();
175
+
176
+ // 出力ディレクトリを確保
177
+ await ensureDirectory(path.dirname(outputPath));
178
+
179
+ // ファイル書き込み
180
+ await fs.writeFile(outputPath, finalCode, 'utf8');
181
+
182
+ // 実行権限の復元(binファイルの場合)
183
+ if (outputPath.includes('/bin/')) {
184
+ await fs.chmod(outputPath, 0o755);
185
+ }
186
+
187
+ return true;
188
+ } catch (error) {
189
+ Logger.error(`Failed to obfuscate ${inputPath}: ${error.message}`);
190
+ return false;
191
+ }
192
+ }
193
+
194
+ /**
195
+ * ファイルの単純コピー
196
+ */
197
+ async function copyFile(inputPath, outputPath) {
198
+ try {
199
+ await ensureDirectory(path.dirname(outputPath));
200
+ await fs.copyFile(inputPath, outputPath);
201
+ return true;
202
+ } catch (error) {
203
+ Logger.error(`Failed to copy ${inputPath}: ${error.message}`);
204
+ return false;
205
+ }
206
+ }
207
+
208
+ /**
209
+ * 対象ファイルの収集
210
+ */
211
+ async function collectTargetFiles() {
212
+ const files = [];
213
+
214
+ // lib/auth/*.js
215
+ const authDir = path.join(PROJECT_ROOT, 'lib', 'auth');
216
+ try {
217
+ const authFiles = await fs.readdir(authDir);
218
+ for (const file of authFiles) {
219
+ if (file.endsWith('.js')) {
220
+ files.push({
221
+ input: path.join(authDir, file),
222
+ output: path.join(OUTPUT_DIR, 'lib', 'auth', file),
223
+ type: 'obfuscate',
224
+ obfuscationType: 'high' // 認証モジュールも高度難読化
225
+ });
226
+ }
227
+ }
228
+ } catch (error) {
229
+ Logger.warn(`lib/auth directory not found: ${error.message}`);
230
+ }
231
+
232
+ // lib/mcp-server/*.{cjs,js}
233
+ const mcpDir = path.join(PROJECT_ROOT, 'lib', 'mcp-server');
234
+ try {
235
+ const mcpFiles = await fs.readdir(mcpDir);
236
+ for (const file of mcpFiles) {
237
+ if (file.endsWith('.cjs') || file.endsWith('.js')) {
238
+ files.push({
239
+ input: path.join(mcpDir, file),
240
+ output: path.join(OUTPUT_DIR, 'lib', 'mcp-server', file),
241
+ type: 'obfuscate',
242
+ obfuscationType: 'high'
243
+ });
244
+ }
245
+ }
246
+ } catch (error) {
247
+ Logger.warn(`lib/mcp-server directory not found: ${error.message}`);
248
+ }
249
+
250
+ // bin/bluelamp-vscode-base
251
+ const baseScript = path.join(PROJECT_ROOT, 'bin', 'bluelamp-vscode-base');
252
+ try {
253
+ await fs.access(baseScript);
254
+ files.push({
255
+ input: baseScript,
256
+ output: path.join(OUTPUT_DIR, 'bin', 'bluelamp-vscode-base'),
257
+ type: 'obfuscate', // 高度難読化を適用
258
+ obfuscationType: 'high'
259
+ });
260
+ } catch (error) {
261
+ Logger.warn(`bin/bluelamp-vscode-base not found: ${error.message}`);
262
+ }
263
+
264
+ // 他のbinファイル(高度難読化)
265
+ const binDir = path.join(PROJECT_ROOT, 'bin');
266
+ try {
267
+ const binFiles = await fs.readdir(binDir);
268
+ for (const file of binFiles) {
269
+ if (file !== 'bluelamp-vscode-base' && file.startsWith('bluelamp-vscode')) {
270
+ files.push({
271
+ input: path.join(binDir, file),
272
+ output: path.join(OUTPUT_DIR, 'bin', file),
273
+ type: 'obfuscate',
274
+ obfuscationType: 'high'
275
+ });
276
+ }
277
+ }
278
+ } catch (error) {
279
+ Logger.warn(`bin directory not found: ${error.message}`);
280
+ }
281
+
282
+ return files;
283
+ }
284
+
285
+ /**
286
+ * 配布用package.jsonの生成
287
+ */
288
+ async function generateReleasePackageJson() {
289
+ try {
290
+ const packageJsonPath = path.join(PROJECT_ROOT, 'package.json');
291
+ const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
292
+
293
+ // 配布用に最適化
294
+ const releasePackageJson = {
295
+ name: packageJson.name,
296
+ version: VERSION,
297
+ description: packageJson.description + ' (Obfuscated Release)',
298
+ main: packageJson.main,
299
+ bin: packageJson.bin,
300
+ keywords: packageJson.keywords,
301
+ author: packageJson.author,
302
+ license: packageJson.license,
303
+ dependencies: packageJson.dependencies,
304
+ engines: packageJson.engines,
305
+ files: packageJson.files,
306
+ preferGlobal: packageJson.preferGlobal,
307
+ repository: packageJson.repository
308
+ };
309
+
310
+ const outputPath = path.join(OUTPUT_DIR, 'package.json');
311
+ await fs.writeFile(outputPath, JSON.stringify(releasePackageJson, null, 2), 'utf8');
312
+
313
+ Logger.success('Generated release package.json');
314
+ return true;
315
+ } catch (error) {
316
+ Logger.error(`Failed to generate package.json: ${error.message}`);
317
+ return false;
318
+ }
319
+ }
320
+
321
+ /**
322
+ * READMEのコピー
323
+ */
324
+ async function copyReadme() {
325
+ try {
326
+ const readmePath = path.join(PROJECT_ROOT, 'README.md');
327
+ const outputPath = path.join(OUTPUT_DIR, 'README.md');
328
+ await copyFile(readmePath, outputPath);
329
+ Logger.success('Copied README.md');
330
+ return true;
331
+ } catch (error) {
332
+ Logger.error(`Failed to copy README.md: ${error.message}`);
333
+ return false;
334
+ }
335
+ }
336
+
337
+ /**
338
+ * メイン処理
339
+ */
340
+ async function main() {
341
+ const startTime = Date.now();
342
+
343
+ Logger.info('🚀 Starting BlueLamp VSCode Release Build with Advanced Obfuscation');
344
+ Logger.info(`📂 Output directory: ${OUTPUT_DIR}`);
345
+
346
+ try {
347
+ // Step 1: クリーンアップ
348
+ Logger.step(1, 6, 'Cleaning release directory...');
349
+ await removeDirectory(RELEASE_DIR);
350
+ await ensureDirectory(OUTPUT_DIR);
351
+
352
+ // Step 2: 対象ファイルの収集
353
+ Logger.step(2, 6, 'Collecting target files...');
354
+ const targetFiles = await collectTargetFiles();
355
+ Logger.info(`📄 Found ${targetFiles.length} files to process`);
356
+
357
+ // Step 3: ファイル処理
358
+ Logger.step(3, 6, 'Processing files with obfuscation...');
359
+ let processedCount = 0;
360
+ let errorCount = 0;
361
+
362
+ for (const file of targetFiles) {
363
+ const fileName = path.basename(file.input);
364
+
365
+ if (file.type === 'obfuscate') {
366
+ const obfType = file.obfuscationType || 'high';
367
+ Logger.info(`🔒 Obfuscating (${obfType}): ${fileName}`);
368
+ const success = await obfuscateFile(file.input, file.output, obfType);
369
+ if (success) {
370
+ processedCount++;
371
+ } else {
372
+ errorCount++;
373
+ }
374
+ } else {
375
+ Logger.info(`📋 Copying: ${fileName}`);
376
+ const success = await copyFile(file.input, file.output);
377
+ if (success) {
378
+ processedCount++;
379
+ } else {
380
+ errorCount++;
381
+ }
382
+ }
383
+ }
384
+
385
+ // Step 4: package.json生成
386
+ Logger.step(4, 6, 'Generating release package.json...');
387
+ await generateReleasePackageJson();
388
+
389
+ // Step 5: README.mdコピー
390
+ Logger.step(5, 6, 'Copying documentation...');
391
+ await copyReadme();
392
+
393
+ // Step 6: 完了報告
394
+ Logger.step(6, 6, 'Build completed!');
395
+
396
+ const endTime = Date.now();
397
+ const duration = ((endTime - startTime) / 1000).toFixed(2);
398
+
399
+ Logger.success('✅ Release build completed successfully!');
400
+ Logger.info(`📊 Processed: ${processedCount} files, Errors: ${errorCount}`);
401
+ Logger.info(`⏱️ Build time: ${duration} seconds`);
402
+ Logger.info(`📦 Release package: ${OUTPUT_DIR}`);
403
+
404
+ if (errorCount > 0) {
405
+ Logger.warn('⚠️ Some files could not be processed. Check the logs above.');
406
+ process.exit(1);
407
+ }
408
+
409
+ } catch (error) {
410
+ Logger.error(`❌ Build failed: ${error.message}`);
411
+ Logger.error(error.stack);
412
+ process.exit(1);
413
+ }
414
+ }
415
+
416
+ // スクリプトを実行
417
+ if (require.main === module) {
418
+ main();
419
+ }
420
+
421
+ module.exports = {
422
+ main,
423
+ HIGH_OBFUSCATION_OPTIONS,
424
+ LIGHT_OBFUSCATION_OPTIONS,
425
+ obfuscateFile
426
+ };
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * BlueLamp コマンド生成スクリプト
5
+ * 18個のコマンドファイルを自動生成
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ const binDir = path.join(__dirname, '..', 'bin');
12
+ const baseScript = path.join(binDir, 'bluelamp-base');
13
+ const hookScript = path.join(binDir, 'bluelamp-hook');
14
+
15
+ // 18個のコマンドを生成
16
+ for (let i = 1; i <= 18; i++) {
17
+ const commandName = `bluelamp${i}`;
18
+ const commandPath = path.join(binDir, commandName);
19
+
20
+ const content = `#!/usr/bin/env node
21
+ require('./bluelamp-base');
22
+ `;
23
+
24
+ fs.writeFileSync(commandPath, content);
25
+ fs.chmodSync(commandPath, '755');
26
+
27
+ console.log(`✅ Created: ${commandName}`);
28
+ }
29
+
30
+ // ベーススクリプトに実行権限を付与
31
+ if (fs.existsSync(baseScript)) {
32
+ fs.chmodSync(baseScript, '755');
33
+ }
34
+
35
+ // Hookスクリプトに実行権限を付与
36
+ if (fs.existsSync(hookScript)) {
37
+ fs.chmodSync(hookScript, '755');
38
+ }
39
+
40
+ console.log('\n✨ 18個のコマンドファイルを生成しました');