Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ AI Efficiency Platform (`ai-efficiency`) is a standalone system for measuring an
- The backend is the central orchestration point for auth, repo management, analysis, attribution, deployment control, and webhook handling.
- The frontend is built separately and embedded into the backend binary for deployment.
- The formal CLI workflow is now sessionless: `ae-cli init`, `ae-cli sync`, and `ae-cli doctor`.
- Legacy `ae-cli start/stop/run/...` commands remain only as hidden compatibility shims that return migration guidance.
- Legacy `ae-cli start/stop/run/...` session commands and local-proxy runtime are retired.
- Production deployment currently supports Docker Compose and Linux systemd.

## Repository Layout
Expand Down
2 changes: 1 addition & 1 deletion ae-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ae-cli sync
ae-cli doctor
```

Legacy `ae-cli start/stop/run/...` session commands are retired from the formal workflow and kept only as hidden compatibility shims with migration guidance.
Legacy `ae-cli start/stop/run/...` session commands are retired. Use the sessionless workflow only.

## Windows

Expand Down
16 changes: 0 additions & 16 deletions ae-cli/cmd/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package cmd
import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/spf13/cobra"
)
Expand All @@ -30,7 +28,6 @@ var doctorCmd = &cobra.Command{
fmt.Fprintf(out, " Git Common: %s\n", ctx.gitCommonDir)
fmt.Fprintf(out, " State Dir: %s\n", ctx.attributionRoot)
fmt.Fprintf(out, " Logged In: %t\n", token != "")
fmt.Fprintf(out, " Hooks Ready: %t\n", hooksInstalled(ctx.gitCommonDir))
if _, err := os.Stat(ctx.attributionRoot); err == nil {
fmt.Fprintf(out, " State Exists: true\n")
} else if os.IsNotExist(err) {
Expand All @@ -42,19 +39,6 @@ var doctorCmd = &cobra.Command{
},
}

func hooksInstalled(gitCommonDir string) bool {
postCommit, err := os.ReadFile(filepath.Join(gitCommonDir, "hooks", "post-commit"))
if err != nil {
return false
}
postRewrite, err := os.ReadFile(filepath.Join(gitCommonDir, "hooks", "post-rewrite"))
if err != nil {
return false
}
return strings.Contains(string(postCommit), "ae-cli hook post-commit") &&
strings.Contains(string(postRewrite), "ae-cli hook post-rewrite")
}

func init() {
rootCmd.AddCommand(doctorCmd)
}
7 changes: 6 additions & 1 deletion ae-cli/cmd/flush.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package cmd

import "github.com/spf13/cobra"
import (
"os"

"github.com/spf13/cobra"
)

var flushCmd = &cobra.Command{
Use: "flush",
Short: "Legacy session workflow entrypoint (retired)",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
_ = os.Getenv("HOME")
return legacyWorkflowRetiredError()
},
}
Expand Down
32 changes: 29 additions & 3 deletions ae-cli/cmd/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@ package cmd

import (
"os"
"os/exec"
"path/filepath"
"strings"
"testing"

"github.com/ai-efficiency/ae-cli/internal/hooks"
"github.com/ai-efficiency/ae-cli/internal/session"
)

func runGitOutput(t *testing.T, dir string, args ...string) string {
t.Helper()
cmd := exec.Command("git", args...)
cmd.Dir = dir
var stderr strings.Builder
cmd.Stderr = &stderr
out, err := cmd.Output()
if err != nil {
t.Fatalf("git %s failed: %v stderr=%s", strings.Join(args, " "), err, stderr.String())
}
return strings.TrimSpace(string(out))
}

func TestHookCommandHasPostRewriteSubcommand(t *testing.T) {
var found bool
for _, c := range hookCmd.Commands() {
Expand All @@ -29,7 +45,13 @@ func TestHookPostCommitCommandQueuesWhenUploaderUnsupported(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)

marker := &session.Marker{SessionID: "sess-1", RepoFullName: "github.com/acme/repo"}
gitDir := runGitOutput(t, repo, "rev-parse", "--absolute-git-dir")
gitCommonDir := runGitOutput(t, repo, "rev-parse", "--git-common-dir")
workspaceID, err := session.DeriveWorkspaceID(repo, repo, gitDir, filepath.Join(repo, gitCommonDir))
if err != nil {
t.Fatalf("DeriveWorkspaceID: %v", err)
}
marker := &session.Marker{SessionID: "sess-1", WorkspaceID: workspaceID, RepoFullName: "github.com/acme/repo"}
if err := session.WriteMarker(repo, marker); err != nil {
t.Fatalf("WriteMarker: %v", err)
}
Expand All @@ -47,9 +69,13 @@ func TestHookPostCommitCommandQueuesWhenUploaderUnsupported(t *testing.T) {
t.Fatalf("hook post-commit RunE: %v", err)
}

q, err := hooks.NewLocalQueue("sess-1")
m, err := session.ReadMarker(repo)
if err != nil {
t.Fatalf("ReadMarker: %v", err)
}
q, err := hooks.NewWorkspaceQueue(m.WorkspaceID)
if err != nil {
t.Fatalf("NewLocalQueue: %v", err)
t.Fatalf("NewWorkspaceQueue: %v", err)
}
items, err := q.List()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions ae-cli/cmd/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var killCmd = &cobra.Command{
Use: "kill <pane-id>",
Short: "Legacy session workflow entrypoint (retired)",
Hidden: true,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return legacyWorkflowRetiredError()
},
Expand Down
1 change: 1 addition & 0 deletions ae-cli/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var runCmd = &cobra.Command{
Use: "run <tool> [args...]",
Short: "Legacy session workflow entrypoint (retired)",
Hidden: true,
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return legacyWorkflowRetiredError()
},
Expand Down
1 change: 1 addition & 0 deletions ae-cli/cmd/test_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func initRepoWithCommitForCmdTests(t *testing.T) string {
runGit(t, dir, "init")
runGit(t, dir, "config", "user.email", "t@example.com")
runGit(t, dir, "config", "user.name", "t")
runGit(t, dir, "remote", "add", "origin", "https://github.com/acme/repo.git")
if err := os.WriteFile(dir+"/a.txt", []byte("a\n"), 0o644); err != nil {
t.Fatalf("write file: %v", err)
}
Expand Down
25 changes: 25 additions & 0 deletions ae-cli/internal/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"time"

"github.com/ai-efficiency/ae-cli/internal/attributionlocal"
"github.com/ai-efficiency/ae-cli/internal/session"
)

Expand Down Expand Up @@ -107,6 +108,30 @@ func WriteCache(sessionID string, snapshot *Snapshot) error {
return nil
}

func WriteWorkspaceCache(workspaceID string, snapshot *Snapshot) error {
workspaceID = strings.TrimSpace(workspaceID)
if workspaceID == "" {
return fmt.Errorf("workspace_id is required")
}
if snapshot == nil {
return fmt.Errorf("snapshot is nil")
}

dir := filepath.Join(attributionlocal.AttributionRootDir(), "workspaces", workspaceID, "collectors")
if err := os.MkdirAll(dir, 0o700); err != nil {
return fmt.Errorf("create workspace collectors dir: %w", err)
}

data, err := json.MarshalIndent(snapshot, "", " ")
if err != nil {
return fmt.Errorf("marshal snapshot: %w", err)
}
if err := os.WriteFile(filepath.Join(dir, "latest.json"), data, 0o600); err != nil {
return fmt.Errorf("write workspace snapshot cache: %w", err)
}
return nil
}

func DefaultPaths(workspaceRoot string) Paths {
out := Paths{
WorkspaceRoot: workspaceRoot,
Expand Down
Loading