zot/packages/agent/modes/study_test.go
patriceckhart fa7d8d8be5 refactor: split source into packages/{provider,core,tui,agent}
Single Go module, four top-level packages under packages/. Import
paths become github.com/patriceckhart/zot/packages/<name>; downstream
consumers can depend on individual packages without pulling the rest.

Layout:
  packages/provider/     LLM clients + catalog
  packages/provider/auth/ credential store + OAuth + login server
  packages/core/         agent loop, sessions, cost
  packages/tui/          terminal toolkit + chat view
  packages/agent/        CLI wiring, system prompt
    extensions/ extproto/ modes/ tools/ skills/ swarm/
    sdk/  (was pkg/zotcore, package renamed zotcore -> sdk)
    ext/  (was pkg/zotext, package renamed zotext -> ext)

internal/ and pkg/ removed. The internal/assets logo moved into
packages/provider/auth/assets.

Public Go SDK identifiers renamed:
  pkg/zotcore (package zotcore) -> packages/agent/sdk (package sdk)
  pkg/zotext  (package zotext)  -> packages/agent/ext (package ext)

This breaks Go-based extensions and embedders; the JSON wire protocol
for extensions and RPC is unchanged, so non-Go extensions, already-
built extension binaries, and zot rpc consumers are unaffected.

Docs, examples, and the built-in write-zot-extension skill updated
for the new paths and identifiers. Shadow-bug fixes in code samples
(ext := ext.New -> e := ext.New).
2026-05-27 09:07:15 +02:00

84 lines
2 KiB
Go

package modes
import (
"os"
"path/filepath"
"testing"
)
func TestBuildStudyPrompt(t *testing.T) {
tmp := t.TempDir()
subdir := filepath.Join(tmp, "internal")
if err := os.Mkdir(subdir, 0o755); err != nil {
t.Fatal(err)
}
file := filepath.Join(tmp, "main.go")
if err := os.WriteFile(file, []byte("package main\n"), 0o644); err != nil {
t.Fatal(err)
}
cases := []struct {
name string
arg string
cwd string
want string
}{
{
name: "empty arg keeps the original cwd prompt",
arg: "",
cwd: tmp,
want: "Read and understand everything in the current directory.",
},
{
name: "relative dir becomes a directory prompt",
arg: "internal",
cwd: tmp,
want: "Read and understand everything in the directory internal.",
},
{
name: "absolute dir under cwd is shown as a relative path",
arg: subdir,
cwd: tmp,
want: "Read and understand everything in the directory internal.",
},
{
name: "relative file becomes a file prompt",
arg: "main.go",
cwd: tmp,
want: "Read and understand the file main.go.",
},
{
name: "absolute file under cwd is shown as a relative path",
arg: file,
cwd: tmp,
want: "Read and understand the file main.go.",
},
{
name: "missing path falls back to the directory phrasing",
arg: "does-not-exist",
cwd: tmp,
want: "Read and understand everything in the directory does-not-exist.",
},
{
name: "absolute path outside cwd keeps its absolute form",
arg: subdir,
cwd: filepath.Join(tmp, "elsewhere"),
want: "Read and understand everything in the directory " + subdir + ".",
},
{
name: "leading and trailing whitespace are stripped",
arg: " main.go ",
cwd: tmp,
want: "Read and understand the file main.go.",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got := buildStudyPrompt(tc.arg, tc.cwd)
if got != tc.want {
t.Fatalf("buildStudyPrompt(%q, %q)\n got: %q\n want: %q", tc.arg, tc.cwd, got, tc.want)
}
})
}
}