neoctl 0.2.17 → 0.2.23

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 (52) hide show
  1. package/README.md +11 -9
  2. package/dist/app/app-prompt.d.ts +2 -0
  3. package/dist/app/app-prompt.js +2 -0
  4. package/dist/app/app-prompt.js.map +1 -1
  5. package/dist/context/compaction.d.ts +12 -0
  6. package/dist/context/compaction.js +22 -0
  7. package/dist/context/compaction.js.map +1 -1
  8. package/dist/context/smoke-context.js +30 -3
  9. package/dist/context/smoke-context.js.map +1 -1
  10. package/dist/core/query.js +8 -4
  11. package/dist/core/query.js.map +1 -1
  12. package/dist/model/config.js +1 -1
  13. package/dist/model/env.js +1 -1
  14. package/dist/model/model-metadata.json +70 -6
  15. package/dist/repl/commands.js +1 -1
  16. package/dist/repl/index.js +2 -2
  17. package/dist/tools/builtins/ripgrep-binary.js +1 -1
  18. package/dist/tools/builtins/ripgrep-binary.js.map +1 -1
  19. package/dist/web/html.js +22 -3
  20. package/dist/web/html.js.map +1 -1
  21. package/dist/web/index.d.ts +35 -1
  22. package/dist/web/index.js +160 -33
  23. package/dist/web/index.js.map +1 -1
  24. package/package.json +5 -3
  25. package/scripts/copy-model-metadata.mjs +4 -4
  26. package/scripts/install-ripgrep.cjs +210 -196
  27. package/scripts/release-local.mjs +190 -190
  28. package/scripts/verify-ripgrep.cjs +86 -0
  29. package/vendor/ripgrep/darwin-arm64/COPYING +3 -3
  30. package/vendor/ripgrep/darwin-arm64/LICENSE-MIT +21 -21
  31. package/vendor/ripgrep/darwin-arm64/UNLICENSE +24 -24
  32. package/vendor/ripgrep/darwin-arm64/manifest.json +7 -7
  33. package/vendor/ripgrep/darwin-x64/COPYING +3 -3
  34. package/vendor/ripgrep/darwin-x64/LICENSE-MIT +21 -21
  35. package/vendor/ripgrep/darwin-x64/UNLICENSE +24 -24
  36. package/vendor/ripgrep/darwin-x64/manifest.json +7 -7
  37. package/vendor/ripgrep/linux-arm64/COPYING +3 -3
  38. package/vendor/ripgrep/linux-arm64/LICENSE-MIT +21 -21
  39. package/vendor/ripgrep/linux-arm64/UNLICENSE +24 -24
  40. package/vendor/ripgrep/linux-arm64/manifest.json +7 -7
  41. package/vendor/ripgrep/linux-x64/COPYING +3 -3
  42. package/vendor/ripgrep/linux-x64/LICENSE-MIT +21 -21
  43. package/vendor/ripgrep/linux-x64/UNLICENSE +24 -24
  44. package/vendor/ripgrep/linux-x64/manifest.json +7 -7
  45. package/vendor/ripgrep/win32-arm64/COPYING +3 -3
  46. package/vendor/ripgrep/win32-arm64/LICENSE-MIT +21 -21
  47. package/vendor/ripgrep/win32-arm64/UNLICENSE +24 -24
  48. package/vendor/ripgrep/win32-arm64/manifest.json +7 -7
  49. package/vendor/ripgrep/win32-x64/COPYING +3 -3
  50. package/vendor/ripgrep/win32-x64/LICENSE-MIT +21 -21
  51. package/vendor/ripgrep/win32-x64/UNLICENSE +24 -24
  52. package/vendor/ripgrep/win32-x64/manifest.json +7 -7
