feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
|
|
|
|
package agentic
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
test: add Good/Bad/Ugly for status, paths, auto_pr, prep — agentic 74.0%
New properly named tests:
- TestStatus_Status_Ugly — dead PID detection (blocked/completed/failed)
- TestPaths_DefaultBranch_{Good,Bad,Ugly} — main/master/non-git
- TestAutoPR_AutoCreatePR_{Good,Bad,Ugly} — early returns + no commits
- TestPrep_BuildPrompt_{Good,Bad,Ugly} — basic/empty/persona+issue
558 agentic tests, 74.0% coverage
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 08:16:53 +00:00
|
|
|
"os/exec"
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
test: add Good/Bad/Ugly for status, paths, auto_pr, prep — agentic 74.0%
New properly named tests:
- TestStatus_Status_Ugly — dead PID detection (blocked/completed/failed)
- TestPaths_DefaultBranch_{Good,Bad,Ugly} — main/master/non-git
- TestAutoPR_AutoCreatePR_{Good,Bad,Ugly} — early returns + no commits
- TestPrep_BuildPrompt_{Good,Bad,Ugly} — basic/empty/persona+issue
558 agentic tests, 74.0% coverage
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 08:16:53 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
test: batch 1 — add 80 Bad/Ugly tests for paths, plan, status, shutdown, forge cmds
Fill missing Good/Bad/Ugly categories for:
- paths.go: LocalFs, WorkspaceRoot, CoreRoot, PlansRoot, AgentName, GitHubOrg, parseInt, DefaultBranch
- plan.go: planCreate/Read/Update/Delete/List Ugly, planPath Ugly, validPlanStatus Ugly
- status.go: writeStatus Bad, status Good/Bad
- shutdown.go: dispatchStart/shutdownGraceful Bad/Ugly, shutdownNow Ugly
- commands_forge.go: all 9 cmd* functions Ugly (with httptest mocks)
- sanitise.go: Bad/Ugly for all 5 functions
- prep.go: various lifecycle Bad/Ugly
Gap: 260 → 208 missing categories
Tests: 566 → 646 (+80)
Coverage: 74.4%
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 08:43:35 +00:00
|
|
|
|
|
|
|
|
core "dappco.re/go/core"
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
)
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPaths_CoreRoot_Good_EnvVar(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
t.Setenv("CORE_WORKSPACE", "/tmp/test-core")
|
|
|
|
|
assert.Equal(t, "/tmp/test-core", CoreRoot())
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPaths_CoreRoot_Good_Fallback(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
t.Setenv("CORE_WORKSPACE", "")
|
|
|
|
|
home, _ := os.UserHomeDir()
|
|
|
|
|
assert.Equal(t, home+"/Code/.core", CoreRoot())
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPaths_WorkspaceRoot_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
t.Setenv("CORE_WORKSPACE", "/tmp/test-core")
|
|
|
|
|
assert.Equal(t, "/tmp/test-core/workspace", WorkspaceRoot())
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPaths_PlansRoot_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
t.Setenv("CORE_WORKSPACE", "/tmp/test-core")
|
|
|
|
|
assert.Equal(t, "/tmp/test-core/plans", PlansRoot())
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPaths_AgentName_Good_EnvVar(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
t.Setenv("AGENT_NAME", "clotho")
|
|
|
|
|
assert.Equal(t, "clotho", AgentName())
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPaths_AgentName_Good_Fallback(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
t.Setenv("AGENT_NAME", "")
|
|
|
|
|
name := AgentName()
|
|
|
|
|
assert.True(t, name == "cladius" || name == "charon", "expected cladius or charon, got %s", name)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPaths_GitHubOrg_Good_EnvVar(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
t.Setenv("GITHUB_ORG", "myorg")
|
|
|
|
|
assert.Equal(t, "myorg", GitHubOrg())
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPaths_GitHubOrg_Good_Fallback(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
t.Setenv("GITHUB_ORG", "")
|
|
|
|
|
assert.Equal(t, "dAppCore", GitHubOrg())
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestQueue_BaseAgent_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
assert.Equal(t, "claude", baseAgent("claude:opus"))
|
|
|
|
|
assert.Equal(t, "claude", baseAgent("claude:haiku"))
|
|
|
|
|
assert.Equal(t, "gemini", baseAgent("gemini:flash"))
|
|
|
|
|
assert.Equal(t, "codex", baseAgent("codex"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestVerify_ExtractPRNumber_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
assert.Equal(t, 123, extractPRNumber("https://forge.lthn.ai/core/go-io/pulls/123"))
|
|
|
|
|
assert.Equal(t, 1, extractPRNumber("https://forge.lthn.ai/core/agent/pulls/1"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestVerify_ExtractPRNumber_Bad_Empty(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
assert.Equal(t, 0, extractPRNumber(""))
|
|
|
|
|
assert.Equal(t, 0, extractPRNumber("https://forge.lthn.ai/core/agent/pulls/"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestAutoPr_Truncate_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
assert.Equal(t, "hello", truncate("hello", 10))
|
|
|
|
|
assert.Equal(t, "hel...", truncate("hello world", 3))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestReviewQueue_CountFindings_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
assert.Equal(t, 0, countFindings("No findings"))
|
|
|
|
|
assert.Equal(t, 2, countFindings("- Issue one\n- Issue two\nSummary"))
|
|
|
|
|
assert.Equal(t, 1, countFindings("⚠ Warning here"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestReviewQueue_ParseRetryAfter_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
d := parseRetryAfter("please try after 4 minutes and 56 seconds")
|
|
|
|
|
assert.InDelta(t, 296.0, d.Seconds(), 1.0)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestReviewQueue_ParseRetryAfter_Good_MinutesOnly(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
d := parseRetryAfter("try after 5 minutes")
|
|
|
|
|
assert.InDelta(t, 300.0, d.Seconds(), 1.0)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestReviewQueue_ParseRetryAfter_Bad_NoMatch(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
d := parseRetryAfter("some random text")
|
|
|
|
|
assert.InDelta(t, 300.0, d.Seconds(), 1.0) // defaults to 5 min
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestRemote_ResolveHost_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
assert.Equal(t, "10.69.69.165:9101", resolveHost("charon"))
|
|
|
|
|
assert.Equal(t, "127.0.0.1:9101", resolveHost("cladius"))
|
|
|
|
|
assert.Equal(t, "127.0.0.1:9101", resolveHost("local"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestRemote_ResolveHost_Good_CustomPort(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
assert.Equal(t, "192.168.1.1:9101", resolveHost("192.168.1.1"))
|
|
|
|
|
assert.Equal(t, "192.168.1.1:8080", resolveHost("192.168.1.1:8080"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestMirror_ExtractJSONField_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
json := `[{"url":"https://github.com/dAppCore/go-io/pull/1"}]`
|
|
|
|
|
assert.Equal(t, "https://github.com/dAppCore/go-io/pull/1", extractJSONField(json, "url"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestMirror_ExtractJSONField_Good_Object(t *testing.T) {
|
feat: devops plugin, CLI commands, Codex dispatch fixes, AX sweep
DevOps plugin (5 skills):
- install-core-agent, repair-core-agent, merge-workspace,
update-deps, clean-workspaces
CLI commands: version, check, extract for diagnostics.
Codex dispatch: --skip-git-repo-check, removed broken
--model-reasoning-effort, --sandbox workspace-write via
--full-auto. Workspace template extracts to wsDir not srcDir.
AX sweep (Codex-generated): sanitise.go extracted from prep/plan,
mirror.go JSON parsing via encoding/json, setup/config.go URL
parsing via net/url, strings/fmt imports eliminated from setup.
CODEX.md template updated with Env/Path patterns.
Review workspace template with audit-only PROMPT.md.
Marketplace updated with devops plugin.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 13:30:27 +00:00
|
|
|
json := `{"url":"https://github.com/dAppCore/go-io/pull/2"}`
|
|
|
|
|
assert.Equal(t, "https://github.com/dAppCore/go-io/pull/2", extractJSONField(json, "url"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestMirror_ExtractJSONField_Good_PrettyPrinted(t *testing.T) {
|
feat: devops plugin, CLI commands, Codex dispatch fixes, AX sweep
DevOps plugin (5 skills):
- install-core-agent, repair-core-agent, merge-workspace,
update-deps, clean-workspaces
CLI commands: version, check, extract for diagnostics.
Codex dispatch: --skip-git-repo-check, removed broken
--model-reasoning-effort, --sandbox workspace-write via
--full-auto. Workspace template extracts to wsDir not srcDir.
AX sweep (Codex-generated): sanitise.go extracted from prep/plan,
mirror.go JSON parsing via encoding/json, setup/config.go URL
parsing via net/url, strings/fmt imports eliminated from setup.
CODEX.md template updated with Env/Path patterns.
Review workspace template with audit-only PROMPT.md.
Marketplace updated with devops plugin.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 13:30:27 +00:00
|
|
|
json := "[\n {\n \"url\": \"https://github.com/dAppCore/go-io/pull/3\"\n }\n]"
|
|
|
|
|
assert.Equal(t, "https://github.com/dAppCore/go-io/pull/3", extractJSONField(json, "url"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestMirror_ExtractJSONField_Bad_Missing(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
assert.Equal(t, "", extractJSONField(`{"name":"test"}`, "url"))
|
|
|
|
|
assert.Equal(t, "", extractJSONField("", "url"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPlan_ValidPlanStatus_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
assert.True(t, validPlanStatus("draft"))
|
|
|
|
|
assert.True(t, validPlanStatus("in_progress"))
|
|
|
|
|
assert.True(t, validPlanStatus("draft"))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPlan_ValidPlanStatus_Bad(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
assert.False(t, validPlanStatus("invalid"))
|
|
|
|
|
assert.False(t, validPlanStatus(""))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 08:32:08 +00:00
|
|
|
func TestPlan_GeneratePlanID_Good(t *testing.T) {
|
feat: rewrite CLAUDE.md, add tests for agentic + prompts packages
CLAUDE.md:
- Complete rewrite reflecting current architecture (30 files, 6.5K lines)
- Documents all 33 MCP tools, 7 agent types, dispatch flow
- Removes all references to deleted packages
Tests:
- pkg/agentic: 20 tests covering paths, extractPRNumber, truncate,
countFindings, parseRetryAfter, resolveHost, baseAgent, validPlanStatus,
generatePlanID, extractJSONField
- pkg/prompts: 7 tests covering Template, Persona, ListTemplates,
ListPersonas, prefix duplication check
Fix: rename support/support-responder → support/responder (caught by test)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 22:09:29 +00:00
|
|
|
id := generatePlanID("Fix the login bug in auth service")
|
|
|
|
|
assert.True(t, len(id) > 0)
|
|
|
|
|
assert.True(t, strings.Contains(id, "fix-the-login-bug"))
|
|
|
|
|
}
|
test: add Good/Bad/Ugly for status, paths, auto_pr, prep — agentic 74.0%
New properly named tests:
- TestStatus_Status_Ugly — dead PID detection (blocked/completed/failed)
- TestPaths_DefaultBranch_{Good,Bad,Ugly} — main/master/non-git
- TestAutoPR_AutoCreatePR_{Good,Bad,Ugly} — early returns + no commits
- TestPrep_BuildPrompt_{Good,Bad,Ugly} — basic/empty/persona+issue
558 agentic tests, 74.0% coverage
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 08:16:53 +00:00
|
|
|
|
|
|
|
|
// --- DefaultBranch ---
|
|
|
|
|
|
|
|
|
|
func TestPaths_DefaultBranch_Good(t *testing.T) {
|
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
|
|
|
|
|
// Init git repo with "main" branch
|
|
|
|
|
cmd := exec.Command("git", "init", "-b", "main", dir)
|
|
|
|
|
require.NoError(t, cmd.Run())
|
|
|
|
|
|
|
|
|
|
cmd = exec.Command("git", "-C", dir, "config", "user.name", "Test")
|
|
|
|
|
require.NoError(t, cmd.Run())
|
|
|
|
|
cmd = exec.Command("git", "-C", dir, "config", "user.email", "test@test.com")
|
|
|
|
|
require.NoError(t, cmd.Run())
|
|
|
|
|
|
|
|
|
|
require.NoError(t, os.WriteFile(dir+"/README.md", []byte("# Test"), 0o644))
|
|
|
|
|
cmd = exec.Command("git", "-C", dir, "add", ".")
|
|
|
|
|
require.NoError(t, cmd.Run())
|
|
|
|
|
cmd = exec.Command("git", "-C", dir, "commit", "-m", "init")
|
|
|
|
|
require.NoError(t, cmd.Run())
|
|
|
|
|
|
|
|
|
|
branch := DefaultBranch(dir)
|
|
|
|
|
assert.Equal(t, "main", branch)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_DefaultBranch_Bad(t *testing.T) {
|
|
|
|
|
// Non-git directory — should return "main" (default)
|
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
branch := DefaultBranch(dir)
|
|
|
|
|
assert.Equal(t, "main", branch)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_DefaultBranch_Ugly(t *testing.T) {
|
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
|
|
|
|
|
// Init git repo with "master" branch
|
|
|
|
|
cmd := exec.Command("git", "init", "-b", "master", dir)
|
|
|
|
|
require.NoError(t, cmd.Run())
|
|
|
|
|
|
|
|
|
|
cmd = exec.Command("git", "-C", dir, "config", "user.name", "Test")
|
|
|
|
|
require.NoError(t, cmd.Run())
|
|
|
|
|
cmd = exec.Command("git", "-C", dir, "config", "user.email", "test@test.com")
|
|
|
|
|
require.NoError(t, cmd.Run())
|
|
|
|
|
|
|
|
|
|
require.NoError(t, os.WriteFile(dir+"/README.md", []byte("# Test"), 0o644))
|
|
|
|
|
cmd = exec.Command("git", "-C", dir, "add", ".")
|
|
|
|
|
require.NoError(t, cmd.Run())
|
|
|
|
|
cmd = exec.Command("git", "-C", dir, "commit", "-m", "init")
|
|
|
|
|
require.NoError(t, cmd.Run())
|
|
|
|
|
|
|
|
|
|
branch := DefaultBranch(dir)
|
|
|
|
|
assert.Equal(t, "master", branch)
|
|
|
|
|
}
|
test: batch 1 — add 80 Bad/Ugly tests for paths, plan, status, shutdown, forge cmds
Fill missing Good/Bad/Ugly categories for:
- paths.go: LocalFs, WorkspaceRoot, CoreRoot, PlansRoot, AgentName, GitHubOrg, parseInt, DefaultBranch
- plan.go: planCreate/Read/Update/Delete/List Ugly, planPath Ugly, validPlanStatus Ugly
- status.go: writeStatus Bad, status Good/Bad
- shutdown.go: dispatchStart/shutdownGraceful Bad/Ugly, shutdownNow Ugly
- commands_forge.go: all 9 cmd* functions Ugly (with httptest mocks)
- sanitise.go: Bad/Ugly for all 5 functions
- prep.go: various lifecycle Bad/Ugly
Gap: 260 → 208 missing categories
Tests: 566 → 646 (+80)
Coverage: 74.4%
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 08:43:35 +00:00
|
|
|
|
|
|
|
|
// --- LocalFs Bad/Ugly ---
|
|
|
|
|
|
|
|
|
|
func TestPaths_LocalFs_Bad_ReadNonExistent(t *testing.T) {
|
|
|
|
|
f := LocalFs()
|
|
|
|
|
r := f.Read("/tmp/nonexistent-path-" + strings.Repeat("x", 20) + "/file.txt")
|
|
|
|
|
assert.False(t, r.OK, "reading a non-existent file should fail")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_LocalFs_Ugly_EmptyPath(t *testing.T) {
|
|
|
|
|
f := LocalFs()
|
|
|
|
|
assert.NotPanics(t, func() {
|
|
|
|
|
f.Read("")
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- WorkspaceRoot Bad/Ugly ---
|
|
|
|
|
|
|
|
|
|
func TestPaths_WorkspaceRoot_Bad_EmptyEnv(t *testing.T) {
|
|
|
|
|
t.Setenv("CORE_WORKSPACE", "")
|
|
|
|
|
home, _ := os.UserHomeDir()
|
|
|
|
|
// Should fall back to ~/Code/.core/workspace
|
|
|
|
|
assert.Equal(t, home+"/Code/.core/workspace", WorkspaceRoot())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_WorkspaceRoot_Ugly_TrailingSlash(t *testing.T) {
|
|
|
|
|
t.Setenv("CORE_WORKSPACE", "/tmp/test-core/")
|
|
|
|
|
// Verify it still constructs a valid path (JoinPath handles trailing slash)
|
|
|
|
|
ws := WorkspaceRoot()
|
|
|
|
|
assert.NotEmpty(t, ws)
|
|
|
|
|
assert.Contains(t, ws, "workspace")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- CoreRoot Bad/Ugly ---
|
|
|
|
|
|
|
|
|
|
func TestPaths_CoreRoot_Bad_WhitespaceEnv(t *testing.T) {
|
|
|
|
|
t.Setenv("CORE_WORKSPACE", " ")
|
|
|
|
|
// Non-empty string (whitespace) will be used as-is
|
|
|
|
|
root := CoreRoot()
|
|
|
|
|
assert.Equal(t, " ", root)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_CoreRoot_Ugly_UnicodeEnv(t *testing.T) {
|
|
|
|
|
t.Setenv("CORE_WORKSPACE", "/tmp/\u00e9\u00e0\u00fc")
|
|
|
|
|
assert.NotPanics(t, func() {
|
|
|
|
|
root := CoreRoot()
|
|
|
|
|
assert.Equal(t, "/tmp/\u00e9\u00e0\u00fc", root)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- PlansRoot Bad/Ugly ---
|
|
|
|
|
|
|
|
|
|
func TestPaths_PlansRoot_Bad_EmptyEnv(t *testing.T) {
|
|
|
|
|
t.Setenv("CORE_WORKSPACE", "")
|
|
|
|
|
home, _ := os.UserHomeDir()
|
|
|
|
|
assert.Equal(t, home+"/Code/.core/plans", PlansRoot())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_PlansRoot_Ugly_NestedPath(t *testing.T) {
|
|
|
|
|
t.Setenv("CORE_WORKSPACE", "/a/b/c/d/e/f")
|
|
|
|
|
assert.Equal(t, "/a/b/c/d/e/f/plans", PlansRoot())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- AgentName Bad/Ugly ---
|
|
|
|
|
|
|
|
|
|
func TestPaths_AgentName_Bad_WhitespaceEnv(t *testing.T) {
|
|
|
|
|
t.Setenv("AGENT_NAME", " ")
|
|
|
|
|
// Whitespace is non-empty, so returned as-is
|
|
|
|
|
assert.Equal(t, " ", AgentName())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_AgentName_Ugly_UnicodeEnv(t *testing.T) {
|
|
|
|
|
t.Setenv("AGENT_NAME", "\u00e9nchantr\u00efx")
|
|
|
|
|
assert.NotPanics(t, func() {
|
|
|
|
|
name := AgentName()
|
|
|
|
|
assert.Equal(t, "\u00e9nchantr\u00efx", name)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- GitHubOrg Bad/Ugly ---
|
|
|
|
|
|
|
|
|
|
func TestPaths_GitHubOrg_Bad_WhitespaceEnv(t *testing.T) {
|
|
|
|
|
t.Setenv("GITHUB_ORG", " ")
|
|
|
|
|
assert.Equal(t, " ", GitHubOrg())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_GitHubOrg_Ugly_SpecialChars(t *testing.T) {
|
|
|
|
|
t.Setenv("GITHUB_ORG", "org/with/slashes")
|
|
|
|
|
assert.NotPanics(t, func() {
|
|
|
|
|
org := GitHubOrg()
|
|
|
|
|
assert.Equal(t, "org/with/slashes", org)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- parseInt Bad/Ugly ---
|
|
|
|
|
|
|
|
|
|
func TestPaths_ParseInt_Bad_EmptyString(t *testing.T) {
|
|
|
|
|
assert.Equal(t, 0, parseInt(""))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_ParseInt_Bad_NonNumeric(t *testing.T) {
|
|
|
|
|
assert.Equal(t, 0, parseInt("abc"))
|
|
|
|
|
assert.Equal(t, 0, parseInt("12.5"))
|
|
|
|
|
assert.Equal(t, 0, parseInt("0xff"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_ParseInt_Bad_WhitespaceOnly(t *testing.T) {
|
|
|
|
|
assert.Equal(t, 0, parseInt(" "))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_ParseInt_Ugly_NegativeNumber(t *testing.T) {
|
|
|
|
|
assert.Equal(t, -42, parseInt("-42"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_ParseInt_Ugly_VeryLargeNumber(t *testing.T) {
|
|
|
|
|
assert.Equal(t, 0, parseInt("99999999999999999999999"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_ParseInt_Ugly_LeadingTrailingWhitespace(t *testing.T) {
|
|
|
|
|
assert.Equal(t, 42, parseInt(" 42 "))
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 09:19:05 +00:00
|
|
|
// --- newFs Good/Bad/Ugly ---
|
|
|
|
|
|
|
|
|
|
func TestPaths_NewFs_Good(t *testing.T) {
|
|
|
|
|
f := newFs("/tmp")
|
|
|
|
|
assert.NotNil(t, f, "newFs should return a non-nil Fs")
|
|
|
|
|
assert.IsType(t, &core.Fs{}, f)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- parseInt Good ---
|
|
|
|
|
|
|
|
|
|
func TestPaths_ParseInt_Good(t *testing.T) {
|
|
|
|
|
assert.Equal(t, 42, parseInt("42"))
|
|
|
|
|
assert.Equal(t, 0, parseInt("0"))
|
|
|
|
|
}
|
test: batch 1 — add 80 Bad/Ugly tests for paths, plan, status, shutdown, forge cmds
Fill missing Good/Bad/Ugly categories for:
- paths.go: LocalFs, WorkspaceRoot, CoreRoot, PlansRoot, AgentName, GitHubOrg, parseInt, DefaultBranch
- plan.go: planCreate/Read/Update/Delete/List Ugly, planPath Ugly, validPlanStatus Ugly
- status.go: writeStatus Bad, status Good/Bad
- shutdown.go: dispatchStart/shutdownGraceful Bad/Ugly, shutdownNow Ugly
- commands_forge.go: all 9 cmd* functions Ugly (with httptest mocks)
- sanitise.go: Bad/Ugly for all 5 functions
- prep.go: various lifecycle Bad/Ugly
Gap: 260 → 208 missing categories
Tests: 566 → 646 (+80)
Coverage: 74.4%
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 08:43:35 +00:00
|
|
|
|
|
|
|
|
func TestPaths_NewFs_Bad_EmptyRoot(t *testing.T) {
|
|
|
|
|
f := newFs("")
|
|
|
|
|
assert.NotNil(t, f, "newFs with empty root should not return nil")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_NewFs_Ugly_UnicodeRoot(t *testing.T) {
|
|
|
|
|
assert.NotPanics(t, func() {
|
|
|
|
|
f := newFs("/tmp/\u00e9\u00e0\u00fc/\u00f1o\u00f0\u00e9s")
|
|
|
|
|
assert.NotNil(t, f)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPaths_NewFs_Ugly_VerifyIsFs(t *testing.T) {
|
|
|
|
|
f := newFs("/tmp")
|
|
|
|
|
assert.IsType(t, &core.Fs{}, f)
|
|
|
|
|
}
|