fix(ax): unify home-path resolution
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
6bc0eb7e46
commit
c077819c0d
5 changed files with 20 additions and 25 deletions
|
|
@ -8,10 +8,6 @@ import (
|
|||
core "dappco.re/go/core"
|
||||
)
|
||||
|
||||
func agentHomeDir() string {
|
||||
return HomeDir()
|
||||
}
|
||||
|
||||
// ingestFindings reads the agent output log and creates issues via the API
|
||||
// for scan/audit results. Only runs for conventions and security templates.
|
||||
func (s *PrepSubsystem) ingestFindings(wsDir string) {
|
||||
|
|
@ -93,7 +89,7 @@ func (s *PrepSubsystem) createIssueViaAPI(repo, title, description, issueType, p
|
|||
}
|
||||
|
||||
// Read the agent API key from file
|
||||
r := fs.Read(core.JoinPath(agentHomeDir(), ".claude", "agent-api.key"))
|
||||
r := fs.Read(core.JoinPath(HomeDir(), ".claude", "agent-api.key"))
|
||||
if !r.OK {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func NewDirect() *DirectSubsystem {
|
|||
apiKey := core.Env("CORE_BRAIN_KEY")
|
||||
keyPath := ""
|
||||
if apiKey == "" {
|
||||
keyPath = brainKeyPath(brainHomeDir())
|
||||
keyPath = brainKeyPath(agentic.HomeDir())
|
||||
if keyPath != "" {
|
||||
if r := fs.Read(keyPath); r.OK {
|
||||
apiKey = core.Trim(r.Value.(string))
|
||||
|
|
@ -97,13 +97,6 @@ func brainKeyPath(home string) string {
|
|||
return core.JoinPath(core.TrimSuffix(home, "/"), ".claude", "brain.key")
|
||||
}
|
||||
|
||||
func brainHomeDir() string {
|
||||
if home := core.Env("CORE_HOME"); home != "" {
|
||||
return home
|
||||
}
|
||||
return core.Env("DIR_HOME")
|
||||
}
|
||||
|
||||
func (s *DirectSubsystem) apiCall(ctx context.Context, method, path string, body any) core.Result {
|
||||
if s.apiKey == "" {
|
||||
return core.Result{
|
||||
|
|
|
|||
|
|
@ -68,6 +68,22 @@ func TestDirect_NewDirect_Good_KeyFromFile(t *testing.T) {
|
|||
assert.Equal(t, "file-key-456", sub.apiKey)
|
||||
}
|
||||
|
||||
func TestDirect_NewDirect_Good_HomeFallback(t *testing.T) {
|
||||
t.Setenv("CORE_BRAIN_URL", "")
|
||||
t.Setenv("CORE_BRAIN_KEY", "")
|
||||
t.Setenv("CORE_HOME", "")
|
||||
t.Setenv("DIR_HOME", "")
|
||||
|
||||
tmpHome := t.TempDir()
|
||||
t.Setenv("HOME", tmpHome)
|
||||
keyDir := core.JoinPath(tmpHome, ".claude")
|
||||
require.True(t, fs.EnsureDir(keyDir).OK)
|
||||
require.True(t, fs.Write(core.JoinPath(keyDir, "brain.key"), " home-key-789 \n").OK)
|
||||
|
||||
sub := NewDirect()
|
||||
assert.Equal(t, "home-key-789", sub.apiKey)
|
||||
}
|
||||
|
||||
func TestDirect_Subsystem_Good_Name(t *testing.T) {
|
||||
sub := &DirectSubsystem{}
|
||||
assert.Equal(t, "brain", sub.Name())
|
||||
|
|
|
|||
|
|
@ -33,16 +33,6 @@ func brainKeyPath(home string) string {
|
|||
return core.JoinPath(home, ".claude", "brain.key")
|
||||
}
|
||||
|
||||
func monitorHomeDir() string {
|
||||
if d := core.Env("CORE_HOME"); d != "" {
|
||||
return d
|
||||
}
|
||||
if d := core.Env("HOME"); d != "" {
|
||||
return d
|
||||
}
|
||||
return core.Env("DIR_HOME")
|
||||
}
|
||||
|
||||
func monitorAPIURL() string {
|
||||
if u := core.Env("CORE_API_URL"); u != "" {
|
||||
return u
|
||||
|
|
@ -54,7 +44,7 @@ func monitorBrainKey() string {
|
|||
if k := core.Env("CORE_BRAIN_KEY"); k != "" {
|
||||
return k
|
||||
}
|
||||
if r := fs.Read(brainKeyPath(monitorHomeDir())); r.OK {
|
||||
if r := fs.Read(brainKeyPath(agentic.HomeDir())); r.OK {
|
||||
if value, ok := resultString(r); ok {
|
||||
return core.Trim(value)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func (m *Subsystem) syncRepos() string {
|
|||
// Pull changed repos
|
||||
basePath := core.Env("CODE_PATH")
|
||||
if basePath == "" {
|
||||
basePath = core.JoinPath(monitorHomeDir(), "Code", "core")
|
||||
basePath = core.JoinPath(agentic.HomeDir(), "Code", "core")
|
||||
}
|
||||
|
||||
var pulled []string
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue