fix(pkg): address code review findings
- Fix import ordering in verify.go and remote_client.go (stdlib before third-party) - Convert os.MkdirAll to fs.EnsureDir in prep.go - Preserve underlying error in !r.OK branches (writeStatus, writePlan, planDelete, planList, resume) Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
0f0764ff59
commit
b266db5069
6 changed files with 16 additions and 10 deletions
|
|
@ -262,7 +262,8 @@ func (s *PrepSubsystem) planDelete(_ context.Context, _ *mcp.CallToolRequest, in
|
|||
}
|
||||
|
||||
if r := fs.Delete(path); !r.OK {
|
||||
return nil, PlanDeleteOutput{}, core.E("planDelete", "failed to delete plan", nil)
|
||||
err, _ := r.Value.(error)
|
||||
return nil, PlanDeleteOutput{}, core.E("planDelete", "failed to delete plan", err)
|
||||
}
|
||||
|
||||
return nil, PlanDeleteOutput{
|
||||
|
|
@ -274,7 +275,8 @@ func (s *PrepSubsystem) planDelete(_ context.Context, _ *mcp.CallToolRequest, in
|
|||
func (s *PrepSubsystem) planList(_ context.Context, _ *mcp.CallToolRequest, input PlanListInput) (*mcp.CallToolResult, PlanListOutput, error) {
|
||||
dir := PlansRoot()
|
||||
if r := fs.EnsureDir(dir); !r.OK {
|
||||
return nil, PlanListOutput{}, core.E("planList", "failed to access plans directory", nil)
|
||||
err, _ := r.Value.(error)
|
||||
return nil, PlanListOutput{}, core.E("planList", "failed to access plans directory", err)
|
||||
}
|
||||
|
||||
entries, err := os.ReadDir(dir)
|
||||
|
|
@ -368,7 +370,8 @@ func readPlan(dir, id string) (*Plan, error) {
|
|||
|
||||
func writePlan(dir string, plan *Plan) (string, error) {
|
||||
if r := fs.EnsureDir(dir); !r.OK {
|
||||
return "", core.E("writePlan", "failed to create plans directory", nil)
|
||||
err, _ := r.Value.(error)
|
||||
return "", core.E("writePlan", "failed to create plans directory", err)
|
||||
}
|
||||
|
||||
path := planPath(dir, plan.ID)
|
||||
|
|
@ -378,7 +381,8 @@ func writePlan(dir string, plan *Plan) (string, error) {
|
|||
}
|
||||
|
||||
if r := fs.Write(path, string(data)); !r.OK {
|
||||
return "", core.E("writePlan", "failed to write plan", nil)
|
||||
err, _ := r.Value.(error)
|
||||
return "", core.E("writePlan", "failed to write plan", err)
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,8 +169,8 @@ func (s *PrepSubsystem) prepWorkspace(ctx context.Context, _ *mcp.CallToolReques
|
|||
// kb/ and specs/ will be created inside src/ after clone
|
||||
|
||||
// Ensure workspace directory exists
|
||||
if err := os.MkdirAll(wsDir, 0755); err != nil {
|
||||
return nil, PrepOutput{}, core.E("prep", "failed to create workspace dir", err)
|
||||
if r := fs.EnsureDir(wsDir); !r.OK {
|
||||
return nil, PrepOutput{}, core.E("prep", "failed to create workspace dir", nil)
|
||||
}
|
||||
|
||||
out := PrepOutput{WorkspaceDir: wsDir}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
package agentic
|
||||
|
||||
import (
|
||||
core "dappco.re/go/core"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
|
|
@ -12,6 +11,7 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
core "dappco.re/go/core"
|
||||
)
|
||||
|
||||
// mcpInitialize performs the MCP initialize handshake over Streamable HTTP.
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ func (s *PrepSubsystem) resume(ctx context.Context, _ *mcp.CallToolRequest, inpu
|
|||
answerPath := filepath.Join(srcDir, "ANSWER.md")
|
||||
content := fmt.Sprintf("# Answer\n\n%s\n", input.Answer)
|
||||
if r := fs.Write(answerPath, content); !r.OK {
|
||||
return nil, ResumeOutput{}, core.E("resume", "failed to write ANSWER.md", nil)
|
||||
err, _ := r.Value.(error)
|
||||
return nil, ResumeOutput{}, core.E("resume", "failed to write ANSWER.md", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ func writeStatus(wsDir string, status *WorkspaceStatus) error {
|
|||
return err
|
||||
}
|
||||
if r := fs.Write(filepath.Join(wsDir, "status.json"), string(data)); !r.OK {
|
||||
return core.E("writeStatus", "failed to write status", nil)
|
||||
err, _ := r.Value.(error)
|
||||
return core.E("writeStatus", "failed to write status", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
package agentic
|
||||
|
||||
import (
|
||||
core "dappco.re/go/core"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
|
@ -15,6 +14,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
core "dappco.re/go/core"
|
||||
)
|
||||
|
||||
// autoVerifyAndMerge runs inline tests (fast gate) and merges if they pass.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue