Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(cli): exec npm shebang wrappers instead of skipping all shebang files (#4085)
wutongyuonced436baa23c83
diff --git a/openviking_cli/rust_cli.py b/openviking_cli/rust_cli.pyindex 270e3037a..46dea6c3a 100644--- a/openviking_cli/rust_cli.py+++ b/openviking_cli/rust_cli.py@@ -75,19 +75,20 @@ def main():except Exception:pass- # 3. 检查 PATH,但跳过当前 Python 脚本+ # 3. 检查 PATH,但跳过当前 Python 入口点path_binary = which("ov")if path_binary:- # 检查文件是否是 Python 脚本(避免无限循环)try:candidate_path = Path(path_binary).resolve()- with open(candidate_path, "rb") as f:- first_bytes = f.read(2)- # Skip if it starts with #! (shebang, likely Python script)- if first_bytes != b"#!":- _exec_binary(path_binary, sys.argv[1:])- except Exception:+ current_path = Path(sys.argv[0])+ if not current_path.is_absolute():+ current_path = Path(which(sys.argv[0]) or current_path)+ current_path = current_path.resolve()+ except OSError:pass+ else:+ if candidate_path != current_path:+ _exec_binary(path_binary, sys.argv[1:])# 都找不到,提示用户print(diff --git a/tests/misc/test_rust_cli.py b/tests/misc/test_rust_cli.pynew file mode 100644index 000000000..f929acdf5--- /dev/null+++ b/tests/misc/test_rust_cli.py@@ -0,0 +1,19 @@+import pytest++from openviking_cli import rust_cli+++def test_main_executes_npm_shebang_wrapper(monkeypatch, tmp_path):+ wrapper = tmp_path / "ov"+ wrapper.write_text("#!/usr/bin/env node\n", encoding="utf-8")++ class Executed(Exception):+ pass++ monkeypatch.setattr(rust_cli.Path, "exists", lambda _path: False)+ monkeypatch.setattr(rust_cli, "which", lambda _name: str(wrapper))+ monkeypatch.setattr(rust_cli, "_exec_binary", lambda *_args: (_ for _ in ()).throw(Executed))+ monkeypatch.setattr(rust_cli.sys, "argv", [str(tmp_path / "openviking"), "--version"])++ with pytest.raises(Executed):+ rust_cli.main()