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"
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestCoreRoot_Good_EnvVar(t *testing.T) {
|
|
|
|
|
t.Setenv("CORE_WORKSPACE", "/tmp/test-core")
|
|
|
|
|
assert.Equal(t, "/tmp/test-core", CoreRoot())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCoreRoot_Good_Fallback(t *testing.T) {
|
|
|
|
|
t.Setenv("CORE_WORKSPACE", "")
|
|
|
|
|
home, _ := os.UserHomeDir()
|
|
|
|
|
assert.Equal(t, home+"/Code/.core", CoreRoot())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestWorkspaceRoot_Good(t *testing.T) {
|
|
|
|
|
t.Setenv("CORE_WORKSPACE", "/tmp/test-core")
|
|
|
|
|
assert.Equal(t, "/tmp/test-core/workspace", WorkspaceRoot())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPlansRoot_Good(t *testing.T) {
|
|
|
|
|
t.Setenv("CORE_WORKSPACE", "/tmp/test-core")
|
|
|
|
|
assert.Equal(t, "/tmp/test-core/plans", PlansRoot())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAgentName_Good_EnvVar(t *testing.T) {
|
|
|
|
|
t.Setenv("AGENT_NAME", "clotho")
|
|
|
|
|
assert.Equal(t, "clotho", AgentName())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAgentName_Good_Fallback(t *testing.T) {
|
|
|
|
|
t.Setenv("AGENT_NAME", "")
|
|
|
|
|
name := AgentName()
|
|
|
|
|
assert.True(t, name == "cladius" || name == "charon", "expected cladius or charon, got %s", name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGitHubOrg_Good_EnvVar(t *testing.T) {
|
|
|
|
|
t.Setenv("GITHUB_ORG", "myorg")
|
|
|
|
|
assert.Equal(t, "myorg", GitHubOrg())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGitHubOrg_Good_Fallback(t *testing.T) {
|
|
|
|
|
t.Setenv("GITHUB_ORG", "")
|
|
|
|
|
assert.Equal(t, "dAppCore", GitHubOrg())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBaseAgent_Good(t *testing.T) {
|
|
|
|
|
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"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestExtractPRNumber_Good(t *testing.T) {
|
|
|
|
|
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"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestExtractPRNumber_Bad_Empty(t *testing.T) {
|
|
|
|
|
assert.Equal(t, 0, extractPRNumber(""))
|
|
|
|
|
assert.Equal(t, 0, extractPRNumber("https://forge.lthn.ai/core/agent/pulls/"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestTruncate_Good(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "hello", truncate("hello", 10))
|
|
|
|
|
assert.Equal(t, "hel...", truncate("hello world", 3))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCountFindings_Good(t *testing.T) {
|
|
|
|
|
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"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestParseRetryAfter_Good(t *testing.T) {
|
|
|
|
|
d := parseRetryAfter("please try after 4 minutes and 56 seconds")
|
|
|
|
|
assert.InDelta(t, 296.0, d.Seconds(), 1.0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestParseRetryAfter_Good_MinutesOnly(t *testing.T) {
|
|
|
|
|
d := parseRetryAfter("try after 5 minutes")
|
|
|
|
|
assert.InDelta(t, 300.0, d.Seconds(), 1.0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestParseRetryAfter_Bad_NoMatch(t *testing.T) {
|
|
|
|
|
d := parseRetryAfter("some random text")
|
|
|
|
|
assert.InDelta(t, 300.0, d.Seconds(), 1.0) // defaults to 5 min
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestResolveHost_Good(t *testing.T) {
|
|
|
|
|
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"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestResolveHost_Good_CustomPort(t *testing.T) {
|
|
|
|
|
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"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestExtractJSONField_Good(t *testing.T) {
|
|
|
|
|
json := `[{"url":"https://github.com/dAppCore/go-io/pull/1"}]`
|
|
|
|
|
assert.Equal(t, "https://github.com/dAppCore/go-io/pull/1", extractJSONField(json, "url"))
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
func TestExtractJSONField_Good_Object(t *testing.T) {
|
|
|
|
|
json := `{"url":"https://github.com/dAppCore/go-io/pull/2"}`
|
|
|
|
|
assert.Equal(t, "https://github.com/dAppCore/go-io/pull/2", extractJSONField(json, "url"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestExtractJSONField_Good_PrettyPrinted(t *testing.T) {
|
|
|
|
|
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"))
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
func TestExtractJSONField_Bad_Missing(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "", extractJSONField(`{"name":"test"}`, "url"))
|
|
|
|
|
assert.Equal(t, "", extractJSONField("", "url"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestValidPlanStatus_Good(t *testing.T) {
|
|
|
|
|
assert.True(t, validPlanStatus("draft"))
|
|
|
|
|
assert.True(t, validPlanStatus("in_progress"))
|
|
|
|
|
assert.True(t, validPlanStatus("draft"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestValidPlanStatus_Bad(t *testing.T) {
|
|
|
|
|
assert.False(t, validPlanStatus("invalid"))
|
|
|
|
|
assert.False(t, validPlanStatus(""))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGeneratePlanID_Good(t *testing.T) {
|
|
|
|
|
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"))
|
|
|
|
|
}
|