plan

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsFailure

func ContainsFailure(result string) (bool, string)

ContainsFailure はツール結果に失敗パターンが含まれるか検出 失敗を検出した場合、(true, 理由) を返す

NOTE: "error:" や "Error:" のような汎用パターンは使用しない。 コード検索結果(例: t.Errorf)やログ出力に含まれる "Error" 文字列で 誤検知してしまうため。実際のコマンド失敗を示す具体的なパターンのみ使用。

func ExtractPlanJSON

func ExtractPlanJSON(response string) string

ExtractPlanJSON はレスポンスからPlan JSONを抽出 見つからない場合は空文字列を返す NOTE: ツール呼び出し JSON ({"tool": ...}) は plan ではないので除外する

func FormatConflictWarning

func FormatConflictWarning(c Conflict) string

FormatConflictWarning は競合情報を警告文字列に整形

func FormatPlan

func FormatPlan(plan *Plan) string

FormatPlan は計画を見やすく整形

func HashToolCalls

func HashToolCalls(toolCalls []*tools.ToolCall) string

HashToolCalls は toolCalls セットのハッシュを生成(ループ検知用)

Types

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"`
}

Plan は実行計画を表す

func ParsePlan

func ParsePlan(jsonStr string) (*Plan, error)

ParsePlan はJSON文字列からPlanを解析

互換対応: - V2形式: {"plan": {...}} - 旧形式: {"summary": "...", "steps": [...]}

func (*Plan) CanExecute

func (p *Plan) CanExecute(stepID int) bool

CanExecute はステップが実行可能かチェック

func (*Plan) GetNextStep

func (p *Plan) GetNextStep() int

GetNextStep は次に実行すべきステップIDを取得

func (*Plan) GetParallelSteps

func (p *Plan) GetParallelSteps() []int

GetParallelSteps は並列実行可能なステップを取得 depends_on が同じステップは並列実行可能と判定

func (*Plan) GetStep

func (p *Plan) GetStep(id int) *PlanStep

GetStep は指定IDのステップを取得

func (*Plan) GetToolsExecuted

func (p *Plan) GetToolsExecuted(stepID int) int

GetToolsExecuted は実行ツール数を取得

func (*Plan) HasFailed

func (p *Plan) HasFailed() bool

HasFailed は失敗したステップがあるかチェック

func (*Plan) IncrementToolsExecuted

func (p *Plan) IncrementToolsExecuted(stepID int)

IncrementToolsExecuted は実行ツール数をインクリメント

func (*Plan) IsCompleted

func (p *Plan) IsCompleted() bool

IsCompleted はすべてのステップが完了したかチェック

func (*Plan) UpdateStatus

func (p *Plan) UpdateStatus(stepID int, status, result string)

UpdateStatus はステップのステータスを更新

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:"-"` // 書き込みファイル
}

PlanStep は計画の1ステップを表す

Jump to

Keyboard shortcuts

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