From 2bbc8063cf3ecba9014f3dcfbaf2a2b76139ae57 Mon Sep 17 00:00:00 2001 From: Snider Date: Sun, 22 Mar 2026 06:47:04 +0000 Subject: [PATCH] feat(agentic): auto-copy AX spec + Core source into agent workspaces prepWorkspace now copies RFC-025-AGENT-EXPERIENCE.md and all Core .go files into .core/reference/ in every dispatched workspace. Agents can read the AX conventions and Core API without network access. Co-Authored-By: Virgil --- pkg/mcp/agentic/prep.go | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/pkg/mcp/agentic/prep.go b/pkg/mcp/agentic/prep.go index d10bdc1..8ea3590 100644 --- a/pkg/mcp/agentic/prep.go +++ b/pkg/mcp/agentic/prep.go @@ -227,12 +227,15 @@ func (s *PrepSubsystem) prepWorkspace(ctx context.Context, _ *mcp.CallToolReques // 8. Copy spec files into specs/ out.SpecFiles = s.copySpecs(wsDir) - // 9. Write PLAN.md from template (if specified) + // 9. Copy AX reference files into .core/reference/ + s.copyReference(wsDir) + + // 11. Write PLAN.md from template (if specified) if input.PlanTemplate != "" { s.writePlanFromTemplate(input.PlanTemplate, input.Variables, input.Task, wsDir) } - // 10. Write prompt template + // 11. Write prompt template s.writePromptTemplate(input.Template, wsDir) out.Success = true @@ -473,6 +476,34 @@ func (s *PrepSubsystem) copySpecs(wsDir string) int { return count } +// copyReference copies the AX spec and Core source files into .core/reference/ +// so dispatched agents can read the conventions and API without network access. +func (s *PrepSubsystem) copyReference(wsDir string) { + refDir := filepath.Join(wsDir, "src", ".core", "reference") + coreio.Local.EnsureDir(refDir) + + // Copy AX spec from docs repo + axSpec := filepath.Join(s.codePath, "core", "docs", "docs", "specs", "RFC-025-AGENT-EXPERIENCE.md") + if data, err := coreio.Local.Read(axSpec); err == nil { + coreio.Local.Write(filepath.Join(refDir, "RFC-025-AGENT-EXPERIENCE.md"), data) + } + + // Copy Core Go source files for API reference + coreGoDir := filepath.Join(s.codePath, "core", "go") + entries, err := coreio.Local.List(coreGoDir) + if err != nil { + return + } + for _, entry := range entries { + if entry.IsDir() || filepath.Ext(entry.Name()) != ".go" { + continue + } + if data, err := coreio.Local.Read(filepath.Join(coreGoDir, entry.Name())); err == nil { + coreio.Local.Write(filepath.Join(refDir, entry.Name()), data) + } + } +} + func (s *PrepSubsystem) generateContext(ctx context.Context, repo, wsDir string) int { if s.brainKey == "" { return 0