kiro

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package kiro contains shared identifiers and helpers used by the Kiro providers.

Index

Constants

View Source
const (
	// ProviderNameIDE is the provider identifier for the Kiro IDE hook provider.
	ProviderNameIDE = "kiro-ide"

	// ProviderNameCLI is the provider identifier for the Kiro CLI hook provider.
	ProviderNameCLI = "kiro-cli"

	// ToolNameFileEdit marks file-modifying Kiro actions for attribution.
	ToolNameFileEdit = "kiro_file_edit"
)

Variables

This section is empty.

Functions

func BuildToolUsesJSON

func BuildToolUsesJSON(filePath, fileOp string) sql.NullString

BuildToolUsesJSON returns a serialized tool_uses payload for a file operation.

func CountExecutionEntries

func CountExecutionEntries(h *SessionHistory) int

CountExecutionEntries returns the number of history entries with an execution ID.

func DecodeProjectPathFromSessionDir

func DecodeProjectPathFromSessionDir(dirName string) string

DecodeProjectPathFromSessionDir reverses the workspace directory encoding used under Kiro's session store.

func EncodeWorkspacePath

func EncodeWorkspacePath(absPath string) string

EncodeWorkspacePath encodes an absolute workspace path to match the workspace session directory naming used by Kiro.

func KiroGlobalStorageDir

func KiroGlobalStorageDir() (string, error)

KiroGlobalStorageDir returns the Kiro agent globalStorage directory for the current OS.

func NewExecutionIDs

func NewExecutionIDs(h *SessionHistory, offset int) []string

NewExecutionIDs returns execution IDs beyond the given execution-entry offset.

func ResolveLatestSession

func ResolveLatestSession(workspacePath string) (sessionID, historyPath string, err error)

ResolveLatestSession finds the most recent session for a workspace. Returns the session ID and path to the session history JSON file.

func ResolveLatestSessionIn

func ResolveLatestSessionIn(sessDir string) (sessionID, historyPath string, err error)

ResolveLatestSessionIn finds the most recent session within a workspace session directory.

func WorkspaceKey

func WorkspaceKey(prefix, absPath string) string

WorkspaceKey derives a deterministic capture-state key from a workspace path and provider prefix.

func WorkspaceSessionDir

func WorkspaceSessionDir(absWorkspacePath string) (string, error)

WorkspaceSessionDir returns the path to the Kiro workspace session directory for the given workspace path.

Types

type AppendInput

type AppendInput struct {
	File            string `json:"file"`
	ModifiedContent string `json:"modifiedContent"`
	OriginalContent string `json:"originalContent"`
}

AppendInput is the parsed input for an "append" action.

type CreateInput

type CreateInput struct {
	File            string `json:"file"`
	ModifiedContent string `json:"modifiedContent"`
	OriginalContent string `json:"originalContent"`
}

CreateInput is the parsed input for a "create" action.

type ExecutionAction

type ExecutionAction struct {
	Type          string          `json:"type"`
	ExecutionID   string          `json:"executionId"`
	ActionID      string          `json:"actionId"`
	ActionType    string          `json:"actionType"`
	ActionState   string          `json:"actionState"`
	Input         json.RawMessage `json:"input,omitempty"`
	Output        json.RawMessage `json:"output,omitempty"`
	ChatSessionID string          `json:"chatSessionId"`
	EmittedAt     int64           `json:"emittedAt"`
}

ExecutionAction is a single action within an execution trace.

type ExecutionIndex

type ExecutionIndex struct {
	Executions []ExecutionMeta `json:"executions"`
	Version    string          `json:"version"`
}

ExecutionIndex is the top-level execution metadata file.

type ExecutionMeta

type ExecutionMeta struct {
	ExecutionID string `json:"executionId"`
	Type        string `json:"type"`
	Status      string `json:"status"`
	StartTime   int64  `json:"startTime"`
	EndTime     int64  `json:"endTime"`
}

ExecutionMeta is a single execution entry in the index.

type ExecutionTrace

type ExecutionTrace struct {
	ExecutionID   string            `json:"executionId"`
	WorkflowType  string            `json:"workflowType"`
	Status        string            `json:"status"`
	StartTime     int64             `json:"startTime"`
	ChatSessionID string            `json:"chatSessionId"`
	Actions       []ExecutionAction `json:"actions"`
}

ExecutionTrace is a full execution trace file.

func ParseExecutionTrace

func ParseExecutionTrace(path string) (*ExecutionTrace, error)

ParseExecutionTrace reads and parses an execution trace JSON file.

type FileOperation

type FileOperation struct {
	ActionType string // "create", "append", "smartRelocate"
	FilePath   string // relative path within the workspace
	Content    string // the content the agent wrote (empty for relocate)
	SourcePath string // for relocate: original path
	DestPath   string // for relocate: new path
	EmittedAt  int64  // unix ms timestamp of the action
}

FileOperation represents a single file change extracted from an execution trace.

func ExtractFileOps

func ExtractFileOps(trace *ExecutionTrace) []FileOperation

ExtractFileOps parses an execution trace and returns all file operations.

type HistoryEntry

type HistoryEntry struct {
	Message     HistoryMessage `json:"message"`
	ExecutionID string         `json:"executionId,omitempty"`
	PromptLogs  []PromptLog    `json:"promptLogs,omitempty"`
}

HistoryEntry is a single message in the session history.

type HistoryMessage

type HistoryMessage struct {
	Role    string          `json:"role"`
	Content json.RawMessage `json:"content"` // string or []ContentBlock
	ID      string          `json:"id"`
}

HistoryMessage is the role+content of a single message.

type PromptLog

type PromptLog struct {
	ModelTitle string `json:"modelTitle"`
	Prompt     string `json:"prompt"`
}

PromptLog records an LLM call within a history entry.

type RelocateInput

type RelocateInput struct {
	SourcePath      string `json:"sourcePath"`
	DestinationPath string `json:"destinationPath"`
}

RelocateInput is the parsed input for a "smartRelocate" action.

type SessionHistory

type SessionHistory struct {
	History            []HistoryEntry `json:"history"`
	SessionID          string         `json:"sessionId"`
	WorkspaceDirectory string         `json:"workspaceDirectory"`
}

SessionHistory is the full session JSON file (<sessionId>.json).

func ParseSessionHistory

func ParseSessionHistory(path string) (*SessionHistory, error)

ParseSessionHistory reads a session history file (<sessionId>.json).

type SessionIndex

type SessionIndex struct {
	SessionID          string `json:"sessionId"`
	Title              string `json:"title"`
	DateCreated        string `json:"dateCreated"`
	WorkspaceDirectory string `json:"workspaceDirectory"`
}

SessionIndex is the top-level sessions.json structure.

func ParseSessionIndex

func ParseSessionIndex(path string) ([]SessionIndex, error)

ParseSessionIndex reads sessions.json and returns all session entries.

Jump to

Keyboard shortcuts

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