Classify a string user entry by promptSource before its leading <

This commit is contained in:
2026-09-28 20:26:34 +02:00
parent 74c2841b8d
commit 8e15ff7f37
+4 -2
View File
@@ -30,7 +30,7 @@ def transcript_path(projects, session_id):
return hit[0] if hit else ""
# <session id>.jsonl, <session id>/subagents/, and from older versions <session id>.superseded-1789290815002/
# <session id>.jsonl, <session id>/subagents/, and from older versions <session id>.superseded-1789290815002/ and <session id>.orphaned-*.jsonl
def session_files(transcript):
return glob.glob(glob.escape(transcript.removesuffix(".jsonl")) + "*")
@@ -67,9 +67,11 @@ def user_entry_kind(entry):
if entry.get("promptSource") == "sdk":
return UserEntryKind.SDK_PROMPT
# {"type": "user", "message": {"content": "<command-name>/model</command-name>\n..."}}
# {"type": "user", "promptSource": "system", "message": {"content": "<task-notification>..."}}
# {"type": "user", "promptSource": "typed", "message": {"content": "merge it"}}
if isinstance(text := content(entry), str):
return UserEntryKind.COMMAND if text.startswith("<") else UserEntryKind.HUMAN
source = entry.get("promptSource")
return UserEntryKind.COMMAND if source == "system" or (source is None and text.startswith("<")) else UserEntryKind.HUMAN
if not parts(entry):
return UserEntryKind.EMPTY
# {"type": "user", "message": {"content": [{"tool_use_id": "toolu_01…", "type": "tool_result", "content": "hi"}]}}