fix: reduce end-user installation footprint

This commit is contained in:
nac
2026-08-15 02:59:28 +00:00
parent 5d3122b7e4
commit 5288590893
10 changed files with 98 additions and 79 deletions
+26 -3
View File
@@ -73,7 +73,10 @@ class AgentInstallTests(unittest.TestCase):
self.assertTrue(first["configCreated"])
self.assertFalse(second["configCreated"])
self.assertEqual(preserved["env"], "custom-env")
self.assertEqual(calls[0][0], ["/opt/bin/uv", "sync", "--locked", "--python", "3.12"])
self.assertEqual(calls[0][0], ["/opt/bin/uv", "sync", "--locked", "--no-dev", "--python", "3.12"])
self.assertEqual(calls[0][1]["env"]["UV_PROJECT_ENVIRONMENT"], str(root / ".venv"))
self.assertEqual(first["dependencies"], "locked-runtime-only")
self.assertEqual(first["environmentPath"], str(root / ".venv"))
self.assertEqual(len(calls), 2)
def test_set_env_backs_up_config_before_changing_it(self) -> None:
@@ -227,12 +230,21 @@ class AgentInstallTests(unittest.TestCase):
writable = agent_install.render_client_config(root, enable_writes=True, which=fake_which)
server = config["mcpServers"]["nocobase-crm"]
self.assertEqual(server["command"], "/opt/bin/uv")
self.assertEqual(server["command"], str(root.resolve() / ".venv" / "bin" / "python"))
self.assertEqual(server["env"]["NOCOBASE_MCP_NB_BIN"], "/opt/bin/nb")
self.assertIn(str(root.resolve()), server["args"])
self.assertIn(str(root.resolve() / "config.json"), server["args"])
self.assertEqual(server["args"][:2], ["-m", "nocobase_crm_mcp.server"])
self.assertNotIn("--enable-writes", server["args"])
self.assertIn("--enable-writes", writable["mcpServers"]["nocobase-crm"]["args"])
def test_client_config_uses_windows_project_environment_python(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
config = agent_install.render_client_config(root, which=fake_which, os_name="nt")
server = config["mcpServers"]["nocobase-crm"]
self.assertEqual(server["command"], str(root.resolve() / ".venv" / "Scripts" / "python.exe"))
def test_doctor_checks_local_install_without_reading_nb_secrets(self) -> None:
commands = []
@@ -254,6 +266,14 @@ class AgentInstallTests(unittest.TestCase):
self.assertTrue(result["ok"])
self.assertEqual(commands[0], ["/opt/bin/uv", "lock", "--check"])
self.assertEqual(
commands[1],
[
str(root.resolve() / ".venv" / "bin" / "python"),
"-c",
"import mcp; import nocobase_crm_mcp",
],
)
self.assertNotIn("--show-secrets", json.dumps(result))
self.assertTrue(any("crm_health" in step for step in result["remainingVerification"]))
@@ -269,6 +289,9 @@ class AgentInstallTests(unittest.TestCase):
self.assertEqual(manifest["authentication"]["secretEntry"], "user-controlled-private-tty")
self.assertFalse(manifest["authentication"]["allowPassword"])
self.assertFalse(manifest["authentication"]["allowCommandLineSecret"])
self.assertEqual(manifest["runtime"]["launcher"], "project-venv-python")
self.assertEqual(manifest["runtime"]["dependencyProfile"], "runtime-only-no-dev")
self.assertFalse(manifest["installation"]["defaultBackgroundService"])
self.assertTrue(manifest["securityDefaults"]["readOnly"])
self.assertFalse(manifest["securityDefaults"]["uploads"])