feat(python-runtime): package the dsh CLI and profile assets

Make the zero-code dsh-python-runtime-closure depend on the real @deepseek-ai/dsh application and every required profile peer, then package apps/cli's built bin instead of the deleted Python carrier. Rename executables to deepseek-harness-sdk-runtime-<platform>-<arch>, update wheel/platform/build workflow discovery, and install a Python dsh console command that requires explicit DSH_HOME before exec.

Include profile, bundle, preset, native addon, and shared-library assets needed by the full CLI. Remove the checked-in default cordis.yml and preserve the existing wheel distribution names, Python module names, sidecar validation, and wire identity. Runtime resolution and release tests pin the new artifacts and dev Node carrier.
This commit is contained in:
Tianyi Cui
2026-08-24 17:28:26 +08:00
parent 809a4c5bad
commit be7b064504
16 changed files with 125 additions and 143 deletions
+7 -2
View File
@@ -59,6 +59,7 @@ def test_pep440_version_spells_a_prerelease_the_python_way() -> None:
def test_macos_wheel_tag_does_not_claim_unsupported_node_platforms() -> None:
assert build_python_release.PLATFORMS["macos-arm64"][0] == "macosx_14_0_arm64"
assert build_python_release.PLATFORMS["macos-arm64"][1] == "deepseek-harness-sdk-runtime-macos-arm64"
def test_platform_manifest_rejects_incomplete_entries(tmp_path: Path) -> None:
@@ -88,7 +89,7 @@ def test_stage_sdk_keeps_distribution_module_and_runtime_pin_distinct(tmp_path:
def test_stage_runtime_copies_platform_payload(
tmp_path: Path, target: str, with_helper: bool
) -> None:
executable = tmp_path / f"dsh-jsonrpc-agent-pkg-{target}"
executable = tmp_path / f"deepseek-harness-sdk-runtime-{target}"
executable.write_bytes(b"runtime")
executable.chmod(0o755)
expected = {executable.name: b"runtime"}
@@ -106,10 +107,14 @@ def test_stage_runtime_copies_platform_payload(
build_python_release.stage_runtime(destination, "1.2.3", executable, executable.name)
runtime_dir = destination / "src" / "deepseek_harness_runtime" / "runtime"
assert {path.name: path.read_bytes() for path in runtime_dir.glob("dsh-jsonrpc-agent-pkg-*")} == expected
assert {
path.name: path.read_bytes()
for path in runtime_dir.glob("deepseek-harness-sdk-runtime-*")
} == expected
pyproject = (destination / "pyproject.toml").read_text()
assert 'license = "MIT"' in pyproject
assert 'license-files = ["LICENSE", "THIRD_PARTY_NOTICES.md"]' in pyproject
assert 'dsh = "deepseek_harness_runtime:main"' in pyproject
assert (destination / "platforms.json").read_bytes() == (
ROOT / "python" / "sdk-runtime" / "platforms.json"
).read_bytes()
+50 -13
View File
@@ -9,21 +9,12 @@ import pytest
from deepseek_harness_runtime import (
RUNTIME_MODE_ENV_VAR,
bundled_default_config_path,
bundled_package_dir,
main,
resolve_bundled_launch_args,
)
def test_default_config_is_shipped_with_the_package() -> None:
path = bundled_default_config_path()
assert path == bundled_package_dir() / "runtime" / "cordis.yml"
config = path.read_text()
assert "@deepseek-ai/dsh-agent-spine-demo" in config
assert "@deepseek-ai/dsh-session-persistence-jsonl" in config
assert "@deepseek-ai/dsh-session-checkpoint-policy" in config
def test_unknown_explicit_mode_fails_loud() -> None:
with pytest.raises(ValueError, match="expected 'exe' or 'node'"):
resolve_bundled_launch_args("bogus")
@@ -49,10 +40,10 @@ def test_runtime_requires_spawn_helper_only_on_macos(
) -> None:
runtime_dir = tmp_path / "runtime"
runtime_dir.mkdir()
linux = runtime_dir / "dsh-jsonrpc-agent-pkg-linux-x64"
linux = runtime_dir / "deepseek-harness-sdk-runtime-linux-x64"
linux.touch()
Path(f"{linux}-rg").touch()
macos = runtime_dir / "dsh-jsonrpc-agent-pkg-macos-arm64"
macos = runtime_dir / "deepseek-harness-sdk-runtime-macos-arm64"
macos.touch()
Path(f"{macos}-rg").touch()
monkeypatch.setattr(runtime, "bundled_package_dir", lambda: tmp_path)
@@ -69,9 +60,55 @@ def test_runtime_requires_ripgrep_sidecar(
) -> None:
runtime_dir = tmp_path / "runtime"
runtime_dir.mkdir()
(runtime_dir / "dsh-jsonrpc-agent-pkg-linux-x64").touch()
(runtime_dir / "deepseek-harness-sdk-runtime-linux-x64").touch()
monkeypatch.setattr(runtime, "bundled_package_dir", lambda: tmp_path)
monkeypatch.setattr(runtime, "_current_platform_tag", lambda: "linux-x64")
with pytest.raises(FileNotFoundError, match="ripgrep sidecar"):
runtime.bundled_runtime_path()
def test_node_mode_runs_the_deployed_dsh_cli(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
bin_js = tmp_path / "runtime" / "node" / "node_modules" / "@deepseek-ai" / "dsh" / "lib" / "bin.js"
bin_js.parent.mkdir(parents=True)
bin_js.touch()
monkeypatch.setattr(runtime, "bundled_package_dir", lambda: tmp_path)
monkeypatch.setattr(runtime.shutil, "which", lambda _name: "/node")
assert resolve_bundled_launch_args("node") == ("/node", str(bin_js))
def test_python_dsh_command_requires_explicit_home(
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
) -> None:
monkeypatch.delenv("DSH_HOME", raising=False)
with pytest.raises(SystemExit) as excinfo:
main()
assert excinfo.value.code == 2
assert "explicit DSH_HOME" in capsys.readouterr().err
def test_python_dsh_command_executes_the_bundled_cli(
monkeypatch: pytest.MonkeyPatch
) -> None:
called: dict[str, object] = {}
monkeypatch.setenv("DSH_HOME", "/explicit/home")
monkeypatch.setattr(runtime, "resolve_bundled_launch_args", lambda: ("/runtime",))
monkeypatch.setattr(runtime.sys, "argv", ["dsh", "plugin", "--profile", "sdk", "list"])
def execvpe(file: str, args: tuple[str, ...], env: dict[str, str]) -> None:
called.update(file=file, args=args, home=env.get("DSH_HOME"))
monkeypatch.setattr(runtime.os, "execvpe", execvpe)
main()
assert called == {
"file": "/runtime",
"args": ("/runtime", "plugin", "--profile", "sdk", "list"),
"home": "/explicit/home",
}