Compare commits
No commits in common. "6e694224ef007747cc6a032d8c45fab7950624aa" and "0cd43c37a75d2cdf4cc704434e95e909a8464318" have entirely different histories.
6e694224ef
...
0cd43c37a7
@ -6,8 +6,6 @@ import time
|
|||||||
import json
|
import json
|
||||||
import shlex
|
import shlex
|
||||||
import builtins
|
import builtins
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from dataclasses import asdict
|
from dataclasses import asdict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Callable
|
from typing import Any, Callable
|
||||||
@ -559,16 +557,8 @@ def _build_prompt_input(input_func: InputFunc) -> InputFunc:
|
|||||||
"checkpoint",
|
"checkpoint",
|
||||||
"exit",
|
"exit",
|
||||||
]
|
]
|
||||||
history = None
|
|
||||||
try:
|
|
||||||
history_path = Path("runtime") / "chat_history.txt"
|
|
||||||
history_path.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
history = FileHistory(str(history_path))
|
|
||||||
except OSError:
|
|
||||||
history = None
|
|
||||||
|
|
||||||
session = PromptSession(
|
session = PromptSession(
|
||||||
history=history,
|
history=FileHistory(str(Path("runtime") / "chat_history.txt")),
|
||||||
completer=WordCompleter(commands, ignore_case=True, sentence=True),
|
completer=WordCompleter(commands, ignore_case=True, sentence=True),
|
||||||
)
|
)
|
||||||
return session.prompt
|
return session.prompt
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
import builtins
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from pam_deploy_graph.agent import PamDeployAgent
|
from pam_deploy_graph.agent import PamDeployAgent
|
||||||
from pam_deploy_graph.fake_runner import FakeActionRunner
|
from pam_deploy_graph.fake_runner import FakeActionRunner
|
||||||
from pam_deploy_graph.interactive import InteractiveCliSession, _build_prompt_input
|
from pam_deploy_graph.interactive import InteractiveCliSession
|
||||||
|
|
||||||
|
|
||||||
PARAMS = {
|
PARAMS = {
|
||||||
@ -133,14 +130,3 @@ def test_chat_can_hot_load_mcp_config(tmp_path: Path):
|
|||||||
assert session.agent.mcp_runner is not None
|
assert session.agent.mcp_runner is not None
|
||||||
assert session.agent.router.mcp_runner is not None
|
assert session.agent.router.mcp_runner is not None
|
||||||
assert any("MCP 配置已加载" in item for item in output)
|
assert any("MCP 配置已加载" in item for item in output)
|
||||||
|
|
||||||
|
|
||||||
def test_prompt_history_creates_runtime_dir(tmp_path: Path, monkeypatch):
|
|
||||||
pytest.importorskip("prompt_toolkit")
|
|
||||||
monkeypatch.chdir(tmp_path)
|
|
||||||
|
|
||||||
prompt = _build_prompt_input(builtins.input)
|
|
||||||
|
|
||||||
assert callable(prompt)
|
|
||||||
assert (tmp_path / "runtime").is_dir()
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user