wave-agent-sdk 0.9.5 → 0.9.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wave-agent-sdk",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "SDK for building AI-powered development tools and agents",
5
5
  "keywords": [
6
6
  "ai",
@@ -23,6 +23,7 @@
23
23
  "src",
24
24
  "bin",
25
25
  "vendor",
26
+ "scripts",
26
27
  "README.md"
27
28
  ],
28
29
  "dependencies": {
@@ -45,6 +46,7 @@
45
46
  },
46
47
  "license": "MIT",
47
48
  "scripts": {
49
+ "postinstall": "node scripts/postinstall.js",
48
50
  "build": "rimraf dist && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
49
51
  "type-check": "tsc --noEmit --incremental",
50
52
  "watch": "tsc -p tsconfig.build.json --watch & tsc-alias -p tsconfig.build.json --watch",
@@ -0,0 +1,109 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { execSync } from "child_process";
4
+ import { fileURLToPath } from "url";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ const MANIFEST_PATH = path.resolve(__dirname, "../bin/rg");
10
+ const VENDOR_DIR = path.resolve(__dirname, "../vendor/ripgrep");
11
+
12
+ async function main() {
13
+ if (!fs.existsSync(MANIFEST_PATH)) {
14
+ console.error(`Manifest not found: ${MANIFEST_PATH}`);
15
+ process.exit(1);
16
+ }
17
+
18
+ const manifestContent = fs.readFileSync(MANIFEST_PATH, "utf-8");
19
+ const jsonContent = manifestContent.replace(/^#!.*\n/, "");
20
+ const manifest = JSON.parse(jsonContent);
21
+ const platforms = manifest.platforms;
22
+
23
+ if (!fs.existsSync(VENDOR_DIR)) {
24
+ fs.mkdirSync(VENDOR_DIR, { recursive: true });
25
+ }
26
+
27
+ for (const [platform, info] of Object.entries(platforms)) {
28
+ const platformDir = path.join(VENDOR_DIR, platform);
29
+ const isWindows = platform.startsWith("windows");
30
+ const binaryName = isWindows ? "rg.exe" : "rg";
31
+ const binaryPath = path.join(platformDir, binaryName);
32
+
33
+ if (fs.existsSync(binaryPath)) {
34
+ console.log(`Binary for ${platform} already exists at ${binaryPath}`);
35
+ if (!isWindows) {
36
+ try {
37
+ fs.chmodSync(binaryPath, 0o755);
38
+ } catch (e) {
39
+ console.warn(`Failed to set permissions for ${binaryPath}: ${e}`);
40
+ }
41
+ }
42
+ continue;
43
+ }
44
+
45
+ console.log(`Installing ripgrep for ${platform}...`);
46
+ fs.mkdirSync(platformDir, { recursive: true });
47
+
48
+ const url = info.providers[0].url;
49
+ const tempFile = path.join(platformDir, `download.${info.format}`);
50
+
51
+ try {
52
+ // Download using curl
53
+ console.log(`Downloading ${url}...`);
54
+ execSync(`curl -L -o "${tempFile}" "${url}"`, { stdio: "inherit" });
55
+
56
+ // Extract
57
+ console.log(`Extracting ${tempFile}...`);
58
+ if (info.format === "tar.gz") {
59
+ // Extract specific file from tar.gz
60
+ const extractDir = path.join(platformDir, "extract");
61
+ fs.mkdirSync(extractDir, { recursive: true });
62
+ execSync(`tar -xzf "${tempFile}" -C "${extractDir}"`, {
63
+ stdio: "inherit",
64
+ });
65
+ const extractedBinary = path.join(extractDir, info.path);
66
+ if (fs.existsSync(extractedBinary)) {
67
+ fs.renameSync(extractedBinary, binaryPath);
68
+ } else {
69
+ throw new Error(`Binary not found in archive: ${info.path}`);
70
+ }
71
+ // Clean up extract dir
72
+ fs.rmSync(extractDir, { recursive: true, force: true });
73
+ } else if (info.format === "zip") {
74
+ const extractDir = path.join(platformDir, "extract");
75
+ fs.mkdirSync(extractDir, { recursive: true });
76
+ execSync(`unzip -o "${tempFile}" -d "${extractDir}"`, {
77
+ stdio: "inherit",
78
+ });
79
+ const extractedBinary = path.join(extractDir, info.path);
80
+ if (fs.existsSync(extractedBinary)) {
81
+ fs.renameSync(extractedBinary, binaryPath);
82
+ } else {
83
+ throw new Error(`Binary not found in archive: ${info.path}`);
84
+ }
85
+ // Clean up extract dir
86
+ fs.rmSync(extractDir, { recursive: true, force: true });
87
+ }
88
+
89
+ // Make executable
90
+ if (!isWindows) {
91
+ fs.chmodSync(binaryPath, 0o755);
92
+ }
93
+
94
+ console.log(`Successfully installed ripgrep for ${platform}`);
95
+ } catch (error) {
96
+ console.error(`Failed to install ripgrep for ${platform}:`, error);
97
+ } finally {
98
+ // Clean up temp file
99
+ if (fs.existsSync(tempFile)) {
100
+ fs.unlinkSync(tempFile);
101
+ }
102
+ }
103
+ }
104
+ }
105
+
106
+ main().catch((err) => {
107
+ console.error(err);
108
+ process.exit(1);
109
+ });
@@ -0,0 +1,35 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ const VENDOR_DIR = path.resolve(__dirname, "../vendor/ripgrep");
9
+
10
+ function chmodRecursive(dir) {
11
+ if (!fs.existsSync(dir)) return;
12
+
13
+ const files = fs.readdirSync(dir);
14
+ for (const file of files) {
15
+ const fullPath = path.join(dir, file);
16
+ const stats = fs.statSync(fullPath);
17
+
18
+ if (stats.isDirectory()) {
19
+ chmodRecursive(fullPath);
20
+ } else if (file === "rg" || file === "rg.exe") {
21
+ if (process.platform !== "win32") {
22
+ try {
23
+ fs.chmodSync(fullPath, 0o755);
24
+ console.log(`Set execution permission for ${fullPath}`);
25
+ } catch (e) {
26
+ console.warn(
27
+ `Failed to set execution permission for ${fullPath}: ${e.message}`,
28
+ );
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+
35
+ chmodRecursive(VENDOR_DIR);