You've already forked agentic-coding-workflow
63 lines
2.6 KiB
Go
63 lines
2.6 KiB
Go
package run
|
|
|
|
// exec_dto.go 定义一次性 exec(run_command / run_tests)的请求/响应契约。
|
|
// 与 run profile 不同:exec 是同步请求-响应,输出在内存捕获后一次性返回。
|
|
|
|
// ExecCommandReq 是 run_command 的输入。WorktreeID 为空 → 在 workspace main_path 执行。
|
|
type ExecCommandReq struct {
|
|
WorkspaceID string `json:"workspace_id"`
|
|
WorktreeID string `json:"worktree_id,omitempty"`
|
|
Command string `json:"command"`
|
|
Args []string `json:"args,omitempty"`
|
|
Env map[string]string `json:"env,omitempty"` // 临时覆盖(明文,不落库)
|
|
TimeoutSec int `json:"timeout_sec,omitempty"`
|
|
}
|
|
|
|
// ExecCommandResp 是 run_command 的结构化结果。
|
|
type ExecCommandResp struct {
|
|
ExitCode int `json:"exit_code"`
|
|
Stdout string `json:"stdout"`
|
|
Stderr string `json:"stderr"`
|
|
DurationMs int64 `json:"duration_ms"`
|
|
TimedOut bool `json:"timed_out"`
|
|
Truncated bool `json:"truncated"`
|
|
}
|
|
|
|
// ExecTestsReq 是 run_tests 的输入:在 run_command 基础上增加 Format(解析格式)。
|
|
type ExecTestsReq struct {
|
|
WorkspaceID string `json:"workspace_id"`
|
|
WorktreeID string `json:"worktree_id,omitempty"`
|
|
Command string `json:"command"`
|
|
Args []string `json:"args,omitempty"`
|
|
Format string `json:"format,omitempty"` // gotest|junit|vitest|auto(默认 auto)
|
|
Env map[string]string `json:"env,omitempty"`
|
|
TimeoutSec int `json:"timeout_sec,omitempty"`
|
|
}
|
|
|
|
// ExecTestsResp 是 run_tests 的结果:run_command 输出 + 结构化测试摘要。
|
|
// ParseError 非空表示解析失败,但原始输出与退出码仍可用——run_tests 永不因解析失败
|
|
// 而向 agent 返回错误。
|
|
type ExecTestsResp struct {
|
|
ExecCommandResp
|
|
Summary TestSummary `json:"summary"`
|
|
ParseError string `json:"parse_error,omitempty"`
|
|
}
|
|
|
|
// TestSummary 是跨框架(go test / JUnit / vitest)归一化的测试结果摘要。
|
|
type TestSummary struct {
|
|
Framework string `json:"framework"`
|
|
Total int `json:"total"`
|
|
Passed int `json:"passed"`
|
|
Failed int `json:"failed"`
|
|
Skipped int `json:"skipped"`
|
|
DurationMs int64 `json:"duration_ms"`
|
|
Failures []TestFailure `json:"failures"`
|
|
}
|
|
|
|
// TestFailure 描述单个失败用例。Package 对非 go 框架可能为空。
|
|
type TestFailure struct {
|
|
Name string `json:"name"`
|
|
Package string `json:"package,omitempty"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|