bluelamp 4.0.14 → 4.0.16

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 (113) hide show
  1. package/bin/bluelamp-vscode-base +1 -317
  2. package/bin/bluelamp1 +0 -0
  3. package/bin/bluelamp10 +0 -0
  4. package/bin/bluelamp100 +0 -0
  5. package/bin/bluelamp11 +0 -0
  6. package/bin/bluelamp12 +0 -0
  7. package/bin/bluelamp13 +0 -0
  8. package/bin/bluelamp14 +0 -0
  9. package/bin/bluelamp15 +0 -0
  10. package/bin/bluelamp16 +0 -0
  11. package/bin/bluelamp17 +0 -0
  12. package/bin/bluelamp18 +0 -0
  13. package/bin/bluelamp19 +0 -0
  14. package/bin/bluelamp2 +0 -0
  15. package/bin/bluelamp20 +0 -0
  16. package/bin/bluelamp21 +0 -0
  17. package/bin/bluelamp22 +0 -0
  18. package/bin/bluelamp23 +0 -0
  19. package/bin/bluelamp24 +0 -0
  20. package/bin/bluelamp25 +0 -0
  21. package/bin/bluelamp26 +0 -0
  22. package/bin/bluelamp27 +0 -0
  23. package/bin/bluelamp28 +0 -0
  24. package/bin/bluelamp29 +0 -0
  25. package/bin/bluelamp3 +0 -0
  26. package/bin/bluelamp30 +0 -0
  27. package/bin/bluelamp31 +0 -0
  28. package/bin/bluelamp32 +0 -0
  29. package/bin/bluelamp33 +0 -0
  30. package/bin/bluelamp34 +0 -0
  31. package/bin/bluelamp35 +0 -0
  32. package/bin/bluelamp36 +0 -0
  33. package/bin/bluelamp37 +0 -0
  34. package/bin/bluelamp38 +0 -0
  35. package/bin/bluelamp39 +0 -0
  36. package/bin/bluelamp4 +0 -0
  37. package/bin/bluelamp40 +0 -0
  38. package/bin/bluelamp41 +0 -0
  39. package/bin/bluelamp42 +0 -0
  40. package/bin/bluelamp43 +0 -0
  41. package/bin/bluelamp44 +0 -0
  42. package/bin/bluelamp45 +0 -0
  43. package/bin/bluelamp46 +0 -0
  44. package/bin/bluelamp47 +0 -0
  45. package/bin/bluelamp48 +0 -0
  46. package/bin/bluelamp49 +0 -0
  47. package/bin/bluelamp5 +0 -0
  48. package/bin/bluelamp50 +0 -0
  49. package/bin/bluelamp51 +0 -0
  50. package/bin/bluelamp52 +0 -0
  51. package/bin/bluelamp53 +0 -0
  52. package/bin/bluelamp54 +0 -0
  53. package/bin/bluelamp55 +0 -0
  54. package/bin/bluelamp56 +0 -0
  55. package/bin/bluelamp57 +0 -0
  56. package/bin/bluelamp58 +0 -0
  57. package/bin/bluelamp59 +0 -0
  58. package/bin/bluelamp6 +0 -0
  59. package/bin/bluelamp60 +0 -0
  60. package/bin/bluelamp61 +0 -0
  61. package/bin/bluelamp62 +0 -0
  62. package/bin/bluelamp63 +0 -0
  63. package/bin/bluelamp64 +0 -0
  64. package/bin/bluelamp65 +0 -0
  65. package/bin/bluelamp66 +0 -0
  66. package/bin/bluelamp67 +0 -0
  67. package/bin/bluelamp68 +0 -0
  68. package/bin/bluelamp69 +0 -0
  69. package/bin/bluelamp7 +0 -0
  70. package/bin/bluelamp70 +0 -0
  71. package/bin/bluelamp71 +0 -0
  72. package/bin/bluelamp72 +0 -0
  73. package/bin/bluelamp73 +0 -0
  74. package/bin/bluelamp74 +0 -0
  75. package/bin/bluelamp75 +0 -0
  76. package/bin/bluelamp76 +0 -0
  77. package/bin/bluelamp77 +0 -0
  78. package/bin/bluelamp78 +0 -0
  79. package/bin/bluelamp79 +0 -0
  80. package/bin/bluelamp8 +0 -0
  81. package/bin/bluelamp80 +0 -0
  82. package/bin/bluelamp81 +0 -0
  83. package/bin/bluelamp82 +0 -0
  84. package/bin/bluelamp83 +0 -0
  85. package/bin/bluelamp84 +0 -0
  86. package/bin/bluelamp85 +0 -0
  87. package/bin/bluelamp86 +0 -0
  88. package/bin/bluelamp87 +0 -0
  89. package/bin/bluelamp88 +0 -0
  90. package/bin/bluelamp89 +0 -0
  91. package/bin/bluelamp9 +0 -0
  92. package/bin/bluelamp90 +0 -0
  93. package/bin/bluelamp91 +0 -0
  94. package/bin/bluelamp92 +0 -0
  95. package/bin/bluelamp93 +0 -0
  96. package/bin/bluelamp94 +0 -0
  97. package/bin/bluelamp95 +0 -0
  98. package/bin/bluelamp96 +0 -0
  99. package/bin/bluelamp97 +0 -0
  100. package/bin/bluelamp98 +0 -0
  101. package/bin/bluelamp99 +0 -0
  102. package/lib/auth/InteractiveLogin.js +1 -243
  103. package/lib/auth/PortalAuthClient.js +1 -187
  104. package/lib/auth/TokenManager.js +1 -258
  105. package/lib/mcp-server/index.cjs +1 -195
  106. package/lib/mcp-server/portal-api-client.cjs +1 -286
  107. package/lib/utils/logger.js +1 -83
  108. package/package.json +7 -17
  109. package/scripts/generate-commands.js +1 -44
  110. package/scripts/playwright-launch.js +2 -0
  111. package/scripts/setup-playwright.js +2 -0
  112. package/README.md +0 -78
  113. package/scripts/build.js +0 -339
