Compare commits
3 Commits
99d523189f
...
v0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b493651c26 | ||
|
|
6169404f34 | ||
|
|
a67106026f |
@@ -47,9 +47,9 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, "bridge: request failed: %v\n", err)
|
fmt.Fprintf(os.Stderr, "bridge: request failed: %v\n", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
io.Copy(os.Stdout, resp.Body)
|
_, _ = io.Copy(os.Stdout, resp.Body)
|
||||||
resp.Body.Close()
|
_ = resp.Body.Close()
|
||||||
os.Stdout.Write([]byte("\n"))
|
_, _ = os.Stdout.Write([]byte("\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
|
|||||||
@@ -28,8 +28,10 @@ func fakeClaudePath(t *testing.T, output string, exitCode int) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestExecutorParsesValidResult(t *testing.T) {
|
func TestExecutorParsesValidResult(t *testing.T) {
|
||||||
validJSON := `{"status":"pass","phase":"red","skill":"tdd","file_path":"/tmp/x_test.go","runner_output":"FAIL","verified":true,"model_used":"self","message":"ok"}`
|
// Fake claude emits the --output-format json envelope that the real CLI produces.
|
||||||
claude := fakeClaudePath(t, validJSON, 0)
|
// The executor extracts the result from the "structured_output" field.
|
||||||
|
envelope := `{"type":"result","subtype":"success","is_error":false,"structured_output":{"status":"pass","phase":"red","skill":"tdd","file_path":"/tmp/x_test.go","runner_output":"FAIL","verified":true,"model_used":"self","message":"ok"}}`
|
||||||
|
claude := fakeClaudePath(t, envelope, 0)
|
||||||
|
|
||||||
ex := iexec.New(iexec.Config{
|
ex := iexec.New(iexec.Config{
|
||||||
ClaudeBinary: claude,
|
ClaudeBinary: claude,
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(response{
|
_ = json.NewEncoder(w).Encode(response{
|
||||||
JSONRPC: "2.0",
|
JSONRPC: "2.0",
|
||||||
ID: req.ID,
|
ID: req.ID,
|
||||||
Result: result,
|
Result: result,
|
||||||
@@ -90,7 +90,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func writeError(w http.ResponseWriter, id any, code int, msg string) {
|
func writeError(w http.ResponseWriter, id any, code int, msg string) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(response{
|
_ = json.NewEncoder(w).Encode(response{
|
||||||
JSONRPC: "2.0",
|
JSONRPC: "2.0",
|
||||||
ID: id,
|
ID: id,
|
||||||
Error: &rpcError{Code: code, Message: msg},
|
Error: &rpcError{Code: code, Message: msg},
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ func Read(sessionsDir, sessionID string) ([]Entry, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("open session log: %w", err)
|
return nil, fmt.Errorf("open session log: %w", err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close() //nolint:errcheck
|
||||||
|
|
||||||
var entries []Entry
|
var entries []Entry
|
||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(f)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func TestHandle_BrainQuery_CallsIngestServer(t *testing.T) {
|
|||||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
assert.Equal(t, "/query", r.URL.Path)
|
assert.Equal(t, "/query", r.URL.Path)
|
||||||
called = true
|
called = true
|
||||||
json.NewEncoder(w).Encode(map[string]any{
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||||
"results": []map[string]any{
|
"results": []map[string]any{
|
||||||
{"path": "wiki/concepts/tdd.md", "title": "TDD", "excerpt": "Test-driven development.", "score": 3},
|
{"path": "wiki/concepts/tdd.md", "title": "TDD", "excerpt": "Test-driven development.", "score": 3},
|
||||||
},
|
},
|
||||||
@@ -45,7 +45,7 @@ func TestHandle_BrainWrite_CallsIngestServer(t *testing.T) {
|
|||||||
require.NoError(t, json.NewDecoder(r.Body).Decode(&body))
|
require.NoError(t, json.NewDecoder(r.Body).Decode(&body))
|
||||||
assert.Equal(t, "concept", body["type"])
|
assert.Equal(t, "concept", body["type"])
|
||||||
assert.Equal(t, "# Test\n\nSome learning.", body["content"])
|
assert.Equal(t, "# Test\n\nSome learning.", body["content"])
|
||||||
json.NewEncoder(w).Encode(map[string]string{"path": "raw/test.md"})
|
_ = json.NewEncoder(w).Encode(map[string]string{"path": "raw/test.md"})
|
||||||
}))
|
}))
|
||||||
defer srv.Close()
|
defer srv.Close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user