feat: finish master-agent prompt and memory runtime

This commit is contained in:
kris
2026-04-01 04:56:07 +08:00
parent d316f0490e
commit ba01ae5393
19 changed files with 461 additions and 70 deletions

View File

@@ -58,7 +58,7 @@ public class MasterAgentMemoryActivityTest {
JSONObject projectMemory = new JSONObject()
.put("memoryId", "mem-project")
.put("scope", "project")
.put("projectId", "master-agent")
.put("projectId", "boss-console")
.put("title", "项目进度")
.put("content", "主 Agent 对话链已接通")
.put("memoryType", "project_progress")
@@ -76,7 +76,7 @@ public class MasterAgentMemoryActivityTest {
View content = activity.findViewById(R.id.screen_content);
assertTrue(viewTreeContainsText(content, "我的通用记忆"));
assertTrue(viewTreeContainsText(content, "当前项目记忆"));
assertTrue(viewTreeContainsText(content, "项目记忆"));
assertTrue(viewTreeContainsText(content, "优先中文回复"));
JSONObject memories = payload.getJSONObject("memories");
JSONArray globalMemoryItems = (JSONArray) ReflectionHelpers.callInstanceMethod(
@@ -125,6 +125,7 @@ public class MasterAgentMemoryActivityTest {
"saveMemory",
ReflectionHelpers.ClassParameter.from(JSONObject.class, null),
ReflectionHelpers.ClassParameter.from(String.class, "project"),
ReflectionHelpers.ClassParameter.from(String.class, "boss-console"),
ReflectionHelpers.ClassParameter.from(String.class, "项目目标"),
ReflectionHelpers.ClassParameter.from(String.class, "把会话页收成微信式列表"),
ReflectionHelpers.ClassParameter.from(String.class, "project_progress"),
@@ -133,7 +134,7 @@ public class MasterAgentMemoryActivityTest {
org.robolectric.Shadows.shadowOf(android.os.Looper.getMainLooper()).idle();
assertEquals(
"{\"scope\":\"project\",\"projectId\":\"master-agent\",\"title\":\"项目目标\",\"content\":\"把会话页收成微信式列表\",\"memoryType\":\"project_progress\",\"tags\":[\"ui\",\"progress\"]}",
"{\"scope\":\"project\",\"projectId\":\"boss-console\",\"title\":\"项目目标\",\"content\":\"把会话页收成微信式列表\",\"memoryType\":\"project_progress\",\"tags\":[\"ui\",\"progress\"]}",
((ScriptedBossApiClient) ReflectionHelpers.getField(activity, "apiClient")).connection.requestBody()
);
}

View File

@@ -113,6 +113,39 @@ public class MasterAgentPromptActivityTest {
);
}
@Test
public void previewUpdatesWhenEditableLayersChange() throws Exception {
TestMasterAgentPromptActivity activity = Robolectric
.buildActivity(
TestMasterAgentPromptActivity.class,
new Intent()
.putExtra(MasterAgentPromptActivity.EXTRA_PROJECT_ID, "master-agent")
.putExtra(MasterAgentPromptActivity.EXTRA_PROJECT_NAME, "主 Agent")
)
.setup()
.get();
JSONObject payload = new JSONObject()
.put("promptPolicy", new JSONObject().put("globalPrompt", "全局主提示词"))
.put("userPrompt", new JSONObject().put("content", "用户私有主提示词"))
.put("projectControls", new JSONObject().put("promptOverride", "当前对话提示词"));
ReflectionHelpers.callInstanceMethod(
activity,
"renderPromptProfile",
ReflectionHelpers.ClassParameter.from(JSONObject.class, payload)
);
EditText userInput = ReflectionHelpers.getField(activity, "userPromptInput");
EditText conversationInput = ReflectionHelpers.getField(activity, "projectPromptInput");
userInput.setText("新的用户提示词");
conversationInput.setText("新的当前对话提示词");
View content = activity.findViewById(R.id.screen_content);
assertTrue(viewTreeContainsText(content, "新的用户提示词"));
assertTrue(viewTreeContainsText(content, "新的当前对话提示词"));
}
private static boolean viewTreeContainsText(View root, String expectedText) {
if (root instanceof TextView) {
CharSequence text = ((TextView) root).getText();