@yi-agent/yi-agent 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/entry.js +42 -0
  2. package/package.json +22 -0
package/entry.js ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ const { existsSync } = require('fs');
3
+ const { join, dirname } = require('path');
4
+
5
+ const platform = process.platform;
6
+ const arch = process.arch;
7
+
8
+ const platformMap = {
9
+ 'darwin-x64': '@yi-agent/yi-agent-darwin-x64',
10
+ 'darwin-arm64': '@yi-agent/yi-agent-darwin-arm64',
11
+ 'linux-x64': '@yi-agent/yi-agent-linux-x64',
12
+ };
13
+
14
+ const key = `${platform}-${arch}`;
15
+ const pkgName = platformMap[key];
16
+
17
+ if (!pkgName) {
18
+ console.error(`Unsupported platform: ${key}`);
19
+ process.exit(1);
20
+ }
21
+
22
+ let binPath;
23
+ try {
24
+ const pkgJsonPath = require.resolve(`${pkgName}/package.json`);
25
+ binPath = join(dirname(pkgJsonPath), 'binaries', 'yi-agent');
26
+ } catch (e) {
27
+ console.error(`Platform package ${pkgName} not installed.`);
28
+ process.exit(1);
29
+ }
30
+
31
+ if (!existsSync(binPath)) {
32
+ console.error(`Binary not found at ${binPath}`);
33
+ process.exit(1);
34
+ }
35
+
36
+ const { spawn } = require('child_process');
37
+ const child = spawn(binPath, process.argv.slice(2), { stdio: 'inherit' });
38
+ child.on('close', (code) => process.exit(code ?? 1));
39
+ child.on('error', (e) => {
40
+ console.error(`Failed to launch yi-agent: ${e.message}`);
41
+ process.exit(1);
42
+ });
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@yi-agent/yi-agent",
3
+ "version": "0.1.0",
4
+ "description": "A coding agent CLI",
5
+ "license": "MIT",
6
+ "engines": {
7
+ "node": ">=14"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/YichenGong/yi-agent"
12
+ },
13
+ "bin": {
14
+ "yi-agent": "entry.js"
15
+ },
16
+ "optionalDependencies": {
17
+ "@yi-agent/yi-agent-darwin-x64": "0.1.0",
18
+ "@yi-agent/yi-agent-darwin-arm64": "0.1.0",
19
+ "@yi-agent/yi-agent-linux-x64": "0.1.0"
20
+ },
21
+ "files": ["entry.js"]
22
+ }