diff --git a/cmd/picoclaw/internal/onboard/command.go b/cmd/picoclaw/internal/onboard/command.go index ec10129594..843ace7e7e 100644 --- a/cmd/picoclaw/internal/onboard/command.go +++ b/cmd/picoclaw/internal/onboard/command.go @@ -1,15 +1,9 @@ package onboard import ( - "embed" - "github.com/spf13/cobra" ) -//go:generate cp -r ../../../../workspace . -//go:embed workspace -var embeddedFiles embed.FS - func NewOnboardCommand() *cobra.Command { cmd := &cobra.Command{ Use: "onboard", diff --git a/cmd/picoclaw/internal/onboard/helpers.go b/cmd/picoclaw/internal/onboard/helpers.go index 4db8bdc8ba..0c5324d628 100644 --- a/cmd/picoclaw/internal/onboard/helpers.go +++ b/cmd/picoclaw/internal/onboard/helpers.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" + picoclaw "github.com/sipeed/picoclaw" "github.com/sipeed/picoclaw/cmd/picoclaw/internal" "github.com/sipeed/picoclaw/pkg/config" ) @@ -47,20 +48,20 @@ func onboard() { } func createWorkspaceTemplates(workspace string) { - err := copyEmbeddedToTarget(workspace) + err := copyEmbeddedToTarget(picoclaw.EmbeddedWorkspace, workspace) if err != nil { fmt.Printf("Error copying workspace templates: %v\n", err) } } -func copyEmbeddedToTarget(targetDir string) error { +func copyEmbeddedToTarget(source fs.FS, targetDir string) error { // Ensure target directory exists if err := os.MkdirAll(targetDir, 0o755); err != nil { return fmt.Errorf("Failed to create target directory: %w", err) } // Walk through all files in embed.FS - err := fs.WalkDir(embeddedFiles, "workspace", func(path string, d fs.DirEntry, err error) error { + err := fs.WalkDir(source, "workspace", func(path string, d fs.DirEntry, err error) error { if err != nil { return err } @@ -71,7 +72,7 @@ func copyEmbeddedToTarget(targetDir string) error { } // Read embedded file - data, err := embeddedFiles.ReadFile(path) + data, err := fs.ReadFile(source, path) if err != nil { return fmt.Errorf("Failed to read embedded file %s: %w", path, err) } diff --git a/cmd/picoclaw/internal/onboard/helpers_test.go b/cmd/picoclaw/internal/onboard/helpers_test.go index f3e0c92e08..cf087c3993 100644 --- a/cmd/picoclaw/internal/onboard/helpers_test.go +++ b/cmd/picoclaw/internal/onboard/helpers_test.go @@ -4,12 +4,14 @@ import ( "os" "path/filepath" "testing" + + picoclaw "github.com/sipeed/picoclaw" ) func TestCopyEmbeddedToTargetUsesAgentsMarkdown(t *testing.T) { targetDir := t.TempDir() - if err := copyEmbeddedToTarget(targetDir); err != nil { + if err := copyEmbeddedToTarget(picoclaw.EmbeddedWorkspace, targetDir); err != nil { t.Fatalf("copyEmbeddedToTarget() error = %v", err) } diff --git a/embedded_workspace.go b/embedded_workspace.go new file mode 100644 index 0000000000..b70f5ecf0e --- /dev/null +++ b/embedded_workspace.go @@ -0,0 +1,8 @@ +package picoclaw + +import "embed" + +// EmbeddedWorkspace bundles the default workspace templates used by `picoclaw onboard`. +// +//go:embed workspace +var EmbeddedWorkspace embed.FS