feat: infrastructure packages and lint cleanup (#281)
* ci: consolidate duplicate workflows and merge CodeQL configs
Remove 17 duplicate workflow files that were split copies of the
combined originals. Each family (CI, CodeQL, Coverage, PR Build,
Alpha Release) had the same job duplicated across separate
push/pull_request/schedule/manual trigger files.
Merge codeql.yml and codescan.yml into a single codeql.yml with
a language matrix covering go, javascript-typescript, python,
and actions — matching the previous default setup coverage.
Remaining workflows (one per family):
- ci.yml (push + PR + manual)
- codeql.yml (push + PR + schedule, all languages)
- coverage.yml (push + PR + manual)
- alpha-release.yml (push + manual)
- pr-build.yml (PR + manual)
- release.yml (tag push)
- agent-verify.yml, auto-label.yml, auto-project.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add collect, config, crypt, plugin packages and fix all lint issues
Add four new infrastructure packages with CLI commands:
- pkg/config: layered configuration (defaults → file → env → flags)
- pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums)
- pkg/plugin: plugin system with GitHub-based install/update/remove
- pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate)
Fix all golangci-lint issues across the entire codebase (~100 errcheck,
staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that
`core go qa` passes with 0 issues.
Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
|
|
|
package collect
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
2026-02-16 14:22:18 +00:00
|
|
|
"forge.lthn.ai/core/go/pkg/cli"
|
|
|
|
|
"forge.lthn.ai/core/go/pkg/collect"
|
|
|
|
|
"forge.lthn.ai/core/go/pkg/i18n"
|
|
|
|
|
"forge.lthn.ai/core/go/pkg/io"
|
feat: infrastructure packages and lint cleanup (#281)
* ci: consolidate duplicate workflows and merge CodeQL configs
Remove 17 duplicate workflow files that were split copies of the
combined originals. Each family (CI, CodeQL, Coverage, PR Build,
Alpha Release) had the same job duplicated across separate
push/pull_request/schedule/manual trigger files.
Merge codeql.yml and codescan.yml into a single codeql.yml with
a language matrix covering go, javascript-typescript, python,
and actions — matching the previous default setup coverage.
Remaining workflows (one per family):
- ci.yml (push + PR + manual)
- codeql.yml (push + PR + schedule, all languages)
- coverage.yml (push + PR + manual)
- alpha-release.yml (push + manual)
- pr-build.yml (PR + manual)
- release.yml (tag push)
- agent-verify.yml, auto-label.yml, auto-project.yml
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add collect, config, crypt, plugin packages and fix all lint issues
Add four new infrastructure packages with CLI commands:
- pkg/config: layered configuration (defaults → file → env → flags)
- pkg/crypt: crypto primitives (Argon2id, AES-GCM, ChaCha20, HMAC, checksums)
- pkg/plugin: plugin system with GitHub-based install/update/remove
- pkg/collect: collection subsystem (GitHub, BitcoinTalk, market, papers, excavate)
Fix all golangci-lint issues across the entire codebase (~100 errcheck,
staticcheck SA1012/SA1019/ST1005, unused, ineffassign fixes) so that
`core go qa` passes with 0 issues.
Closes #167, #168, #170, #250, #251, #252, #253, #254, #255, #256
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:34:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
cli.RegisterCommands(AddCollectCommands)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Style aliases from shared package
|
|
|
|
|
var (
|
|
|
|
|
dimStyle = cli.DimStyle
|
|
|
|
|
successStyle = cli.SuccessStyle
|
|
|
|
|
errorStyle = cli.ErrorStyle
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Shared flags across all collect subcommands
|
|
|
|
|
var (
|
|
|
|
|
collectOutputDir string
|
|
|
|
|
collectVerbose bool
|
|
|
|
|
collectDryRun bool
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// AddCollectCommands registers the 'collect' command and all subcommands.
|
|
|
|
|
func AddCollectCommands(root *cli.Command) {
|
|
|
|
|
collectCmd := &cli.Command{
|
|
|
|
|
Use: "collect",
|
|
|
|
|
Short: i18n.T("cmd.collect.short"),
|
|
|
|
|
Long: i18n.T("cmd.collect.long"),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Persistent flags shared across subcommands
|
|
|
|
|
cli.PersistentStringFlag(collectCmd, &collectOutputDir, "output", "o", "./collect", i18n.T("cmd.collect.flag.output"))
|
|
|
|
|
cli.PersistentBoolFlag(collectCmd, &collectVerbose, "verbose", "v", false, i18n.T("common.flag.verbose"))
|
|
|
|
|
cli.PersistentBoolFlag(collectCmd, &collectDryRun, "dry-run", "", false, i18n.T("cmd.collect.flag.dry_run"))
|
|
|
|
|
|
|
|
|
|
root.AddCommand(collectCmd)
|
|
|
|
|
|
|
|
|
|
addGitHubCommand(collectCmd)
|
|
|
|
|
addBitcoinTalkCommand(collectCmd)
|
|
|
|
|
addMarketCommand(collectCmd)
|
|
|
|
|
addPapersCommand(collectCmd)
|
|
|
|
|
addExcavateCommand(collectCmd)
|
|
|
|
|
addProcessCommand(collectCmd)
|
|
|
|
|
addDispatchCommand(collectCmd)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// newConfig creates a collection Config using the shared persistent flags.
|
|
|
|
|
// It uses io.Local for real filesystem access rather than the mock medium.
|
|
|
|
|
func newConfig() *collect.Config {
|
|
|
|
|
cfg := collect.NewConfigWithMedium(io.Local, collectOutputDir)
|
|
|
|
|
cfg.Verbose = collectVerbose
|
|
|
|
|
cfg.DryRun = collectDryRun
|
|
|
|
|
return cfg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setupVerboseLogging registers event handlers on the dispatcher for verbose output.
|
|
|
|
|
func setupVerboseLogging(cfg *collect.Config) {
|
|
|
|
|
if !cfg.Verbose {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cfg.Dispatcher.On(collect.EventStart, func(e collect.Event) {
|
|
|
|
|
cli.Print("%s %s\n", dimStyle.Render("[start]"), e.Message)
|
|
|
|
|
})
|
|
|
|
|
cfg.Dispatcher.On(collect.EventProgress, func(e collect.Event) {
|
|
|
|
|
cli.Print("%s %s\n", dimStyle.Render("[progress]"), e.Message)
|
|
|
|
|
})
|
|
|
|
|
cfg.Dispatcher.On(collect.EventItem, func(e collect.Event) {
|
|
|
|
|
cli.Print("%s %s\n", dimStyle.Render("[item]"), e.Message)
|
|
|
|
|
})
|
|
|
|
|
cfg.Dispatcher.On(collect.EventError, func(e collect.Event) {
|
|
|
|
|
cli.Print("%s %s\n", errorStyle.Render("[error]"), e.Message)
|
|
|
|
|
})
|
|
|
|
|
cfg.Dispatcher.On(collect.EventComplete, func(e collect.Event) {
|
|
|
|
|
cli.Print("%s %s\n", successStyle.Render("[complete]"), e.Message)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// printResult prints a formatted summary of a collection result.
|
|
|
|
|
func printResult(result *collect.Result) {
|
|
|
|
|
if result == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if result.Items > 0 {
|
|
|
|
|
cli.Success(fmt.Sprintf("Collected %d items from %s", result.Items, result.Source))
|
|
|
|
|
} else {
|
|
|
|
|
cli.Dim(fmt.Sprintf("No items collected from %s", result.Source))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if result.Skipped > 0 {
|
|
|
|
|
cli.Dim(fmt.Sprintf(" Skipped: %d", result.Skipped))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if result.Errors > 0 {
|
|
|
|
|
cli.Warn(fmt.Sprintf(" Errors: %d", result.Errors))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if collectVerbose && len(result.Files) > 0 {
|
|
|
|
|
cli.Dim(fmt.Sprintf(" Files: %d", len(result.Files)))
|
|
|
|
|
for _, f := range result.Files {
|
|
|
|
|
cli.Print(" %s\n", dimStyle.Render(f))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|