gitgram/aitimemachine/beads/cmd/bd/store_factory_nocgo.go
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
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>
2026-06-23 14:14:09 +03:00

104 lines
3.4 KiB
Go

//go:build !cgo
package main
import (
"context"
"fmt"
"github.com/steveyegge/beads/internal/configfile"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/dbproxy/util"
"github.com/steveyegge/beads/internal/storage/dolt"
)
func usesSQLServer() bool {
return true
}
// isEmbeddedMode reports whether the command is using embedded Dolt storage.
func isEmbeddedMode() bool {
return false
}
func usesProxiedServer() bool {
if shouldUseGlobals() {
return proxiedServerMode
}
return cmdCtx != nil && cmdCtx.ProxiedServerMode
}
func newDoltStore(ctx context.Context, cfg *dolt.Config) (storage.DoltStorage, error) {
if cfg.ProxiedServer {
// TODO: this should not be a store
// it should be a uow provider
return nil, fmt.Errorf("proxy server store should be uow provider")
}
if !cfg.ServerMode {
return nil, fmt.Errorf("%s", nocgoEmbeddedErrMsg)
}
return dolt.New(ctx, cfg)
}
// acquireEmbeddedLock returns a no-op lock in non-CGO builds.
func acquireEmbeddedLock(_ string, _ bool) (util.Unlocker, error) {
return util.NoopLock{}, nil
}
// newDoltStoreFromConfig creates a SQL-server-backed storage backend from config.
func newDoltStoreFromConfig(ctx context.Context, beadsDir string) (storage.DoltStorage, error) {
cfg, err := configfile.Load(beadsDir)
if err == nil && cfg != nil && cfg.IsDoltProxiedServerMode() {
// TODO: this needs to be uow provider
return nil, fmt.Errorf("proxy server store should be uow provider")
// return newProxiedServerStore(ctx, &dolt.Config{
// BeadsDir: beadsDir,
// Database: cfg.GetDoltDatabase(),
// ProxiedServer: true,
// })
}
if err == nil && cfg != nil && cfg.IsDoltServerMode() {
return dolt.NewFromConfig(ctx, beadsDir)
}
return nil, fmt.Errorf("%s", nocgoEmbeddedErrMsg)
}
// newReadOnlyStoreFromConfig creates a read-only SQL-server-backed storage backend.
func newReadOnlyStoreFromConfig(ctx context.Context, beadsDir string) (storage.DoltStorage, error) {
cfg, err := configfile.Load(beadsDir)
if err == nil && cfg != nil && cfg.IsDoltProxiedServerMode() {
// TODO: this needs to be uow provider
return nil, fmt.Errorf("proxy server store needs to be uow provider")
// return newProxiedServerStore(ctx, &dolt.Config{
// BeadsDir: beadsDir,
// Database: cfg.GetDoltDatabase(),
// ProxiedServer: true,
// ReadOnly: true,
// })
}
if err == nil && cfg != nil && cfg.IsDoltServerMode() {
return dolt.NewFromConfigWithOptions(ctx, beadsDir, &dolt.Config{ReadOnly: true})
}
return nil, fmt.Errorf("%s", nocgoEmbeddedErrMsg)
}
const nocgoEmbeddedErrMsg = `embedded Dolt requires a CGO build, but this bd binary was built with CGO_ENABLED=0.
Three options:
1. Use the proxied dolt sql-server (no external server, no reinstall):
bd init --proxied-server
bd spawns a per-workspace proxy + child dolt sql-server under
.beads/proxieddb/ and manages their lifecycle for you.
2. Use external server mode (no reinstall needed):
bd init --server
Requires a running 'dolt sql-server'. See docs/DOLT.md.
3. Reinstall with embedded-mode support:
brew install beads # macOS / Linux
npm install -g @beads/bd # any platform with Node
curl -fsSL https://raw.githubusercontent.com/steveyegge/beads/main/scripts/install.sh | bash
See docs/INSTALLING.md for the full comparison.`