Share prompt instructions and simplify validation helpers
This commit is contained in:
@@ -44,7 +44,7 @@ func (m Metadata) DiagnosticsMap() map[string]any {
|
||||
}
|
||||
}
|
||||
|
||||
// Filesystem contains the PromptKit definitions and the shared hardening fragment.
|
||||
// Filesystem contains the PromptKit definitions and shared instruction fragments.
|
||||
func Filesystem() fs.FS { return embeddedAssets }
|
||||
|
||||
func LookupMetadata(promptID string) (Metadata, bool) {
|
||||
@@ -75,10 +75,21 @@ func RegisteredMetadata() []Metadata {
|
||||
return out
|
||||
}
|
||||
|
||||
func HardeningText() string {
|
||||
raw, err := embeddedAssets.ReadFile("assets/shared/prompt_hardening.md")
|
||||
// SharedVariables supplies embedded instructions through the normal PromptKit variables.
|
||||
func SharedVariables() map[string]string {
|
||||
return map[string]string{
|
||||
"HardeningPolicy": HardeningText(),
|
||||
"ProposalContract": sharedText("proposal_contract.md"),
|
||||
"ValidationContract": sharedText("validation_contract.md"),
|
||||
}
|
||||
}
|
||||
|
||||
func HardeningText() string { return sharedText("prompt_hardening.md") }
|
||||
|
||||
func sharedText(name string) string {
|
||||
raw, err := embeddedAssets.ReadFile("assets/shared/" + name)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("read embedded hardening policy: %v", err))
|
||||
panic(fmt.Sprintf("read embedded prompt fragment %s: %v", name, err))
|
||||
}
|
||||
return string(raw)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user