feat: add params_schema column for function composability

Nueva columna params_schema en functions con migración 009. Almacena JSON
con descripción semántica de inputs/outputs para que agentes razonen sobre
composabilidad de funciones. Incluye: campo en modelo Go, parsing de params/output
del frontmatter YAML, serialización a JSON, FTS5 rebuild con nueva columna,
hash de contenido actualizado, y warning en indexer cuando faltan params.
This commit is contained in:
2026-04-05 18:45:01 +02:00
parent 7ca3ffb92c
commit 0da3e530dd
6 changed files with 89 additions and 2 deletions
+22
View File
@@ -2,6 +2,7 @@ package registry
import (
"bytes"
"encoding/json"
"fmt"
"os"
"path/filepath"
@@ -32,6 +33,10 @@ type rawFunction struct {
TestFilePath string `yaml:"test_file_path"`
FilePath string `yaml:"file_path"`
// Params schema
Params []rawParam `yaml:"params"`
Output string `yaml:"output"`
// Source attribution
SourceRepo string `yaml:"source_repo"`
SourceLicense string `yaml:"source_license"`
@@ -45,6 +50,12 @@ type rawFunction struct {
Variant []string `yaml:"variant"`
}
// rawParam describes a function parameter with semantic meaning.
type rawParam struct {
Name string `yaml:"name" json:"name"`
Desc string `yaml:"desc" json:"desc"`
}
// rawType mirrors the YAML frontmatter of a type .md file.
type rawType struct {
Name string `yaml:"name"`
@@ -175,6 +186,17 @@ func ParseFunctionMD(path string, root string) (*Function, error) {
SourceFile: raw.SourceFile,
}
// Serialize params + output to JSON for params_schema column
if len(raw.Params) > 0 || raw.Output != "" {
schema := struct {
Params []rawParam `json:"params,omitempty"`
Output string `json:"output,omitempty"`
}{Params: raw.Params, Output: raw.Output}
if b, err := json.Marshal(schema); err == nil {
f.ParamsSchema = string(b)
}
}
if root != "" && raw.FilePath != "" {
codePath := filepath.Join(root, raw.FilePath)
if codeData, err := os.ReadFile(codePath); err == nil {