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>
106 lines
2.4 KiB
Go
106 lines
2.4 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestLastTouchedBasic(t *testing.T) {
|
|
// Create a temp directory to simulate .beads
|
|
tmpDir := t.TempDir()
|
|
beadsDir := filepath.Join(tmpDir, ".beads")
|
|
if err := os.MkdirAll(beadsDir, 0755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Create a marker file so FindBeadsDir recognizes this as a valid beads directory
|
|
if err := os.WriteFile(filepath.Join(beadsDir, "config.yaml"), []byte{}, 0644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Save the original working directory
|
|
origDir, err := os.Getwd()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer func() {
|
|
_ = os.Chdir(origDir)
|
|
}()
|
|
|
|
// Change to temp directory so FindBeadsDir finds our .beads
|
|
if err := os.Chdir(tmpDir); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Test that no last touched returns empty
|
|
got := GetLastTouchedID()
|
|
if got != "" {
|
|
t.Errorf("GetLastTouchedID() = %q, want empty", got)
|
|
}
|
|
|
|
// Set and retrieve
|
|
testID := "bd-test123"
|
|
SetLastTouchedID(testID)
|
|
got = GetLastTouchedID()
|
|
if got != testID {
|
|
t.Errorf("GetLastTouchedID() = %q, want %q", got, testID)
|
|
}
|
|
|
|
// Update with new ID
|
|
testID2 := "bd-test456"
|
|
SetLastTouchedID(testID2)
|
|
got = GetLastTouchedID()
|
|
if got != testID2 {
|
|
t.Errorf("GetLastTouchedID() = %q, want %q", got, testID2)
|
|
}
|
|
|
|
// Clear and verify
|
|
ClearLastTouched()
|
|
got = GetLastTouchedID()
|
|
if got != "" {
|
|
t.Errorf("After ClearLastTouched(), GetLastTouchedID() = %q, want empty", got)
|
|
}
|
|
}
|
|
|
|
func TestSetLastTouchedIDIgnoresEmpty(t *testing.T) {
|
|
// Create a temp directory
|
|
tmpDir := t.TempDir()
|
|
beadsDir := filepath.Join(tmpDir, ".beads")
|
|
if err := os.MkdirAll(beadsDir, 0755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Create a marker file so FindBeadsDir recognizes this as a valid beads directory
|
|
if err := os.WriteFile(filepath.Join(beadsDir, "config.yaml"), []byte{}, 0644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Save the original working directory
|
|
origDir, err := os.Getwd()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer func() {
|
|
_ = os.Chdir(origDir)
|
|
}()
|
|
|
|
// Change to temp directory
|
|
if err := os.Chdir(tmpDir); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// First set a value
|
|
testID := "bd-original"
|
|
SetLastTouchedID(testID)
|
|
|
|
// Try to set empty - should be ignored
|
|
SetLastTouchedID("")
|
|
|
|
// Should still have original value
|
|
got := GetLastTouchedID()
|
|
if got != testID {
|
|
t.Errorf("After SetLastTouchedID(\"\"), GetLastTouchedID() = %q, want %q", got, testID)
|
|
}
|
|
}
|