package/scripts/build.js DELETED
@@ -1,339 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * BlueLamp CLI - Production Build Script
4
- *
5
- * 2段階難読化戦略:
6
- * - Terser: 一般ファイル(軽量縮小化)
7
- * - javascript-obfuscator HIGH: 機密ファイル(強力な保護)
8
- */
9
-
10
- const fs = require('fs').promises;
11
- const path = require('path');
12
-
13
- const PROJECT_ROOT = path.dirname(__dirname);
14
- const SRC_DIR = PROJECT_ROOT; // 現在はsrc/なし、後で移行
15
- const DIST_DIR = path.join(PROJECT_ROOT, 'dist');
16
-
17
- // 機密ファイル(HIGH難読化対象)
18
- const SENSITIVE_FILES = [
19
- 'lib/auth/InteractiveLogin.js',
20
- 'lib/auth/PortalAuthClient.js',
21
- 'lib/auth/TokenManager.js',
22
- 'lib/mcp-server/portal-api-client.cjs',
23
- 'bin/bluelamp-vscode-base'
24
- ];
25
-
26
- // 非処理ファイル(そのままコピー)
27
- const COPY_ONLY_FILES = [
28
- 'lib/agents/ブルーランプ.md'
29
- ];
30
-
31
- // HIGH難読化設定(機密ファイル用)
32
- const HIGH_OBFUSCATION_OPTIONS = {
33
- compact: true,
34
- controlFlowFlattening: true,
35
- controlFlowFlatteningThreshold: 0.75,
36
- deadCodeInjection: true,
37
- deadCodeInjectionThreshold: 0.4,
38
- debugProtection: true,
39
- debugProtectionInterval: 4000,
40
- disableConsoleOutput: false,
41
- identifierNamesGenerator: 'hexadecimal',
42
- log: false,
43
- numbersToExpressions: true,
44
- renameGlobals: true,
45
- selfDefending: true,
46
- simplify: true,
47
- splitStrings: true,
48
- splitStringsChunkLength: 5,
49
- stringArray: true,
50
- stringArrayCallsTransform: true,
51
- stringArrayCallsTransformThreshold: 0.8,
52
- stringArrayEncoding: ['base64'],
53
- stringArrayIndexShift: true,
54
- stringArrayRotate: true,
55
- stringArrayShuffle: true,
56
- stringArrayWrappersCount: 2,
57
- stringArrayWrappersChainedCalls: true,
58
- stringArrayWrappersParametersMaxCount: 4,
59
- stringArrayWrappersType: 'function',
60
- stringArrayThreshold: 0.8,
61
- transformObjectKeys: true,
62
- unicodeEscapeSequence: false
63
- };
64
-
65
- // Terser設定(一般ファイル用)
66
- const TERSER_OPTIONS = {
67
- compress: {
68
- dead_code: true,
69
- drop_console: false,
70
- drop_debugger: true,
71
- passes: 2
72
- },
73
- mangle: {
74
- reserved: ['require', 'module', 'exports', 'process', '__dirname', '__filename']
75
- },
76
- format: {
77
- comments: false
78
- }
79
- };
80
-
81
- class Logger {
82
- static info(msg) { console.log(`\x1b[36m[INFO]\x1b[0m ${msg}`); }
83
- static success(msg) { console.log(`\x1b[32m[OK]\x1b[0m ${msg}`); }
84
- static warn(msg) { console.log(`\x1b[33m[WARN]\x1b[0m ${msg}`); }
85
- static error(msg) { console.log(`\x1b[31m[ERROR]\x1b[0m ${msg}`); }
86
- }
87
-
88
- async function ensureDir(dirPath) {
89
- try {
90
- await fs.mkdir(dirPath, { recursive: true });
91
- } catch (e) {
92
- if (e.code !== 'EEXIST') throw e;
93
- }
94
- }
95
-
96
- async function cleanDir(dirPath) {
97
- try {
98
- await fs.rm(dirPath, { recursive: true, force: true });
99
- } catch (e) {
100
- // ignore
101
- }
102
- await ensureDir(dirPath);
103
- }
104
-
105
- function isSensitiveFile(relativePath) {
106
- return SENSITIVE_FILES.some(sf => relativePath.endsWith(sf) || relativePath === sf);
107
- }
108
-
109
- function isCopyOnlyFile(relativePath) {
110
- return COPY_ONLY_FILES.some(cf => relativePath.endsWith(cf) || relativePath === cf);
111
- }
112
-
113
- function isJavaScriptFile(filePath) {
114
- // .js, .cjs, または拡張子なしのbin/ファイル(bluelamp-vscode-base)
115
- if (filePath.endsWith('.js') || filePath.endsWith('.cjs')) return true;
116
- // bin/bluelamp-vscode-base は拡張子がないがJSファイル
117
- if (filePath.includes('bin/bluelamp-vscode-base')) return true;
118
- return false;
119
- }
120
-
121
- async function processWithTerser(code, filePath) {
122
- try {
123
- const { minify } = require('terser');
124
- const result = await minify(code, TERSER_OPTIONS);
125
- if (result.error) throw result.error;
126
- return result.code;
127
- } catch (error) {
128
- Logger.warn(`Terser failed for ${filePath}, using original: ${error.message}`);
129
- return code;
130
- }
131
- }
132
-
133
- function processWithObfuscator(code) {
134
- const JavaScriptObfuscator = require('javascript-obfuscator');
135
- const result = JavaScriptObfuscator.obfuscate(code, HIGH_OBFUSCATION_OPTIONS);
136
- return result.getObfuscatedCode();
137
- }
138
-
139
- async function processFile(srcPath, destPath, relativePath) {
140
- const content = await fs.readFile(srcPath, 'utf8');
141
-
142
- // 非JSファイルまたはコピーのみファイル
143
- if (!isJavaScriptFile(srcPath) || isCopyOnlyFile(relativePath)) {
144
- await ensureDir(path.dirname(destPath));
145
- await fs.writeFile(destPath, content, 'utf8');
146
- Logger.info(`Copy: ${relativePath}`);
147
- return 'copy';
148
- }
149
-
150
- // shebang行の抽出
151
- let shebang = '';
152
- let codeToProcess = content;
153
- if (content.startsWith('#!')) {
154
- const idx = content.indexOf('\n');
155
- shebang = content.substring(0, idx + 1);
156
- codeToProcess = content.substring(idx + 1);
157
- }
158
-
159
- let processedCode;
160
- let processType;
161
-
162
- if (isSensitiveFile(relativePath)) {
163
- // 機密ファイル: HIGH難読化
164
- processedCode = processWithObfuscator(codeToProcess);
165
- processType = 'HIGH';
166
- Logger.success(`HIGH obfuscate: ${relativePath}`);
167
- } else {
168
- // 一般ファイル: Terser縮小化
169
- processedCode = await processWithTerser(codeToProcess, relativePath);
170
- processType = 'Terser';
171
- Logger.info(`Terser minify: ${relativePath}`);
172
- }
173
-
174
- const finalCode = shebang + processedCode;
175
-
176
- await ensureDir(path.dirname(destPath));
177
- await fs.writeFile(destPath, finalCode, 'utf8');
178
-
179
- // bin/ファイルの実行権限復元
180
- if (relativePath.startsWith('bin/')) {
181
- await fs.chmod(destPath, 0o755);
182
- }
183
-
184
- return processType;
185
- }
186
-
187
- async function collectFiles(dir, baseDir = dir) {
188
- const files = [];
189
- const entries = await fs.readdir(dir, { withFileTypes: true });
190
-
191
- for (const entry of entries) {
192
- const fullPath = path.join(dir, entry.name);
193
- const relativePath = path.relative(baseDir, fullPath);
194
-
195
- // 除外パターン
196
- if (entry.name.startsWith('.') ||
197
- entry.name === 'node_modules' ||
198
- entry.name === 'dist' ||
199
- entry.name === 'release' ||
200
- entry.name === 'docs' ||
201
- entry.name === 'scripts' ||
202
- entry.name === 'test-mcp.js' ||
203
- entry.name === 'test-mcp-api.js' ||
204
- entry.name.endsWith('.md') && !COPY_ONLY_FILES.includes(relativePath)) {
205
- continue;
206
- }
207
-
208
- if (entry.isDirectory()) {
209
- const subFiles = await collectFiles(fullPath, baseDir);
210
- files.push(...subFiles);
211
- } else {
212
- files.push({ fullPath, relativePath });
213
- }
214
- }
215
-
216
- return files;
217
- }
218
-
219
- async function main() {
220
- const startTime = Date.now();
221
-
222
- console.log('');
223
- console.log('╔═══════════════════════════════════════════════════════════╗');
224
- console.log('║ BlueLamp CLI - Production Build ║');
225
- console.log('║ 2-Stage Obfuscation: Terser + HIGH ║');
226
- console.log('╚═══════════════════════════════════════════════════════════╝');
227
- console.log('');
228
-
229
- // 依存関係チェック
230
- try {
231
- require('terser');
232
- require('javascript-obfuscator');
233
- } catch (e) {
234
- Logger.error('Missing dependencies. Run: npm install');
235
- process.exit(1);
236
- }
237
-
238
- // dist/をクリーン
239
- Logger.info('Cleaning dist/...');
240
- await cleanDir(DIST_DIR);
241
-
242
- // 対象ファイル収集
243
- Logger.info('Collecting files...');
244
-
245
- const targetDirs = ['bin', 'lib'];
246
- const allFiles = [];
247
-
248
- for (const dir of targetDirs) {
249
- const dirPath = path.join(SRC_DIR, dir);
250
- try {
251
- const files = await collectFiles(dirPath, SRC_DIR);
252
- allFiles.push(...files);
253
- } catch (e) {
254
- Logger.warn(`Directory not found: ${dir}`);
255
- }
256
- }
257
-
258
- Logger.info(`Found ${allFiles.length} files to process`);
259
- console.log('');
260
-
261
- // ファイル処理
262
- const stats = { terser: 0, high: 0, copy: 0, error: 0 };
263
-
264
- for (const file of allFiles) {
265
- const destPath = path.join(DIST_DIR, file.relativePath);
266
-
267
- try {
268
- const type = await processFile(file.fullPath, destPath, file.relativePath);
269
- if (type === 'Terser') stats.terser++;
270
- else if (type === 'HIGH') stats.high++;
271
- else stats.copy++;
272
- } catch (error) {
273
- Logger.error(`Failed: ${file.relativePath} - ${error.message}`);
274
- stats.error++;
275
- }
276
- }
277
-
278
- // package.json生成(dist用に調整)
279
- Logger.info('Generating dist/package.json...');
280
- const pkgPath = path.join(SRC_DIR, 'package.json');
281
- const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
282
-
283
- // binパスをdist/相対に変更しない(npm publishはdist/から行う)
284
- const distPkg = {
285
- name: pkg.name,
286
- version: pkg.version,
287
- description: pkg.description,
288
- main: pkg.main.replace('lib/', './lib/'),
289
- bin: {},
290
- keywords: pkg.keywords,
291
- author: pkg.author,
292
- license: pkg.license,
293
- dependencies: pkg.dependencies,
294
- engines: pkg.engines,
295
- files: ['bin/', 'lib/'],
296
- preferGlobal: pkg.preferGlobal,
297
- repository: pkg.repository
298
- };
299
-
300
- // binパスを相対パスに
301
- for (const [cmd, binPath] of Object.entries(pkg.bin)) {
302
- distPkg.bin[cmd] = binPath.replace('./bin/', './bin/');
303
- }
304
-
305
- await fs.writeFile(
306
- path.join(DIST_DIR, 'package.json'),
307
- JSON.stringify(distPkg, null, 2),
308
- 'utf8'
309
- );
310
-
311
- // 結果表示
312
- const duration = ((Date.now() - startTime) / 1000).toFixed(2);
313
-
314
- console.log('');
315
- console.log('╔═══════════════════════════════════════════════════════════╗');
316
- console.log('║ Build Complete ║');
317
- console.log('╠═══════════════════════════════════════════════════════════╣');
318
- console.log(`║ Terser (general): ${String(stats.terser).padStart(3)} files ║`);
319
- console.log(`║ HIGH (sensitive): ${String(stats.high).padStart(3)} files ║`);
320
- console.log(`║ Copy only: ${String(stats.copy).padStart(3)} files ║`);
321
- console.log(`║ Errors: ${String(stats.error).padStart(3)} files ║`);
322
- console.log(`║ Time: ${duration.padStart(5)}s ║`);
323
- console.log('╠═══════════════════════════════════════════════════════════╣');
324
- console.log('║ Output: dist/ ║');
325
- console.log('║ ║');
326
- console.log('║ To publish: ║');
327
- console.log('║ cd dist && npm publish ║');
328
- console.log('╚═══════════════════════════════════════════════════════════╝');
329
- console.log('');
330
-
331
- if (stats.error > 0) {
332
- process.exit(1);
333
- }
334
- }
335
-
336
- main().catch(e => {
337
- Logger.error(e.message);
338
- process.exit(1);
339
- });