mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 15:01:34 +08:00
Merge pull request #15351 from helix4u/fix/tui-rebuild-missing-ink-bundle
fix(tui): rebuild when ink bundle is missing
This commit is contained in:
@@ -839,6 +839,8 @@ def _find_bundled_tui(tui_dir: Path) -> Optional[Path]:
|
|||||||
|
|
||||||
|
|
||||||
def _tui_build_needed(tui_dir: Path) -> bool:
|
def _tui_build_needed(tui_dir: Path) -> bool:
|
||||||
|
if _hermes_ink_bundle_stale(tui_dir):
|
||||||
|
return True
|
||||||
entry = tui_dir / "dist" / "entry.js"
|
entry = tui_dir / "dist" / "entry.js"
|
||||||
if not entry.exists():
|
if not entry.exists():
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -19,6 +19,18 @@ def _touch_ink(root: Path) -> None:
|
|||||||
ink.write_text("{}")
|
ink.write_text("{}")
|
||||||
|
|
||||||
|
|
||||||
|
def _touch_tui_entry(root: Path) -> None:
|
||||||
|
entry = root / "dist" / "entry.js"
|
||||||
|
entry.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
entry.write_text("console.log('tui')")
|
||||||
|
|
||||||
|
|
||||||
|
def _touch_ink_bundle(root: Path) -> None:
|
||||||
|
bundle = root / "packages" / "hermes-ink" / "dist" / "ink-bundle.js"
|
||||||
|
bundle.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
bundle.write_text("export {}")
|
||||||
|
|
||||||
|
|
||||||
def test_need_install_when_ink_missing(tmp_path: Path, main_mod) -> None:
|
def test_need_install_when_ink_missing(tmp_path: Path, main_mod) -> None:
|
||||||
(tmp_path / "package-lock.json").write_text("{}")
|
(tmp_path / "package-lock.json").write_text("{}")
|
||||||
assert main_mod._tui_need_npm_install(tmp_path) is True
|
assert main_mod._tui_need_npm_install(tmp_path) is True
|
||||||
@@ -51,3 +63,19 @@ def test_need_install_when_marker_missing(tmp_path: Path, main_mod) -> None:
|
|||||||
def test_no_install_without_lockfile_when_ink_present(tmp_path: Path, main_mod) -> None:
|
def test_no_install_without_lockfile_when_ink_present(tmp_path: Path, main_mod) -> None:
|
||||||
_touch_ink(tmp_path)
|
_touch_ink(tmp_path)
|
||||||
assert main_mod._tui_need_npm_install(tmp_path) is False
|
assert main_mod._tui_need_npm_install(tmp_path) is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_build_needed_when_local_ink_bundle_missing(tmp_path: Path, main_mod) -> None:
|
||||||
|
_touch_tui_entry(tmp_path)
|
||||||
|
_touch_ink(tmp_path)
|
||||||
|
|
||||||
|
assert main_mod._tui_need_npm_install(tmp_path) is False
|
||||||
|
assert main_mod._tui_build_needed(tmp_path) is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_build_not_needed_when_entry_and_ink_bundle_present(tmp_path: Path, main_mod) -> None:
|
||||||
|
_touch_tui_entry(tmp_path)
|
||||||
|
_touch_ink(tmp_path)
|
||||||
|
_touch_ink_bundle(tmp_path)
|
||||||
|
|
||||||
|
assert main_mod._tui_build_needed(tmp_path) is False
|
||||||
|
|||||||
Reference in New Issue
Block a user