draft

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package draft provides draft management for spec authoring.

Index

Constants

This section is empty.

Variables

View Source
var ErrDraftExists = errors.New("draft already exists")

ErrDraftExists indicates a draft already exists.

View Source
var ErrDraftNotFound = errors.New("draft not found")

ErrDraftNotFound indicates no draft exists.

View Source
var ErrSpecExists = errors.New("spec already exists")

ErrSpecExists indicates the final spec already exists.

Functions

func AddEvalResult

func AddEvalResult(projectPath string, specType types.SpecType, score float64, passed bool, findings int) error

AddEvalResult adds an evaluation result to the draft metadata.

func Discard

func Discard(projectPath string, specType types.SpecType) error

Discard removes a draft and its metadata.

func DraftPath

func DraftPath(projectPath string, specType types.SpecType) string

DraftPath returns the full path for a draft file.

func Exists

func Exists(projectPath string, specType types.SpecType) bool

Exists checks if a draft exists for the given project and spec type.

func Finalize

func Finalize(projectPath string, specType types.SpecType) error

Finalize promotes a draft to the final spec location.

func MetadataPath

func MetadataPath(projectPath string, specType types.SpecType) string

MetadataPath returns the full path for a draft metadata file.

func SpecExists

func SpecExists(projectPath string, specType types.SpecType) bool

SpecExists checks if the final spec already exists.

Types

type Draft

type Draft struct {
	Metadata Metadata
	Content  string
}

Draft represents a draft document with its metadata.

func Get

func Get(projectPath string, specType types.SpecType) (*Draft, error)

Get retrieves an existing draft.

func ListDrafts

func ListDrafts(projectPath string) ([]*Draft, error)

ListDrafts returns all drafts in a project.

func Start

func Start(projectPath string, specType types.SpecType) (*Draft, error)

Start initializes a new draft for a spec type. Returns the template content and metadata, or error if draft/spec already exists.

func Update

func Update(projectPath string, specType types.SpecType, content string) (*Draft, error)

Update saves updated content to the draft.

type EvalSummary

type EvalSummary struct {
	Timestamp time.Time `json:"timestamp"`
	Score     float64   `json:"score"`
	Passed    bool      `json:"passed"`
	Findings  int       `json:"findings"`
}

EvalSummary summarizes a previous evaluation.

type Metadata

type Metadata struct {
	SpecType    types.SpecType `json:"spec_type"`
	ProjectName string         `json:"project_name"`
	StartedAt   time.Time      `json:"started_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	Version     int            `json:"version"`
	EvalHistory []EvalSummary  `json:"eval_history,omitempty"`
}

Metadata contains draft metadata.

type Session

type Session struct {
	ProjectPath string
	SpecType    types.SpecType
	Draft       *Draft
}

Session manages the state of a draft authoring session.

func ResumeSession

func ResumeSession(projectPath string, specType types.SpecType) (*Session, error)

ResumeSession resumes an existing draft session.

func StartSession

func StartSession(projectPath string, specType types.SpecType) (*Session, error)

StartSession begins a new draft session. If a draft already exists, it resumes that draft instead of creating a new one.

func (*Session) Content

func (s *Session) Content() string

Content returns the current draft content.

func (*Session) Discard

func (s *Session) Discard() error

Discard removes the draft.

func (*Session) EvalCount

func (s *Session) EvalCount() int

EvalCount returns the number of evaluations performed.

func (*Session) Finalize

func (s *Session) Finalize() error

Finalize promotes the draft to final spec.

func (*Session) HasPassingEval

func (s *Session) HasPassingEval() bool

HasPassingEval returns true if the draft has passed evaluation at least once.

func (*Session) Instructions

func (s *Session) Instructions() string

Instructions returns authoring instructions based on current status.

func (*Session) IsNew

func (s *Session) IsNew() bool

IsNew returns true if this is a newly created draft (version 1).

func (*Session) LastEval

func (s *Session) LastEval() *EvalSummary

LastEval returns the most recent evaluation summary, or nil if none.

func (*Session) RecordEval

func (s *Session) RecordEval(score float64, passed bool, findings int) error

RecordEval records an evaluation result.

func (*Session) Status

func (s *Session) Status() SessionStatus

Status returns the current session status.

func (*Session) Summary

func (s *Session) Summary() SessionSummary

Summary returns a summary of the session.

func (*Session) Update

func (s *Session) Update(content string) error

Update saves new content to the session's draft.

func (*Session) Version

func (s *Session) Version() int

Version returns the current draft version.

type SessionStatus

type SessionStatus string

SessionStatus represents the status of a draft session.

const (
	StatusNew       SessionStatus = "new"       // Just started, no edits
	StatusEditing   SessionStatus = "editing"   // Has edits, not evaluated
	StatusEvaluated SessionStatus = "evaluated" // Has been evaluated
	StatusPassing   SessionStatus = "passing"   // Passed evaluation
	StatusFailing   SessionStatus = "failing"   // Failed evaluation
	StatusReady     SessionStatus = "ready"     // Ready to finalize
)

type SessionSummary

type SessionSummary struct {
	SpecType      types.SpecType `json:"spec_type"`
	SpecName      string         `json:"spec_name"`
	Version       int            `json:"version"`
	Status        SessionStatus  `json:"status"`
	EvalCount     int            `json:"eval_count"`
	LastScore     *float64       `json:"last_score,omitempty"`
	LastPassed    *bool          `json:"last_passed,omitempty"`
	HasTemplate   bool           `json:"has_template"`
	ContentLength int            `json:"content_length"`
}

Summary returns a brief summary of the session state.

Jump to

Keyboard shortcuts

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