2026-01-27 21:08:51 +00:00
|
|
|
// Package repos provides functionality for managing multi-repo workspaces.
|
|
|
|
|
// It reads a repos.yaml registry file that defines repositories, their types,
|
|
|
|
|
// dependencies, and metadata.
|
|
|
|
|
package repos
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"strings"
|
|
|
|
|
|
refactor: strip to pure package library (#3)
- Fix remaining 187 pkg/ files referencing core/cli → core/go
- Move SDK library code from internal/cmd/sdk/ → pkg/sdk/ (new package)
- Create pkg/rag/helpers.go with convenience functions from internal/cmd/rag/
- Fix pkg/mcp/tools_rag.go to use pkg/rag instead of internal/cmd/rag
- Fix pkg/build/buildcmd/cmd_sdk.go and pkg/release/sdk.go to use pkg/sdk
- Remove all non-library content: main.go, internal/, cmd/, docker/,
scripts/, tasks/, tools/, .core/, .forgejo/, .woodpecker/, Taskfile.yml
- Run go mod tidy to trim unused dependencies
core/go is now a pure Go package suite (library only).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Claude <developers@lethean.io>
Reviewed-on: https://forge.lthn.ai/core/go/pulls/3
2026-02-16 14:23:45 +00:00
|
|
|
"forge.lthn.ai/core/go/pkg/io"
|
2026-01-27 21:08:51 +00:00
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Registry represents a collection of repositories defined in repos.yaml.
|
|
|
|
|
type Registry struct {
|
feat: git command, build improvements, and go fmt git-aware (#74)
* feat(go): make go fmt git-aware by default
- By default, only check changed Go files (modified, staged, untracked)
- Add --all flag to check all files (previous behaviour)
- Reduces noise when running fmt on large codebases
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(build): minimal output by default, add missing i18n
- Default output now shows single line: "Success Built N artifacts (dir)"
- Add --verbose/-v flag to show full detailed output
- Add all missing i18n translations for build commands
- Errors still show failure reason in minimal mode
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add root-level `core git` command
- Create pkg/gitcmd with git workflow commands as root menu
- Export command builders from pkg/dev (AddCommitCommand, etc.)
- Commands available under both `core git` and `core dev` for compatibility
- Git commands: health, commit, push, pull, work, sync, apply
- GitHub orchestration stays in dev: issues, reviews, ci, impact
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(qa): add docblock coverage checking
Implement docblock/docstring coverage analysis for Go code:
- New `core qa docblock` command to check coverage
- Shows compact file:line list when under threshold
- Integrate with `core go qa` as a default check
- Add --docblock-threshold flag (default 80%)
The checker uses Go AST parsing to find exported symbols
(functions, types, consts, vars) without documentation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- Fix doc comment: "status" → "health" in gitcmd package
- Implement --check flag for `core go fmt` (exits non-zero if files need formatting)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add docstrings for 100% coverage
Add documentation comments to all exported symbols:
- pkg/build: ProjectType constants
- pkg/cli: LogLevel, RenderStyle, TableStyle
- pkg/framework: ServiceFor, MustServiceFor, Core.Core
- pkg/git: GitError.Error, GitError.Unwrap
- pkg/i18n: Handler Match/Handle methods
- pkg/log: Level constants
- pkg/mcp: Tool input/output types
- pkg/php: Service constants, QA types, service methods
- pkg/process: ServiceError.Error
- pkg/repos: RepoType constants
- pkg/setup: ChangeType, ChangeCategory constants
- pkg/workspace: AddWorkspaceCommands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: standardize line endings to LF
Add .gitattributes to enforce LF line endings for all text files.
Normalize all existing files to use Unix-style line endings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- cmd_format.go: validate --check/--fix mutual exclusivity, capture stderr
- cmd_docblock.go: return error instead of os.Exit(1) for proper error handling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback (round 2)
- linuxkit.go: propagate state update errors, handle cmd.Wait() errors in waitForExit
- mcp.go: guard against empty old_string in editDiff to prevent runaway edits
- cmd_docblock.go: log parse errors instead of silently skipping
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 10:48:44 +00:00
|
|
|
Version int `yaml:"version"`
|
|
|
|
|
Org string `yaml:"org"`
|
|
|
|
|
BasePath string `yaml:"base_path"`
|
|
|
|
|
Repos map[string]*Repo `yaml:"repos"`
|
|
|
|
|
Defaults RegistryDefaults `yaml:"defaults"`
|
2026-02-04 18:03:54 +00:00
|
|
|
medium io.Medium `yaml:"-"`
|
2026-01-27 21:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RegistryDefaults contains default values applied to all repos.
|
|
|
|
|
type RegistryDefaults struct {
|
|
|
|
|
CI string `yaml:"ci"`
|
|
|
|
|
License string `yaml:"license"`
|
|
|
|
|
Branch string `yaml:"branch"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RepoType indicates the role of a repository in the ecosystem.
|
|
|
|
|
type RepoType string
|
|
|
|
|
|
feat: git command, build improvements, and go fmt git-aware (#74)
* feat(go): make go fmt git-aware by default
- By default, only check changed Go files (modified, staged, untracked)
- Add --all flag to check all files (previous behaviour)
- Reduces noise when running fmt on large codebases
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(build): minimal output by default, add missing i18n
- Default output now shows single line: "Success Built N artifacts (dir)"
- Add --verbose/-v flag to show full detailed output
- Add all missing i18n translations for build commands
- Errors still show failure reason in minimal mode
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add root-level `core git` command
- Create pkg/gitcmd with git workflow commands as root menu
- Export command builders from pkg/dev (AddCommitCommand, etc.)
- Commands available under both `core git` and `core dev` for compatibility
- Git commands: health, commit, push, pull, work, sync, apply
- GitHub orchestration stays in dev: issues, reviews, ci, impact
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(qa): add docblock coverage checking
Implement docblock/docstring coverage analysis for Go code:
- New `core qa docblock` command to check coverage
- Shows compact file:line list when under threshold
- Integrate with `core go qa` as a default check
- Add --docblock-threshold flag (default 80%)
The checker uses Go AST parsing to find exported symbols
(functions, types, consts, vars) without documentation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- Fix doc comment: "status" → "health" in gitcmd package
- Implement --check flag for `core go fmt` (exits non-zero if files need formatting)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add docstrings for 100% coverage
Add documentation comments to all exported symbols:
- pkg/build: ProjectType constants
- pkg/cli: LogLevel, RenderStyle, TableStyle
- pkg/framework: ServiceFor, MustServiceFor, Core.Core
- pkg/git: GitError.Error, GitError.Unwrap
- pkg/i18n: Handler Match/Handle methods
- pkg/log: Level constants
- pkg/mcp: Tool input/output types
- pkg/php: Service constants, QA types, service methods
- pkg/process: ServiceError.Error
- pkg/repos: RepoType constants
- pkg/setup: ChangeType, ChangeCategory constants
- pkg/workspace: AddWorkspaceCommands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: standardize line endings to LF
Add .gitattributes to enforce LF line endings for all text files.
Normalize all existing files to use Unix-style line endings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- cmd_format.go: validate --check/--fix mutual exclusivity, capture stderr
- cmd_docblock.go: return error instead of os.Exit(1) for proper error handling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback (round 2)
- linuxkit.go: propagate state update errors, handle cmd.Wait() errors in waitForExit
- mcp.go: guard against empty old_string in editDiff to prevent runaway edits
- cmd_docblock.go: log parse errors instead of silently skipping
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 10:48:44 +00:00
|
|
|
// Repository type constants for ecosystem classification.
|
2026-01-27 21:08:51 +00:00
|
|
|
const (
|
feat: git command, build improvements, and go fmt git-aware (#74)
* feat(go): make go fmt git-aware by default
- By default, only check changed Go files (modified, staged, untracked)
- Add --all flag to check all files (previous behaviour)
- Reduces noise when running fmt on large codebases
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(build): minimal output by default, add missing i18n
- Default output now shows single line: "Success Built N artifacts (dir)"
- Add --verbose/-v flag to show full detailed output
- Add all missing i18n translations for build commands
- Errors still show failure reason in minimal mode
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add root-level `core git` command
- Create pkg/gitcmd with git workflow commands as root menu
- Export command builders from pkg/dev (AddCommitCommand, etc.)
- Commands available under both `core git` and `core dev` for compatibility
- Git commands: health, commit, push, pull, work, sync, apply
- GitHub orchestration stays in dev: issues, reviews, ci, impact
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(qa): add docblock coverage checking
Implement docblock/docstring coverage analysis for Go code:
- New `core qa docblock` command to check coverage
- Shows compact file:line list when under threshold
- Integrate with `core go qa` as a default check
- Add --docblock-threshold flag (default 80%)
The checker uses Go AST parsing to find exported symbols
(functions, types, consts, vars) without documentation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- Fix doc comment: "status" → "health" in gitcmd package
- Implement --check flag for `core go fmt` (exits non-zero if files need formatting)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add docstrings for 100% coverage
Add documentation comments to all exported symbols:
- pkg/build: ProjectType constants
- pkg/cli: LogLevel, RenderStyle, TableStyle
- pkg/framework: ServiceFor, MustServiceFor, Core.Core
- pkg/git: GitError.Error, GitError.Unwrap
- pkg/i18n: Handler Match/Handle methods
- pkg/log: Level constants
- pkg/mcp: Tool input/output types
- pkg/php: Service constants, QA types, service methods
- pkg/process: ServiceError.Error
- pkg/repos: RepoType constants
- pkg/setup: ChangeType, ChangeCategory constants
- pkg/workspace: AddWorkspaceCommands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: standardize line endings to LF
Add .gitattributes to enforce LF line endings for all text files.
Normalize all existing files to use Unix-style line endings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- cmd_format.go: validate --check/--fix mutual exclusivity, capture stderr
- cmd_docblock.go: return error instead of os.Exit(1) for proper error handling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback (round 2)
- linuxkit.go: propagate state update errors, handle cmd.Wait() errors in waitForExit
- mcp.go: guard against empty old_string in editDiff to prevent runaway edits
- cmd_docblock.go: log parse errors instead of silently skipping
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 10:48:44 +00:00
|
|
|
// RepoTypeFoundation indicates core foundation packages.
|
2026-01-27 21:08:51 +00:00
|
|
|
RepoTypeFoundation RepoType = "foundation"
|
feat: git command, build improvements, and go fmt git-aware (#74)
* feat(go): make go fmt git-aware by default
- By default, only check changed Go files (modified, staged, untracked)
- Add --all flag to check all files (previous behaviour)
- Reduces noise when running fmt on large codebases
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(build): minimal output by default, add missing i18n
- Default output now shows single line: "Success Built N artifacts (dir)"
- Add --verbose/-v flag to show full detailed output
- Add all missing i18n translations for build commands
- Errors still show failure reason in minimal mode
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add root-level `core git` command
- Create pkg/gitcmd with git workflow commands as root menu
- Export command builders from pkg/dev (AddCommitCommand, etc.)
- Commands available under both `core git` and `core dev` for compatibility
- Git commands: health, commit, push, pull, work, sync, apply
- GitHub orchestration stays in dev: issues, reviews, ci, impact
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(qa): add docblock coverage checking
Implement docblock/docstring coverage analysis for Go code:
- New `core qa docblock` command to check coverage
- Shows compact file:line list when under threshold
- Integrate with `core go qa` as a default check
- Add --docblock-threshold flag (default 80%)
The checker uses Go AST parsing to find exported symbols
(functions, types, consts, vars) without documentation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- Fix doc comment: "status" → "health" in gitcmd package
- Implement --check flag for `core go fmt` (exits non-zero if files need formatting)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add docstrings for 100% coverage
Add documentation comments to all exported symbols:
- pkg/build: ProjectType constants
- pkg/cli: LogLevel, RenderStyle, TableStyle
- pkg/framework: ServiceFor, MustServiceFor, Core.Core
- pkg/git: GitError.Error, GitError.Unwrap
- pkg/i18n: Handler Match/Handle methods
- pkg/log: Level constants
- pkg/mcp: Tool input/output types
- pkg/php: Service constants, QA types, service methods
- pkg/process: ServiceError.Error
- pkg/repos: RepoType constants
- pkg/setup: ChangeType, ChangeCategory constants
- pkg/workspace: AddWorkspaceCommands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: standardize line endings to LF
Add .gitattributes to enforce LF line endings for all text files.
Normalize all existing files to use Unix-style line endings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- cmd_format.go: validate --check/--fix mutual exclusivity, capture stderr
- cmd_docblock.go: return error instead of os.Exit(1) for proper error handling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback (round 2)
- linuxkit.go: propagate state update errors, handle cmd.Wait() errors in waitForExit
- mcp.go: guard against empty old_string in editDiff to prevent runaway edits
- cmd_docblock.go: log parse errors instead of silently skipping
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 10:48:44 +00:00
|
|
|
// RepoTypeModule indicates reusable module packages.
|
|
|
|
|
RepoTypeModule RepoType = "module"
|
|
|
|
|
// RepoTypeProduct indicates end-user product applications.
|
|
|
|
|
RepoTypeProduct RepoType = "product"
|
|
|
|
|
// RepoTypeTemplate indicates starter templates.
|
|
|
|
|
RepoTypeTemplate RepoType = "template"
|
2026-01-27 21:08:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Repo represents a single repository in the registry.
|
|
|
|
|
type Repo struct {
|
|
|
|
|
Name string `yaml:"-"` // Set from map key
|
2026-01-28 14:50:55 +00:00
|
|
|
Type string `yaml:"type"`
|
2026-01-27 21:08:51 +00:00
|
|
|
DependsOn []string `yaml:"depends_on"`
|
|
|
|
|
Description string `yaml:"description"`
|
|
|
|
|
Docs bool `yaml:"docs"`
|
|
|
|
|
CI string `yaml:"ci"`
|
|
|
|
|
Domain string `yaml:"domain,omitempty"`
|
2026-01-28 14:50:55 +00:00
|
|
|
Clone *bool `yaml:"clone,omitempty"` // nil = true, false = skip cloning
|
2026-01-27 21:08:51 +00:00
|
|
|
|
|
|
|
|
// Computed fields
|
2026-02-04 18:03:54 +00:00
|
|
|
Path string `yaml:"-"` // Full path to repo directory
|
|
|
|
|
registry *Registry `yaml:"-"`
|
2026-01-27 21:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-04 18:03:54 +00:00
|
|
|
// LoadRegistry reads and parses a repos.yaml file from the given medium.
|
|
|
|
|
// The path should be a valid path for the provided medium.
|
|
|
|
|
func LoadRegistry(m io.Medium, path string) (*Registry, error) {
|
|
|
|
|
content, err := m.Read(path)
|
2026-01-27 21:08:51 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("failed to read registry file: %w", err)
|
|
|
|
|
}
|
docs(audit): add dependency security audit report (#248)
* feat(devops): migrate filesystem operations to io.Local abstraction
Migrate config.go:
- os.ReadFile → io.Local.Read
Migrate devops.go:
- os.Stat → io.Local.IsFile
Migrate images.go:
- os.MkdirAll → io.Local.EnsureDir
- os.Stat → io.Local.IsFile
- os.ReadFile → io.Local.Read
- os.WriteFile → io.Local.Write
Migrate test.go:
- os.ReadFile → io.Local.Read
- os.Stat → io.Local.IsFile
Migrate claude.go:
- os.Stat → io.Local.IsDir
Updated tests to reflect improved behavior:
- Manifest.Save() now creates parent directories
- hasFile() correctly returns false for directories
Part of #101 (io.Medium migration tracking issue).
Closes #107
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore(io): migrate remaining packages to io.Local abstraction
Migrate filesystem operations to use the io.Local abstraction for
improved security, testability, and consistency:
- pkg/cache: Replace os.ReadFile, WriteFile, Remove, RemoveAll with
io.Local equivalents. io.Local.Write creates parent dirs automatically.
- pkg/agentic: Migrate config.go and context.go to use io.Local for
reading config files and gathering file context.
- pkg/repos: Use io.Local.Read, Exists, IsDir, List for registry
operations and git repo detection.
- pkg/release: Use io.Local for config loading, existence checks,
and artifact discovery.
- pkg/devops/sources: Use io.Local.EnsureDir for CDN download.
All paths are converted to absolute using filepath.Abs() before
calling io.Local methods to handle relative paths correctly.
Closes #104, closes #106, closes #108, closes #111
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore(io): migrate pkg/cli and pkg/container to io.Local abstraction
Continue io.Medium migration for the remaining packages:
- pkg/cli/daemon.go: PIDFile Acquire/Release now use io.Local.Read,
Delete, and Write for managing daemon PID files.
- pkg/container/state.go: LoadState and SaveState use io.Local for
JSON state persistence. EnsureLogsDir uses io.Local.EnsureDir.
- pkg/container/templates.go: Template loading and directory scanning
now use io.Local.IsFile, IsDir, Read, and List.
- pkg/container/linuxkit.go: Image validation uses io.Local.IsFile,
log file check uses io.Local.IsFile. Streaming log file creation
(os.Create) remains unchanged as io.Local doesn't support streaming.
Closes #105, closes #107
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs(audit): add dependency security audit report
Complete security audit of all project dependencies:
- Run govulncheck: No vulnerabilities found
- Run go mod verify: All modules verified
- Document 15 direct dependencies and 161 indirect
- Assess supply chain risks: Low risk overall
- Verify lock files are committed with integrity hashes
- Provide CI integration recommendations
Closes #185
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(ci): build core CLI from source instead of downloading release
The workflows were trying to download from a non-existent release URL.
Now builds the CLI directly using `go build` with version injection.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: trigger CI with updated workflow
* chore(ci): add workflow_dispatch trigger for manual runs
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 08:04:26 +00:00
|
|
|
data := []byte(content)
|
2026-01-27 21:08:51 +00:00
|
|
|
|
|
|
|
|
var reg Registry
|
|
|
|
|
if err := yaml.Unmarshal(data, ®); err != nil {
|
|
|
|
|
return nil, fmt.Errorf("failed to parse registry file: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-04 18:03:54 +00:00
|
|
|
reg.medium = m
|
|
|
|
|
|
2026-01-27 21:08:51 +00:00
|
|
|
// Expand base path
|
|
|
|
|
reg.BasePath = expandPath(reg.BasePath)
|
|
|
|
|
|
|
|
|
|
// Set computed fields on each repo
|
|
|
|
|
for name, repo := range reg.Repos {
|
|
|
|
|
repo.Name = name
|
|
|
|
|
repo.Path = filepath.Join(reg.BasePath, name)
|
2026-02-04 18:03:54 +00:00
|
|
|
repo.registry = ®
|
2026-01-27 21:08:51 +00:00
|
|
|
|
|
|
|
|
// Apply defaults if not set
|
|
|
|
|
if repo.CI == "" {
|
|
|
|
|
repo.CI = reg.Defaults.CI
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ®, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FindRegistry searches for repos.yaml in common locations.
|
|
|
|
|
// It checks: current directory, parent directories, and home directory.
|
2026-02-04 18:03:54 +00:00
|
|
|
// This function is primarily intended for use with io.Local or other local-like filesystems.
|
|
|
|
|
func FindRegistry(m io.Medium) (string, error) {
|
2026-01-27 21:08:51 +00:00
|
|
|
// Check current directory and parents
|
|
|
|
|
dir, err := os.Getwd()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
|
candidate := filepath.Join(dir, "repos.yaml")
|
2026-02-04 18:03:54 +00:00
|
|
|
if m.Exists(candidate) {
|
2026-01-27 21:08:51 +00:00
|
|
|
return candidate, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parent := filepath.Dir(dir)
|
|
|
|
|
if parent == dir {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
dir = parent
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check home directory common locations
|
|
|
|
|
home, err := os.UserHomeDir()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commonPaths := []string{
|
|
|
|
|
filepath.Join(home, "Code", "host-uk", "repos.yaml"),
|
|
|
|
|
filepath.Join(home, ".config", "core", "repos.yaml"),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, p := range commonPaths {
|
2026-02-04 18:03:54 +00:00
|
|
|
if m.Exists(p) {
|
2026-01-27 21:08:51 +00:00
|
|
|
return p, nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "", fmt.Errorf("repos.yaml not found")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ScanDirectory creates a Registry by scanning a directory for git repos.
|
|
|
|
|
// This is used as a fallback when no repos.yaml is found.
|
2026-02-04 18:03:54 +00:00
|
|
|
// The dir should be a valid path for the provided medium.
|
|
|
|
|
func ScanDirectory(m io.Medium, dir string) (*Registry, error) {
|
|
|
|
|
entries, err := m.List(dir)
|
2026-01-27 21:08:51 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("failed to read directory: %w", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reg := &Registry{
|
|
|
|
|
Version: 1,
|
2026-02-04 18:03:54 +00:00
|
|
|
BasePath: dir,
|
2026-01-27 21:08:51 +00:00
|
|
|
Repos: make(map[string]*Repo),
|
2026-02-04 18:03:54 +00:00
|
|
|
medium: m,
|
2026-01-27 21:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Try to detect org from git remote
|
|
|
|
|
for _, entry := range entries {
|
|
|
|
|
if !entry.IsDir() {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-04 18:03:54 +00:00
|
|
|
repoPath := filepath.Join(dir, entry.Name())
|
2026-01-27 21:08:51 +00:00
|
|
|
gitPath := filepath.Join(repoPath, ".git")
|
|
|
|
|
|
2026-02-04 18:03:54 +00:00
|
|
|
if !m.IsDir(gitPath) {
|
2026-01-27 21:08:51 +00:00
|
|
|
continue // Not a git repo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
repo := &Repo{
|
2026-02-04 18:03:54 +00:00
|
|
|
Name: entry.Name(),
|
|
|
|
|
Path: repoPath,
|
|
|
|
|
Type: "module", // Default type
|
|
|
|
|
registry: reg,
|
2026-01-27 21:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reg.Repos[entry.Name()] = repo
|
|
|
|
|
|
|
|
|
|
// Try to detect org from first repo's remote
|
|
|
|
|
if reg.Org == "" {
|
2026-02-04 18:03:54 +00:00
|
|
|
reg.Org = detectOrg(m, repoPath)
|
2026-01-27 21:08:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return reg, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// detectOrg tries to extract the GitHub org from a repo's origin remote.
|
2026-02-04 18:03:54 +00:00
|
|
|
func detectOrg(m io.Medium, repoPath string) string {
|
2026-01-27 21:08:51 +00:00
|
|
|
// Try to read git remote
|
docs(audit): add dependency security audit report (#248)
* feat(devops): migrate filesystem operations to io.Local abstraction
Migrate config.go:
- os.ReadFile → io.Local.Read
Migrate devops.go:
- os.Stat → io.Local.IsFile
Migrate images.go:
- os.MkdirAll → io.Local.EnsureDir
- os.Stat → io.Local.IsFile
- os.ReadFile → io.Local.Read
- os.WriteFile → io.Local.Write
Migrate test.go:
- os.ReadFile → io.Local.Read
- os.Stat → io.Local.IsFile
Migrate claude.go:
- os.Stat → io.Local.IsDir
Updated tests to reflect improved behavior:
- Manifest.Save() now creates parent directories
- hasFile() correctly returns false for directories
Part of #101 (io.Medium migration tracking issue).
Closes #107
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore(io): migrate remaining packages to io.Local abstraction
Migrate filesystem operations to use the io.Local abstraction for
improved security, testability, and consistency:
- pkg/cache: Replace os.ReadFile, WriteFile, Remove, RemoveAll with
io.Local equivalents. io.Local.Write creates parent dirs automatically.
- pkg/agentic: Migrate config.go and context.go to use io.Local for
reading config files and gathering file context.
- pkg/repos: Use io.Local.Read, Exists, IsDir, List for registry
operations and git repo detection.
- pkg/release: Use io.Local for config loading, existence checks,
and artifact discovery.
- pkg/devops/sources: Use io.Local.EnsureDir for CDN download.
All paths are converted to absolute using filepath.Abs() before
calling io.Local methods to handle relative paths correctly.
Closes #104, closes #106, closes #108, closes #111
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore(io): migrate pkg/cli and pkg/container to io.Local abstraction
Continue io.Medium migration for the remaining packages:
- pkg/cli/daemon.go: PIDFile Acquire/Release now use io.Local.Read,
Delete, and Write for managing daemon PID files.
- pkg/container/state.go: LoadState and SaveState use io.Local for
JSON state persistence. EnsureLogsDir uses io.Local.EnsureDir.
- pkg/container/templates.go: Template loading and directory scanning
now use io.Local.IsFile, IsDir, Read, and List.
- pkg/container/linuxkit.go: Image validation uses io.Local.IsFile,
log file check uses io.Local.IsFile. Streaming log file creation
(os.Create) remains unchanged as io.Local doesn't support streaming.
Closes #105, closes #107
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs(audit): add dependency security audit report
Complete security audit of all project dependencies:
- Run govulncheck: No vulnerabilities found
- Run go mod verify: All modules verified
- Document 15 direct dependencies and 161 indirect
- Assess supply chain risks: Low risk overall
- Verify lock files are committed with integrity hashes
- Provide CI integration recommendations
Closes #185
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(ci): build core CLI from source instead of downloading release
The workflows were trying to download from a non-existent release URL.
Now builds the CLI directly using `go build` with version injection.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: trigger CI with updated workflow
* chore(ci): add workflow_dispatch trigger for manual runs
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 08:04:26 +00:00
|
|
|
configPath := filepath.Join(repoPath, ".git", "config")
|
2026-02-04 18:03:54 +00:00
|
|
|
content, err := m.Read(configPath)
|
2026-01-27 21:08:51 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
// Look for patterns like github.com:org/repo or github.com/org/repo
|
|
|
|
|
for _, line := range strings.Split(content, "\n") {
|
|
|
|
|
line = strings.TrimSpace(line)
|
|
|
|
|
if !strings.HasPrefix(line, "url = ") {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
url := strings.TrimPrefix(line, "url = ")
|
|
|
|
|
|
|
|
|
|
// git@github.com:org/repo.git
|
|
|
|
|
if strings.Contains(url, "github.com:") {
|
|
|
|
|
parts := strings.Split(url, ":")
|
|
|
|
|
if len(parts) >= 2 {
|
|
|
|
|
orgRepo := strings.TrimSuffix(parts[1], ".git")
|
|
|
|
|
orgParts := strings.Split(orgRepo, "/")
|
|
|
|
|
if len(orgParts) >= 1 {
|
|
|
|
|
return orgParts[0]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://github.com/org/repo.git
|
|
|
|
|
if strings.Contains(url, "github.com/") {
|
|
|
|
|
parts := strings.Split(url, "github.com/")
|
|
|
|
|
if len(parts) >= 2 {
|
|
|
|
|
orgRepo := strings.TrimSuffix(parts[1], ".git")
|
|
|
|
|
orgParts := strings.Split(orgRepo, "/")
|
|
|
|
|
if len(orgParts) >= 1 {
|
|
|
|
|
return orgParts[0]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// List returns all repos in the registry.
|
|
|
|
|
func (r *Registry) List() []*Repo {
|
|
|
|
|
repos := make([]*Repo, 0, len(r.Repos))
|
|
|
|
|
for _, repo := range r.Repos {
|
feat: git command, build improvements, and go fmt git-aware (#74)
* feat(go): make go fmt git-aware by default
- By default, only check changed Go files (modified, staged, untracked)
- Add --all flag to check all files (previous behaviour)
- Reduces noise when running fmt on large codebases
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(build): minimal output by default, add missing i18n
- Default output now shows single line: "Success Built N artifacts (dir)"
- Add --verbose/-v flag to show full detailed output
- Add all missing i18n translations for build commands
- Errors still show failure reason in minimal mode
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add root-level `core git` command
- Create pkg/gitcmd with git workflow commands as root menu
- Export command builders from pkg/dev (AddCommitCommand, etc.)
- Commands available under both `core git` and `core dev` for compatibility
- Git commands: health, commit, push, pull, work, sync, apply
- GitHub orchestration stays in dev: issues, reviews, ci, impact
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(qa): add docblock coverage checking
Implement docblock/docstring coverage analysis for Go code:
- New `core qa docblock` command to check coverage
- Shows compact file:line list when under threshold
- Integrate with `core go qa` as a default check
- Add --docblock-threshold flag (default 80%)
The checker uses Go AST parsing to find exported symbols
(functions, types, consts, vars) without documentation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- Fix doc comment: "status" → "health" in gitcmd package
- Implement --check flag for `core go fmt` (exits non-zero if files need formatting)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add docstrings for 100% coverage
Add documentation comments to all exported symbols:
- pkg/build: ProjectType constants
- pkg/cli: LogLevel, RenderStyle, TableStyle
- pkg/framework: ServiceFor, MustServiceFor, Core.Core
- pkg/git: GitError.Error, GitError.Unwrap
- pkg/i18n: Handler Match/Handle methods
- pkg/log: Level constants
- pkg/mcp: Tool input/output types
- pkg/php: Service constants, QA types, service methods
- pkg/process: ServiceError.Error
- pkg/repos: RepoType constants
- pkg/setup: ChangeType, ChangeCategory constants
- pkg/workspace: AddWorkspaceCommands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: standardize line endings to LF
Add .gitattributes to enforce LF line endings for all text files.
Normalize all existing files to use Unix-style line endings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- cmd_format.go: validate --check/--fix mutual exclusivity, capture stderr
- cmd_docblock.go: return error instead of os.Exit(1) for proper error handling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback (round 2)
- linuxkit.go: propagate state update errors, handle cmd.Wait() errors in waitForExit
- mcp.go: guard against empty old_string in editDiff to prevent runaway edits
- cmd_docblock.go: log parse errors instead of silently skipping
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 10:48:44 +00:00
|
|
|
|
2026-01-27 21:08:51 +00:00
|
|
|
repos = append(repos, repo)
|
|
|
|
|
}
|
|
|
|
|
return repos
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a repo by name.
|
|
|
|
|
func (r *Registry) Get(name string) (*Repo, bool) {
|
|
|
|
|
repo, ok := r.Repos[name]
|
|
|
|
|
return repo, ok
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ByType returns repos filtered by type.
|
2026-01-28 14:50:55 +00:00
|
|
|
func (r *Registry) ByType(t string) []*Repo {
|
2026-01-27 21:08:51 +00:00
|
|
|
var repos []*Repo
|
|
|
|
|
for _, repo := range r.Repos {
|
|
|
|
|
if repo.Type == t {
|
|
|
|
|
repos = append(repos, repo)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return repos
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TopologicalOrder returns repos sorted by dependency order.
|
|
|
|
|
// Foundation repos come first, then modules, then products.
|
|
|
|
|
func (r *Registry) TopologicalOrder() ([]*Repo, error) {
|
|
|
|
|
// Build dependency graph
|
|
|
|
|
visited := make(map[string]bool)
|
|
|
|
|
visiting := make(map[string]bool)
|
|
|
|
|
var result []*Repo
|
|
|
|
|
|
|
|
|
|
var visit func(name string) error
|
|
|
|
|
visit = func(name string) error {
|
|
|
|
|
if visited[name] {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
if visiting[name] {
|
|
|
|
|
return fmt.Errorf("circular dependency detected: %s", name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
repo, ok := r.Repos[name]
|
|
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("unknown repo: %s", name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
visiting[name] = true
|
|
|
|
|
for _, dep := range repo.DependsOn {
|
|
|
|
|
if err := visit(dep); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
visiting[name] = false
|
|
|
|
|
visited[name] = true
|
|
|
|
|
result = append(result, repo)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for name := range r.Repos {
|
|
|
|
|
if err := visit(name); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Exists checks if the repo directory exists on disk.
|
|
|
|
|
func (repo *Repo) Exists() bool {
|
2026-02-04 18:03:54 +00:00
|
|
|
return repo.getMedium().IsDir(repo.Path)
|
2026-01-27 21:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsGitRepo checks if the repo directory contains a .git folder.
|
|
|
|
|
func (repo *Repo) IsGitRepo() bool {
|
|
|
|
|
gitPath := filepath.Join(repo.Path, ".git")
|
2026-02-04 18:03:54 +00:00
|
|
|
return repo.getMedium().IsDir(gitPath)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (repo *Repo) getMedium() io.Medium {
|
|
|
|
|
if repo.registry != nil && repo.registry.medium != nil {
|
|
|
|
|
return repo.registry.medium
|
|
|
|
|
}
|
|
|
|
|
return io.Local
|
2026-01-27 21:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// expandPath expands ~ to home directory.
|
|
|
|
|
func expandPath(path string) string {
|
|
|
|
|
if strings.HasPrefix(path, "~/") {
|
|
|
|
|
home, err := os.UserHomeDir()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return path
|
|
|
|
|
}
|
|
|
|
|
return filepath.Join(home, path[2:])
|
|
|
|
|
}
|
|
|
|
|
return path
|
feat: git command, build improvements, and go fmt git-aware (#74)
* feat(go): make go fmt git-aware by default
- By default, only check changed Go files (modified, staged, untracked)
- Add --all flag to check all files (previous behaviour)
- Reduces noise when running fmt on large codebases
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(build): minimal output by default, add missing i18n
- Default output now shows single line: "Success Built N artifacts (dir)"
- Add --verbose/-v flag to show full detailed output
- Add all missing i18n translations for build commands
- Errors still show failure reason in minimal mode
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add root-level `core git` command
- Create pkg/gitcmd with git workflow commands as root menu
- Export command builders from pkg/dev (AddCommitCommand, etc.)
- Commands available under both `core git` and `core dev` for compatibility
- Git commands: health, commit, push, pull, work, sync, apply
- GitHub orchestration stays in dev: issues, reviews, ci, impact
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(qa): add docblock coverage checking
Implement docblock/docstring coverage analysis for Go code:
- New `core qa docblock` command to check coverage
- Shows compact file:line list when under threshold
- Integrate with `core go qa` as a default check
- Add --docblock-threshold flag (default 80%)
The checker uses Go AST parsing to find exported symbols
(functions, types, consts, vars) without documentation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- Fix doc comment: "status" → "health" in gitcmd package
- Implement --check flag for `core go fmt` (exits non-zero if files need formatting)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add docstrings for 100% coverage
Add documentation comments to all exported symbols:
- pkg/build: ProjectType constants
- pkg/cli: LogLevel, RenderStyle, TableStyle
- pkg/framework: ServiceFor, MustServiceFor, Core.Core
- pkg/git: GitError.Error, GitError.Unwrap
- pkg/i18n: Handler Match/Handle methods
- pkg/log: Level constants
- pkg/mcp: Tool input/output types
- pkg/php: Service constants, QA types, service methods
- pkg/process: ServiceError.Error
- pkg/repos: RepoType constants
- pkg/setup: ChangeType, ChangeCategory constants
- pkg/workspace: AddWorkspaceCommands
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: standardize line endings to LF
Add .gitattributes to enforce LF line endings for all text files.
Normalize all existing files to use Unix-style line endings.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback
- cmd_format.go: validate --check/--fix mutual exclusivity, capture stderr
- cmd_docblock.go: return error instead of os.Exit(1) for proper error handling
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: address CodeRabbit review feedback (round 2)
- linuxkit.go: propagate state update errors, handle cmd.Wait() errors in waitForExit
- mcp.go: guard against empty old_string in editDiff to prevent runaway edits
- cmd_docblock.go: log parse errors instead of silently skipping
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 10:48:44 +00:00
|
|
|
}
|