@@ -1,196 +1,210 @@
1
- #!/usr/bin/env node
2
- const fs = require("node:fs");
3
- const fsp = require("node:fs/promises");
4
- const os = require("node:os");
5
- const path = require("node:path");
6
- const { execFileSync } = require("node:child_process");
7
-
8
- const REPO = "BurntSushi/ripgrep";
9
- const LATEST_RELEASE_URL = `https://api.github.com/repos/${REPO}/releases/latest`;
10
- const PROJECT_ROOT = path.resolve(__dirname, "..");
11
- const VENDOR_ROOT = path.join(PROJECT_ROOT, "vendor", "ripgrep");
12
- const OPTIONAL = process.argv.includes("--optional");
13
- const FORCE = process.argv.includes("--force");
14
- const ALL = process.argv.includes("--all");
15
-
16
- const TARGETS = {
17
- "win32-x64": [/x86_64-pc-windows-msvc\.zip$/i],
18
- "win32-arm64": [/aarch64-pc-windows-msvc\.zip$/i],
19
- "linux-x64": [/x86_64-unknown-linux-musl\.tar\.gz$/i, /x86_64-unknown-linux-gnu\.tar\.gz$/i],
20
- "linux-arm64": [/aarch64-unknown-linux-gnu\.tar\.gz$/i, /aarch64-unknown-linux-musl\.tar\.gz$/i],
21
- "darwin-x64": [/x86_64-apple-darwin\.tar\.gz$/i],
22
- "darwin-arm64": [/aarch64-apple-darwin\.tar\.gz$/i],
23
- };
24
-
25
- main().catch((error) => {
26
- const message = error instanceof Error ? error.message : String(error);
27
- if (OPTIONAL) {
28
- console.warn(`[ripgrep] optional install skipped: ${message}`);
29
- process.exit(0);
30
- }
31
- console.error(`[ripgrep] install failed: ${message}`);
32
- process.exit(1);
33
- });
34
-
35
- async function main() {
36
- const release = await getJson(LATEST_RELEASE_URL);
37
- const keys = ALL ? Object.keys(TARGETS) : [platformKey()];
38
- for (const key of keys) {
39
- await installTarget(release, key);
40
- }
41
- }
42
-
43
- async function installTarget(release, key) {
44
- const executable = key.startsWith("win32-") ? "rg.exe" : "rg";
45
- const targetDir = path.join(VENDOR_ROOT, key);
46
- const targetPath = path.join(targetDir, executable);
47
-
48
- if (!FORCE && fs.existsSync(targetPath)) {
49
- console.error(`[ripgrep] using existing ${path.relative(PROJECT_ROOT, targetPath)}`);
50
- return;
51
- }
52
-
53
- const asset = selectAsset(release.assets ?? [], key);
54
- if (!asset) throw new Error(`no ripgrep release asset found for ${key}`);
55
-
56
- const tempDir = await fsp.mkdtemp(path.join(os.tmpdir(), "agent-rg-"));
57
- try {
58
- const archivePath = path.join(tempDir, asset.name);
59
- const extractDir = path.join(tempDir, "extract");
60
- await fsp.mkdir(extractDir, { recursive: true });
61
-
62
- console.error(`[ripgrep] downloading ${asset.name}`);
63
- await download(asset.browser_download_url, archivePath);
64
- extractArchive(archivePath, extractDir);
65
-
66
- const binaryPath = await findFile(extractDir, executable);
67
- if (!binaryPath) throw new Error(`${executable} not found inside ${asset.name}`);
68
-
69
- await fsp.rm(targetDir, { recursive: true, force: true });
70
- await fsp.mkdir(targetDir, { recursive: true });
71
- await fsp.copyFile(binaryPath, targetPath);
72
- if (!key.startsWith("win32-")) await fsp.chmod(targetPath, 0o755);
73
-
74
- await copyLicenseFiles(extractDir, targetDir);
75
- await fsp.writeFile(
76
- path.join(targetDir, "manifest.json"),
77
- `${JSON.stringify({
78
- name: "ripgrep",
79
- version: release.tag_name,
80
- source: release.html_url,
81
- asset: asset.name,
82
- installedAt: new Date().toISOString(),
83
- }, null, 2)}\n`,
84
- "utf8",
85
- );
86
- console.error(`[ripgrep] installed ${path.relative(PROJECT_ROOT, targetPath)}`);
87
- } finally {
88
- await fsp.rm(tempDir, { recursive: true, force: true });
89
- }
90
- }
91
-
92
- function platformKey() {
93
- const key = `${process.platform}-${process.arch}`;
94
- if (!TARGETS[key]) throw new Error(`unsupported platform: ${key}`);
95
- return key;
96
- }
97
-
98
- function selectAsset(assets, key) {
99
- const patterns = TARGETS[key];
100
- return assets.find((asset) => patterns.some((pattern) => pattern.test(asset.name)));
101
- }
102
-
103
- async function getJson(url) {
104
- try {
105
- const response = await fetchWithRetry(url, {
106
- headers: {
107
- Accept: "application/vnd.github+json",
108
- "User-Agent": "agent-scaffold-ripgrep-installer",
109
- },
110
- });
111
- if (!response.ok) throw new Error(`GET ${url} returned ${response.status}: ${(await response.text()).slice(0, 200)}`);
112
- return response.json();
113
- } catch (error) {
114
- const body = curlGet(url);
115
- return JSON.parse(body.toString("utf8"));
116
- }
117
- }
118
-
119
- async function download(url, destination) {
120
- try {
121
- const response = await fetchWithRetry(url, { headers: { "User-Agent": "agent-scaffold-ripgrep-installer" } });
122
- if (!response.ok) throw new Error(`download returned ${response.status}`);
123
- await fsp.writeFile(destination, Buffer.from(await response.arrayBuffer()));
124
- } catch (error) {
125
- curlDownload(url, destination);
126
- }
127
- }
128
-
129
- async function fetchWithRetry(url, options, attempts = 3) {
130
- let lastError;
131
- for (let attempt = 1; attempt <= attempts; attempt += 1) {
132
- try {
133
- const response = await fetch(url, options);
134
- if (response.ok || response.status < 500 || attempt === attempts) return response;
135
- lastError = new Error(`HTTP ${response.status}`);
136
- } catch (error) {
137
- lastError = error;
138
- if (attempt === attempts) break;
139
- }
140
- await delay(1000 * attempt);
141
- }
142
- throw lastError;
143
- }
144
-
145
- function delay(ms) {
146
- return new Promise((resolve) => setTimeout(resolve, ms));
147
- }
148
-
149
- function curlGet(url) {
150
- return execFileSync("curl", ["-fL", "--retry", "3", "--retry-delay", "1", "-H", "Accept: application/vnd.github+json", "-H", "User-Agent: agent-scaffold-ripgrep-installer", url], { maxBuffer: 1024 * 1024 * 20 });
151
- }
152
-
153
- function curlDownload(url, destination) {
154
- execFileSync("curl", ["-fL", "--retry", "3", "--retry-delay", "1", "-H", "User-Agent: agent-scaffold-ripgrep-installer", "-o", destination, url], { stdio: "ignore" });
155
- }
156
-
157
- function extractArchive(archivePath, destination) {
158
- try {
159
- execFileSync("tar", ["-xf", archivePath, "-C", destination], { stdio: "ignore" });
160
- return;
161
- } catch (error) {
162
- if (process.platform !== "win32" || !archivePath.toLowerCase().endsWith(".zip")) throw error;
163
- }
164
-
165
- execFileSync("powershell", [
166
- "-NoProfile",
167
- "-Command",
168
- "Expand-Archive -LiteralPath $args[0] -DestinationPath $args[1] -Force",
169
- archivePath,
170
- destination,
171
- ], { stdio: "ignore" });
172
- }
173
-
174
- async function findFile(root, fileName) {
175
- const entries = await fsp.readdir(root, { withFileTypes: true });
176
- for (const entry of entries) {
177
- const fullPath = path.join(root, entry.name);
178
- if (entry.isFile() && entry.name === fileName) return fullPath;
179
- if (entry.isDirectory()) {
180
- const found = await findFile(fullPath, fileName);
181
- if (found) return found;
182
- }
183
- }
184
- return undefined;
185
- }
186
-
187
- async function copyLicenseFiles(root, targetDir) {
188
- const entries = await fsp.readdir(root, { withFileTypes: true });
189
- for (const entry of entries) {
190
- const fullPath = path.join(root, entry.name);
191
- if (entry.isFile() && /^licen[sc]e|copying|unlicense/i.test(entry.name)) {
192
- await fsp.copyFile(fullPath, path.join(targetDir, entry.name));
193
- }
194
- if (entry.isDirectory()) await copyLicenseFiles(fullPath, targetDir);
195
- }
196
- }
1
+ #!/usr/bin/env node
2
+ const fs = require("node:fs");
3
+ const fsp = require("node:fs/promises");
4
+ const os = require("node:os");
5
+ const path = require("node:path");
6
+ const { execFileSync } = require("node:child_process");
7
+
8
+ const REPO = "BurntSushi/ripgrep";
9
+ const LATEST_RELEASE_URL = `https://api.github.com/repos/${REPO}/releases/latest`;
10
+ const PROJECT_ROOT = path.resolve(__dirname, "..");
11
+ const VENDOR_ROOT = path.join(PROJECT_ROOT, "vendor", "ripgrep");
12
+ const OPTIONAL = process.argv.includes("--optional");
13
+ const FORCE = process.argv.includes("--force");
14
+ const ALL = process.argv.includes("--all");
15
+
16
+ const TARGETS = {
17
+ "win32-x64": [/x86_64-pc-windows-msvc\.zip$/i],
18
+ "win32-arm64": [/aarch64-pc-windows-msvc\.zip$/i],
19
+ "linux-x64": [/x86_64-unknown-linux-musl\.tar\.gz$/i, /x86_64-unknown-linux-gnu\.tar\.gz$/i],
20
+ "linux-arm64": [/aarch64-unknown-linux-gnu\.tar\.gz$/i, /aarch64-unknown-linux-musl\.tar\.gz$/i],
21
+ "darwin-x64": [/x86_64-apple-darwin\.tar\.gz$/i],
22
+ "darwin-arm64": [/aarch64-apple-darwin\.tar\.gz$/i],
23
+ };
24
+
25
+ main().catch((error) => {
26
+ const message = error instanceof Error ? error.message : String(error);
27
+ if (OPTIONAL) {
28
+ console.warn(`[ripgrep] optional install skipped: ${message}`);
29
+ process.exit(0);
30
+ }
31
+ console.error(`[ripgrep] install failed: ${message}`);
32
+ process.exit(1);
33
+ });
34
+
35
+ async function main() {
36
+ const keys = ALL ? Object.keys(TARGETS) : [platformKey()];
37
+ const pendingKeys = [];
38
+
39
+ for (const key of keys) {
40
+ const executable = key.startsWith("win32-") ? "rg.exe" : "rg";
41
+ const targetPath = path.join(VENDOR_ROOT, key, executable);
42
+ if (!FORCE && fs.existsSync(targetPath)) {
43
+ console.error(`[ripgrep] using existing ${path.relative(PROJECT_ROOT, targetPath)}`);
44
+ } else {
45
+ pendingKeys.push(key);
46
+ }
47
+ }
48
+
49
+ if (pendingKeys.length === 0) return;
50
+
51
+ const release = await getJson(LATEST_RELEASE_URL);
52
+ for (const key of pendingKeys) {
53
+ await installTarget(release, key);
54
+ }
55
+ }
56
+
57
+ async function installTarget(release, key) {
58
+ const executable = key.startsWith("win32-") ? "rg.exe" : "rg";
59
+ const targetDir = path.join(VENDOR_ROOT, key);
60
+ const targetPath = path.join(targetDir, executable);
61
+
62
+ if (!FORCE && fs.existsSync(targetPath)) {
63
+ console.error(`[ripgrep] using existing ${path.relative(PROJECT_ROOT, targetPath)}`);
64
+ return;
65
+ }
66
+
67
+ const asset = selectAsset(release.assets ?? [], key);
68
+ if (!asset) throw new Error(`no ripgrep release asset found for ${key}`);
69
+
70
+ const tempDir = await fsp.mkdtemp(path.join(os.tmpdir(), "agent-rg-"));
71
+ try {
72
+ const archivePath = path.join(tempDir, asset.name);
73
+ const extractDir = path.join(tempDir, "extract");
74
+ await fsp.mkdir(extractDir, { recursive: true });
75
+
76
+ console.error(`[ripgrep] downloading ${asset.name}`);
77
+ await download(asset.browser_download_url, archivePath);
78
+ extractArchive(archivePath, extractDir);
79
+
80
+ const binaryPath = await findFile(extractDir, executable);
81
+ if (!binaryPath) throw new Error(`${executable} not found inside ${asset.name}`);
82
+
83
+ await fsp.rm(targetDir, { recursive: true, force: true });
84
+ await fsp.mkdir(targetDir, { recursive: true });
85
+ await fsp.copyFile(binaryPath, targetPath);
86
+ if (!key.startsWith("win32-")) await fsp.chmod(targetPath, 0o755);
87
+
88
+ await copyLicenseFiles(extractDir, targetDir);
89
+ await fsp.writeFile(
90
+ path.join(targetDir, "manifest.json"),
91
+ `${JSON.stringify({
92
+ name: "ripgrep",
93
+ version: release.tag_name,
94
+ source: release.html_url,
95
+ asset: asset.name,
96
+ installedAt: new Date().toISOString(),
97
+ }, null, 2)}\n`,
98
+ "utf8",
99
+ );
100
+ console.error(`[ripgrep] installed ${path.relative(PROJECT_ROOT, targetPath)}`);
101
+ } finally {
102
+ await fsp.rm(tempDir, { recursive: true, force: true });
103
+ }
104
+ }
105
+
106
+ function platformKey() {
107
+ const key = `${process.platform}-${process.arch}`;
108
+ if (!TARGETS[key]) throw new Error(`unsupported platform: ${key}`);
109
+ return key;
110
+ }
111
+
112
+ function selectAsset(assets, key) {
113
+ const patterns = TARGETS[key];
114
+ return assets.find((asset) => patterns.some((pattern) => pattern.test(asset.name)));
115
+ }
116
+
117
+ async function getJson(url) {
118
+ try {
119
+ const response = await fetchWithRetry(url, {
120
+ headers: {
121
+ Accept: "application/vnd.github+json",
122
+ "User-Agent": "agent-scaffold-ripgrep-installer",
123
+ },
124
+ });
125
+ if (!response.ok) throw new Error(`GET ${url} returned ${response.status}: ${(await response.text()).slice(0, 200)}`);
126
+ return response.json();
127
+ } catch (error) {
128
+ const body = curlGet(url);
129
+ return JSON.parse(body.toString("utf8"));
130
+ }
131
+ }
132
+
133
+ async function download(url, destination) {
134
+ try {
135
+ const response = await fetchWithRetry(url, { headers: { "User-Agent": "agent-scaffold-ripgrep-installer" } });
136
+ if (!response.ok) throw new Error(`download returned ${response.status}`);
137
+ await fsp.writeFile(destination, Buffer.from(await response.arrayBuffer()));
138
+ } catch (error) {
139
+ curlDownload(url, destination);
140
+ }
141
+ }
142
+
143
+ async function fetchWithRetry(url, options, attempts = 3) {
144
+ let lastError;
145
+ for (let attempt = 1; attempt <= attempts; attempt += 1) {
146
+ try {
147
+ const response = await fetch(url, options);
148
+ if (response.ok || response.status < 500 || attempt === attempts) return response;
149
+ lastError = new Error(`HTTP ${response.status}`);
150
+ } catch (error) {
151
+ lastError = error;
152
+ if (attempt === attempts) break;
153
+ }
154
+ await delay(1000 * attempt);
155
+ }
156
+ throw lastError;
157
+ }
158
+
159
+ function delay(ms) {
160
+ return new Promise((resolve) => setTimeout(resolve, ms));
161
+ }
162
+
163
+ function curlGet(url) {
164
+ return execFileSync("curl", ["-fL", "--retry", "3", "--retry-delay", "1", "-H", "Accept: application/vnd.github+json", "-H", "User-Agent: agent-scaffold-ripgrep-installer", url], { maxBuffer: 1024 * 1024 * 20 });
165
+ }
166
+
167
+ function curlDownload(url, destination) {
168
+ execFileSync("curl", ["-fL", "--retry", "3", "--retry-delay", "1", "-H", "User-Agent: agent-scaffold-ripgrep-installer", "-o", destination, url], { stdio: "ignore" });
169
+ }
170
+
171
+ function extractArchive(archivePath, destination) {
172
+ try {
173
+ execFileSync("tar", ["-xf", archivePath, "-C", destination], { stdio: "ignore" });
174
+ return;
175
+ } catch (error) {
176
+ if (process.platform !== "win32" || !archivePath.toLowerCase().endsWith(".zip")) throw error;
177
+ }
178
+
179
+ execFileSync("powershell", [
180
+ "-NoProfile",
181
+ "-Command",
182
+ "Expand-Archive -LiteralPath $args[0] -DestinationPath $args[1] -Force",
183
+ archivePath,
184
+ destination,
185
+ ], { stdio: "ignore" });
186
+ }
187
+
188
+ async function findFile(root, fileName) {
189
+ const entries = await fsp.readdir(root, { withFileTypes: true });
190
+ for (const entry of entries) {
191
+ const fullPath = path.join(root, entry.name);
192
+ if (entry.isFile() && entry.name === fileName) return fullPath;
193
+ if (entry.isDirectory()) {
194
+ const found = await findFile(fullPath, fileName);
195
+ if (found) return found;
196
+ }
197
+ }
198
+ return undefined;
199
+ }
200
+
201
+ async function copyLicenseFiles(root, targetDir) {
202
+ const entries = await fsp.readdir(root, { withFileTypes: true });
203
+ for (const entry of entries) {
204
+ const fullPath = path.join(root, entry.name);
205
+ if (entry.isFile() && /^licen[sc]e|copying|unlicense/i.test(entry.name)) {
206
+ await fsp.copyFile(fullPath, path.join(targetDir, entry.name));
207
+ }
208
+ if (entry.isDirectory()) await copyLicenseFiles(fullPath, targetDir);
209
+ }
210
+ }