Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions go/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,28 @@ func TestScriptFile(t *testing.T) {
socketPath, stop, _ := startTestDaemon(t)
defer stop()

cmd := exec.Command(os.Args[0], "--socket", socketPath, "testdata/compute.jl")
cmd.Env = append(os.Environ(), "TEST_CLI=1")
out, err := cmd.Output()
stderr := ""
if err != nil {
cwd, err := os.Getwd()
require.NoError(t, err)
scriptPath := filepath.Join(cwd, "testdata", "compute.jl")
scriptDir := filepath.Dir(scriptPath)
expected := "42\n" + scriptPath + "\n" + scriptDir

run := func(arg string) string {
t.Helper()
cmd := exec.Command(os.Args[0], "--socket", socketPath, arg)
cmd.Env = append(os.Environ(), "TEST_CLI=1")
cmd.Dir = cwd
out, err := cmd.Output()
stderr := ""
if e, ok := err.(*exec.ExitError); ok {
stderr = string(e.Stderr)
}
require.NoErrorf(t, err, "stderr:\n%s", stderr)
return string(out)
}
require.NoErrorf(t, err, "script stderr:\n%s", stderr)
require.Equal(t, "42\n", string(out))

require.Equal(t, expected, run(scriptPath), "absolute path")
require.Equal(t, expected, run("testdata/compute.jl"), "relative path resolved against client cwd")
}

func TestPrintResult(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ func main() {
}

default:
b, err := os.ReadFile(args[0])
if err == nil {
cmdEval(*socketFlag, string(b), *projectFlag, *sessionFlag, *timeoutFlag, *juliaCmdFlag, false, *freshFlag, *traceFlag)
if _, err := os.Stat(args[0]); err == nil {
code := fmt.Sprintf("cd(%q) do; Base.include(Main, %q); end", mustGetwd(), args[0])
cmdEval(*socketFlag, code, *projectFlag, *sessionFlag, *timeoutFlag, *juliaCmdFlag, false, *freshFlag, *traceFlag)
return
}
fmt.Fprintf(os.Stderr, "unknown command: %s\n", args[0])
Expand Down
2 changes: 1 addition & 1 deletion go/testdata/compute.jl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
println(6 * 7)
print(6 * 7, "\n", @__FILE__, "\n", @__DIR__)
9 changes: 6 additions & 3 deletions skills/julia-client/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ description: "Evaluate Julia in long-lived background sessions so imports, varia

## Preferred workflow

Treat `julia-client` like persistent REPL: run setup once with `julia-client -E 'using MyPackage; x = load_fixture()'`, then `julia-client -E 'MyPackage.transform(x)'` to display results while reusing session. After editing package code, `Revise` automatically updates definitions. Do not repeat imports, fixture setup, or `--project=.` for the current directory.
Treat `julia-client` like persistent REPL: run setup once with `julia-client -E 'using MyPackage; x = load_fixture()'`, then `julia-client -E 'MyPackage.transform(x)'` to display results while reusing session. After editing package code, `Revise` automatically updates definitions.

- Don't repeat yourself: avoid repeating same setup in every command.
- Use `--fresh` flag for struct revision (Revise disables by default) or when clean state is required.
- Don't repeat yourself
- Import packages once per session; later calls should use already-loaded names.
- Avoid repeating fixture/setup code in every command.
- Session routing: `--session LABEL` > `--project PROJECT`; default to `--project=@.` when omit both.
- Avoid `--fresh` unless changing struct/type definitions or requiring clean state.

## Other Examples

Expand Down
Loading