<commit_before>package workflow

import (
	"github.com/calebamiles/keps/pkg/keps"
	"github.com/calebamiles/keps/pkg/keps/sections"
	"github.com/calebamiles/keps/pkg/settings"
)

// Plan helps an author sketch out guides for
//  - operators: who may be forced to interact with the enhancement in rage and want to understand
//               how things can go wrong, how to know its working, and what other moving parts does
//               this enhancement interact with
//  - other developers: who need to review, comprehend, and extend the enhancement over its lifetime
//  - teachers: documentation writers, technical trainers, writers, all want to understand how to talk
//              about the enhancement
// Guide templates are rendered and their locations added to the KEP metadata. Plan also adds a template
// for iterating on success criteria as the enhancement works towards general availability
func Plan(runtime settings.Runtime) error {
	kep, err := keps.Open(runtime.TargetDir())
	if err != nil {
		return err
	}

	sectionContent, err := sections.ForImplementableState(kep)
	if err != nil {
		return err
	}

	kep.AddSections(sectionContent)
	err = kep.Persist()
	if err != nil {
		return err
	}

	err = kep.Persist()
	if err != nil {
		return err
	}

	// TODO add mechanics for creating PR

	return nil
}
<commit_msg>fixup: don't double call persist in the plan phase<commit_after>package workflow

import (
	"github.com/calebamiles/keps/pkg/keps"
	"github.com/calebamiles/keps/pkg/keps/sections"
	"github.com/calebamiles/keps/pkg/settings"
)

// Plan helps an author sketch out guides for
//  - operators: who may be forced to interact with the enhancement in rage and want to understand
//               how things can go wrong, how to know its working, and what other moving parts does
//               this enhancement interact with
//  - other developers: who need to review, comprehend, and extend the enhancement over its lifetime
//  - teachers: documentation writers, technical trainers, writers, all want to understand how to talk
//              about the enhancement
// Guide templates are rendered and their locations added to the KEP metadata. Plan also adds a template
// for iterating on success criteria as the enhancement works towards general availability
func Plan(runtime settings.Runtime) error {
	kep, err := keps.Open(runtime.TargetDir())
	if err != nil {
		return err
	}

	sectionContent, err := sections.ForImplementableState(kep)
	if err != nil {
		return err
	}

	kep.AddSections(sectionContent)
	err = kep.Persist()
	if err != nil {
		return err
	}

	// TODO add mechanics for creating PR

	return nil
}

{'fraction_non_alphanumeric': 0.07924528301886792, 'fraction_numerical': 0.0, 'mean_word_length': 3.3530377668308704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2323996', 'n_tokens_mistral': 758, 'n_tokens_neox': 729, 'n_words': 305}