testjsonl

package
v0.22.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package testjsonl provides shared JSONL fixture builders for Claude and Codex session test data. Used by both parser and sync test packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaudeAssistantJSON

func ClaudeAssistantJSON(content any, timestamp string) string

ClaudeAssistantJSON returns a Claude assistant message as a JSON string.

func ClaudeEntryJSON added in v0.7.0

func ClaudeEntryJSON(
	entryType, content, timestamp, uuid, parentUuid string,
	cwd ...string,
) string

ClaudeEntryJSON returns a Claude JSONL entry with uuid and parentUuid fields.

func ClaudeMetaUserJSON

func ClaudeMetaUserJSON(
	content, timestamp string, meta, compact bool,
) string

ClaudeMetaUserJSON returns a Claude user message with optional isMeta and isCompactSummary flags as a JSON string.

func ClaudeSnapshotJSON

func ClaudeSnapshotJSON(timestamp string) string

ClaudeSnapshotJSON returns a Claude snapshot message as a JSON string.

func ClaudeToolResultUserJSON added in v0.7.0

func ClaudeToolResultUserJSON(
	toolUseID, resultContent, timestamp string,
) string

ClaudeToolResultUserJSON returns a Claude user message containing only a tool_result block (no text content). These messages are filtered out by pairAndFilter.

func ClaudeUserJSON

func ClaudeUserJSON(
	content, timestamp string, cwd ...string,
) string

ClaudeUserJSON returns a Claude user message as a JSON string.

func ClaudeUserWithSessionIDJSON added in v0.3.2

func ClaudeUserWithSessionIDJSON(
	content, timestamp, sessionID string, cwd ...string,
) string

ClaudeUserWithSessionIDJSON returns a Claude user message with a sessionId field as a JSON string.

func CodexFunctionCallArgsJSON added in v0.2.0

func CodexFunctionCallArgsJSON(
	name string, arguments any, timestamp string,
) string

CodexFunctionCallArgsJSON returns a Codex function_call response_item with arguments payload.

func CodexFunctionCallFieldsJSON added in v0.2.1

func CodexFunctionCallFieldsJSON(
	name string, arguments, input any, timestamp string,
) string

CodexFunctionCallFieldsJSON returns a Codex function_call response_item with explicit arguments and input fields.

func CodexFunctionCallJSON

func CodexFunctionCallJSON(
	name, summary, timestamp string,
) string

CodexFunctionCallJSON returns a Codex function_call response_item as a JSON string.

func CodexFunctionCallOutputJSON added in v0.17.0

func CodexFunctionCallOutputJSON(
	callID string, output any, timestamp string,
) string

CodexFunctionCallOutputJSON returns a Codex function_call_output response_item.

func CodexFunctionCallWithCallIDJSON added in v0.17.0

func CodexFunctionCallWithCallIDJSON(
	name, callID string, arguments any, timestamp string,
) string

CodexFunctionCallWithCallIDJSON returns a Codex function_call response_item with an explicit call_id.

func CodexMsgJSON

func CodexMsgJSON(role, text, timestamp string) string

CodexMsgJSON returns a Codex response_item message as a JSON string.

func CodexSessionMetaJSON

func CodexSessionMetaJSON(
	id, cwd, originator, timestamp string,
) string

CodexSessionMetaJSON returns a Codex session_meta message as a JSON string.

func CodexTokenCountJSON added in v0.20.0

func CodexTokenCountJSON(
	timestamp string,
	inputTokens, outputTokens, cachedInputTokens int,
) string

CodexTokenCountJSON returns a Codex event_msg with payload.type=token_count and last_token_usage fields.

func CodexTurnContextJSON added in v0.16.0

func CodexTurnContextJSON(model, timestamp string) string

CodexTurnContextJSON returns a Codex turn_context entry as a JSON string with the given model.

func GeminiAssistantMsg

func GeminiAssistantMsg(
	id, timestamp, content string, opts *GeminiMsgOpts,
) map[string]any

GeminiAssistantMsg builds a Gemini assistant message object.

func GeminiInfoMsg

func GeminiInfoMsg(
	id, timestamp, content, msgType string,
) map[string]any

GeminiInfoMsg builds a Gemini info/system message object.

func GeminiSessionJSON

