@opentmd/cli 0.1.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 (2) hide show
  1. package/bin/opentmd.js +70 -0
  2. package/package.json +39 -0
package/bin/opentmd.js ADDED
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawn } = require("child_process");
5
+ const { existsSync } = require("fs");
6
+ const path = require("path");
7
+
8
+ const PLATFORM_PACKAGES = {
9
+ darwin: {
10
+ arm64: "@opentmd/cli-darwin-arm64",
11
+ x64: "@opentmd/cli-darwin-x64",
12
+ },
13
+ linux: {
14
+ arm64: "@opentmd/cli-linux-arm64",
15
+ x64: "@opentmd/cli-linux-x64",
16
+ },
17
+ };
18
+
19
+ const os = process.platform;
20
+ const arch = process.arch;
21
+ const pkgName = PLATFORM_PACKAGES[os]?.[arch];
22
+
23
+ if (!pkgName) {
24
+ console.error(
25
+ `Unsupported platform: ${os} ${arch}. ` +
26
+ "OpenTMD provides binaries for darwin (arm64/x64) and linux (arm64/x64)."
27
+ );
28
+ process.exit(1);
29
+ }
30
+
31
+ let pkgDir;
32
+ try {
33
+ pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
34
+ } catch {
35
+ console.error(
36
+ `Binary package ${pkgName} not found.\n` +
37
+ " This can happen when --ignore-scripts was used or the install was interrupted.\n" +
38
+ " To fix: npm rebuild @opentmd/cli\n" +
39
+ " Or reinstall: npm install -g @opentmd/cli\n"
40
+ );
41
+ process.exit(1);
42
+ }
43
+
44
+ const binPath = path.join(pkgDir, "bin", "opentmd");
45
+
46
+ if (!existsSync(binPath)) {
47
+ console.error(
48
+ `Binary not found at ${binPath}.\n Reinstall: npm install -g @opentmd/cli\n`
49
+ );
50
+ process.exit(1);
51
+ }
52
+
53
+ const child = spawn(binPath, process.argv.slice(2), {
54
+ stdio: "inherit",
55
+ env: process.env,
56
+ });
57
+
58
+ ["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
59
+ process.on(sig, () => {
60
+ if (!child.killed) child.kill(sig);
61
+ });
62
+ });
63
+
64
+ child.on("exit", (code, signal) => {
65
+ if (signal) {
66
+ process.kill(process.pid, signal);
67
+ } else {
68
+ process.exit(code ?? 1);
69
+ }
70
+ });
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@opentmd/cli",
3
+ "version": "0.1.0",
4
+ "description": "Open-source terminal AI coding assistant — connect any LLM, edit code, run commands",
5
+ "keywords": [
6
+ "ai",
7
+ "coding",
8
+ "cli",
9
+ "agent",
10
+ "terminal",
11
+ "llm",
12
+ "opentmd"
13
+ ],
14
+ "homepage": "https://github.com/opentmd/opentmd-cli",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/opentmd/opentmd-cli.git"
18
+ },
19
+ "license": "MIT",
20
+ "author": "OpenTMD",
21
+ "bin": {
22
+ "opentmd": "./bin/opentmd.js"
23
+ },
24
+ "files": [
25
+ "bin/opentmd.js"
26
+ ],
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "optionalDependencies": {
34
+ "@opentmd/cli-darwin-arm64": "0.1.0",
35
+ "@opentmd/cli-darwin-x64": "0.1.0",
36
+ "@opentmd/cli-linux-arm64": "0.1.0",
37
+ "@opentmd/cli-linux-x64": "0.1.0"
38
+ }
39
+ }