* feat(io): add streaming API to Medium interface and optimize agentic context - Added ReadStream and WriteStream to io.Medium interface. - Implemented streaming methods in local and mock mediums. - Updated pkg/agentic/context.go to use streaming I/O with LimitReader. - Added 5000-byte truncation limit for all AI context file reads to reduce memory usage. - Documented when to use streaming vs full-file APIs in io.Medium. * feat(io): optimize streaming API and fix PR feedback - Fixed resource leak in agentic context by using defer for closing file streams. - Improved truncation logic in agentic context to handle multibyte characters correctly by checking byte length before string conversion. - Added comprehensive documentation to ReadStream and WriteStream in local medium. - Added unit tests for ReadStream and WriteStream in local medium. - Applied formatting and fixed auto-merge CI configuration. * feat(io): add streaming API and fix CI failures (syntax fix) - Introduced ReadStream and WriteStream to io.Medium interface. - Implemented streaming methods in local and mock mediums. - Optimized agentic context with streaming reads and truncation logic. - Fixed syntax error in local client tests by overwriting the file. - Fixed auto-merge CI by adding checkout and repository context. - Applied formatting fixes.
98 lines
1.4 KiB
Go
98 lines
1.4 KiB
Go
package cli
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func captureOutput(f func()) string {
|
|
old := os.Stdout
|
|
r, w, _ := os.Pipe()
|
|
os.Stdout = w
|
|
|
|
f()
|
|
|
|
_ = w.Close()
|
|
os.Stdout = old
|
|
|
|
var buf bytes.Buffer
|
|
_, _ = io.Copy(&buf, r)
|
|
return buf.String()
|
|
}
|
|
|
|
func TestSemanticOutput(t *testing.T) {
|
|
UseASCII()
|
|
|
|
// Test Success
|
|
out := captureOutput(func() {
|
|
Success("done")
|
|
})
|
|
if out == "" {
|
|
t.Error("Success output empty")
|
|
}
|
|
|
|
// Test Error
|
|
out = captureOutput(func() {
|
|
Error("fail")
|
|
})
|
|
if out == "" {
|
|
t.Error("Error output empty")
|
|
}
|
|
|
|
// Test Warn
|
|
out = captureOutput(func() {
|
|
Warn("warn")
|
|
})
|
|
if out == "" {
|
|
t.Error("Warn output empty")
|
|
}
|
|
|
|
// Test Info
|
|
out = captureOutput(func() {
|
|
Info("info")
|
|
})
|
|
if out == "" {
|
|
t.Error("Info output empty")
|
|
}
|
|
|
|
// Test Task
|
|
out = captureOutput(func() {
|
|
Task("task", "msg")
|
|
})
|
|
if out == "" {
|
|
t.Error("Task output empty")
|
|
}
|
|
|
|
// Test Section
|
|
out = captureOutput(func() {
|
|
Section("section")
|
|
})
|
|
if out == "" {
|
|
t.Error("Section output empty")
|
|
}
|
|
|
|
// Test Hint
|
|
out = captureOutput(func() {
|
|
Hint("hint", "msg")
|
|
})
|
|
if out == "" {
|
|
t.Error("Hint output empty")
|
|
}
|
|
|
|
// Test Result
|
|
out = captureOutput(func() {
|
|
Result(true, "pass")
|
|
})
|
|
if out == "" {
|
|
t.Error("Result(true) output empty")
|
|
}
|
|
|
|
out = captureOutput(func() {
|
|
Result(false, "fail")
|
|
})
|
|
if out == "" {
|
|
t.Error("Result(false) output empty")
|
|
}
|
|
}
|