import json
import os
import sqlite3
import subprocess
import sys
import tempfile
def main():
goosedump_bin = os.environ.get("GOOSEDUMP_BIN", "")
if not goosedump_bin:
print("FAIL GOOSEDUMP_BIN not set")
sys.exit(1)
pass_count = 0
fail_count = 0
def passed(name):
nonlocal pass_count
pass_count += 1
print(f"PASS {name}")
def failed(name, reason):
nonlocal fail_count
fail_count += 1
print(f"FAIL {name} -- {reason}")
def run(args, env=None, cwd=None):
result = subprocess.run(
[goosedump_bin] + args,
capture_output=True,
text=True,
env=env,
cwd=cwd,
)
return result.returncode, result.stdout, result.stderr
def expect_success(name, args, env, cwd, contains):
status, stdout, stderr = run(args, env=env, cwd=cwd)
if status != 0:
failed(name, f"expected status 0, got {status} stderr={stderr[:200]}")
return
if contains is not None and contains not in stdout:
failed(name, f"expected output to contain '{contains}'. stdout: {stdout[:400]}")
return
passed(name)
def expect_not_contains(name, args, env, cwd, not_contains):
status, stdout, stderr = run(args, env=env, cwd=cwd)
if status != 0:
failed(name, f"expected status 0, got {status} stderr={stderr[:200]}")
return
if not_contains in stdout:
failed(name, f"output must not contain '{not_contains}'. stdout: {stdout[:400]}")
return
passed(name)
def expect_failure(name, args, env, cwd):
status, stdout, _stderr = run(args, env=env, cwd=cwd)
if status != 0:
passed(name)
else:
failed(name, f"expected failure but got success. stdout: {stdout[:200]}")
def expect_stdout(name, args, env, cwd, *patterns):
status, stdout, stderr = run(args, env=env, cwd=cwd)
if status != 0:
failed(name, f"expected status 0, got {status} stderr={stderr[:200]}")
return
for p in patterns:
if p not in stdout:
failed(name, f"output missing '{p}'. stdout: {stdout[:400]}")
return
passed(name)
def expect_failure_stdout(name, args, env, cwd, expected_status, *patterns):
status, stdout, _stderr = run(args, env=env, cwd=cwd)
if status != expected_status:
failed(name, f"expected status {expected_status}, got {status}")
return
for p in patterns:
if p not in stdout:
failed(name, f"output missing '{p}'. stdout: {stdout[:400]}")
return
passed(name)
def write_jsonl(file, value):
file.write(json.dumps(value) + "\n")
with tempfile.TemporaryDirectory() as tmpdir:
oc_dir = os.path.join(tmpdir, "opencode")
os.makedirs(oc_dir)
oc_db = os.path.join(oc_dir, "opencode.db")
conn = sqlite3.connect(oc_db)
conn.execute(
"CREATE TABLE message(session_id TEXT, id TEXT, data TEXT, time_created INTEGER)"
)
conn.execute(
"CREATE TABLE part(session_id TEXT, message_id TEXT, data TEXT, time_created INTEGER)"
)
sid1 = "sesh-alpha"
conn.execute(
"INSERT INTO message VALUES(?, ?, ?, ?)",
(
sid1,
"msg-a",
json.dumps({"role": "user", "id": "entry-alpha", "parentID": ""}),
1000,
),
)
conn.execute(
"INSERT INTO part VALUES(?, ?, ?, ?)",
(
sid1,
"msg-a",
json.dumps({"type": "text", "text": "search keyword STARTREK-DISCO"}),
1000,
),
)
conn.execute(
"INSERT INTO message VALUES(?, ?, ?, ?)",
(
sid1,
"msg-b",
json.dumps(
{"role": "assistant", "id": "entry-bravo", "parentID": "entry-alpha"}
),
2000,
),
)
conn.execute(
"INSERT INTO part VALUES(?, ?, ?, ?)",
(
sid1,
"msg-b",
json.dumps({"type": "reasoning", "text": "need to read a file"}),
2000,
),
)
conn.execute(
"INSERT INTO part VALUES(?, ?, ?, ?)",
(
sid1,
"msg-b",
json.dumps({"type": "text", "text": "found STARTREK-DISCO in source"}),
2001,
),
)
conn.execute(
"INSERT INTO part VALUES(?, ?, ?, ?)",
(
sid1,
"msg-b",
json.dumps(
{
"type": "tool",
"name": "read",
"arguments": {
"filePath": "src/main.rs",
"description": "read tool",
},
}
),
2002,
),
)
sid2 = "sesh-bravo"
conn.execute(
"INSERT INTO message VALUES(?, ?, ?, ?)",
(
sid2,
"msg-c",
json.dumps({"role": "user", "id": "entry-charlie", "parentID": ""}),
3000,
),
)
conn.execute(
"INSERT INTO part VALUES(?, ?, ?, ?)",
(
sid2,
"msg-c",
json.dumps({"type": "text", "text": "query about TANGO-SIERRA"}),
3000,
),
)
conn.commit()
conn.close()
crush_db = os.path.join(tmpdir, "crush.db")
conn = sqlite3.connect(crush_db)
conn.execute(
"CREATE TABLE messages(session_id TEXT, role TEXT, parts TEXT, created_at TEXT)"
)
csid = "sesh-crush"
conn.execute(
"INSERT INTO messages VALUES(?, ?, ?, ?)",
(
csid,
"user",
json.dumps([{"type": "text", "text": "explain ZULU-NOVEMBER"}]),
"2026-01-01T00:00:00Z",
),
)
conn.execute(
"INSERT INTO messages VALUES(?, ?, ?, ?)",
(
csid,
"assistant",
json.dumps(
[
{
"type": "text",
"text": "ZULU-NOVEMBER is a code pattern",
},
{
"type": "tool_use",
"name": "grep",
"input": {"pattern": "ZULU", "filePath": "lib.rs"},
"result": "lib.rs:9: ZULU-NOVEMBER",
},
]
),
"2026-01-01T00:00:01Z",
),
)
conn.commit()
conn.close()
with open(os.path.join(tmpdir, ".crush.json"), "w") as f:
json.dump({"data_directory": "."}, f)
pi_dir = os.path.join(tmpdir, "pi-sessions")
os.makedirs(pi_dir)
pi_file = os.path.join(pi_dir, "pi-sesh.jsonl")
with open(pi_file, "w") as f:
f.write(
json.dumps(
{
"type": "session",
"id": "sesh-pi",
"cwd": "/tmp/project",
}
)
+ "\n"
)
f.write(
json.dumps(
{
"type": "message",
"id": "pi-entry-1",
"parentId": "",
"message": {
"role": "user",
"content": [
{"type": "text", "text": "find TRIPLA-ESPRESSO"}
],
},
}
)
+ "\n"
)
f.write(
json.dumps(
{
"type": "message",
"id": "pi-entry-2",
"parentId": "pi-entry-1",
"message": {
"role": "assistant",
"content": [
{
"type": "thinking",
"text": "searching for TRIPLA-ESPRESSO",
},
{
"type": "text",
"text": "found TRIPLA-ESPRESSO in file",
},
{
"type": "toolCall",
"name": "bash",
"arguments": {
"command": "grep TRIPLA src/*.rs"
},
},
{
"type": "toolCall",
"name": "todo",
"arguments": {"action": "update"},
},
],
},
}
)
+ "\n"
)
f.write(
json.dumps(
{
"type": "message",
"id": "pi-entry-3",
"parentId": "pi-entry-2",
"message": {
"role": "bashExecution",
"command": "grep TRIPLA src/*.rs",
"content": [
{
"type": "text",
"text": "src/main.rs:123: TRIPLA-ESPRESSO\ntest result: ok. 1 passed",
}
],
},
}
)
+ "\n"
)
f.write(
json.dumps(
{
"type": "message",
"id": "pi-entry-4",
"parentId": "pi-entry-3",
"message": {
"role": "toolResult",
"toolName": "todo",
"content": "Created #99: Review compact parity (pending)\nUpdated #99 (pending -> in_progress)\n1:928|// SPDX-License-Identifier\n.git/\nnode_modules/",
},
}
)
+ "\n"
)
f.write(
json.dumps(
{
"type": "message",
"id": "pi-entry-5",
"parentId": "pi-entry-4",
"message": {
"role": "assistant",
"content": [
{
"type": "text",
"text": "The earlier error is fixed; tests are passing.",
}
],
},
}
)
+ "\n"
)
pi_merge_file = os.path.join(pi_dir, "pi-merge.jsonl")
with open(pi_merge_file, "w") as f:
f.write(
json.dumps(
{
"type": "session",
"id": "sesh-pi-merge",
"cwd": "/tmp/project",
}
)
+ "\n"
)
f.write(
json.dumps(
{
"type": "message",
"id": "pi-merge-1",
"parentId": "",
"message": {
"role": "assistant",
"content": [
{
"type": "text",
"text": "[Session Goal]\n- Preserve durable context (#prior-goal)\n\n---\n\n[User Preferences]\n- Always run clippy (#prior-pref)\n\n---\n\n[assistant]\nold transcript line",
}
],
},
}
)
+ "\n"
)
pi_long_file = os.path.join(pi_dir, "pi-long.jsonl")
with open(pi_long_file, "w") as f:
def long_msg(idx, parent, role, text):
return {
"type": "message",
"id": f"long-{idx}",
"parentId": parent,
"message": {
"role": role,
"content": [{"type": "text", "text": text}],
},
}
write_jsonl(
f, {"type": "session", "id": "sesh-pi-long", "cwd": "/tmp/project"}
)
write_jsonl(
f, long_msg(1, "", "user", "establish the espresso machine baseline")
)
write_jsonl(
f,
long_msg(
2,
"long-1",
"assistant",
"OPENING-ASSISTANT-MARKER reviewing the initial layout",
),
)
prev = "long-2"
for n in range(3, 143):
write_jsonl(
f, long_msg(n, prev, "assistant", f"step {n} inspecting module {n}")
)
prev = f"long-{n}"
write_jsonl(
f,
long_msg(
143,
prev,
"assistant",
"TAIL-RECENT-MARKER final verification of the pipeline",
),
)
codex_home = os.path.join(tmpdir, "codex-home")
codex_sessions_dir = os.path.join(codex_home, "sessions", "2026", "06", "11")
os.makedirs(codex_sessions_dir)
codex_id = "019eb466-8e72-7dd0-8a10-9c8963f7d86c"
codex_file = os.path.join(
codex_sessions_dir,
"rollout-2026-06-11T04-58-00-019eb466-8e72-7dd0-8a10-9c8963f7d86c.jsonl",
)
codex_entries = [
{
"timestamp": "2026-06-11T01:58:35.740Z",
"type": "session_meta",
"payload": {
"id": codex_id,
"timestamp": "2026-06-11T01:58:00.570Z",
"cwd": "/tmp/project",
"originator": "codex-tui",
},
},
{
"timestamp": "2026-06-11T01:58:35.777Z",
"type": "response_item",
"payload": {
"type": "message",
"id": "codex-user-1",
"role": "user",
"content": [{"type": "input_text", "text": "find DEADBEEF"}],
},
},
{
"timestamp": "2026-06-11T01:58:36.000Z",
"type": "response_item",
"payload": {
"type": "message",
"id": "codex-assistant-1",
"role": "assistant",
"content": [
{"type": "output_text", "text": "I found DEADBEEF in source"}
],
},
},
{
"timestamp": "2026-06-11T01:58:36.250Z",
"type": "response_item",
"payload": {
"type": "function_call",
"call_id": "call-codex-grep",
"name": "grep",
"arguments": json.dumps({"pattern": "DEADBEEF", "path": "src/main.rs"}),
},
},
{
"timestamp": "2026-06-11T01:58:36.300Z",
"type": "response_item",
"payload": {
"type": "reasoning",
"id": "codex-reasoning-1",
"summary": [
{
"type": "summary_text",
"text": "consider DEADBEEF search plan",
}
],
},
},
{
"timestamp": "2026-06-11T01:58:36.350Z",
"type": "response_item",
"payload": {
"type": "custom_tool_call",
"call_id": "call-codex-custom",
"name": "lookup",
"input": {"query": "DEADBEEF custom"},
},
},
{
"timestamp": "2026-06-11T01:58:36.400Z",
"type": "response_item",
"payload": {
"type": "local_shell_call",
"call_id": "call-codex-shell",
"action": {"command": "grep DEADBEEF src/main.rs"},
},
},
{
"timestamp": "2026-06-11T01:58:36.500Z",
"type": "response_item",
"payload": {
"type": "function_call_output",
"call_id": "call-codex-grep",
"output": "src/main.rs:7: DEADBEEF",
},
},
]
with open(codex_file, "w") as f:
for entry in codex_entries:
write_jsonl(f, entry)
goose_sessions_dir = os.path.join(tmpdir, "goose", "sessions")
os.makedirs(goose_sessions_dir)
goose_db = os.path.join(goose_sessions_dir, "sessions.db")
conn = sqlite3.connect(goose_db)
conn.execute("CREATE TABLE sessions(id TEXT PRIMARY KEY, name TEXT, working_dir TEXT, updated_at TIMESTAMP)")
conn.execute(
"CREATE TABLE messages(id INTEGER PRIMARY KEY AUTOINCREMENT, message_id TEXT, session_id TEXT, role TEXT, content_json TEXT, created_timestamp INTEGER)"
)
gsid = "sesh-goose"
conn.execute(
"INSERT INTO sessions VALUES(?, ?, ?, ?)",
(gsid, "Review Session", "/tmp/project", "2026-06-10T00:00:00Z"),
)
conn.execute(
"INSERT INTO messages VALUES(?, ?, ?, ?, ?, ?)",
(
1,
"msg-1",
gsid,
"user",
json.dumps([{"type": "text", "text": "find YANKEE-ECHO"}]),
1000,
),
)
conn.execute(
"INSERT INTO messages VALUES(?, ?, ?, ?, ?, ?)",
(
2,
"msg-2",
gsid,
"assistant",
json.dumps([
{"type": "thinking", "thinking": "searching for YANKEE-ECHO", "signature": ""},
{"type": "text", "text": "let me search for that"},
]),
2000,
),
)
conn.execute(
"INSERT INTO messages VALUES(?, ?, ?, ?, ?, ?)",
(
3,
"msg-3",
gsid,
"assistant",
json.dumps([
{"type": "toolRequest", "id": "call_00", "toolCall": {"status": "success", "value": {"name": "grep", "arguments": {"pattern": "YANKEE"}}}},
]),
3000,
),
)
conn.execute(
"INSERT INTO messages VALUES(?, ?, ?, ?, ?, ?)",
(
4,
"msg-4",
gsid,
"user",
json.dumps([
{"type": "toolResponse", "id": "call_00", "toolResult": {"status": "success", "value": {"name": "grep", "content": [{"type": "text", "text": "src/main.rs:42: YANKEE-ECHO"}]}}},
]),
4000,
),
)
conn.commit()
conn.close()
claude_home = os.path.join(tmpdir, "claude-home")
claude_dir = os.path.join(claude_home, "projects", "project-claude")
os.makedirs(claude_dir)
claude_file = os.path.join(claude_dir, "sesh-claude.jsonl")
claude_entries = [
{"type": "mode", "mode": "normal", "sessionId": "sesh-claude"},
{
"type": "user",
"uuid": "claude-user-1",
"parentUuid": None,
"sessionId": "sesh-claude",
"cwd": "/tmp/project",
"gitBranch": "main",
"timestamp": "2026-06-11T01:58:35.777Z",
"message": {"role": "user", "content": "find SLOP-STARS"},
},
{
"type": "assistant",
"uuid": "claude-asst-1",
"parentUuid": "claude-user-1",
"sessionId": "sesh-claude",
"cwd": "/tmp/project",
"timestamp": "2026-06-11T01:58:36.000Z",
"message": {
"role": "assistant",
"model": "claude-opus-4-8",
"content": [
{
"type": "thinking",
"thinking": "looking for SLOP-STARS",
"signature": "sig",
},
{"type": "text", "text": "I found SLOP-STARS in source"},
{
"type": "tool_use",
"id": "toolu_grep",
"name": "Bash",
"input": {"command": "grep SLOP src/*.rs"},
},
],
},
},
{
"type": "user",
"uuid": "claude-tool-1",
"parentUuid": "claude-asst-1",
"sessionId": "sesh-claude",
"cwd": "/tmp/project",
"timestamp": "2026-06-11T01:58:36.100Z",
"message": {
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_grep",
"content": [
{"type": "text", "text": "src/main.rs:7: SLOP-STARS"}
],
}
],
},
},
{
"type": "assistant",
"uuid": "claude-asst-2",
"parentUuid": "claude-tool-1",
"sessionId": "sesh-claude",
"cwd": "/tmp/project",
"timestamp": "2026-06-11T01:58:36.200Z",
"message": {
"role": "assistant",
"model": "claude-opus-4-8",
"content": [
{
"type": "tool_use",
"id": "toolu_read",
"name": "Read",
"input": {"file_path": "/nope"},
}
],
},
},
{
"type": "user",
"uuid": "claude-tool-2",
"parentUuid": "claude-asst-2",
"sessionId": "sesh-claude",
"cwd": "/tmp/project",
"timestamp": "2026-06-11T01:58:36.300Z",
"message": {
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_read",
"content": "file not found",
"is_error": True,
}
],
},
},
]
with open(claude_file, "w") as f:
for entry in claude_entries:
write_jsonl(f, entry)
gemini_home = os.path.join(tmpdir, "gemini-home")
gemini_chats = os.path.join(gemini_home, "tmp", "project-gemini", "chats")
os.makedirs(gemini_chats)
gemini_file = os.path.join(gemini_chats, "session-gemini-1.json")
gemini_record = {
"sessionId": "11111111-1111-1111-1111-111111111111",
"projectHash": "project-gemini",
"startTime": "2026-06-11T02:00:00.000Z",
"lastUpdated": "2026-06-11T02:01:00.000Z",
"messages": [
{
"id": "gem-user-1",
"timestamp": "2026-06-11T02:00:00.000Z",
"type": "user",
"content": "find SLOP-STARS",
},
{
"id": "gem-asst-1",
"timestamp": "2026-06-11T02:00:01.000Z",
"type": "gemini",
"model": "gemini-2.5-pro",
"thoughts": [
{
"subject": "Searching",
"description": "looking for SLOP-STARS",
"timestamp": "2026-06-11T02:00:01.000Z",
}
],
"content": "I found SLOP-STARS in source",
"toolCalls": [
{
"id": "tc-grep",
"name": "grep_search",
"args": {"pattern": "SLOP"},
"status": "success",
"timestamp": "2026-06-11T02:00:01.500Z",
"result": [
{
"functionResponse": {
"id": "tc-grep",
"name": "grep_search",
"response": {
"output": "src/main.rs:7: SLOP-STARS"
},
}
}
],
},
{
"id": "tc-read",
"name": "read_file",
"args": {"path": "/nope"},
"status": "error",
"timestamp": "2026-06-11T02:00:01.700Z",
"result": [
{
"functionResponse": {
"id": "tc-read",
"name": "read_file",
"response": {"error": "file not found"},
}
}
],
},
],
},
],
}
with open(gemini_file, "w") as f:
json.dump(gemini_record, f)
base_env = os.environ.copy()
base_env["GOOSEDUMP_DATA_DIR"] = tmpdir
base_env["PI_CODING_AGENT_SESSION_DIR"] = pi_dir
base_env["CODEX_HOME"] = codex_home
base_env["CLAUDE_CONFIG_DIR"] = claude_home
base_env["GEMINI_DIR"] = gemini_home
base_env["XDG_CACHE_HOME"] = os.path.join(tmpdir, "cache")
expect_stdout(
"opencode: list contexts",
["list", "opencode:*"],
base_env,
None,
"opencode:sesh-alpha",
"opencode:sesh-bravo",
)
expect_stdout(
"opencode: display messages",
["show", "opencode:sesh-alpha"],
base_env,
None,
'"entryId": "entry-alpha"',
'"role": "user"',
"STARTREK-DISCO",
'"entryId": "entry-bravo"',
'"kind": "assistant"',
)
expect_stdout(
"opencode: IR assistant parts",
["show", "opencode:sesh-alpha"],
base_env,
None,
'"thinking"',
"need to read a file",
'"text"',
"found STARTREK-DISCO in source",
'"toolCalls"',
'"name": "read"',
'"filePath": "src/main.rs"',
)
expect_success(
"opencode: grep literal match",
["grep", "opencode:sesh-alpha", "STARTREK-DISCO"],
base_env,
None,
"STARTREK-DISCO",
)
expect_success(
"opencode: grep glob match",
["grep", "opencode:sesh-alpha", "START*DISCO"],
base_env,
None,
"STARTREK-DISCO",
)
expect_success(
"opencode: grep no match",
["grep", "opencode:sesh-alpha", "NONEXISTENT-ZZ"],
base_env,
None,
'"hits": []',
)
expect_success(
"opencode: ranked search",
["search", "opencode:sesh-alpha", "STARTREK"],
base_env,
None,
"STARTREK",
)
expect_stdout(
"opencode: ID filter",
["show", "opencode:sesh-alpha", "--ids", "entry-alpha"],
base_env,
None,
'"entryId": "entry-alpha"',
)
expect_not_contains(
"opencode: ID filter excludes other",
["show", "opencode:sesh-alpha", "--ids", "entry-alpha"],
base_env,
None,
"entry-bravo",
)
expect_stdout(
"opencode: lineage scope",
["show", "opencode:sesh-alpha", "--scope", "lineage"],
base_env,
None,
'"entryId": "entry-alpha"',
'"entryId": "entry-bravo"',
)
expect_stdout(
"crush: list contexts",
["list", "crush:*"],
base_env,
tmpdir,
"crush:sesh-crush",
)
expect_stdout(
"crush: display messages",
["show", "crush:sesh-crush"],
base_env,
tmpdir,
'"entryId": "crush-0"',
"ZULU-NOVEMBER",
'"entryId": "crush-1"',
"code pattern",
)
expect_stdout(
"crush: IR tool result",
["show", "crush:sesh-crush"],
base_env,
tmpdir,
'"toolCalls"',
'"name": "grep"',
'"filePath": "lib.rs"',
'"entryId": "crush-1-tr0"',
'"toolName": "grep"',
"lib.rs:9: ZULU-NOVEMBER",
)
expect_stdout(
"pi: list contexts",
["list", "pi:*"],
base_env,
None,
"pi:sesh-pi",
)
expect_stdout(
"pi: display messages",
["show", "pi:sesh-pi"],
base_env,
None,
'"entryId": "pi-entry-1"',
"TRIPLA-ESPRESSO",
'"entryId": "pi-entry-2"',
'"entryId": "pi-entry-3"',
'"kind": "bash"',
"grep TRIPLA src/*.rs",
)
expect_success(
"pi: filtered grep no match",
["grep", "pi:sesh-pi", "found", "--ids", "pi-entry-1"],
base_env,
None,
'"hits": []',
)
expect_success(
"pi: unfiltered grep match",
["grep", "pi:sesh-pi", "found"],
base_env,
None,
"found TRIPLA-ESPRESSO in file",
)
expect_stdout(
"pi: compact compaction context",
["compact", "pi:sesh-pi"],
base_env,
None,
'"goals"',
"find TRIPLA-ESPRESSO (#pi-entry-1)",
"[user]",
"[assistant]",
"* bash ",
"$ grep TRIPLA src/*.rs",
)
expect_stdout(
"pi: compact from entry",
["compact", "pi:sesh-pi", "--from", "pi-entry-2"],
base_env,
None,
'"goals"',
"Ongoing development work",
"[assistant]",
)
expect_not_contains(
"pi: compact from excludes earlier entry",
["compact", "pi:sesh-pi", "--from", "pi-entry-2"],
base_env,
None,
"find TRIPLA-ESPRESSO",
)
expect_not_contains(
"pi: compact until excludes later entry",
["compact", "pi:sesh-pi", "--from", "pi-entry-2", "--until", "pi-entry-3"],
base_env,
None,
"Recent check passed",
)
expect_failure(
"pi: compact invalid range",
["compact", "pi:sesh-pi", "--from", "pi-entry-4", "--until", "pi-entry-2"],
base_env,
None,
)
expect_failure(
"pi: compact from with ids",
["compact", "pi:sesh-pi", "--from", "pi-entry-2", "--ids", "pi-entry-2"],
base_env,
None,
)
expect_not_contains(
"pi: compact filters todo noise",
["compact", "pi:sesh-pi"],
base_env,
None,
"Created #99",
)
expect_not_contains(
"pi: compact filters todo tool call",
["compact", "pi:sesh-pi"],
base_env,
None,
"* todo",
)
expect_stdout(
"pi: compact skips resolved failure",
["compact", "pi:sesh-pi"],
base_env,
None,
'"outstanding": []',
)
expect_success(
"pi: compact merges prior durable section",
["compact", "pi:sesh-pi-merge"],
base_env,
None,
"Always run clippy (#prior-pref)",
)
expect_not_contains(
"pi: compact skips prior transcript",
["compact", "pi:sesh-pi-merge"],
base_env,
None,
"old transcript line",
)
expect_not_contains(
"pi: compact filters hashline noise",
["compact", "pi:sesh-pi"],
base_env,
None,
"1:928|//",
)
expect_not_contains(
"pi: compact filters file-list noise",
["compact", "pi:sesh-pi"],
base_env,
None,
".git/",
)
expect_stdout(
"pi: compact keeps brief opening and recent tail",
["compact", "pi:sesh-pi-long"],
base_env,
None,
"OPENING-ASSISTANT-MARKER",
"earlier lines omitted",
"TAIL-RECENT-MARKER",
)
expect_stdout(
"codex: list contexts",
["list", "codex:*"],
base_env,
None,
f"codex:{codex_id}",
)
expect_stdout(
"codex: display messages",
["show", f"codex:{codex_id}"],
base_env,
None,
'"entryId": "codex-user-1"',
"DEADBEEF",
'"entryId": "codex-assistant-1"',
'"entryId": "call-codex-grep"',
'"path": "src/main.rs"',
'"entryId": "codex-reasoning-1"',
"consider DEADBEEF search plan",
'"entryId": "call-codex-custom"',
'"query": "DEADBEEF custom"',
'"entryId": "call-codex-shell"',
'"command": "grep DEADBEEF src/main.rs"',
'"entryId": "call-codex-grep-output"',
)
expect_success(
"codex: grep match",
["grep", f"codex:{codex_id}", "DEADBEEF"],
base_env,
None,
"DEADBEEF",
)
expect_success(
"codex: grep command match",
["grep", f"codex:{codex_id}", "grep DEADBEEF src/main.rs"],
base_env,
None,
"grep DEADBEEF src/main.rs",
)
expect_stdout(
"goose: list contexts",
["list", "goose:*"],
base_env,
None,
"goose:sesh-goose",
)
expect_stdout(
"goose: display messages",
["show", "goose:sesh-goose"],
base_env,
None,
'"entryId": "goose-1"',
"YANKEE-ECHO",
'"entryId": "goose-2"',
"let me search",
'"entryId": "goose-3"',
'"pattern": "YANKEE"',
'"entryId": "goose-4"',
'"toolName": "grep"',
)
expect_stdout(
"goose: IR assistant and tool result",
["show", "goose:sesh-goose"],
base_env,
None,
'"thinking"',
"searching for YANKEE-ECHO",
'"toolCalls"',
'"pattern": "YANKEE"',
'"entryId": "goose-4"',
)
expect_success(
"goose: grep match",
["grep", "goose:sesh-goose", "YANKEE-ECHO"],
base_env,
None,
"YANKEE-ECHO",
)
expect_stdout(
"goose: lineage scope",
["show", "goose:sesh-goose", "--scope", "lineage"],
base_env,
None,
'"entryId": "goose-1"',
'"entryId": "goose-4"',
)
expect_stdout(
"claude: list contexts",
["list", "claude:*"],
base_env,
None,
"claude:sesh-claude",
)
expect_stdout(
"claude: display messages",
["show", "claude:sesh-claude"],
base_env,
None,
'"entryId": "claude-user-1"',
"SLOP-STARS",
'"entryId": "claude-asst-1"',
'"entryId": "claude-tool-1"',
'"toolName": "Bash"',
"src/main.rs:7: SLOP-STARS",
)
expect_stdout(
"claude: IR assistant parts",
["show", "claude:sesh-claude"],
base_env,
None,
'"thinking"',
"looking for SLOP-STARS",
'"text"',
"I found SLOP-STARS in source",
'"toolCalls"',
'"command": "grep SLOP src/*.rs"',
)
expect_stdout(
"claude: tool result error marker",
["show", "claude:sesh-claude"],
base_env,
None,
'"entryId": "claude-tool-2"',
'"toolName": "Read"',
'"isError": true',
"file not found",
)
expect_success(
"claude: grep literal match",
["grep", "claude:sesh-claude", "SLOP-STARS"],
base_env,
None,
"SLOP-STARS",
)
expect_success(
"claude: grep glob match",
["grep", "claude:sesh-claude", "SLOP*STARS"],
base_env,
None,
"SLOP-STARS",
)
expect_success(
"claude: ranked search",
["search", "claude:sesh-claude", "SLOP"],
base_env,
None,
"SLOP",
)
expect_stdout(
"claude: prefix id resolution",
["show", "claude:sesh-cl"],
base_env,
None,
'"entryId": "claude-user-1"',
)
expect_stdout(
"claude: lineage scope",
["show", "claude:sesh-claude", "--scope", "lineage"],
base_env,
None,
'"entryId": "claude-user-1"',
'"entryId": "claude-tool-2"',
)
expect_stdout(
"gemini: list contexts",
["list", "gemini:*"],
base_env,
None,
"gemini:session-gemini-1",
)
expect_stdout(
"gemini: display messages",
["show", "gemini:session-gemini-1"],
base_env,
None,
'"entryId": "gem-user-1"',
"find SLOP-STARS",
'"entryId": "gem-asst-1"',
'"entryId": "gem-asst-1-tool-0"',
'"toolName": "grep_search"',
"src/main.rs:7: SLOP-STARS",
)
expect_stdout(
"gemini: IR assistant parts",
["show", "gemini:session-gemini-1"],
base_env,
None,
'"thinking"',
"looking for SLOP-STARS",
'"text"',
"I found SLOP-STARS in source",
'"toolCalls"',
'"pattern": "SLOP"',
)
expect_stdout(
"gemini: tool result error marker",
["show", "gemini:session-gemini-1"],
base_env,
None,
'"entryId": "gem-asst-1-tool-1"',
'"toolName": "read_file"',
'"isError": true',
"file not found",
)
expect_success(
"gemini: grep glob match",
["grep", "gemini:session-gemini-1", "SLOP*STARS"],
base_env,
None,
"SLOP-STARS",
)
expect_success(
"gemini: ranked search",
["search", "gemini:session-gemini-1", "SLOP"],
base_env,
None,
"SLOP",
)
expect_stdout(
"gemini: prefix id resolution",
["show", "gemini:session-gem"],
base_env,
None,
'"entryId": "gem-user-1"',
)
expect_stdout(
"list: aggregates all providers with tags",
["list"],
base_env,
None,
"opencode:sesh-alpha",
"goose:sesh-goose",
"pi:sesh-pi",
)
expect_stdout(
"list: glob scopes to one provider",
["list", "goose:*"],
base_env,
None,
"goose:sesh-goose",
)
expect_not_contains(
"list: glob excludes other providers",
["list", "goose:*"],
base_env,
None,
"opencode:sesh-alpha",
)
expect_stdout(
"list: glob matches id suffix across providers",
["list", "*sesh-alpha"],
base_env,
None,
"opencode:sesh-alpha",
)
expect_stdout(
"list: bare token searched anywhere in tag",
["list", "goose"],
base_env,
None,
"goose:sesh-goose",
)
expect_stdout(
"list: id fragment matched without provider",
["list", "sesh-cl"],
base_env,
None,
"claude:sesh-claude",
)
expect_failure(
"cli: unknown provider",
["show", "bogus:abc"],
base_env,
None,
)
expect_failure(
"cli: target without provider",
["show", "sesh-alpha"],
base_env,
None,
)
expect_failure_stdout(
"cli: no arguments",
[],
base_env,
None,
2,
"Usage: goosedump <command> [<args>]",
)
expect_failure(
"cli: grep without context-id",
["grep", "opencode:foo"],
base_env,
None,
)
expect_failure(
"cli: missing subcommand",
["opencode", "sesh-alpha"],
base_env,
None,
)
expect_failure(
"cli: --page with grep",
["grep", "opencode:sesh-alpha", "STARTREK", "--page", "1"],
base_env,
None,
)
expect_failure(
"cli: invalid --scope",
["show", "opencode:sesh-alpha", "--scope", "bogus"],
base_env,
None,
)
expect_failure(
"cli: --page zero",
[
"search",
"opencode:sesh-alpha",
"STARTREK",
"--page",
"0",
],
base_env,
None,
)
print(f"SUMMARY pass={pass_count} fail={fail_count} tmp={tmpdir}")
if fail_count != 0:
sys.exit(1)
if __name__ == "__main__":
main()