feat(brain): add path field to brain_ingest for /ingest-path routing

Adds an optional path field to brain_ingest so Claude can ingest files
or directories directly by path without embedding content in the call.
Routing: path set → /ingest-path; content+source set → /ingest; neither → error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mathias Bergqvist
2026-04-22 23:01:05 +02:00
parent 2f4b577131
commit a6dce972d6
3 changed files with 77 additions and 10 deletions

View File

@@ -64,8 +64,9 @@ func (s *Skill) write(ctx context.Context, args json.RawMessage) (json.RawMessag
}
type ingestArgs struct {
Content string `json:"content"`
Source string `json:"source"`
Content string `json:"content,omitempty"`
Source string `json:"source,omitempty"`
Path string `json:"path,omitempty"`
DryRun bool `json:"dry_run,omitempty"`
}
@@ -74,16 +75,24 @@ func (s *Skill) ingest(ctx context.Context, args json.RawMessage) (json.RawMessa
if err := json.Unmarshal(args, &a); err != nil {
return nil, fmt.Errorf("parse args: %w", err)
}
if a.Content == "" {
return nil, fmt.Errorf("content is required")
}
if a.Source == "" {
return nil, fmt.Errorf("source is required")
}
if s.cfg.IngestSvcURL == "" {
return nil, fmt.Errorf("brain_ingest: INGEST_SVC_URL not configured")
}
return s.postTo(ctx, s.cfg.IngestSvcURL+"/ingest", a)
if a.Path != "" {
return s.postTo(ctx, s.cfg.IngestSvcURL+"/ingest-path", map[string]any{
"path": a.Path,
"source": a.Source,
"dry_run": a.DryRun,
})
}
if a.Content != "" && a.Source != "" {
return s.postTo(ctx, s.cfg.IngestSvcURL+"/ingest", map[string]any{
"content": a.Content,
"source": a.Source,
"dry_run": a.DryRun,
})
}
return nil, fmt.Errorf("either content+source or path is required")
}
type searchArgs struct {