Documentation
¶
Overview ¶
Package plan は計画の永続化を提供する
Index ¶
- func ContainsFailure(result string) (bool, string)
- func ContainsPlanJSON(response string) bool
- func ExtractPlanJSON(response string) string
- func FormatConflictWarning(c Conflict) string
- func FormatPlan(plan *Plan) string
- type Clarification
- type Conflict
- type DependencyAnalyzer
- func (da *DependencyAnalyzer) Analyze(steps []PlanStep) *DependencyResult
- func (da *DependencyAnalyzer) AnalyzeAndWarn(steps []PlanStep, parallelStepIDs []int) ([]PlanStep, []string)
- func (da *DependencyAnalyzer) DetectConflicts(parallelStepIDs []int, steps []PlanStep) []Conflict
- func (da *DependencyAnalyzer) EnhanceWithLSP(steps []PlanStep) []PlanStep
- func (da *DependencyAnalyzer) ExtractFilesFromStep(step *PlanStep) (readFiles, writeFiles []string)
- func (da *DependencyAnalyzer) InferDependencies(steps []PlanStep) []PlanStep
- type DependencyResult
- type FailureAction
- type Plan
- func (p *Plan) AddLog(log StepLog)
- func (p *Plan) CanExecute(stepID int) bool
- func (p *Plan) GetNextStep() int
- func (p *Plan) GetParallelSteps() []int
- func (p *Plan) GetStep(id int) *PlanStep
- func (p *Plan) GetToolsExecuted(stepID int) int
- func (p *Plan) HasFailed() bool
- func (p *Plan) IncrementToolsExecuted(stepID int)
- func (p *Plan) IsCompleted() bool
- func (p *Plan) UpdateStatus(stepID int, status, result string)
- type PlanMetadata
- type PlanStatus
- type PlanStep
- type PlanStorage
- type StepLog
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsFailure ¶
ContainsFailure はツール結果に失敗パターンが含まれるか検出 失敗を検出した場合、(true, 理由) を返す
NOTE: "error:" や "Error:" のような汎用パターンは使用しない。 コード検索結果(例: t.Errorf)やログ出力に含まれる "Error" 文字列で 誤検知してしまうため。実際のコマンド失敗を示す具体的なパターンのみ使用。
func ContainsPlanJSON ¶ added in v0.46.0
ContainsPlanJSON はレスポンスに Plan JSON が含まれるかを判定
func ExtractPlanJSON ¶
ExtractPlanJSON はレスポンスからPlan JSONを抽出 見つからない場合は空文字列を返す NOTE: ツール呼び出し JSON ({"tool": ...}) は plan ではないので除外する
func FormatConflictWarning ¶
FormatConflictWarning は競合情報を警告文字列に整形
Types ¶
type Clarification ¶ added in v0.46.0
type Clarification struct {
Question string `json:"question"`
QuestionType string `json:"question_type"` // single_choice, multi_choice, free_text
Options []string `json:"options,omitempty"`
Answer string `json:"answer,omitempty"`
Answers []string `json:"answers,omitempty"`
AskedAt time.Time `json:"asked_at"`
}
Clarification はユーザーへの質問と回答
type Conflict ¶
type Conflict struct {
StepIDs []int // 競合するステップID
ConflictType string // "write-write", "read-write", "write-read"
Files []string // 競合ファイル
Message string // 詳細メッセージ
}
Conflict は並列実行時の競合情報
type DependencyAnalyzer ¶
type DependencyAnalyzer struct {
// contains filtered or unexported fields
}
DependencyAnalyzer はプランステップ間の依存関係を解析
func NewDependencyAnalyzer ¶
func NewDependencyAnalyzer(lspClient *lsp.Client) *DependencyAnalyzer
NewDependencyAnalyzer は DependencyAnalyzer を作成
func (*DependencyAnalyzer) Analyze ¶
func (da *DependencyAnalyzer) Analyze(steps []PlanStep) *DependencyResult
Analyze はステップ間の依存関係を解析
func (*DependencyAnalyzer) AnalyzeAndWarn ¶
func (da *DependencyAnalyzer) AnalyzeAndWarn(steps []PlanStep, parallelStepIDs []int) ([]PlanStep, []string)
AnalyzeAndWarn は依存関係を解析し、競合があれば警告を返す
func (*DependencyAnalyzer) DetectConflicts ¶
func (da *DependencyAnalyzer) DetectConflicts(parallelStepIDs []int, steps []PlanStep) []Conflict
DetectConflicts は並列実行時の競合を検出
func (*DependencyAnalyzer) EnhanceWithLSP ¶
func (da *DependencyAnalyzer) EnhanceWithLSP(steps []PlanStep) []PlanStep
EnhanceWithLSP はLSPを使用して依存関係を強化 WriteFilesに含まれるファイルのシンボル参照を取得し、 参照元ファイルが他のステップで使用されていれば依存関係を追加
func (*DependencyAnalyzer) ExtractFilesFromStep ¶
func (da *DependencyAnalyzer) ExtractFilesFromStep(step *PlanStep) (readFiles, writeFiles []string)
ExtractFilesFromStep はステップからファイルパスを抽出
func (*DependencyAnalyzer) InferDependencies ¶
func (da *DependencyAnalyzer) InferDependencies(steps []PlanStep) []PlanStep
InferDependencies は依存関係を自動推論 RAW (Read After Write): BがAの書き込みファイルを読む WAW (Write After Write): 両方が同じファイルに書く WAR (Write After Read): BがAの読み取りファイルに書く
type DependencyResult ¶
type DependencyResult struct {
Steps []PlanStep // 依存関係が補完されたステップ
Conflicts []Conflict // 検出された競合
Warnings []string // 警告メッセージ
}
DependencyResult は依存関係解析の結果
type FailureAction ¶
type FailureAction string
FailureAction は失敗時のユーザー選択
const ( FailureActionRetry FailureAction = "retry" FailureActionComment FailureAction = "comment" FailureActionSkip FailureAction = "skip" FailureActionAbort FailureAction = "abort" )
type Plan ¶
type Plan struct {
// 既存フィールド
Summary string `json:"summary"`
Steps []PlanStep `json:"steps"`
// メタデータ(新規)
ID string `json:"id,omitempty"`
Title string `json:"title,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
Status PlanStatus `json:"status,omitempty"`
Model string `json:"model,omitempty"`
Provider string `json:"provider,omitempty"`
UserRequest string `json:"user_request,omitempty"`
Clarifications []Clarification `json:"clarifications,omitempty"`
ExecutionLog []StepLog `json:"execution_log,omitempty"`
}
Plan は実行計画を表す
func ParsePlan ¶
ParsePlan はJSON文字列からPlanを解析
互換対応: - V2形式: {"plan": {...}} - 旧形式: {"summary": "...", "steps": [...]}
func (*Plan) GetParallelSteps ¶
GetParallelSteps は並列実行可能なステップを取得 depends_on が同じステップは並列実行可能と判定
func (*Plan) GetToolsExecuted ¶
GetToolsExecuted は実行ツール数を取得
func (*Plan) IncrementToolsExecuted ¶
IncrementToolsExecuted は実行ツール数をインクリメント
func (*Plan) UpdateStatus ¶
UpdateStatus はステップのステータスを更新
type PlanMetadata ¶ added in v0.46.0
type PlanMetadata struct {
ID string
Title string
Status PlanStatus
CreatedAt time.Time
UpdatedAt time.Time
Filename string
}
PlanMetadata は計画の概要情報
type PlanStatus ¶ added in v0.46.0
type PlanStatus string
PlanStatus は計画の全体ステータス
const ( PlanStatusDraft PlanStatus = "draft" PlanStatusPending PlanStatus = "pending" PlanStatusApproved PlanStatus = "approved" PlanStatusRunning PlanStatus = "running" PlanStatusCompleted PlanStatus = "completed" PlanStatusFailed PlanStatus = "failed" PlanStatusCancelled PlanStatus = "cancelled" )
type PlanStep ¶
type PlanStep struct {
ID int `json:"id"`
Description string `json:"description"`
Tools []string `json:"tools"` // 使用予定ツール
DependsOn []int `json:"depends_on"` // 依存するステップID
Status string `json:"status"` // "pending", "running", "completed", "failed"
Result string `json:"result"` // 実行結果
ToolsExecuted int `json:"-"` // 実際に実行されたツール数
// ファイルアクセス情報(依存関係解析で使用)
TargetFiles []string `json:"-"` // 操作対象ファイル(推論結果)
ReadFiles []string `json:"-"` // 読み取りファイル
WriteFiles []string `json:"-"` // 書き込みファイル
// 追加フィールド(Phase 1)
Files []string `json:"files,omitempty"` // 関連ファイル
StartedAt *time.Time `json:"started_at,omitempty"` // 開始時刻
CompletedAt *time.Time `json:"completed_at,omitempty"` // 完了時刻
}
PlanStep は計画の1ステップを表す
type PlanStorage ¶ added in v0.46.0
type PlanStorage struct {
// contains filtered or unexported fields
}
PlanStorage は計画の永続化を管理
func NewPlanStorage ¶ added in v0.46.0
func NewPlanStorage() (*PlanStorage, error)
NewPlanStorage はカレントディレクトリ基準で Storage を作成
func (*PlanStorage) Delete ¶ added in v0.46.0
func (s *PlanStorage) Delete(filename string) error
Delete は計画を削除
func (*PlanStorage) List ¶ added in v0.46.0
func (s *PlanStorage) List() ([]PlanMetadata, error)
List は全計画を一覧取得(新しい順)
func (*PlanStorage) Load ¶ added in v0.46.0
func (s *PlanStorage) Load(filename string) (*Plan, error)
Load は計画を Markdown ファイルから読み込み
type StepLog ¶ added in v0.46.0
type StepLog struct {
StepID int `json:"step_id"`
ToolName string `json:"tool_name"`
ToolArgs map[string]string `json:"tool_args,omitempty"`
Result string `json:"result,omitempty"`
Error string `json:"error,omitempty"`
ExecutedAt time.Time `json:"executed_at"`
DurationMs int64 `json:"duration_ms"`
}
StepLog はステップ実行の詳細ログ