refactor(agentic): clarify AX local identifiers
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
1d47df4899
commit
f2f29ceb5f
4 changed files with 40 additions and 40 deletions
|
|
@ -791,9 +791,9 @@ func anyMapValue(value any) map[string]any {
|
|||
if result := core.JSONUnmarshalString(trimmed, &values); result.OK {
|
||||
return values
|
||||
}
|
||||
var strings map[string]string
|
||||
if result := core.JSONUnmarshalString(trimmed, &strings); result.OK {
|
||||
return anyMapValue(strings)
|
||||
var stringValues map[string]string
|
||||
if result := core.JSONUnmarshalString(trimmed, &stringValues); result.OK {
|
||||
return anyMapValue(stringValues)
|
||||
}
|
||||
}
|
||||
values := stringMapValue(trimmed)
|
||||
|
|
|
|||
|
|
@ -217,39 +217,39 @@ func (s *PrepSubsystem) listPRs(ctx context.Context, _ *mcp.CallToolRequest, inp
|
|||
input.Limit = 20
|
||||
}
|
||||
|
||||
var repos []string
|
||||
var repositories []string
|
||||
if input.Repo != "" {
|
||||
repos = []string{input.Repo}
|
||||
repositories = []string{input.Repo}
|
||||
} else {
|
||||
var err error
|
||||
repos, err = s.listOrgRepos(ctx, input.Org)
|
||||
if err != nil {
|
||||
return nil, ListPRsOutput{}, err
|
||||
var repositoryErr error
|
||||
repositories, repositoryErr = s.listOrgRepos(ctx, input.Org)
|
||||
if repositoryErr != nil {
|
||||
return nil, ListPRsOutput{}, repositoryErr
|
||||
}
|
||||
}
|
||||
|
||||
var allPRs []PRInfo
|
||||
var allPullRequests []PRInfo
|
||||
|
||||
for _, repo := range repos {
|
||||
for _, repo := range repositories {
|
||||
prs, err := s.listRepoPRs(ctx, input.Org, repo, input.State)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
allPRs = append(allPRs, prs...)
|
||||
allPullRequests = append(allPullRequests, prs...)
|
||||
|
||||
if len(allPRs) >= input.Limit {
|
||||
if len(allPullRequests) >= input.Limit {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if len(allPRs) > input.Limit {
|
||||
allPRs = allPRs[:input.Limit]
|
||||
if len(allPullRequests) > input.Limit {
|
||||
allPullRequests = allPullRequests[:input.Limit]
|
||||
}
|
||||
|
||||
return nil, ListPRsOutput{
|
||||
Success: true,
|
||||
Count: len(allPRs),
|
||||
PRs: allPRs,
|
||||
Count: len(allPullRequests),
|
||||
PRs: allPullRequests,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,15 +80,15 @@ func ReadStatusResult(workspaceDir string) core.Result {
|
|||
}
|
||||
return core.Result{Value: core.E("ReadStatusResult", core.Concat("status not found for ", workspaceDir), err), OK: false}
|
||||
}
|
||||
var s WorkspaceStatus
|
||||
if parseResult := core.JSONUnmarshalString(r.Value.(string), &s); !parseResult.OK {
|
||||
var workspaceStatus WorkspaceStatus
|
||||
if parseResult := core.JSONUnmarshalString(r.Value.(string), &workspaceStatus); !parseResult.OK {
|
||||
err, _ := parseResult.Value.(error)
|
||||
if err == nil {
|
||||
return core.Result{Value: core.E("ReadStatusResult", "invalid status json", nil), OK: false}
|
||||
}
|
||||
return core.Result{Value: core.E("ReadStatusResult", "invalid status json", err), OK: false}
|
||||
}
|
||||
return core.Result{Value: &s, OK: true}
|
||||
return core.Result{Value: &workspaceStatus, OK: true}
|
||||
}
|
||||
|
||||
// result := ReadStatusResult("/path/to/workspace")
|
||||
|
|
@ -140,7 +140,7 @@ func (s *PrepSubsystem) status(ctx context.Context, _ *mcp.CallToolRequest, inpu
|
|||
runtime = s.Core()
|
||||
}
|
||||
|
||||
var out StatusOutput
|
||||
var statusSummary StatusOutput
|
||||
|
||||
for _, statusPath := range statusFiles {
|
||||
workspaceDir := core.PathDir(statusPath)
|
||||
|
|
@ -149,8 +149,8 @@ func (s *PrepSubsystem) status(ctx context.Context, _ *mcp.CallToolRequest, inpu
|
|||
result := ReadStatusResult(workspaceDir)
|
||||
workspaceStatus, ok := workspaceStatusValue(result)
|
||||
if !ok {
|
||||
out.Total++
|
||||
out.Failed++
|
||||
statusSummary.Total++
|
||||
statusSummary.Failed++
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -172,18 +172,18 @@ func (s *PrepSubsystem) status(ctx context.Context, _ *mcp.CallToolRequest, inpu
|
|||
}
|
||||
}
|
||||
|
||||
out.Total++
|
||||
statusSummary.Total++
|
||||
switch workspaceStatus.Status {
|
||||
case "running":
|
||||
out.Running++
|
||||
statusSummary.Running++
|
||||
case "queued":
|
||||
out.Queued++
|
||||
statusSummary.Queued++
|
||||
case "completed":
|
||||
out.Completed++
|
||||
statusSummary.Completed++
|
||||
case "failed":
|
||||
out.Failed++
|
||||
statusSummary.Failed++
|
||||
case "blocked":
|
||||
out.Blocked = append(out.Blocked, BlockedInfo{
|
||||
statusSummary.Blocked = append(statusSummary.Blocked, BlockedInfo{
|
||||
Name: name,
|
||||
Repo: workspaceStatus.Repo,
|
||||
Agent: workspaceStatus.Agent,
|
||||
|
|
@ -192,5 +192,5 @@ func (s *PrepSubsystem) status(ctx context.Context, _ *mcp.CallToolRequest, inpu
|
|||
}
|
||||
}
|
||||
|
||||
return nil, out, nil
|
||||
return nil, statusSummary, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,15 +131,15 @@ func driveEndpoint(c *core.Core, name string) (base, token string) {
|
|||
|
||||
func httpDo(ctx context.Context, method, url, body, token, authScheme string) core.Result {
|
||||
var request *http.Request
|
||||
var err error
|
||||
var requestErr error
|
||||
|
||||
if body != "" {
|
||||
request, err = http.NewRequestWithContext(ctx, method, url, core.NewReader(body))
|
||||
request, requestErr = http.NewRequestWithContext(ctx, method, url, core.NewReader(body))
|
||||
} else {
|
||||
request, err = http.NewRequestWithContext(ctx, method, url, nil)
|
||||
request, requestErr = http.NewRequestWithContext(ctx, method, url, nil)
|
||||
}
|
||||
if err != nil {
|
||||
return core.Result{Value: core.E("httpDo", "create request", err), OK: false}
|
||||
if requestErr != nil {
|
||||
return core.Result{Value: core.E("httpDo", "create request", requestErr), OK: false}
|
||||
}
|
||||
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
|
|
@ -151,15 +151,15 @@ func httpDo(ctx context.Context, method, url, body, token, authScheme string) co
|
|||
request.Header.Set("Authorization", core.Concat(authScheme, " ", token))
|
||||
}
|
||||
|
||||
response, err := defaultClient.Do(request)
|
||||
if err != nil {
|
||||
return core.Result{Value: core.E("httpDo", "request failed", err), OK: false}
|
||||
response, requestErr := defaultClient.Do(request)
|
||||
if requestErr != nil {
|
||||
return core.Result{Value: core.E("httpDo", "request failed", requestErr), OK: false}
|
||||
}
|
||||
|
||||
readResult := core.ReadAll(response.Body)
|
||||
if !readResult.OK {
|
||||
err, _ := readResult.Value.(error)
|
||||
return core.Result{Value: core.E("httpDo", "failed to read response", err), OK: false}
|
||||
readErr, _ := readResult.Value.(error)
|
||||
return core.Result{Value: core.E("httpDo", "failed to read response", readErr), OK: false}
|
||||
}
|
||||
|
||||
return core.Result{Value: readResult.Value.(string), OK: response.StatusCode < 400}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue