fix(ax): rename ambiguous prep helpers
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
28300e5a48
commit
e8249c590e
7 changed files with 115 additions and 115 deletions
|
|
@ -55,7 +55,7 @@ func (s *PrepSubsystem) runTask(ctx context.Context, options core.Options) core.
|
|||
org = "core"
|
||||
}
|
||||
|
||||
issue := parseIntStr(issueValue)
|
||||
issue := parseIntString(issueValue)
|
||||
|
||||
core.Print(nil, "core-agent run task")
|
||||
core.Print(nil, " repo: %s/%s", org, repo)
|
||||
|
|
@ -114,10 +114,10 @@ func (s *PrepSubsystem) cmdPrep(options core.Options) core.Result {
|
|||
}
|
||||
|
||||
if value := options.String("issue"); value != "" {
|
||||
prepInput.Issue = parseIntStr(value)
|
||||
prepInput.Issue = parseIntString(value)
|
||||
}
|
||||
if value := options.String("pr"); value != "" {
|
||||
prepInput.PR = parseIntStr(value)
|
||||
prepInput.PR = parseIntString(value)
|
||||
}
|
||||
if value := options.String("branch"); value != "" {
|
||||
prepInput.Branch = value
|
||||
|
|
@ -130,7 +130,7 @@ func (s *PrepSubsystem) cmdPrep(options core.Options) core.Result {
|
|||
prepInput.Branch = "dev"
|
||||
}
|
||||
|
||||
_, prepOutput, err := s.TestPrepWorkspace(context.Background(), prepInput)
|
||||
_, prepOutput, err := s.PrepareWorkspace(context.Background(), prepInput)
|
||||
if err != nil {
|
||||
core.Print(nil, "error: %v", err)
|
||||
return core.Result{Value: err, OK: false}
|
||||
|
|
@ -197,7 +197,7 @@ func (s *PrepSubsystem) cmdPrompt(options core.Options) core.Result {
|
|||
Persona: options.String("persona"),
|
||||
}
|
||||
|
||||
prompt, memories, consumers := s.TestBuildPrompt(context.Background(), prepInput, "dev", repoPath)
|
||||
prompt, memories, consumers := s.BuildPrompt(context.Background(), prepInput, "dev", repoPath)
|
||||
core.Print(nil, "memories: %d", memories)
|
||||
core.Print(nil, "consumers: %d", consumers)
|
||||
core.Print(nil, "")
|
||||
|
|
@ -245,8 +245,8 @@ func (s *PrepSubsystem) cmdExtract(options core.Options) core.Result {
|
|||
return core.Result{OK: true}
|
||||
}
|
||||
|
||||
// parseIntStr("issue-42") // 42
|
||||
func parseIntStr(s string) int {
|
||||
// parseIntString("issue-42") // 42
|
||||
func parseIntString(s string) int {
|
||||
n := 0
|
||||
for _, ch := range s {
|
||||
if ch >= '0' && ch <= '9' {
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ package agentic
|
|||
|
||||
import core "dappco.re/go/core"
|
||||
|
||||
func Example_parseIntStr() {
|
||||
core.Println(parseIntStr("42"))
|
||||
core.Println(parseIntStr("abc"))
|
||||
core.Println(parseIntStr(""))
|
||||
func Example_parseIntString() {
|
||||
core.Println(parseIntString("42"))
|
||||
core.Println(parseIntString("abc"))
|
||||
core.Println(parseIntString(""))
|
||||
// Output:
|
||||
// 42
|
||||
// 0
|
||||
|
|
|
|||
|
|
@ -684,11 +684,11 @@ func TestCommands_CmdOrchestrator_Good_CancelledCtx(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCommands_ParseIntStr_Good(t *testing.T) {
|
||||
assert.Equal(t, 42, parseIntStr("42"))
|
||||
assert.Equal(t, 123, parseIntStr("issue-123"))
|
||||
assert.Equal(t, 0, parseIntStr(""))
|
||||
assert.Equal(t, 0, parseIntStr("abc"))
|
||||
assert.Equal(t, 7, parseIntStr("#7"))
|
||||
assert.Equal(t, 42, parseIntString("42"))
|
||||
assert.Equal(t, 123, parseIntString("issue-123"))
|
||||
assert.Equal(t, 0, parseIntString(""))
|
||||
assert.Equal(t, 0, parseIntString("abc"))
|
||||
assert.Equal(t, 7, parseIntString("#7"))
|
||||
}
|
||||
|
||||
// --- Registration verification ---
|
||||
|
|
@ -815,7 +815,7 @@ func TestCommands_CmdRunTask_Ugly_MixedIssueString(t *testing.T) {
|
|||
core.Option{Key: "task", Value: "fix it"},
|
||||
core.Option{Key: "issue", Value: "issue-42abc"},
|
||||
))
|
||||
// Will fail on dispatch but exercises parseIntStr with mixed chars
|
||||
// Will fail on dispatch but exercises parseIntString with mixed chars
|
||||
assert.False(t, r.OK)
|
||||
}
|
||||
|
||||
|
|
@ -882,16 +882,16 @@ func TestCommands_CmdStatus_Ugly_NonDirEntries(t *testing.T) {
|
|||
// --- ParseIntStr Bad/Ugly ---
|
||||
|
||||
func TestCommands_ParseIntStr_Bad_NegativeAndOverflow(t *testing.T) {
|
||||
// parseIntStr extracts digits only, ignoring minus signs
|
||||
assert.Equal(t, 5, parseIntStr("-5")) // extracts "5", ignores "-"
|
||||
assert.Equal(t, 0, parseIntStr("-")) // no digits
|
||||
assert.Equal(t, 0, parseIntStr("---")) // no digits
|
||||
// parseIntString extracts digits only, ignoring minus signs
|
||||
assert.Equal(t, 5, parseIntString("-5")) // extracts "5", ignores "-"
|
||||
assert.Equal(t, 0, parseIntString("-")) // no digits
|
||||
assert.Equal(t, 0, parseIntString("---")) // no digits
|
||||
}
|
||||
|
||||
func TestCommands_ParseIntStr_Ugly_UnicodeAndMixed(t *testing.T) {
|
||||
// Unicode digits (e.g. Arabic-Indic) are NOT ASCII 0-9 so ignored
|
||||
assert.Equal(t, 0, parseIntStr("\u0661\u0662\u0663")) // ١٢٣ — not ASCII digits
|
||||
assert.Equal(t, 42, parseIntStr("abc42xyz")) // mixed chars
|
||||
assert.Equal(t, 123, parseIntStr("1a2b3c")) // interleaved
|
||||
assert.Equal(t, 0, parseIntStr(" \t\n")) // whitespace only
|
||||
assert.Equal(t, 0, parseIntString("\u0661\u0662\u0663")) // ١٢٣ — not ASCII digits
|
||||
assert.Equal(t, 42, parseIntString("abc42xyz")) // mixed chars
|
||||
assert.Equal(t, 123, parseIntString("1a2b3c")) // interleaved
|
||||
assert.Equal(t, 0, parseIntString(" \t\n")) // whitespace only
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ func (s *PrepSubsystem) cmdWorkspaceDispatch(options core.Options) core.Result {
|
|||
Org: options.String("org"),
|
||||
Template: options.String("template"),
|
||||
Branch: options.String("branch"),
|
||||
Issue: parseIntStr(options.String("issue")),
|
||||
PR: parseIntStr(options.String("pr")),
|
||||
Issue: parseIntString(options.String("issue")),
|
||||
PR: parseIntString(options.String("pr")),
|
||||
}
|
||||
_, out, err := s.dispatch(context.Background(), nil, input)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -501,13 +501,13 @@ func (s *PrepSubsystem) copyRepoSpecs(workspaceDir, repo string) {
|
|||
}
|
||||
}
|
||||
|
||||
// _, out, err := prep.TestPrepWorkspace(ctx, input)
|
||||
func (s *PrepSubsystem) TestPrepWorkspace(ctx context.Context, input PrepInput) (*mcp.CallToolResult, PrepOutput, error) {
|
||||
// _, out, err := prep.PrepareWorkspace(ctx, input)
|
||||
func (s *PrepSubsystem) PrepareWorkspace(ctx context.Context, input PrepInput) (*mcp.CallToolResult, PrepOutput, error) {
|
||||
return s.prepWorkspace(ctx, nil, input)
|
||||
}
|
||||
|
||||
// prompt, memories, consumers := prep.TestBuildPrompt(ctx, input, "dev", repoPath)
|
||||
func (s *PrepSubsystem) TestBuildPrompt(ctx context.Context, input PrepInput, branch, repoPath string) (string, int, int) {
|
||||
// prompt, memories, consumers := prep.BuildPrompt(ctx, input, "dev", repoPath)
|
||||
func (s *PrepSubsystem) BuildPrompt(ctx context.Context, input PrepInput, branch, repoPath string) (string, int, int) {
|
||||
return s.buildPrompt(ctx, input, branch, repoPath)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ import (
|
|||
func TestPrep_Shutdown_Good(t *testing.T) {
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
err := s.Shutdown(context.Background())
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -64,9 +64,9 @@ use (
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: dir,
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
codePath: dir,
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
list, count := s.findConsumersList("go")
|
||||
|
|
@ -92,9 +92,9 @@ use (
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: dir,
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
codePath: dir,
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
list, count := s.findConsumersList("go")
|
||||
|
|
@ -105,9 +105,9 @@ use (
|
|||
func TestPrep_FindConsumersList_Bad_NoGoWork(t *testing.T) {
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
list, count := s.findConsumersList("go")
|
||||
|
|
@ -144,9 +144,9 @@ func TestPrep_PullWikiContent_Good_WithPages(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
content := s.pullWikiContent(context.Background(), "core", "go-io")
|
||||
|
|
@ -164,9 +164,9 @@ func TestPrep_PullWikiContent_Good_NoPages(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
content := s.pullWikiContent(context.Background(), "core", "go-io")
|
||||
|
|
@ -187,9 +187,9 @@ func TestPrep_GetIssueBody_Good(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
body := s.getIssueBody(context.Background(), "core", "go-io", 15)
|
||||
|
|
@ -204,9 +204,9 @@ func TestPrep_GetIssueBody_Bad_NotFound(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
body := s.getIssueBody(context.Background(), "core", "go-io", 999)
|
||||
|
|
@ -222,9 +222,9 @@ func TestPrep_BuildPrompt_Good_BasicFields(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
prompt, memories, consumers := s.buildPrompt(context.Background(), PrepInput{
|
||||
|
|
@ -256,10 +256,10 @@ func TestPrep_BuildPrompt_Good_WithIssue(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
prompt, _, _ := s.buildPrompt(context.Background(), PrepInput{
|
||||
|
|
@ -275,16 +275,16 @@ func TestPrep_BuildPrompt_Good_WithIssue(t *testing.T) {
|
|||
|
||||
// --- buildPrompt (naming convention tests) ---
|
||||
|
||||
func TestPrep_BuildPrompt_Good(t *testing.T) {
|
||||
func TestPrep_BuildPromptNaming_Good(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
// Create go.mod to detect language as "go"
|
||||
fs.Write(core.JoinPath(dir, "go.mod"), "module test\n\ngo 1.22\n")
|
||||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
prompt, memories, consumers := s.buildPrompt(context.Background(), PrepInput{
|
||||
|
|
@ -303,13 +303,13 @@ func TestPrep_BuildPrompt_Good(t *testing.T) {
|
|||
assert.Equal(t, 0, consumers)
|
||||
}
|
||||
|
||||
func TestPrep_BuildPrompt_Bad(t *testing.T) {
|
||||
func TestPrep_BuildPromptNaming_Bad(t *testing.T) {
|
||||
// Empty repo path — still produces a prompt (no crash)
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
prompt, memories, consumers := s.buildPrompt(context.Background(), PrepInput{
|
||||
|
|
@ -324,7 +324,7 @@ func TestPrep_BuildPrompt_Bad(t *testing.T) {
|
|||
assert.Equal(t, 0, consumers)
|
||||
}
|
||||
|
||||
func TestPrep_BuildPrompt_Ugly(t *testing.T) {
|
||||
func TestPrep_BuildPromptNaming_Ugly(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
fs.Write(core.JoinPath(dir, "go.mod"), "module test\n\ngo 1.22\n")
|
||||
|
||||
|
|
@ -339,10 +339,10 @@ func TestPrep_BuildPrompt_Ugly(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
prompt, _, _ := s.buildPrompt(context.Background(), PrepInput{
|
||||
|
|
@ -375,9 +375,9 @@ func TestPrep_BuildPrompt_Ugly_WithGitLog(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
prompt, _, _ := s.buildPrompt(context.Background(), PrepInput{
|
||||
|
|
@ -399,8 +399,8 @@ func TestDispatch_RunQA_Good_PHPNoComposer(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
// Will fail (composer not found) — that's the expected path
|
||||
result := s.runQA(dir)
|
||||
|
|
@ -418,9 +418,9 @@ func TestPrep_PullWikiContent_Bad(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
content := s.pullWikiContent(context.Background(), "core", "go-io")
|
||||
|
|
@ -448,9 +448,9 @@ func TestPrep_PullWikiContent_Ugly(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
content := s.pullWikiContent(context.Background(), "core", "go-io")
|
||||
|
|
@ -464,8 +464,8 @@ func TestPrep_RenderPlan_Ugly(t *testing.T) {
|
|||
// Template with variables that don't exist in template — variables just won't match
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
// Passing variables that won't match any {{placeholder}} in the template
|
||||
|
|
@ -494,10 +494,10 @@ func TestPrep_BrainRecall_Ugly(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
brainURL: srv.URL,
|
||||
brainKey: "test-key",
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
brainURL: srv.URL,
|
||||
brainKey: "test-key",
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
recall, count := s.brainRecall(context.Background(), "go-io")
|
||||
|
|
@ -513,9 +513,9 @@ func TestPrep_PrepWorkspace_Ugly(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
codePath: t.TempDir(),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
// Repo name "." — should be rejected as invalid
|
||||
|
|
@ -554,9 +554,9 @@ func TestPrep_FindConsumersList_Ugly(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: dir,
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
codePath: dir,
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
// Should not panic, just skip missing go.mod entries
|
||||
|
|
@ -580,9 +580,9 @@ func TestPrep_GetIssueBody_Ugly(t *testing.T) {
|
|||
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
forge: forge.NewForge(srv.URL, "test-token"),
|
||||
backoff: make(map[string]time.Time),
|
||||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
body := s.getIssueBody(context.Background(), "core", "go-io", 99)
|
||||
|
|
|
|||
|
|
@ -575,9 +575,9 @@ func TestPrep_DetectBuildCmd_Ugly(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
// --- TestPrepWorkspace (public API wrapper) ---
|
||||
// --- PrepareWorkspace ---
|
||||
|
||||
func TestPrep_TestPrepWorkspace_Good(t *testing.T) {
|
||||
func TestPrep_PrepareWorkspace_Good(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
t.Setenv("CORE_WORKSPACE", root)
|
||||
|
||||
|
|
@ -589,7 +589,7 @@ func TestPrep_TestPrepWorkspace_Good(t *testing.T) {
|
|||
}
|
||||
|
||||
// Valid input but repo won't exist — still exercises the public wrapper delegation
|
||||
_, _, err := s.TestPrepWorkspace(context.Background(), PrepInput{
|
||||
_, _, err := s.PrepareWorkspace(context.Background(), PrepInput{
|
||||
Repo: "go-io",
|
||||
Issue: 1,
|
||||
})
|
||||
|
|
@ -597,7 +597,7 @@ func TestPrep_TestPrepWorkspace_Good(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestPrep_TestPrepWorkspace_Bad(t *testing.T) {
|
||||
func TestPrep_PrepareWorkspace_Bad(t *testing.T) {
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: t.TempDir(),
|
||||
|
|
@ -606,12 +606,12 @@ func TestPrep_TestPrepWorkspace_Bad(t *testing.T) {
|
|||
}
|
||||
|
||||
// Missing repo — should return error
|
||||
_, _, err := s.TestPrepWorkspace(context.Background(), PrepInput{})
|
||||
_, _, err := s.PrepareWorkspace(context.Background(), PrepInput{})
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "repo is required")
|
||||
}
|
||||
|
||||
func TestPrep_TestPrepWorkspace_Ugly(t *testing.T) {
|
||||
func TestPrep_PrepareWorkspace_Ugly(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
t.Setenv("CORE_WORKSPACE", root)
|
||||
|
||||
|
|
@ -623,7 +623,7 @@ func TestPrep_TestPrepWorkspace_Ugly(t *testing.T) {
|
|||
}
|
||||
|
||||
// Bare ".." is caught as invalid repo name by PathBase check
|
||||
_, _, err := s.TestPrepWorkspace(context.Background(), PrepInput{
|
||||
_, _, err := s.PrepareWorkspace(context.Background(), PrepInput{
|
||||
Repo: "..",
|
||||
Issue: 1,
|
||||
})
|
||||
|
|
@ -631,9 +631,9 @@ func TestPrep_TestPrepWorkspace_Ugly(t *testing.T) {
|
|||
assert.Contains(t, err.Error(), "invalid repo name")
|
||||
}
|
||||
|
||||
// --- TestBuildPrompt (public API wrapper) ---
|
||||
// --- BuildPrompt ---
|
||||
|
||||
func TestPrep_TestBuildPrompt_Good(t *testing.T) {
|
||||
func TestPrep_BuildPrompt_Good(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
require.True(t, fs.Write(core.JoinPath(dir, "go.mod"), "module test").OK)
|
||||
|
||||
|
|
@ -644,7 +644,7 @@ func TestPrep_TestBuildPrompt_Good(t *testing.T) {
|
|||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
prompt, memories, consumers := s.TestBuildPrompt(context.Background(), PrepInput{
|
||||
prompt, memories, consumers := s.BuildPrompt(context.Background(), PrepInput{
|
||||
Task: "Review code",
|
||||
Org: "core",
|
||||
Repo: "go-io",
|
||||
|
|
@ -657,7 +657,7 @@ func TestPrep_TestBuildPrompt_Good(t *testing.T) {
|
|||
assert.Equal(t, 0, consumers)
|
||||
}
|
||||
|
||||
func TestPrep_TestBuildPrompt_Bad(t *testing.T) {
|
||||
func TestPrep_BuildPrompt_Bad(t *testing.T) {
|
||||
s := &PrepSubsystem{
|
||||
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
|
||||
codePath: t.TempDir(),
|
||||
|
|
@ -666,7 +666,7 @@ func TestPrep_TestBuildPrompt_Bad(t *testing.T) {
|
|||
}
|
||||
|
||||
// Empty inputs — should still return a prompt string without panicking
|
||||
prompt, memories, consumers := s.TestBuildPrompt(context.Background(), PrepInput{}, "", "")
|
||||
prompt, memories, consumers := s.BuildPrompt(context.Background(), PrepInput{}, "", "")
|
||||
assert.NotEmpty(t, prompt)
|
||||
assert.Contains(t, prompt, "TASK:")
|
||||
assert.Contains(t, prompt, "CONSTRAINTS:")
|
||||
|
|
@ -674,7 +674,7 @@ func TestPrep_TestBuildPrompt_Bad(t *testing.T) {
|
|||
assert.Equal(t, 0, consumers)
|
||||
}
|
||||
|
||||
func TestPrep_TestBuildPrompt_Ugly(t *testing.T) {
|
||||
func TestPrep_BuildPrompt_Ugly(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
s := &PrepSubsystem{
|
||||
|
|
@ -685,7 +685,7 @@ func TestPrep_TestBuildPrompt_Ugly(t *testing.T) {
|
|||
}
|
||||
|
||||
// Unicode in all fields — should not panic
|
||||
prompt, _, _ := s.TestBuildPrompt(context.Background(), PrepInput{
|
||||
prompt, _, _ := s.BuildPrompt(context.Background(), PrepInput{
|
||||
Task: "\u00e9nchantr\u00efx \u2603 \U0001f600",
|
||||
Org: "c\u00f6re",
|
||||
Repo: "g\u00f6-i\u00f6",
|
||||
|
|
@ -817,7 +817,7 @@ func TestPrep_PrepWorkspace_Good(t *testing.T) {
|
|||
failCount: make(map[string]int),
|
||||
}
|
||||
|
||||
_, out, err := s.TestPrepWorkspace(context.Background(), PrepInput{
|
||||
_, out, err := s.PrepareWorkspace(context.Background(), PrepInput{
|
||||
Repo: "test-repo",
|
||||
Issue: 1,
|
||||
Task: "Fix tests",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue