feat(prompts): add new templates for memory migration and weekly review

This commit is contained in:
2026-03-26 23:08:16 +02:00
parent eefa78d011
commit b74d63c543
6 changed files with 354 additions and 0 deletions

View File

@@ -171,6 +171,7 @@ func (c *Client) ExtractMetadata(ctx context.Context, input string) (thoughttype
metadataText := strings.TrimSpace(resp.Choices[0].Message.Content)
metadataText = stripCodeFence(metadataText)
metadataText = extractJSONObject(metadataText)
var metadata thoughttypes.ThoughtMetadata
if err := json.Unmarshal([]byte(metadataText), &metadata); err != nil {
@@ -286,6 +287,17 @@ func (c *Client) doJSON(ctx context.Context, path string, requestBody any, dest
return lastErr
}
// extractJSONObject finds the first complete {...} block in s.
// It handles models that prepend prose to a JSON response despite json_object mode.
func extractJSONObject(s string) string {
start := strings.Index(s, "{")
end := strings.LastIndex(s, "}")
if start == -1 || end == -1 || end <= start {
return s
}
return s[start : end+1]
}
func stripCodeFence(value string) string {
value = strings.TrimSpace(value)
if !strings.HasPrefix(value, "```") {