@exonix/tchat-cli 1.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.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @exonix/tchat-cli
2
+
3
+ T信平台命令行工具,面向 AI 助手和开发者,默认输出紧凑 JSON。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g @exonix/tchat-cli
9
+ ```
10
+
11
+ ## 配置
12
+
13
+ 设置环境变量:
14
+
15
+ ```bash
16
+ export TCHAT_ACCESSTOKEN="your_access_token"
17
+ ```
18
+
19
+ ## 使用
20
+
21
+ ```bash
22
+ # 查看帮助
23
+ tchat --help
24
+
25
+ # 首页模块分类
26
+ tchat widget list
27
+ tchat widget list --name 考勤
28
+
29
+ # 消息搜索
30
+ tchat msg search --session "g@10000219039" --sender user001 --type SESSION_RECENT
31
+
32
+ # 通讯录搜索
33
+ tchat contact search -k "张三" --user user001
34
+ ```
35
+
36
+ ## 环境
37
+
38
+ | 参数 | 默认值 | 说明 |
39
+ |------|--------|------|
40
+ | `--env` | `test` | `test` 或 `prod` |
41
+
42
+ ## 文档
43
+
44
+ 详见 [USAGE.md](https://github.com/your-org/tchat-cli/blob/main/USAGE.md)
45
+
46
+ ## License
47
+
48
+ MIT
package/bin/tchat ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { execFileSync } = require("child_process");
5
+ const path = require("path");
6
+ const { findBinary } = require("../scripts/install.js");
7
+
8
+ const binPath = findBinary();
9
+ const args = process.argv.slice(2);
10
+
11
+ try {
12
+ execFileSync(binPath, args, { stdio: "inherit" });
13
+ } catch (err) {
14
+ if (err.status !== undefined) {
15
+ process.exit(err.status);
16
+ }
17
+ throw err;
18
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@exonix/tchat-cli",
3
+ "version": "1.0.0",
4
+ "description": "TChat CLI - AI friendly command line tool for TChat platform",
5
+ "keywords": ["tchat", "cli", "teamwork", "ai"],
6
+ "license": "MIT",
7
+ "bin": {
8
+ "tchat": "bin/tchat"
9
+ },
10
+ "files": ["bin/", "scripts/"],
11
+ "scripts": {
12
+ "postinstall": "node scripts/install.js"
13
+ },
14
+ "optionalDependencies": {
15
+ "@exonix/tchat-cli-darwin-arm64": "1.0.0",
16
+ "@exonix/tchat-cli-darwin-x64": "1.0.0",
17
+ "@exonix/tchat-cli-linux-x64": "1.0.0",
18
+ "@exonix/tchat-cli-linux-arm64": "1.0.0",
19
+ "@exonix/tchat-cli-win32-x64": "1.0.0"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/your-org/tchat-cli.git"
24
+ },
25
+ "engines": {
26
+ "node": ">=14"
27
+ }
28
+ }
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+
7
+ const PLATFORM_PACKAGES = {
8
+ "darwin-arm64": "@exonix/tchat-cli-darwin-arm64",
9
+ "darwin-x64": "@exonix/tchat-cli-darwin-x64",
10
+ "linux-x64": "@exonix/tchat-cli-linux-x64",
11
+ "linux-arm64": "@exonix/tchat-cli-linux-arm64",
12
+ "win32-x64": "@exonix/tchat-cli-win32-x64",
13
+ };
14
+
15
+ function getPlatformKey() {
16
+ const platform = process.platform;
17
+ const arch = process.arch;
18
+
19
+ // Normalize
20
+ const p = platform === "win32" ? "win32" : platform;
21
+ const a = arch === "x64" ? "x64" : arch === "arm64" ? "arm64" : arch;
22
+
23
+ return `${p}-${a}`;
24
+ }
25
+
26
+ function findBinary() {
27
+ const key = getPlatformKey();
28
+ const pkgName = PLATFORM_PACKAGES[key];
29
+
30
+ if (!pkgName) {
31
+ console.error(
32
+ `@exonix/tchat-cli: Unsupported platform: ${process.platform} ${process.arch}`
33
+ );
34
+ console.error(`@exonix/tchat-cli: Supported: ${Object.keys(PLATFORM_PACKAGES).join(", ")}`);
35
+ process.exit(1);
36
+ }
37
+
38
+ try {
39
+ const pkgDir = path.dirname(require.resolve(pkgName + "/package.json"));
40
+ const ext = process.platform === "win32" ? ".exe" : "";
41
+ const binPath = path.join(pkgDir, "bin", "tchat" + ext);
42
+
43
+ if (fs.existsSync(binPath)) {
44
+ return binPath;
45
+ }
46
+ } catch (e) {
47
+ // package not found
48
+ }
49
+
50
+ console.error(
51
+ `@exonix/tchat-cli: Could not find ${pkgName} binary. Try reinstalling:`
52
+ );
53
+ console.error(` npm install -g @exonix/tchat-cli`);
54
+ process.exit(1);
55
+ }
56
+
57
+ // During postinstall, just verify the binary exists
58
+ if (require.main === module) {
59
+ const binPath = findBinary();
60
+ console.log(`@exonix/tchat-cli: Binary found at ${binPath}`);
61
+ }
62
+
63
+ module.exports = { findBinary };