lato-cli 1.0.1

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
File without changes
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "lato-cli",
3
+ "version": "1.0.1",
4
+ "description": "Lato — AI coding agent CLI.",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/lazyarjun2005-rgb/lato",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/lazyarjun2005-rgb/lato.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/lazyarjun2005-rgb/lato/issues"
13
+ },
14
+ "keywords": [
15
+ "ai",
16
+ "cli",
17
+ "coding-agent",
18
+ "terminal",
19
+ "lato"
20
+ ],
21
+ "bin": {
22
+ "lato": "bin/lato"
23
+ },
24
+ "files": [
25
+ "bin",
26
+ "scripts",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "scripts": {
31
+ "postinstall": "node scripts/postinstall.js"
32
+ },
33
+ "engines": {
34
+ "node": ">=18"
35
+ },
36
+ "type": "commonjs"
37
+ }
@@ -0,0 +1,125 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const os = require('os');
6
+ const https = require('https');
7
+ const { execFileSync } = require('child_process');
8
+
9
+ const VERSION = 'v1.0.1';
10
+ const REPO = 'lazyarjun2005-rgb/lato';
11
+
12
+ function platformName() {
13
+ switch (process.platform) {
14
+ case 'linux':
15
+ return 'linux';
16
+ case 'darwin':
17
+ return 'darwin';
18
+ case 'win32':
19
+ return 'windows';
20
+ default:
21
+ throw new Error(`Unsupported operating system: ${process.platform}`);
22
+ }
23
+ }
24
+
25
+ function archName() {
26
+ switch (process.arch) {
27
+ case 'x64':
28
+ return 'amd64';
29
+ case 'arm64':
30
+ return 'arm64';
31
+ default:
32
+ throw new Error(`Unsupported CPU architecture: ${process.arch}`);
33
+ }
34
+ }
35
+
36
+ function binaryName(platform, arch) {
37
+ return platform === 'windows'
38
+ ? `lato-${platform}-${arch}.exe`
39
+ : `lato-${platform}-${arch}`;
40
+ }
41
+
42
+ function download(url, destination) {
43
+ return new Promise((resolve, reject) => {
44
+ const request = https.get(
45
+ url,
46
+ {
47
+ headers: {
48
+ 'User-Agent': 'lato-cli-installer',
49
+ Accept: 'application/octet-stream'
50
+ }
51
+ },
52
+ response => {
53
+ if (
54
+ response.statusCode >= 300 &&
55
+ response.statusCode < 400 &&
56
+ response.headers.location
57
+ ) {
58
+ response.resume();
59
+ download(response.headers.location, destination)
60
+ .then(resolve)
61
+ .catch(reject);
62
+ return;
63
+ }
64
+
65
+ if (response.statusCode !== 200) {
66
+ response.resume();
67
+ reject(
68
+ new Error(`GitHub returned HTTP ${response.statusCode}`)
69
+ );
70
+ return;
71
+ }
72
+
73
+ const file = fs.createWriteStream(destination);
74
+
75
+ response.pipe(file);
76
+
77
+ file.on('finish', () => {
78
+ file.close(resolve);
79
+ });
80
+
81
+ file.on('error', error => {
82
+ file.close();
83
+ fs.rmSync(destination, { force: true });
84
+ reject(error);
85
+ });
86
+ }
87
+ );
88
+
89
+ request.on('error', reject);
90
+ });
91
+ }
92
+
93
+ async function main() {
94
+ const platform = platformName();
95
+ const arch = archName();
96
+ const asset = binaryName(platform, arch);
97
+
98
+ const url =
99
+ `https://github.com/${REPO}/releases/download/${VERSION}/${asset}`;
100
+
101
+ const binDir = path.join(__dirname, '..', 'bin');
102
+ const destination = path.join(
103
+ binDir,
104
+ platform === 'windows' ? 'lato.exe' : 'lato'
105
+ );
106
+
107
+ fs.mkdirSync(binDir, { recursive: true });
108
+
109
+ console.log(`Installing Lato ${VERSION}...`);
110
+ console.log(`Platform: ${platform}-${arch}`);
111
+ console.log(`Downloading: ${asset}`);
112
+
113
+ await download(url, destination);
114
+
115
+ if (platform !== 'windows') {
116
+ fs.chmodSync(destination, 0o755);
117
+ }
118
+
119
+ console.log(`Lato installed successfully.`);
120
+ }
121
+
122
+ main().catch(error => {
123
+ console.error(`Lato installation failed: ${error.message}`);
124
+ process.exit(1);
125
+ });