imtoagent 0.2.4 → 0.2.5
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/package.json +3 -3
- package/scripts/postinstall.cjs +28 -74
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imtoagent",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "IM
|
|
3
|
+
"version": "0.2.5",
|
|
4
|
+
"description": "IM \u2194 Agent \u7edf\u4e00\u7f51\u5173 \u2014 \u98de\u4e66/Telegram/\u5fae\u4fe1/\u4f01\u4e1a\u5fae\u4fe1\u5bf9\u63a5 Claude Code/Codex/OpenCode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"imtoagent": "./bin/imtoagent.cjs"
|
|
@@ -53,4 +53,4 @@
|
|
|
53
53
|
"url": "https://github.com/YOUR_USERNAME/imtoagent/issues"
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://github.com/YOUR_USERNAME/imtoagent#readme"
|
|
56
|
-
}
|
|
56
|
+
}
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -1,90 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// ================================================================
|
|
3
|
-
// postinstall.
|
|
3
|
+
// postinstall.cjs — npm 安装后引导
|
|
4
4
|
// ================================================================
|
|
5
|
-
//
|
|
5
|
+
// 参考 OpenClaw 的设计:postinstall 只做技术性维护,不做交互。
|
|
6
|
+
// 交互式配置由用户运行 `imtoagent setup` 或 `imtoagent` 触发。
|
|
6
7
|
// ================================================================
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const { execSync } = require('child_process');
|
|
9
|
+
"use strict";
|
|
11
10
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
const path = require("path");
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// 1. PATH 中有 bun
|
|
18
|
-
try {
|
|
19
|
-
const r = execSync('which bun', { encoding: 'utf-8', timeout: 3000 }).trim();
|
|
20
|
-
if (r) return r;
|
|
21
|
-
} catch {}
|
|
22
|
-
// 2. 常见安装路径
|
|
23
|
-
const candidates = [
|
|
24
|
-
path.join(HOME, '.bun', 'bin', 'bun'),
|
|
25
|
-
'/usr/local/bin/bun',
|
|
26
|
-
'/opt/homebrew/bin/bun',
|
|
27
|
-
];
|
|
28
|
-
for (const p of candidates) {
|
|
29
|
-
if (fs.existsSync(p)) return p;
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
14
|
+
const HOME = process.env.HOME || process.env.USERPROFILE || "";
|
|
15
|
+
const DATA_DIR = path.join(HOME, ".imtoagent");
|
|
33
16
|
|
|
34
17
|
try {
|
|
35
|
-
const configExists = fs.existsSync(path.join(DATA_DIR,
|
|
18
|
+
const configExists = fs.existsSync(path.join(DATA_DIR, "config.json"));
|
|
36
19
|
|
|
37
20
|
if (configExists) {
|
|
38
|
-
console.log(
|
|
39
|
-
✅
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
21
|
+
console.log("");
|
|
22
|
+
console.log("✅ imtoagent 升级成功!");
|
|
23
|
+
console.log("");
|
|
24
|
+
console.log(" 数据目录: " + DATA_DIR);
|
|
25
|
+
console.log(" 配置文件保持不变,无需重新配置。");
|
|
26
|
+
console.log(' 运行 "imtoagent start" 启动网关。');
|
|
27
|
+
console.log("");
|
|
44
28
|
} else {
|
|
45
|
-
console.log(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
58
|
-
|
|
59
|
-
rl.question('是否立即运行配置向导?[Y/n]: ', (answer) => {
|
|
60
|
-
rl.close();
|
|
61
|
-
const yes = (answer || '').trim().toLowerCase();
|
|
62
|
-
if (yes === '' || yes === 'y' || yes === 'yes') {
|
|
63
|
-
const bunPath = findBun();
|
|
64
|
-
if (!bunPath) {
|
|
65
|
-
console.error('\n⚠️ bun 未安装,请先安装: https://bun.sh');
|
|
66
|
-
console.error(' 安装后运行: imtoagent setup\n');
|
|
67
|
-
process.exit(0);
|
|
68
|
-
}
|
|
69
|
-
console.log('\n🚀 启动配置向导...\n');
|
|
70
|
-
const pkgDir = path.resolve(__dirname, '..');
|
|
71
|
-
execSync(`${bunPath} bin/imtoagent setup`, {
|
|
72
|
-
cwd: pkgDir,
|
|
73
|
-
stdio: 'inherit',
|
|
74
|
-
env: { ...process.env },
|
|
75
|
-
});
|
|
76
|
-
} else {
|
|
77
|
-
console.log('\n稍后运行 "imtoagent setup" 即可开始配置。');
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
console.log(' 运行 "imtoagent setup" 开始配置');
|
|
82
|
-
console.log(' 然后运行 "imtoagent start" 启动网关\n');
|
|
83
|
-
}
|
|
29
|
+
console.log("");
|
|
30
|
+
console.log("🎉 imtoagent 安装成功!");
|
|
31
|
+
console.log("");
|
|
32
|
+
console.log(" 首次使用,请运行以下命令完成初始化配置:");
|
|
33
|
+
console.log("");
|
|
34
|
+
console.log(' imtoagent setup # 交互式配置向导');
|
|
35
|
+
console.log(' imtoagent # 无命令时自动检测,未配置也会进入向导');
|
|
36
|
+
console.log("");
|
|
37
|
+
console.log(" 配置完成后启动网关:");
|
|
38
|
+
console.log("");
|
|
39
|
+
console.log(" imtoagent start");
|
|
40
|
+
console.log("");
|
|
84
41
|
}
|
|
85
42
|
} catch (e) {
|
|
86
43
|
// 静默失败,不影响安装
|
|
87
|
-
if (e.message && !e.message.includes('readline')) {
|
|
88
|
-
console.error(`[postinstall] 提示失败: ${e.message}`);
|
|
89
|
-
}
|
|
90
44
|
}
|