refactor: migrate core/agent to Core primitives — reference implementation
Phase 1: go-io/go-log → core.Fs{}, core.E(), core.Error/Info/Warn
Phase 2: strings/fmt → core.Contains, core.Sprintf, core.Split etc
Phase 3: embed.FS → core.Mount/core.Embed, core.Extract
Phase 4: cmd/main.go → core.Command(), c.Cli().Run(), no cli package
All packages migrated:
- pkg/lib (Codex): core.Mount, core.Extract, Result returns, AX comments
- pkg/setup (Codex): core.Fs, core.E, fixed missing lib helpers
- pkg/brain (Codex): Core primitives, AX comments
- pkg/monitor (Codex): Core string/logging primitives
- pkg/agentic (Codex): 20 files, Core primitives throughout
- cmd/main.go: pure Core CLI, no fmt/log/filepath/strings/cli
Remaining stdlib: path/filepath (Core doesn't wrap OS paths),
fmt.Sscanf/strings.Map (no Core equivalent).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 06:13:41 +00:00
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
|
|
|
|
package setup
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestDetect_Good(t *testing.T) {
|
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
require.True(t, fs.WriteMode(filepath.Join(dir, "go.mod"), "module example.com/test\n", 0644).OK)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, TypeGo, Detect(dir))
|
|
|
|
|
assert.Equal(t, []ProjectType{TypeGo}, DetectAll(dir))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGenerateBuildConfig_Good(t *testing.T) {
|
|
|
|
|
cfg, err := GenerateBuildConfig("/tmp/example", TypeGo)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
assert.Contains(t, cfg, "# example build configuration")
|
|
|
|
|
assert.Contains(t, cfg, "project:")
|
|
|
|
|
assert.Contains(t, cfg, "name: example")
|
|
|
|
|
assert.Contains(t, cfg, "type: go")
|
|
|
|
|
assert.Contains(t, cfg, "main: ./cmd/example")
|
|
|
|
|
assert.Contains(t, cfg, "cgo: false")
|
|
|
|
|
}
|
|
|
|
|
|
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 TestParseGitRemote_Good(t *testing.T) {
|
|
|
|
|
tests := map[string]string{
|
|
|
|
|
"https://github.com/dAppCore/go-io.git": "dAppCore/go-io",
|
|
|
|
|
"git@github.com:dAppCore/go-io.git": "dAppCore/go-io",
|
|
|
|
|
"ssh://git@forge.lthn.ai:2223/core/agent.git": "core/agent",
|
|
|
|
|
"ssh://git@forge.lthn.ai:2223/core/agent": "core/agent",
|
|
|
|
|
"git@forge.lthn.ai:core/agent.git": "core/agent",
|
|
|
|
|
"/srv/git/core/agent.git": "srv/git/core/agent",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for remote, want := range tests {
|
|
|
|
|
assert.Equal(t, want, parseGitRemote(remote), remote)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestParseGitRemote_Bad(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "", parseGitRemote(""))
|
|
|
|
|
assert.Equal(t, "", parseGitRemote("origin"))
|
|
|
|
|
}
|
|
|
|
|
|
refactor: migrate core/agent to Core primitives — reference implementation
Phase 1: go-io/go-log → core.Fs{}, core.E(), core.Error/Info/Warn
Phase 2: strings/fmt → core.Contains, core.Sprintf, core.Split etc
Phase 3: embed.FS → core.Mount/core.Embed, core.Extract
Phase 4: cmd/main.go → core.Command(), c.Cli().Run(), no cli package
All packages migrated:
- pkg/lib (Codex): core.Mount, core.Extract, Result returns, AX comments
- pkg/setup (Codex): core.Fs, core.E, fixed missing lib helpers
- pkg/brain (Codex): Core primitives, AX comments
- pkg/monitor (Codex): Core string/logging primitives
- pkg/agentic (Codex): 20 files, Core primitives throughout
- cmd/main.go: pure Core CLI, no fmt/log/filepath/strings/cli
Remaining stdlib: path/filepath (Core doesn't wrap OS paths),
fmt.Sscanf/strings.Map (no Core equivalent).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 06:13:41 +00:00
|
|
|
func TestRun_Good(t *testing.T) {
|
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
require.True(t, fs.WriteMode(filepath.Join(dir, "go.mod"), "module example.com/test\n", 0644).OK)
|
|
|
|
|
|
|
|
|
|
err := Run(Options{Path: dir})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
build := fs.Read(filepath.Join(dir, ".core", "build.yaml"))
|
|
|
|
|
require.True(t, build.OK)
|
|
|
|
|
assert.Contains(t, build.Value.(string), "type: go")
|
|
|
|
|
|
|
|
|
|
test := fs.Read(filepath.Join(dir, ".core", "test.yaml"))
|
|
|
|
|
require.True(t, test.OK)
|
|
|
|
|
assert.Contains(t, test.Value.(string), "go test ./...")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestRun_TemplateAlias_Good(t *testing.T) {
|
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
require.True(t, fs.WriteMode(filepath.Join(dir, "go.mod"), "module example.com/test\n", 0644).OK)
|
|
|
|
|
|
|
|
|
|
err := Run(Options{Path: dir, Template: "agent"})
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
prompt := fs.Read(filepath.Join(dir, "PROMPT.md"))
|
|
|
|
|
require.True(t, prompt.OK)
|
|
|
|
|
assert.Contains(t, prompt.Value.(string), "This workspace was scaffolded by pkg/setup.")
|
|
|
|
|
}
|