Capture keyed prompts and source-backed content at load time
This commit is contained in:
19
internal/promptdef/hash.go
Normal file
19
internal/promptdef/hash.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package promptdef
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/domain"
|
||||
)
|
||||
|
||||
// HashDefinition hashes an execution-ready prompt, including captured content.
|
||||
func HashDefinition(definition *domain.PromptDefinition) (string, error) {
|
||||
bytes, err := json.Marshal(definition)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
sum := sha256.Sum256(bytes)
|
||||
return hex.EncodeToString(sum[:]), nil
|
||||
}
|
||||
Reference in New Issue
Block a user