func GeminiSessionJSON(
	sessionID, projectHash string,
	startTime, lastUpdated string,
	messages []map[string]any,
) string

GeminiSessionJSON builds a complete Gemini session JSON string from the given parameters.

func GeminiUserMsg

func GeminiUserMsg(
	id, timestamp, content string,
) map[string]any

GeminiUserMsg builds a Gemini user message object.

func JoinJSONL

func JoinJSONL(lines ...string) string

JoinJSONL joins JSON lines with newlines and appends a trailing newline.

Types

type GeminiMsgOpts

type GeminiMsgOpts struct {
	Thoughts  []GeminiThought
	ToolCalls []GeminiToolCall
	Model     string
}

GeminiMsgOpts holds optional fields for a Gemini assistant message.

type GeminiThought

type GeminiThought struct {
	Subject     string
	Description string
	Timestamp   string
}

GeminiThought defines a thought for Gemini test fixtures.

type GeminiToolCall

type GeminiToolCall struct {
	ID           string
	Name         string
	DisplayName  string
	Args         map[string]string
	ResultOutput string // if set, generates inline functionResponse result
}

GeminiToolCall defines a tool call for Gemini test fixtures.

type SessionBuilder

type SessionBuilder struct {
	// contains filtered or unexported fields
}

SessionBuilder constructs JSONL session content using a fluent API.

func NewSessionBuilder

func NewSessionBuilder() *SessionBuilder

NewSessionBuilder returns a new empty SessionBuilder.

func (*SessionBuilder) AddClaudeAssistant

func (b *SessionBuilder) AddClaudeAssistant(
	timestamp, text string,
) *SessionBuilder

AddClaudeAssistant appends a Claude assistant message line.

func (*SessionBuilder) AddClaudeAssistantWithUUID added in v0.7.0

func (b *SessionBuilder) AddClaudeAssistantWithUUID(
	timestamp, text, uuid, parentUuid string,
) *SessionBuilder

AddClaudeAssistantWithUUID appends a Claude assistant message with uuid and parentUuid fields.

func (*SessionBuilder) AddClaudeMetaUser

func (b *SessionBuilder) AddClaudeMetaUser(
	timestamp, content string, meta, compact bool,
) *SessionBuilder

AddClaudeMetaUser appends a Claude user message line with isMeta and/or isCompactSummary flags.

func (*SessionBuilder) AddClaudeUser

func (b *SessionBuilder) AddClaudeUser(
	timestamp, content string, cwd ...string,
) *SessionBuilder

AddClaudeUser appends a Claude user message line.

func (*SessionBuilder) AddClaudeUserWithSessionID added in v0.3.2

func (b *SessionBuilder) AddClaudeUserWithSessionID(
	timestamp, content, sessionID string, cwd ...string,
) *SessionBuilder

AddClaudeUserWithSessionID appends a Claude user message line with a sessionId field.

func (*SessionBuilder) AddClaudeUserWithUUID added in v0.7.0

func (b *SessionBuilder) AddClaudeUserWithUUID(
	timestamp, content, uuid, parentUuid string,
	cwd ...string,
) *SessionBuilder

AddClaudeUserWithUUID appends a Claude user message with uuid and parentUuid fields.

func (*SessionBuilder) AddCodexFunctionCall

func (b *SessionBuilder) AddCodexFunctionCall(
	timestamp, name, summary string,
) *SessionBuilder

AddCodexFunctionCall appends a Codex function_call line.

func (*SessionBuilder) AddCodexMessage

func (b *SessionBuilder) AddCodexMessage(
	timestamp, role, text string,
) *SessionBuilder

AddCodexMessage appends a Codex response_item line.

func (*SessionBuilder) AddCodexMeta

func (b *SessionBuilder) AddCodexMeta(
	timestamp, id, cwd, originator string,
) *SessionBuilder

AddCodexMeta appends a Codex session_meta line.

func (*SessionBuilder) AddRaw

func (b *SessionBuilder) AddRaw(line string) *SessionBuilder

AddRaw appends an arbitrary raw line.

func (*SessionBuilder) String

func (b *SessionBuilder) String() string

String returns the JSONL content with a trailing newline.

func (*SessionBuilder) StringNoTrailingNewline

func (b *SessionBuilder) StringNoTrailingNewline() string

StringNoTrailingNewline returns the JSONL content without a trailing newline.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL