format

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BudgetInfo added in v0.5.0

type BudgetInfo struct {
	MaxTokens       int `xml:"maxTokens"`       // Maximum token budget (0 = unlimited)
	EstimatedTokens int `xml:"estimatedTokens"` // Actual estimated tokens in output
	FileTruncations int `xml:"fileTruncations"` // Number of files that were truncated
}

BudgetInfo tracks token budget and truncation statistics (PTX v2.0)

type DependencyInfo

type DependencyInfo struct {
	Imports   map[string][]string `xml:"imports>file"`
	Packages  []string            `xml:"packages>package"`
	CoreFiles []string            `xml:"coreFiles>file"`
}

type DirectoryNode

type DirectoryNode struct {
	Name     string           `xml:"name,attr"`
	Type     string           `xml:"type,attr"` // "file" or "dir"
	Children []*DirectoryNode `xml:"node,omitempty"`
}

DirectoryNode represents a node in the directory tree

func (*DirectoryNode) ToMarkdown

func (d *DirectoryNode) ToMarkdown(level int) string

Helper function to convert DirectoryNode to markdown string

type FileInfo

type FileInfo struct {
	Path       string          `xml:"path,attr"`
	Content    string          `xml:"content"`
	Tokens     int             `xml:"tokens,omitempty"`     // PTX v2.0: Token count for this file
	Truncation *TruncationInfo `xml:"truncation,omitempty"` // PTX v2.0: Truncation metadata if file was truncated
}

type FileStatistics

type FileStatistics struct {
	TotalFiles   int            `xml:"totalFiles"`
	FilesByType  map[string]int `xml:"-"` // Exclude from direct XML marshaling
	TotalLines   int            `xml:"totalLines"`
	PackageCount int            `xml:"packageCount"`
}

type FilterConfig added in v0.5.0

type FilterConfig struct {
	Includes []string `xml:"includes>include,omitempty"` // File patterns explicitly included
	Excludes []string `xml:"excludes>exclude,omitempty"` // File patterns explicitly excluded
}

FilterConfig describes the filter configuration used to generate this output (PTX v2.0)

type Formatter

type Formatter interface {
	Format(project *ProjectOutput) (string, error)
}

Formatter interface for different output formats

func GetFormatter

func GetFormatter(format string) (Formatter, error)

Get appropriate formatter based on format string

type GitInfo

type GitInfo struct {
	Branch        string `xml:"branch"`
	CommitHash    string `xml:"commitHash"`
	CommitMessage string `xml:"commitMessage"`
}

type JSONLFormatter added in v0.5.0

type JSONLFormatter struct{} // JSONL - Machine-friendly sidecar format (one JSON object per line)

func (*JSONLFormatter) Format added in v0.5.0

func (j *JSONLFormatter) Format(project *ProjectOutput) (string, error)

JSONLFormatter implements machine-friendly JSONL output (one JSON object per line) This format is ideal for programmatic processing, streaming, and pipeline integration

type MarkdownFormatter

type MarkdownFormatter struct{}

func (*MarkdownFormatter) Format

func (m *MarkdownFormatter) Format(project *ProjectOutput) (string, error)

type Metadata

type Metadata struct {
	Language     string   `xml:"language"`
	Version      string   `xml:"version"`
	Dependencies []string `xml:"dependencies>dependency,omitempty"`
}

type OutputFormat

type OutputFormat string
const (
	FormatMarkdown   OutputFormat = "markdown"
	FormatXML        OutputFormat = "xml"
	FormatPTX        OutputFormat = "ptx"         // PTX v2.0 (TOON-based with multiline code and enhanced manifest)
	FormatTOON       OutputFormat = "toon"        // Alias for PTX (backward compatibility)
	FormatTOONStrict OutputFormat = "toon-strict" // TOON v1.3 strict compliance
	FormatTOONV13    OutputFormat = "toon-v1.3"   // Alias for toon-strict
	FormatJSONL      OutputFormat = "jsonl"       // JSONL - machine-friendly sidecar format
)

type PTXFormatter added in v0.4.2

type PTXFormatter struct{} // PTX v2.0 - TOON-based with multiline code and enhanced manifest

func (*PTXFormatter) Format added in v0.4.2

func (t *PTXFormatter) Format(project *ProjectOutput) (string, error)

PTXFormatter formats project data in PTX v2.0 format (TOON-based with multiline code and enhanced manifest)

type ProjectAnalysis

type ProjectAnalysis struct {
	EntryPoints   map[string]string `xml:"entryPoints,omitempty"`
	ConfigFiles   map[string]string `xml:"configFiles,omitempty"`
	CoreFiles     map[string]string `xml:"coreFiles,omitempty"`
	TestFiles     map[string]string `xml:"testFiles,omitempty"`
	Documentation map[string]string `xml:"documentation,omitempty"`
}

type ProjectOutput

type ProjectOutput struct {
	XMLName       xml.Name         `xml:"project"`
	DirectoryTree *DirectoryNode   `xml:"directoryTree"`
	GitInfo       *GitInfo         `xml:"gitInfo,omitempty"`
	Metadata      *Metadata        `xml:"metadata,omitempty"`
	Files         []FileInfo       `xml:"files>file,omitempty"`
	Overview      *ProjectOverview `xml:"overview,omitempty"`
	FileStats     *FileStatistics  `xml:"fileStats,omitempty"`
	Dependencies  *DependencyInfo  `xml:"dependencies,omitempty"`
	Analysis      *ProjectAnalysis `xml:"analysis,omitempty"`
	Budget        *BudgetInfo      `xml:"budget,omitempty"`       // PTX v2.0: Token budget tracking
	FilterConfig  *FilterConfig    `xml:"filterConfig,omitempty"` // PTX v2.0: Filter configuration used
}

type ProjectOverview

type ProjectOverview struct {
	Description string   `xml:"description"`
	Purpose     string   `xml:"purpose"`
	Features    []string `xml:"features>feature,omitempty"`
}

type TOONEncoder added in v0.4.0

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

TOONEncoder encodes Go values to TOON format

func NewTOONEncoder added in v0.4.0

func NewTOONEncoder() *TOONEncoder

NewTOONEncoder creates a new TOON encoder

func (*TOONEncoder) Encode added in v0.4.0

func (e *TOONEncoder) Encode(v interface{}) (string, error)

Encode encodes a Go value to TOON format string

type TOONStrictFormatter added in v0.4.2

type TOONStrictFormatter struct{} // TOON v1.3 strict compliance

func (*TOONStrictFormatter) Format added in v0.4.2

func (t *TOONStrictFormatter) Format(project *ProjectOutput) (string, error)

TOONStrictFormatter implements TOON v1.3 strict compliance This formatter follows the official TOON specification exactly, using escaped strings for code content instead of multiline blocks.

type TruncationInfo added in v0.5.0

type TruncationInfo struct {
	Mode           string `xml:"mode"`           // Truncation mode (e.g., "head:300,tail:53")
	OriginalTokens int    `xml:"originalTokens"` // Token count before truncation
}

TruncationInfo describes how a file was truncated (PTX v2.0)

type XMLFormatter

type XMLFormatter struct{}

func (*XMLFormatter) Format

func (x *XMLFormatter) Format(project *ProjectOutput) (string, error)

Jump to

Keyboard shortcuts

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