From 8255db243511012575b543778c9ab3730884bad9 Mon Sep 17 00:00:00 2001 From: Jean Machuca Date: Tue, 3 Nov 2026 03:13:38 +0000 Subject: [PATCH] fix: apply gofmt -s formatting --- cmd/init_cmd.go | 6 +-- cmd/init_test.go | 32 ++++++++-------- cmd/install_dependencies.go | 2 +- cmd/pack.go | 7 ++-- cmd/publish.go | 8 ++-- cmd/register_dependencies.go | 6 +-- cmd/search.go | 12 +++--- cmd/tune.go | 10 ++--- internal/archive/archive.go | 56 +++++++++++++-------------- internal/config/config.go | 2 +- internal/config/secrets_test.go | 8 ++-- internal/manager/manager_test.go | 66 ++++++++++++++++---------------- internal/normalize/normalize.go | 12 +++--- internal/queue/queue.go | 8 ++-- internal/queue/queue_test.go | 2 +- internal/registry/registry.go | 30 +++++++-------- internal/schema/schema.go | 2 +- 17 files changed, 134 insertions(+), 135 deletions(-) diff --git a/cmd/init_cmd.go b/cmd/init_cmd.go index 3e37190..e2e425c 100644 --- a/cmd/init_cmd.go +++ b/cmd/init_cmd.go @@ -480,9 +480,9 @@ func writeWorkflows(dir string) error { } files := map[string]string{ - filepath.Join(dir, ".github", "docker", "Dockerfile.ci"): dockerfileCI, - filepath.Join(dir, ".github", "workflows", "ci.yml"): workflowCI, - filepath.Join(dir, ".github", "workflows", "publish.yml"): workflowPublish, + filepath.Join(dir, ".github", "docker", "Dockerfile.ci"): dockerfileCI, + filepath.Join(dir, ".github", "workflows", "ci.yml"): workflowCI, + filepath.Join(dir, ".github", "workflows", "publish.yml"): workflowPublish, } for path, content := range files { diff --git a/cmd/init_test.go b/cmd/init_test.go index b62d8d4..b4e0638 100644 --- a/cmd/init_test.go +++ b/cmd/init_test.go @@ -8,10 +8,10 @@ import ( func TestInitCmd(t *testing.T) { tests := []struct { - name string - args []string - template string - wantErr bool + name string + args []string + template string + wantErr bool checkFiles []string }{ { @@ -28,8 +28,8 @@ func TestInitCmd(t *testing.T) { }, }, { - name: "prompt-only template", - args: []string{"prompt-skill"}, + name: "prompt-only template", + args: []string{"prompt-skill"}, template: "prompt-only", checkFiles: []string{ "prompt-skill/cognitive.json", @@ -40,8 +40,8 @@ func TestInitCmd(t *testing.T) { }, }, { - name: "mcp-bridge template", - args: []string{"bridge-skill"}, + name: "mcp-bridge template", + args: []string{"bridge-skill"}, template: "mcp-bridge", checkFiles: []string{ "bridge-skill/cognitive.json", @@ -52,8 +52,8 @@ func TestInitCmd(t *testing.T) { }, }, { - name: "gguf-model template", - args: []string{"model-skill"}, + name: "gguf-model template", + args: []string{"model-skill"}, template: "gguf-model", checkFiles: []string{ "model-skill/cognitive.json", @@ -63,8 +63,8 @@ func TestInitCmd(t *testing.T) { }, }, { - name: "firmware template", - args: []string{"firmware-skill"}, + name: "firmware template", + args: []string{"firmware-skill"}, template: "firmware", checkFiles: []string{ "firmware-skill/cognitive.json", @@ -74,8 +74,8 @@ func TestInitCmd(t *testing.T) { }, }, { - name: "full template", - args: []string{"full-skill"}, + name: "full template", + args: []string{"full-skill"}, template: "full", checkFiles: []string{ "full-skill/cognitive.json", @@ -89,8 +89,8 @@ func TestInitCmd(t *testing.T) { }, }, { - name: "directory already exists", - args: []string{"existing-dir"}, + name: "directory already exists", + args: []string{"existing-dir"}, wantErr: true, }, } diff --git a/cmd/install_dependencies.go b/cmd/install_dependencies.go index 81cfdaf..1d8d650 100644 --- a/cmd/install_dependencies.go +++ b/cmd/install_dependencies.go @@ -47,7 +47,7 @@ var installDepsCmd = &cobra.Command{ _ = queue.MarkInstalled(root, stage, entry.Filename) continue } - + if err := queue.MarkInstalled(root, stage, entry.Filename); err != nil { return fmt.Errorf("failed to mark %s as installed: %w", entry.Dependency.Name, err) } diff --git a/cmd/pack.go b/cmd/pack.go index 6cdf6e8..e71fe12 100644 --- a/cmd/pack.go +++ b/cmd/pack.go @@ -103,9 +103,9 @@ After packing, the archive is automatically verified for integrity.`, // Convert typedManifest back to map[string]interface{} to keep compatibility with loadAndMergeManifests' return type // although we could just change the return type of loadAndMergeManifests to *archive.Manifest. // For now, let's just marshal and unmarshal. - data, _ := json.Marshal(typedManifest) - manifest = make(map[string]interface{}) - _ = json.Unmarshal(data, &manifest) + data, _ := json.Marshal(typedManifest) + manifest = make(map[string]interface{}) + _ = json.Unmarshal(data, &manifest) } manifestData, err := json.MarshalIndent(manifest, "", " ") @@ -163,7 +163,6 @@ After packing, the archive is automatically verified for integrity.`, fmt.Println(msg) return nil }, - } func collectManifestRefs(m *archive.Manifest) []string { diff --git a/cmd/publish.go b/cmd/publish.go index 6e1492f..069750a 100644 --- a/cmd/publish.go +++ b/cmd/publish.go @@ -19,10 +19,10 @@ const maxCGPSize = 32 << 20 // 32 MB Cloud Run request limit var ( publishDownloadURL string - publishTags []string - publishScope string - publishVisibility string - publishKeyPath string + publishTags []string + publishScope string + publishVisibility string + publishKeyPath string ) var registryClient registry.Registry diff --git a/cmd/register_dependencies.go b/cmd/register_dependencies.go index a14f5b5..3ac80ae 100644 --- a/cmd/register_dependencies.go +++ b/cmd/register_dependencies.go @@ -13,10 +13,10 @@ import ( var registerDepsCmd = &cobra.Command{ Use: "register-dependencies ", Short: "Register system-level dependencies for an installed patch in the queue", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { packageName := args[0] - + // Resolve root from global flag root := "/" if rootDir != "/" { @@ -29,7 +29,7 @@ var registerDepsCmd = &cobra.Command{ if root != "/" { installPath = fmt.Sprintf("%s/%s", root, installPath) } - + manifest, err := archive.LoadManifest(installPath) if err != nil { return fmt.Errorf("could not load manifest for %s: %w", packageName, err) diff --git a/cmd/search.go b/cmd/search.go index 48ae819..4392af9 100644 --- a/cmd/search.go +++ b/cmd/search.go @@ -32,12 +32,12 @@ var searchCmd = &cobra.Command{ rc := registry.New(regURL) opts := registry.SearchOptions{ - License: searchLicense, - MinRAM: searchMinRAM, - Page: searchPage, - PerPage: 20, - Capability: searchCapability, - Exact: searchExact, + License: searchLicense, + MinRAM: searchMinRAM, + Page: searchPage, + PerPage: 20, + Capability: searchCapability, + Exact: searchExact, } results, err := rc.Search(query, opts) if err != nil { diff --git a/cmd/tune.go b/cmd/tune.go index 86eb9ef..3e60e0e 100644 --- a/cmd/tune.go +++ b/cmd/tune.go @@ -46,9 +46,9 @@ the designated training tool via the system daemon.`, if tuneFinalize { // Finalize/Quantize payload := map[string]interface{}{ - "package": pkgName, - "quantize": tuneQuantize, - "finalize": true, + "package": pkgName, + "quantize": tuneQuantize, + "finalize": true, } if err := daemon.SendMessage("cpm_tune", payload); err != nil { return fmt.Errorf("ERROR:T104: failed to trigger finalization: %w", err) @@ -69,7 +69,7 @@ the designated training tool via the system daemon.`, } if m.Training.DataRequirements != nil && samples < m.Training.DataRequirements.MinSamples { - return fmt.Errorf("ERROR:T105: insufficient data for tuning (%d/%d samples)", + return fmt.Errorf("ERROR:T105: insufficient data for tuning (%d/%d samples)", samples, m.Training.DataRequirements.MinSamples) } @@ -82,7 +82,7 @@ the designated training tool via the system daemon.`, if err := daemon.SendMessage("cpm_tune", payload); err != nil { return fmt.Errorf("ERROR:T106: failed to trigger tuning: %w", err) } - fmt.Printf("✓ Tuning triggered for %s (background: %v, epochs: %d)\n", + fmt.Printf("✓ Tuning triggered for %s (background: %v, epochs: %d)\n", pkgName, tuneBackground, tuneEpochs) } diff --git a/internal/archive/archive.go b/internal/archive/archive.go index 077b33b..f1b2e05 100644 --- a/internal/archive/archive.go +++ b/internal/archive/archive.go @@ -24,20 +24,20 @@ type HardwareDependencies struct { } type Manifest struct { - Name string `json:"name"` - Version string `json:"version"` - Description string `json:"description"` - Author string `json:"author,omitempty"` - License string `json:"license,omitempty"` - Source *SourceInfo `json:"source,omitempty"` - Dependencies map[string]string `json:"dependencies,omitempty"` - HardwareRequirements *HardwareReq `json:"hardware_requirements,omitempty"` + Name string `json:"name"` + Version string `json:"version"` + Description string `json:"description"` + Author string `json:"author,omitempty"` + License string `json:"license,omitempty"` + Source *SourceInfo `json:"source,omitempty"` + Dependencies map[string]string `json:"dependencies,omitempty"` + HardwareRequirements *HardwareReq `json:"hardware_requirements,omitempty"` HardwareDependencies *HardwareDependencies `json:"hardware_dependencies,omitempty"` - Brain *BrainConfig `json:"brain,omitempty"` - Runtime *RuntimeConfig `json:"runtime,omitempty"` - Training *TrainingConfig `json:"training,omitempty"` - Checksum *ChecksumInfo `json:"checksum,omitempty"` - UnlockCodes []string `json:"unlock_codes,omitempty"` + Brain *BrainConfig `json:"brain,omitempty"` + Runtime *RuntimeConfig `json:"runtime,omitempty"` + Training *TrainingConfig `json:"training,omitempty"` + Checksum *ChecksumInfo `json:"checksum,omitempty"` + UnlockCodes []string `json:"unlock_codes,omitempty"` } type ChecksumInfo struct { @@ -60,18 +60,18 @@ type HardwareReq struct { } type BrainConfig struct { - BaseModel string `json:"base_model,omitempty"` - Adapter string `json:"adapter,omitempty"` - RawModel *ModelConfig `json:"raw_model,omitempty"` - WideModel *ModelConfig `json:"wide_model,omitempty"` + BaseModel string `json:"base_model,omitempty"` + Adapter string `json:"adapter,omitempty"` + RawModel *ModelConfig `json:"raw_model,omitempty"` + WideModel *ModelConfig `json:"wide_model,omitempty"` } type ModelConfig struct { - BaseModel string `json:"base_model,omitempty"` - Adapter string `json:"adapter,omitempty"` - Weights *WeightsConfig `json:"weights,omitempty"` - Parameters *BrainParameters `json:"parameters,omitempty"` - Routing []RoutingHint `json:"routing,omitempty"` + BaseModel string `json:"base_model,omitempty"` + Adapter string `json:"adapter,omitempty"` + Weights *WeightsConfig `json:"weights,omitempty"` + Parameters *BrainParameters `json:"parameters,omitempty"` + Routing []RoutingHint `json:"routing,omitempty"` } type WeightsConfig struct { @@ -113,11 +113,11 @@ type RoutingHint struct { } type RuntimeConfig struct { - SystemPrompt string `json:"system_prompt,omitempty"` - ToolsRoot string `json:"tools_root,omitempty"` - MCPServers []MCPServer `json:"mcp_servers,omitempty"` - Background bool `json:"background,omitempty"` - Capabilities []string `json:"capabilities,omitempty"` + SystemPrompt string `json:"system_prompt,omitempty"` + ToolsRoot string `json:"tools_root,omitempty"` + MCPServers []MCPServer `json:"mcp_servers,omitempty"` + Background bool `json:"background,omitempty"` + Capabilities []string `json:"capabilities,omitempty"` } type TrainingConfig struct { @@ -152,7 +152,7 @@ func ReadManifest(r io.Reader) (*Manifest, error) { return nil, fmt.Errorf("gzip: %w", err) } defer gzr.Close() - + tr := tar.NewReader(gzr) for { hdr, err := tr.Next() diff --git a/internal/config/config.go b/internal/config/config.go index 4573e41..b1b8ccc 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -35,7 +35,7 @@ func Load(path string) (*Registries, error) { } var file struct { - Official struct { + Official struct { Primary string `toml:"primary"` Mirrors map[string]string `toml:"mirrors"` } `toml:"official"` diff --git a/internal/config/secrets_test.go b/internal/config/secrets_test.go index 529f74a..43c5309 100644 --- a/internal/config/secrets_test.go +++ b/internal/config/secrets_test.go @@ -88,12 +88,12 @@ func TestLoadReturnsEmptyWhenNotExist(t *testing.T) { func TestMergeSecrets(t *testing.T) { global := &Secrets{Secrets: map[string]string{ - "GLOBAL_KEY": "global-val", - "SHARED_KEY": "global-shared", + "GLOBAL_KEY": "global-val", + "SHARED_KEY": "global-shared", }} patch := &Secrets{Secrets: map[string]string{ - "PATCH_KEY": "patch-val", - "SHARED_KEY": "patch-shared", + "PATCH_KEY": "patch-val", + "SHARED_KEY": "patch-shared", }} merged := MergeSecrets(global, patch) diff --git a/internal/manager/manager_test.go b/internal/manager/manager_test.go index 84cce39..dd0f72c 100644 --- a/internal/manager/manager_test.go +++ b/internal/manager/manager_test.go @@ -154,12 +154,12 @@ func TestInstall(t *testing.T) { func TestIsInstalled(t *testing.T) { tests := []struct { - name string - root string - dep archive.SystemDependency - runFunc func(name string, args ...string) error - want bool - wantErr bool + name string + root string + dep archive.SystemDependency + runFunc func(name string, args ...string) error + want bool + wantErr bool }{ { name: "apk installed", @@ -193,9 +193,9 @@ func TestIsInstalled(t *testing.T) { wantErr: true, }, { - name: "other manager", - root: "/", - dep: archive.SystemDependency{Name: "zlib", Manager: "npm"}, + name: "other manager", + root: "/", + dep: archive.SystemDependency{Name: "zlib", Manager: "npm"}, want: false, wantErr: false, }, @@ -220,41 +220,41 @@ func TestIsInstalled(t *testing.T) { func TestResolveVersion(t *testing.T) { tests := []struct { - name string - root string - dep archive.SystemDependency - output string - want string - wantErr bool + name string + root string + dep archive.SystemDependency + output string + want string + wantErr bool }{ { - name: "apk success", - root: "/", - dep: archive.SystemDependency{Name: "zlib", Manager: "apk"}, - output: "zlib-1.2.11-r0", - want: "1.2.11", + name: "apk success", + root: "/", + dep: archive.SystemDependency{Name: "zlib", Manager: "apk"}, + output: "zlib-1.2.11-r0", + want: "1.2.11", wantErr: false, }, { - name: "apk not found", - root: "/", - dep: archive.SystemDependency{Name: "fake", Manager: "apk"}, - output: "", - want: "latest", + name: "apk not found", + root: "/", + dep: archive.SystemDependency{Name: "fake", Manager: "apk"}, + output: "", + want: "latest", wantErr: false, }, { - name: "apk error", - root: "/", - dep: archive.SystemDependency{Name: "zlib", Manager: "apk"}, - output: "", + name: "apk error", + root: "/", + dep: archive.SystemDependency{Name: "zlib", Manager: "apk"}, + output: "", wantErr: true, }, { - name: "other manager", - root: "/", - dep: archive.SystemDependency{Name: "zlib", Manager: "npm"}, - want: "latest", + name: "other manager", + root: "/", + dep: archive.SystemDependency{Name: "zlib", Manager: "npm"}, + want: "latest", wantErr: false, }, } diff --git a/internal/normalize/normalize.go b/internal/normalize/normalize.go index baf1c50..51b3bfb 100644 --- a/internal/normalize/normalize.go +++ b/internal/normalize/normalize.go @@ -60,12 +60,12 @@ func detectManifest(dir string) (*archive.Manifest, error) { } type packageJSON struct { - Name string `json:"name"` - Version string `json:"version"` - Description string `json:"description,omitempty"` - Author string `json:"author,omitempty"` - License string `json:"license,omitempty"` - CognitiveOS map[string]interface{} `json:"cognitive_os"` + Name string `json:"name"` + Version string `json:"version"` + Description string `json:"description,omitempty"` + Author string `json:"author,omitempty"` + License string `json:"license,omitempty"` + CognitiveOS map[string]interface{} `json:"cognitive_os"` } func parsePackageJSON(data []byte) (*archive.Manifest, error) { diff --git a/internal/queue/queue.go b/internal/queue/queue.go index bb522f3..17a6d75 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -13,10 +13,10 @@ import ( // QueueEntry represents a parsed queue file. type QueueEntry struct { - Filename string `json:"-"` - PatchName string `json:"patch_name"` + Filename string `json:"-"` + PatchName string `json:"patch_name"` PatchVersion string `json:"patch_version"` - Dependency archive.SystemDependency `json:"dependency"` + Dependency archive.SystemDependency `json:"dependency"` RegisteredAt time.Time `json:"registered_at"` } @@ -36,7 +36,7 @@ func Register(root, patchName, patchVersion string, dep archive.SystemDependency sPatchName := sanitize(patchName) sPatchVersion := sanitize(patchVersion) sDepName := sanitize(dep.Name) - + version := dep.Version if version == "" { version = "latest" diff --git a/internal/queue/queue_test.go b/internal/queue/queue_test.go index bd7af9f..4beeec0 100644 --- a/internal/queue/queue_test.go +++ b/internal/queue/queue_test.go @@ -72,7 +72,7 @@ func TestQueue(t *testing.T) { t.Run("RemoveByPatch", func(t *testing.T) { // Register again _ = Register(root, patchName, patchVersion, dep) - + err := RemoveByPatch(root, patchName, patchVersion) if err != nil { t.Fatalf("RemoveByPatch failed: %v", err) diff --git a/internal/registry/registry.go b/internal/registry/registry.go index 9c872ce..1d63578 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -18,20 +18,20 @@ type SearchResult struct { } type PatchSummary struct { - Name string `json:"name"` - Version string `json:"version"` - Description string `json:"description"` - License string `json:"license"` - ChecksumSHA256 string `json:"checksum_sha256"` + Name string `json:"name"` + Version string `json:"version"` + Description string `json:"description"` + License string `json:"license"` + ChecksumSHA256 string `json:"checksum_sha256"` } type PatchMetadata struct { - Name string `json:"name"` - Version string `json:"version"` - Description string `json:"description"` - ChecksumSHA256 string `json:"checksum_sha256"` - DownloadURL string `json:"download_url"` - Status string `json:"status"` + Name string `json:"name"` + Version string `json:"version"` + Description string `json:"description"` + ChecksumSHA256 string `json:"checksum_sha256"` + DownloadURL string `json:"download_url"` + Status string `json:"status"` } type VersionInfo struct { @@ -40,9 +40,9 @@ type VersionInfo struct { } type DependencyTree struct { - Name string `json:"name"` - Version string `json:"version"` - Dependencies []DependencyTree `json:"dependencies"` + Name string `json:"name"` + Version string `json:"version"` + Dependencies []DependencyTree `json:"dependencies"` } type SearchOptions struct { @@ -231,7 +231,7 @@ func (c *Client) Download(name, version string, opts DownloadOptions) (io.ReadCl return nil, fmt.Errorf("create request: %w", err) } req.Header.Set("User-Agent", "cpm/1.0") - + client := &http.Client{ Timeout: 30 * time.Second, CheckRedirect: func(req *http.Request, via []*http.Request) error { diff --git a/internal/schema/schema.go b/internal/schema/schema.go index b6c13bf..3b9ee39 100644 --- a/internal/schema/schema.go +++ b/internal/schema/schema.go @@ -1,8 +1,8 @@ package schema import ( - "encoding/json" _ "embed" + "encoding/json" "fmt" "github.com/santhosh-tekuri/jsonschema/v6"