Skip to content

Commit

Permalink
Use project root dir as script's cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
rtfeldman committed Mar 10, 2025
1 parent f645604 commit 1c3b0b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 0 additions & 1 deletion crates/assistant_scripting/src/sandbox_preamble.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ io.open = sb_io_open
-- Add the sandboxed io library to the sandbox environment
-- sandbox.io = io -- Uncomment this line to re-enable sandboxed file I/O.


-- Load the script with the sandbox environment
local user_script_fn, err = load(user_script, nil, "t", sandbox)

Expand Down
8 changes: 8 additions & 0 deletions crates/assistant_scripting/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ impl ScriptSession {
let lua = Lua::new();
lua.set_memory_limit(2 * 1024 * 1024 * 1024)?; // 2 GB
let globals = lua.globals();

// Use the project root dir as the script's current working dir.
if let Some(root_dir) = &root_dir {
if let Some(root_dir) = root_dir.to_str() {
globals.set("cwd", root_dir)?;
}
}

globals.set(
"sb_print",
lua.create_function({
Expand Down

0 comments on commit 1c3b0b4

Please sign in to comment.