@buda-ai/connector 0.1.33 → 0.1.35

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.
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Sourced through BASH_ENV for Pi bash tool processes. Raising the score is
4
+ # permitted without CAP_SYS_RESOURCE and is inherited by every child process.
5
+ case "${BUDA_TOOL_OOM_SCORE_ADJ:-900}" in
6
+ '' | *[!0-9]*)
7
+ _buda_tool_oom_score=900
8
+ ;;
9
+ *)
10
+ _buda_tool_oom_score="${BUDA_TOOL_OOM_SCORE_ADJ:-900}"
11
+ ;;
12
+ esac
13
+
14
+ if [ "$_buda_tool_oom_score" -gt 1000 ]; then
15
+ _buda_tool_oom_score=1000
16
+ fi
17
+
18
+ printf '%s\n' "$_buda_tool_oom_score" >"/proc/$$/oom_score_adj" 2>/dev/null || true
19
+ unset _buda_tool_oom_score
@@ -258,7 +258,7 @@ For larger apps, create in phases:
258
258
  1. Foundation: scaffold, dependencies, layout, routing
259
259
  2. Core feature: main user journey
260
260
  3. Polish: styling, empty states, errors, responsive behavior
261
- 4. Verification: build/lint/test and browser preview
261
+ 4. Verification: build/lint/test and local browser preview
262
262
  5. Git: commit the slice when the working tree has meaningful changes
263
263
 
264
264
  ### 3. Create or edit files
@@ -327,7 +327,7 @@ If lint is not configured, do not invent a full lint setup unless useful. At min
327
327
 
328
328
  ### 5. Launch a live preview when visual output matters
329
329
 
330
- If the user wants to view, run, preview, open, demo, or inspect the app in a browser, also use the `request_preview_url` tool to output the both a PUBLIC And Local URL
330
+ If the user wants to view, run, preview, open, demo, or inspect the app in a local browser, also use the `request_preview_url` tool to output the both a PUBLIC And Local URL
331
331
 
332
332
  **For static apps, serve `public/` with a zero-dependency static server — do NOT install a dev server or run a package manager.** From the app folder run e.g. `python3 -m http.server <port> --directory public` (or `bunx serve public -l <port>` only if Python is unavailable), then share the URL the same way as below.
333
333
 
@@ -76,11 +76,11 @@ Users want to **see** it running — not read a code block.
76
76
  8. **Never hardcode working directory**. Derive paths relative to the project directory. Do not assume `/agent/` unless that is the actual project root.
77
77
  9. **Support multiple simultaneous dev servers**. PID/log files must be scoped per project (use a hash or sanitized project path), not a single global `/tmp/buda-preview.*`.
78
78
  10. **Read `buda.app.json` first**. If a `buda.app.json` exists in the project directory, read it to get the dev command, port, and other settings before falling back to defaults.
79
+ 11. Do not use AI Browser for sandbox localhost previews unless the user explicitly wants the AI-controlled CDP browser to visit the signed external preview URL.
79
80
 
80
81
  ## AI Browser vs Local Browser
81
82
 
82
83
  - Use this skill and `get_preview_url` when the user wants to preview a local dev server or generated app. Buda opens that preview in **Local Browser**.
83
- - Do not use AI Browser for sandbox localhost previews unless the user explicitly wants the AI-controlled CDP browser to visit the signed external preview URL.
84
84
 
85
85
  ---
86
86
 
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { readFileSync } = require("fs");
4
+ const path = require("path");
5
+
6
+ const PACKAGE_JSON_PATH = path.join(__dirname, "..", "package.json");
7
+ const NODE_DOWNLOAD_URL = "https://nodejs.org/en/download";
8
+
9
+ function parseVersion(value) {
10
+ const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(value);
11
+ if (!match) throw new Error(`Invalid Node.js version: ${value}`);
12
+ return match.slice(1).map(Number);
13
+ }
14
+
15
+ function parseMinimumVersion(requirement) {
16
+ const match = /^>=\s*(\d+\.\d+\.\d+)$/.exec(requirement);
17
+ if (!match) {
18
+ throw new Error(
19
+ `Unsupported package.json engines.node requirement: ${JSON.stringify(requirement)}`,
20
+ );
21
+ }
22
+ return match[1];
23
+ }
24
+
25
+ function isVersionAtLeast(detected, required) {
26
+ const detectedParts = parseVersion(detected);
27
+ const requiredParts = parseVersion(required);
28
+ for (let index = 0; index < requiredParts.length; index += 1) {
29
+ if (detectedParts[index] > requiredParts[index]) return true;
30
+ if (detectedParts[index] < requiredParts[index]) return false;
31
+ }
32
+ return true;
33
+ }
34
+
35
+ function readNodeRequirement(readPackageJson = readFileSync) {
36
+ const packageJson = JSON.parse(readPackageJson(PACKAGE_JSON_PATH, "utf8"));
37
+ if (
38
+ typeof packageJson !== "object" ||
39
+ packageJson === null ||
40
+ typeof packageJson.engines !== "object" ||
41
+ packageJson.engines === null ||
42
+ typeof packageJson.engines.node !== "string"
43
+ ) {
44
+ throw new Error("package.json engines.node must be configured");
45
+ }
46
+ return packageJson.engines.node;
47
+ }
48
+
49
+ function unsupportedNodeMessage(detected, requirement) {
50
+ return [
51
+ "Buda AI Connector requires a newer version of Node.js.",
52
+ "",
53
+ `Detected: Node.js v${detected}`,
54
+ `Required: Node.js ${requirement}`,
55
+ "Recommended: Node.js 24 LTS",
56
+ "",
57
+ `Upgrade Node.js: ${NODE_DOWNLOAD_URL}`,
58
+ "After upgrading, run your Buda Connector command again.",
59
+ "",
60
+ ].join("\n");
61
+ }
62
+
63
+ async function runBootstrap(options = {}) {
64
+ const detected = options.nodeVersion || process.versions.node;
65
+ const requirement = options.nodeRequirement || readNodeRequirement(options.readPackageJson);
66
+ const required = parseMinimumVersion(requirement);
67
+ if (!isVersionAtLeast(detected, required)) {
68
+ const writeError = options.writeError || ((message) => process.stderr.write(message));
69
+ writeError(unsupportedNodeMessage(detected, requirement));
70
+ return 1;
71
+ }
72
+
73
+ const loadCli = options.loadCli || (() => import("./cli.js"));
74
+ await loadCli();
75
+ return 0;
76
+ }
77
+
78
+ if (require.main === module) {
79
+ runBootstrap()
80
+ .then((exitCode) => {
81
+ process.exitCode = exitCode;
82
+ })
83
+ .catch((error) => {
84
+ console.error("[buda-connector] failed to start:", error);
85
+ process.exitCode = 1;
86
+ });
87
+ }
88
+
89
+ module.exports = {
90
+ isVersionAtLeast,
91
+ parseMinimumVersion,
92
+ parseVersion,
93
+ readNodeRequirement,
94
+ runBootstrap,
95
+ unsupportedNodeMessage,
96
+ };