bluelamp 4.0.14 → 4.0.15
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.
- package/bin/bluelamp-vscode-base +1 -317
- package/bin/bluelamp1 +0 -0
- package/bin/bluelamp10 +0 -0
- package/bin/bluelamp100 +0 -0
- package/bin/bluelamp11 +0 -0
- package/bin/bluelamp12 +0 -0
- package/bin/bluelamp13 +0 -0
- package/bin/bluelamp14 +0 -0
- package/bin/bluelamp15 +0 -0
- package/bin/bluelamp16 +0 -0
- package/bin/bluelamp17 +0 -0
- package/bin/bluelamp18 +0 -0
- package/bin/bluelamp19 +0 -0
- package/bin/bluelamp2 +0 -0
- package/bin/bluelamp20 +0 -0
- package/bin/bluelamp21 +0 -0
- package/bin/bluelamp22 +0 -0
- package/bin/bluelamp23 +0 -0
- package/bin/bluelamp24 +0 -0
- package/bin/bluelamp25 +0 -0
- package/bin/bluelamp26 +0 -0
- package/bin/bluelamp27 +0 -0
- package/bin/bluelamp28 +0 -0
- package/bin/bluelamp29 +0 -0
- package/bin/bluelamp3 +0 -0
- package/bin/bluelamp30 +0 -0
- package/bin/bluelamp31 +0 -0
- package/bin/bluelamp32 +0 -0
- package/bin/bluelamp33 +0 -0
- package/bin/bluelamp34 +0 -0
- package/bin/bluelamp35 +0 -0
- package/bin/bluelamp36 +0 -0
- package/bin/bluelamp37 +0 -0
- package/bin/bluelamp38 +0 -0
- package/bin/bluelamp39 +0 -0
- package/bin/bluelamp4 +0 -0
- package/bin/bluelamp40 +0 -0
- package/bin/bluelamp41 +0 -0
- package/bin/bluelamp42 +0 -0
- package/bin/bluelamp43 +0 -0
- package/bin/bluelamp44 +0 -0
- package/bin/bluelamp45 +0 -0
- package/bin/bluelamp46 +0 -0
- package/bin/bluelamp47 +0 -0
- package/bin/bluelamp48 +0 -0
- package/bin/bluelamp49 +0 -0
- package/bin/bluelamp5 +0 -0
- package/bin/bluelamp50 +0 -0
- package/bin/bluelamp51 +0 -0
- package/bin/bluelamp52 +0 -0
- package/bin/bluelamp53 +0 -0
- package/bin/bluelamp54 +0 -0
- package/bin/bluelamp55 +0 -0
- package/bin/bluelamp56 +0 -0
- package/bin/bluelamp57 +0 -0
- package/bin/bluelamp58 +0 -0
- package/bin/bluelamp59 +0 -0
- package/bin/bluelamp6 +0 -0
- package/bin/bluelamp60 +0 -0
- package/bin/bluelamp61 +0 -0
- package/bin/bluelamp62 +0 -0
- package/bin/bluelamp63 +0 -0
- package/bin/bluelamp64 +0 -0
- package/bin/bluelamp65 +0 -0
- package/bin/bluelamp66 +0 -0
- package/bin/bluelamp67 +0 -0
- package/bin/bluelamp68 +0 -0
- package/bin/bluelamp69 +0 -0
- package/bin/bluelamp7 +0 -0
- package/bin/bluelamp70 +0 -0
- package/bin/bluelamp71 +0 -0
- package/bin/bluelamp72 +0 -0
- package/bin/bluelamp73 +0 -0
- package/bin/bluelamp74 +0 -0
- package/bin/bluelamp75 +0 -0
- package/bin/bluelamp76 +0 -0
- package/bin/bluelamp77 +0 -0
- package/bin/bluelamp78 +0 -0
- package/bin/bluelamp79 +0 -0
- package/bin/bluelamp8 +0 -0
- package/bin/bluelamp80 +0 -0
- package/bin/bluelamp81 +0 -0
- package/bin/bluelamp82 +0 -0
- package/bin/bluelamp83 +0 -0
- package/bin/bluelamp84 +0 -0
- package/bin/bluelamp85 +0 -0
- package/bin/bluelamp86 +0 -0
- package/bin/bluelamp87 +0 -0
- package/bin/bluelamp88 +0 -0
- package/bin/bluelamp89 +0 -0
- package/bin/bluelamp9 +0 -0
- package/bin/bluelamp90 +0 -0
- package/bin/bluelamp91 +0 -0
- package/bin/bluelamp92 +0 -0
- package/bin/bluelamp93 +0 -0
- package/bin/bluelamp94 +0 -0
- package/bin/bluelamp95 +0 -0
- package/bin/bluelamp96 +0 -0
- package/bin/bluelamp97 +0 -0
- package/bin/bluelamp98 +0 -0
- package/bin/bluelamp99 +0 -0
- package/lib/auth/InteractiveLogin.js +1 -243
- package/lib/auth/PortalAuthClient.js +1 -187
- package/lib/auth/TokenManager.js +1 -258
- package/lib/mcp-server/index.cjs +1 -195
- package/lib/mcp-server/portal-api-client.cjs +1 -286
- package/lib/utils/logger.js +1 -83
- package/package.json +4 -18
- package/README.md +0 -78
- package/scripts/build.js +0 -339
- package/scripts/generate-commands.js +0 -45
package/lib/utils/logger.js
CHANGED
|
@@ -1,83 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* BlueLamp VSCode Logger
|
|
3
|
-
* 環境変数ベースのログレベル制御
|
|
4
|
-
*
|
|
5
|
-
* @module logger
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const LOG_LEVELS = {
|
|
9
|
-
debug: 0,
|
|
10
|
-
info: 1,
|
|
11
|
-
warn: 2,
|
|
12
|
-
error: 3,
|
|
13
|
-
silent: 4
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const LOG_LEVEL = process.env.BLUELAMP_LOG_LEVEL || 'info';
|
|
17
|
-
const currentLevel = LOG_LEVELS[LOG_LEVEL] ?? LOG_LEVELS.info;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* タイムスタンプ付きログメッセージを生成
|
|
21
|
-
* @param {string} level - ログレベル
|
|
22
|
-
* @param {string} message - メッセージ
|
|
23
|
-
* @returns {string} フォーマット済みメッセージ
|
|
24
|
-
*/
|
|
25
|
-
function formatMessage(level, message) {
|
|
26
|
-
const timestamp = new Date().toISOString();
|
|
27
|
-
return `[${timestamp}] [${level.toUpperCase()}] ${message}`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* ログ出力関数
|
|
32
|
-
*/
|
|
33
|
-
const logger = {
|
|
34
|
-
/**
|
|
35
|
-
* デバッグログ
|
|
36
|
-
* @param {string} message - メッセージ
|
|
37
|
-
*/
|
|
38
|
-
debug(message) {
|
|
39
|
-
if (currentLevel <= LOG_LEVELS.debug) {
|
|
40
|
-
console.error(formatMessage('debug', message));
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 情報ログ
|
|
46
|
-
* @param {string} message - メッセージ
|
|
47
|
-
*/
|
|
48
|
-
info(message) {
|
|
49
|
-
if (currentLevel <= LOG_LEVELS.info) {
|
|
50
|
-
console.error(formatMessage('info', message));
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* 警告ログ
|
|
56
|
-
* @param {string} message - メッセージ
|
|
57
|
-
*/
|
|
58
|
-
warn(message) {
|
|
59
|
-
if (currentLevel <= LOG_LEVELS.warn) {
|
|
60
|
-
console.warn(formatMessage('warn', message));
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* エラーログ
|
|
66
|
-
* @param {string} message - メッセージ
|
|
67
|
-
*/
|
|
68
|
-
error(message) {
|
|
69
|
-
if (currentLevel <= LOG_LEVELS.error) {
|
|
70
|
-
console.error(formatMessage('error', message));
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* ログレベルを取得
|
|
76
|
-
* @returns {string} 現在のログレベル
|
|
77
|
-
*/
|
|
78
|
-
getLevel() {
|
|
79
|
-
return LOG_LEVEL;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
module.exports = { logger, LOG_LEVELS };
|
|
1
|
+
const LOG_LEVELS={debug:0,info:1,warn:2,error:3,silent:4},LOG_LEVEL=process.env.BLUELAMP_LOG_LEVEL||"info",currentLevel=LOG_LEVELS[LOG_LEVEL]??LOG_LEVELS.info;function formatMessage(e,r){return`[${(new Date).toISOString()}] [${e.toUpperCase()}] ${r}`}const logger={debug(e){currentLevel<=LOG_LEVELS.debug&&console.error(formatMessage("debug",e))},info(e){currentLevel<=LOG_LEVELS.info&&console.error(formatMessage("info",e))},warn(e){currentLevel<=LOG_LEVELS.warn&&console.warn(formatMessage("warn",e))},error(e){currentLevel<=LOG_LEVELS.error&&console.error(formatMessage("error",e))},getLevel:()=>LOG_LEVEL};module.exports={logger:logger,LOG_LEVELS:LOG_LEVELS};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bluelamp",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.15",
|
|
4
4
|
"description": "BlueLamp MCP Server - 100 Customizable Development Prompts for Claude Code",
|
|
5
|
-
"main": "lib/mcp-server/index.cjs",
|
|
5
|
+
"main": "./lib/mcp-server/index.cjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"bluelamp1": "./bin/bluelamp1",
|
|
8
8
|
"bluelamp2": "./bin/bluelamp2",
|
|
@@ -105,13 +105,6 @@
|
|
|
105
105
|
"bluelamp99": "./bin/bluelamp99",
|
|
106
106
|
"bluelamp100": "./bin/bluelamp100"
|
|
107
107
|
},
|
|
108
|
-
"scripts": {
|
|
109
|
-
"postinstall": "node scripts/generate-commands.js",
|
|
110
|
-
"test": "jest",
|
|
111
|
-
"test:coverage": "jest --coverage",
|
|
112
|
-
"test:mcp": "node test-mcp.js",
|
|
113
|
-
"build": "node scripts/build.js"
|
|
114
|
-
},
|
|
115
108
|
"keywords": [
|
|
116
109
|
"vscode",
|
|
117
110
|
"bluelamp",
|
|
@@ -134,18 +127,11 @@
|
|
|
134
127
|
},
|
|
135
128
|
"files": [
|
|
136
129
|
"bin/",
|
|
137
|
-
"lib/"
|
|
138
|
-
"scripts/",
|
|
139
|
-
"README.md"
|
|
130
|
+
"lib/"
|
|
140
131
|
],
|
|
141
132
|
"preferGlobal": true,
|
|
142
133
|
"repository": {
|
|
143
134
|
"type": "git",
|
|
144
135
|
"url": "https://github.com/yamatovision/bluelamp-cli.git"
|
|
145
|
-
},
|
|
146
|
-
"devDependencies": {
|
|
147
|
-
"javascript-obfuscator": "^4.1.1",
|
|
148
|
-
"jest": "^30.2.0",
|
|
149
|
-
"terser": "^5.44.0"
|
|
150
136
|
}
|
|
151
|
-
}
|
|
137
|
+
}
|
package/README.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# BlueLamp MCP Server
|
|
2
|
-
|
|
3
|
-
Claude Code用の18種類の開発プロンプト知識注入システム
|
|
4
|
-
|
|
5
|
-
## インストール
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install -g bluelamp
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## 使用方法
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
bluelamp1 # 要件定義エンジニアとして起動
|
|
15
|
-
bluelamp2 # Git管理エンジニアとして起動
|
|
16
|
-
# ... 18種類のコマンド
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## コマンド一覧
|
|
20
|
-
|
|
21
|
-
| コマンド | キーワード | 役割 |
|
|
22
|
-
|---------|----------|------|
|
|
23
|
-
| `bluelamp1` | @要件定義 | 要件定義エンジニア |
|
|
24
|
-
| `bluelamp2` | @Git管理 | Git/GitHub管理 |
|
|
25
|
-
| `bluelamp3` | @フロントエンド基盤 | フロントエンド基盤オーケストレーター |
|
|
26
|
-
| `bluelamp4` | @ページ実装オーケストレーター | ページ実装統括 |
|
|
27
|
-
| `bluelamp5` | @環境構築オーケストレーター | 環境構築 |
|
|
28
|
-
| `bluelamp6` | @バックエンド計画オーケストレーター | バックエンド実装計画 |
|
|
29
|
-
| `bluelamp7` | @バックエンド実装オーケストレーター | バックエンド実装統括 |
|
|
30
|
-
| `bluelamp8` | @フロントエンド実装オーケストレーター | API統合統括 |
|
|
31
|
-
| `bluelamp9` | @E2Eテストオーケストレーター | E2Eテスト統括 |
|
|
32
|
-
| `bluelamp10` | @本番運用診断オーケストレーター | CVSS 3.1準拠本番運用診断 |
|
|
33
|
-
| `bluelamp11` | @デプロイオーケストレーター | デプロイメント統括 |
|
|
34
|
-
| `bluelamp12` | @拡張要件定義 | 拡張要件定義オーケストレーター |
|
|
35
|
-
| `bluelamp13` | @拡張機能実装 | 拡張機能実装オーケストレーター |
|
|
36
|
-
| `bluelamp14` | @デバッグ技術 | 自己完結型デバッグマスター |
|
|
37
|
-
| `bluelamp15` | @リファクタリング | 超並列リファクタリング |
|
|
38
|
-
| `bluelamp16` | @ドキュメント生成 | ドキュメント生成統括 |
|
|
39
|
-
| `bluelamp17` | @相談 | 相談対応 |
|
|
40
|
-
| `bluelamp18` | @MCP追加 | MCP追加エージェント |
|
|
41
|
-
|
|
42
|
-
## 必要要件
|
|
43
|
-
|
|
44
|
-
- Node.js 18以上
|
|
45
|
-
- Claude Code CLI
|
|
46
|
-
- BlueLamp Portalアカウント
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
## 開発者向け
|
|
51
|
-
|
|
52
|
-
### ローカルビルド(難読化)
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
npm run build
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
2段階難読化を適用してdist/に出力:
|
|
59
|
-
- **HIGH**: 認証・API関連ファイル(制御フロー平坦化、文字列暗号化)
|
|
60
|
-
- **Terser**: 一般ファイル(軽量縮小化)
|
|
61
|
-
|
|
62
|
-
### npm公開(GitHub Actions)
|
|
63
|
-
|
|
64
|
-
タグをプッシュすると自動でnpmに公開されます:
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
npm version patch # 4.0.9
|
|
68
|
-
git push && git push --tags
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
GitHub Actionsが自動で:
|
|
72
|
-
1. 依存関係インストール
|
|
73
|
-
2. 難読化ビルド
|
|
74
|
-
3. npmに公開
|
|
75
|
-
|
|
76
|
-
## ライセンス
|
|
77
|
-
|
|
78
|
-
MIT
|
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
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* BlueLamp コマンド生成スクリプト
|
|
5
|
-
* bluelamp1〜100 の100個のコマンドファイルを自動生成
|
|
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-vscode-base');
|
|
13
|
-
|
|
14
|
-
// 生成するコマンド数(100スロット対応)
|
|
15
|
-
const MAX_SLOTS = 100;
|
|
16
|
-
|
|
17
|
-
console.log('🔵 BlueLamp コマンド生成開始...\n');
|
|
18
|
-
|
|
19
|
-
// bluelamp1〜100 を生成
|
|
20
|
-
let createdCount = 0;
|
|
21
|
-
for (let i = 1; i <= MAX_SLOTS; i++) {
|
|
22
|
-
const commandName = `bluelamp${i}`;
|
|
23
|
-
const commandPath = path.join(binDir, commandName);
|
|
24
|
-
|
|
25
|
-
// ラッパースクリプトを作成
|
|
26
|
-
const content = `#!/usr/bin/env node
|
|
27
|
-
require('./bluelamp-vscode-base');
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
fs.writeFileSync(commandPath, content);
|
|
31
|
-
fs.chmodSync(commandPath, '755');
|
|
32
|
-
createdCount++;
|
|
33
|
-
|
|
34
|
-
// 進捗表示(10個ごと)
|
|
35
|
-
if (i % 10 === 0) {
|
|
36
|
-
console.log(` ✅ bluelamp1〜${i} 作成完了`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// ベーススクリプトにも実行権限を付与
|
|
41
|
-
if (fs.existsSync(baseScript)) {
|
|
42
|
-
fs.chmodSync(baseScript, '755');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
console.log(`\n✨ ${createdCount}個のコマンドファイルを生成しました (bluelamp1〜bluelamp${MAX_SLOTS})`);
|