Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
138 lines
3.6 KiB
Go
138 lines
3.6 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/steveyegge/beads/cmd/bd/doctor"
|
|
"github.com/steveyegge/beads/cmd/bd/doctor/fix"
|
|
"github.com/steveyegge/beads/internal/ui"
|
|
)
|
|
|
|
// runArtifactsCheck runs detailed classic artifact detection.
|
|
// With --clean, removes safe-to-delete artifacts after confirmation.
|
|
func runArtifactsCheck(path string, clean bool, yes bool) {
|
|
report, err := doctor.ScanForArtifacts(path)
|
|
if err != nil {
|
|
FatalError("scanning artifacts: %v", err)
|
|
}
|
|
|
|
if report.TotalCount == 0 {
|
|
if !jsonOutput {
|
|
fmt.Println("No classic artifacts detected.")
|
|
} else {
|
|
outputJSON(map[string]interface{}{
|
|
"total_count": 0,
|
|
})
|
|
}
|
|
return
|
|
}
|
|
|
|
if jsonOutput {
|
|
// GH#2438: When --clean is also set, perform cleanup before outputting
|
|
// JSON. Previously, --json returned early and skipped the clean logic,
|
|
// so `bd doctor --check=artifacts --clean --json` would report findings
|
|
// but never delete them.
|
|
if clean && report.SafeDeleteCount > 0 {
|
|
if err := fix.ClassicArtifacts(path); err != nil {
|
|
FatalError("during cleanup: %v", err)
|
|
}
|
|
// Re-scan to show post-cleanup state
|
|
report, err = doctor.ScanForArtifacts(path)
|
|
if err != nil {
|
|
FatalError("re-scanning artifacts: %v", err)
|
|
}
|
|
}
|
|
|
|
result := map[string]interface{}{
|
|
"total_count": report.TotalCount,
|
|
"safe_delete_count": report.SafeDeleteCount,
|
|
"sqlite_artifacts": len(report.SQLiteArtifacts),
|
|
"cruft_beads_dirs": len(report.CruftBeadsDirs),
|
|
"redirect_issues": len(report.RedirectIssues),
|
|
}
|
|
|
|
var findings []map[string]interface{}
|
|
for _, lists := range [][]doctor.ArtifactFinding{
|
|
report.SQLiteArtifacts,
|
|
report.CruftBeadsDirs, report.RedirectIssues,
|
|
} {
|
|
for _, f := range lists {
|
|
findings = append(findings, map[string]interface{}{
|
|
"path": f.Path,
|
|
"type": f.Type,
|
|
"description": f.Description,
|
|
"safe_delete": f.SafeDelete,
|
|
})
|
|
}
|
|
}
|
|
result["findings"] = findings
|
|
outputJSON(result)
|
|
return
|
|
}
|
|
|
|
// Human-readable output
|
|
fmt.Printf("Found %d classic artifact(s) (%d safe to delete):\n\n", report.TotalCount, report.SafeDeleteCount)
|
|
|
|
if len(report.SQLiteArtifacts) > 0 {
|
|
fmt.Printf("SQLite Artifacts (%d):\n", len(report.SQLiteArtifacts))
|
|
for _, f := range report.SQLiteArtifacts {
|
|
safeTag := ""
|
|
if f.SafeDelete {
|
|
safeTag = " [safe]"
|
|
}
|
|
fmt.Printf(" %s%s\n", f.Path, safeTag)
|
|
fmt.Printf(" %s\n", ui.RenderMuted(f.Description))
|
|
}
|
|
fmt.Println()
|
|
}
|
|
|
|
if len(report.CruftBeadsDirs) > 0 {
|
|
fmt.Printf("Cruft .beads Directories (%d):\n", len(report.CruftBeadsDirs))
|
|
for _, f := range report.CruftBeadsDirs {
|
|
safeTag := ""
|
|
if f.SafeDelete {
|
|
safeTag = " [safe]"
|
|
}
|
|
fmt.Printf(" %s%s\n", f.Path, safeTag)
|
|
fmt.Printf(" %s\n", ui.RenderMuted(f.Description))
|
|
}
|
|
fmt.Println()
|
|
}
|
|
|
|
if len(report.RedirectIssues) > 0 {
|
|
fmt.Printf("Redirect Issues (%d):\n", len(report.RedirectIssues))
|
|
for _, f := range report.RedirectIssues {
|
|
fmt.Printf(" %s\n", f.Path)
|
|
fmt.Printf(" %s\n", ui.RenderMuted(f.Description))
|
|
}
|
|
fmt.Println()
|
|
}
|
|
|
|
if !clean {
|
|
fmt.Println("Run 'bd doctor --check=artifacts --clean' to remove safe-to-delete artifacts.")
|
|
return
|
|
}
|
|
|
|
if report.SafeDeleteCount == 0 {
|
|
fmt.Println("No artifacts are safe to auto-delete. Manual review required.")
|
|
return
|
|
}
|
|
|
|
// Confirmation prompt
|
|
if !yes {
|
|
fmt.Printf("Delete %d safe-to-delete artifact(s)? [y/N] ", report.SafeDeleteCount)
|
|
var response string
|
|
_, _ = fmt.Scanln(&response)
|
|
if strings.ToLower(response) != "y" {
|
|
fmt.Println("Canceled.")
|
|
return
|
|
}
|
|
}
|
|
|
|
// Perform cleanup
|
|
if err := fix.ClassicArtifacts(path); err != nil {
|
|
FatalError("during cleanup: %v", err)
|
|
}
|
|
}
|