relay-flow 0.1.0-alpha.0 → 0.2.1-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +160 -143
  2. package/cmd/relay-flow/commands_test.go +968 -0
  3. package/cmd/relay-flow/main.go +877 -175
  4. package/cmd/relay-flow/scenario_test.go +1310 -0
  5. package/cmd/relay-flow/serve.go +610 -0
  6. package/examples/default-story-workflow.yaml +88 -0
  7. package/go.mod +69 -2
  8. package/go.sum +185 -0
  9. package/internal/config/config.go +88 -0
  10. package/internal/config/machine.go +99 -48
  11. package/internal/config/machine_test.go +248 -0
  12. package/internal/config/merge_test.go +118 -0
  13. package/internal/config/writeatomic.go +36 -0
  14. package/internal/config/writeatomic_test.go +98 -0
  15. package/internal/execution/goworkflows/activities.go +490 -0
  16. package/internal/execution/goworkflows/engine.go +520 -0
  17. package/internal/execution/goworkflows/engine_test.go +660 -0
  18. package/internal/execution/goworkflows/fakes_test.go +509 -0
  19. package/internal/execution/goworkflows/interpreter.go +613 -0
  20. package/internal/execution/goworkflows/logging_test.go +154 -0
  21. package/internal/execution/goworkflows/mailbox_test.go +423 -0
  22. package/internal/execution/goworkflows/node_runtime_integration_test.go +133 -0
  23. package/internal/execution/goworkflows/node_runtime_test.go +510 -0
  24. package/internal/execution/goworkflows/projection.go +504 -0
  25. package/internal/execution/goworkflows/recovery_test.go +1092 -0
  26. package/internal/execution/goworkflows/retry_log_test.go +59 -0
  27. package/internal/execution/goworkflows/retry_projection_test.go +98 -0
  28. package/internal/harness/contract_test.go +174 -0
  29. package/internal/harness/factory.go +63 -0
  30. package/internal/harness/harness.go +41 -0
  31. package/internal/harness/opencode/opencode.go +166 -0
  32. package/internal/harness/opencode/opencode_test.go +50 -0
  33. package/internal/harness/plugin_selection_test.go +126 -0
  34. package/internal/identity/identity.go +37 -0
  35. package/internal/logging/logging.go +56 -0
  36. package/internal/logging/logging_test.go +116 -0
  37. package/internal/paths/paths.go +69 -0
  38. package/internal/recover/recover.go +115 -0
  39. package/internal/repo/poller.go +186 -0
  40. package/internal/repo/poller_test.go +327 -0
  41. package/internal/repo/repo.go +132 -0
  42. package/internal/repo/service.go +216 -0
  43. package/internal/repo/service_test.go +298 -0
  44. package/internal/retry/retry.go +118 -0
  45. package/internal/router/router.go +84 -0
  46. package/internal/router/router_test.go +231 -0
  47. package/internal/run/manager.go +121 -0
  48. package/internal/run/run.go +140 -0
  49. package/internal/run/run_identity_test.go +52 -0
  50. package/internal/run/run_manager_test.go +286 -0
  51. package/internal/runner/contract_test.go +259 -0
  52. package/internal/runner/factory.go +65 -0
  53. package/internal/runner/orca/orca.go +341 -172
  54. package/internal/runner/orca/orca_test.go +256 -143
  55. package/internal/runner/orca/orcacli/orcacli.go +220 -0
  56. package/internal/runner/orca/orcacli/orcacli_test.go +157 -0
  57. package/internal/runner/orca/orcacli/testdata/repo-list.json +18 -0
  58. package/internal/runner/orca/orcacli/testdata/strict-orca.sh +32 -0
  59. package/internal/runner/orca/orcacli/testdata/terminal-close.json +12 -0
  60. package/internal/runner/orca/orcacli/testdata/terminal-create.json +18 -0
  61. package/internal/runner/orca/orcacli/testdata/terminal-list.json +51 -0
  62. package/internal/runner/orca/orcacli/testdata/terminal-send.json +1 -0
  63. package/internal/runner/orca/orcacli/testdata/terminal-show.json +1 -0
  64. package/internal/runner/orca/orcacli/testdata/worktree-create.json +22 -0
  65. package/internal/runner/orca/orcacli/testdata/worktree-list.json +31 -0
  66. package/internal/runner/orca/orcacli/testdata/worktree-remove.json +6 -0
  67. package/internal/runner/runner.go +54 -64
  68. package/internal/server/api_test.go +300 -0
  69. package/internal/server/client.go +192 -74
  70. package/internal/server/fixture_test.go +248 -0
  71. package/internal/server/server.go +425 -248
  72. package/internal/server/shutdown_test.go +116 -0
  73. package/internal/task/auth_test.go +48 -0
  74. package/internal/task/contract_test.go +225 -0
  75. package/internal/task/factory.go +119 -0
  76. package/internal/task/jira/auth.go +183 -0
  77. package/internal/task/jira/auth_test.go +107 -0
  78. package/internal/task/jira/effects_test.go +39 -0
  79. package/internal/task/jira/filters_test.go +254 -0
  80. package/internal/task/jira/helpers_test.go +70 -0
  81. package/internal/task/jira/jira.go +538 -0
  82. package/internal/task/jira/normalize.go +119 -0
  83. package/internal/task/jira/rest/adf.go +128 -0
  84. package/internal/task/jira/rest/client.go +573 -0
  85. package/internal/task/jira/rest/client_test.go +381 -0
  86. package/internal/task/jira/testdata/jira_search_issues.json +120 -0
  87. package/internal/task/jira/transition_defaults_test.go +158 -0
  88. package/internal/task/jira/validation_test.go +94 -0
  89. package/internal/task/task.go +84 -0
  90. package/internal/workflow/report.go +85 -0
  91. package/internal/workflow/report_test.go +259 -0
  92. package/internal/workflow/service.go +142 -0
  93. package/internal/workflow/store.go +136 -0
  94. package/internal/workflow/store_test.go +282 -0
  95. package/internal/workflow/workflow.go +345 -0
  96. package/internal/workflow/workflow_test.go +412 -0
  97. package/package.json +7 -2
  98. package/internal/acli/acli.go +0 -229
  99. package/internal/config/demo_test.go +0 -17
  100. package/internal/config/schema.go +0 -193
  101. package/internal/config/schema_test.go +0 -162
  102. package/internal/daemon/daemon.go +0 -218
  103. package/internal/daemon/daemon_test.go +0 -204
  104. package/internal/discovery/discovery.go +0 -122
  105. package/internal/discovery/discovery_test.go +0 -62
  106. package/internal/opencode/opencode.go +0 -26
  107. package/internal/orcacli/orcacli.go +0 -264
  108. package/internal/runner/orca/README.md +0 -64
  109. package/internal/runner/runner_test.go +0 -64
  110. package/internal/server/server_test.go +0 -195
  111. package/internal/tasks/jira/README.md +0 -69
  112. package/internal/tasks/jira/component_test.go +0 -16
  113. package/internal/tasks/jira/decode.go +0 -24
  114. package/internal/tasks/jira/jira.go +0 -231
  115. package/internal/tasks/jira/jira_test.go +0 -259
  116. package/internal/tasks/jira/jql_test.go +0 -16
  117. package/internal/tasks/tasks.go +0 -90
  118. package/internal/tasks/tasks_test.go +0 -91
@@ -0,0 +1,220 @@
1
+ // Package orcacli wraps the Orca CLI behind a small fakeable interface.
2
+ // Every call is real; there is no dry-run mode.
3
+ package orcacli
4
+
5
+ import (
6
+ "context"
7
+ "encoding/json"
8
+ "errors"
9
+ "fmt"
10
+ "os/exec"
11
+ "regexp"
12
+ "strings"
13
+ )
14
+
15
+ var ErrTerminalUnavailable = errors.New("terminal unavailable")
16
+
17
+ // Repo is an Orca-registered repository.
18
+ type Repo struct {
19
+ ID string `json:"id"`
20
+ DisplayName string `json:"displayName"`
21
+ Path string `json:"path"`
22
+ }
23
+
24
+ // Worktree is an Orca worktree (a runner environment).
25
+ type Worktree struct {
26
+ ID string `json:"id"`
27
+ RepoID string `json:"repoId"`
28
+ DisplayName string `json:"displayName"`
29
+ Branch string `json:"branch"`
30
+ Path string `json:"path"`
31
+ IsMainWorktree bool `json:"isMainWorktree"`
32
+ }
33
+
34
+ // Terminal is a tab's persistent identity: Title is the tab-level title set
35
+ // via --title, which persists — unlike the pane-level title, which the
36
+ // running program resets.
37
+ type Terminal struct {
38
+ Handle string
39
+ Title string
40
+ Connected bool
41
+ }
42
+
43
+ // Client is the fakeable Orca CLI seam used by the Orca runner adapter.
44
+ type Client interface {
45
+ ListRepos(ctx context.Context) ([]Repo, error)
46
+ ListWorktrees(ctx context.Context) ([]Worktree, error)
47
+ CreateWorktree(ctx context.Context, ticketKey, repoID, parentWorktreeID, baseBranch string) error
48
+ SetWorktreeStatus(ctx context.Context, worktreeID, status string) error
49
+ DeleteWorktree(ctx context.Context, worktreeID string) error
50
+ ShowTerminal(ctx context.Context, handle string) (Terminal, error)
51
+ SendTerminal(ctx context.Context, handle, text string) error
52
+ ListTerminals(ctx context.Context, worktree string) ([]Terminal, error)
53
+ CreateTerminal(ctx context.Context, ticketKey, title, command string) (handle string, err error)
54
+ CloseTerminal(ctx context.Context, handle string) error
55
+ }
56
+
57
+ // CLI is the production Client backed by the orca binary.
58
+ type CLI struct{}
59
+
60
+ func New() *CLI { return &CLI{} }
61
+
62
+ func (CLI) ListRepos(ctx context.Context) ([]Repo, error) {
63
+ var res struct {
64
+ Result struct {
65
+ Repos []Repo `json:"repos"`
66
+ } `json:"result"`
67
+ }
68
+ if err := runJSON(ctx, &res, "repo", "list", "--json"); err != nil {
69
+ return nil, fmt.Errorf("orca repo list: %w", err)
70
+ }
71
+ return res.Result.Repos, nil
72
+ }
73
+
74
+ func (CLI) ListWorktrees(ctx context.Context) ([]Worktree, error) {
75
+ var res struct {
76
+ Result struct {
77
+ Worktrees []Worktree `json:"worktrees"`
78
+ } `json:"result"`
79
+ }
80
+ if err := runJSON(ctx, &res, "worktree", "list", "--json"); err != nil {
81
+ return nil, fmt.Errorf("orca worktree list: %w", err)
82
+ }
83
+ return res.Result.Worktrees, nil
84
+ }
85
+
86
+ // CreateWorktree always sets --parent-worktree and --base-branch explicitly
87
+ // (never Orca's inferred defaults) so every ticket worktree has a
88
+ // deliberate, known ancestry.
89
+ func (CLI) CreateWorktree(ctx context.Context, ticketKey, repoID, parentWorktreeID, baseBranch string) error {
90
+ return run(ctx, "worktree", "create", "--name", ticketKey, "--repo", "id:"+repoID,
91
+ "--parent-worktree", "worktree:"+parentWorktreeID, "--base-branch", baseBranch, "--json")
92
+ }
93
+
94
+ func (CLI) SetWorktreeStatus(ctx context.Context, worktreeID, status string) error {
95
+ return run(ctx, "worktree", "set", "--worktree", "id:"+worktreeID, "--workspace-status", status, "--json")
96
+ }
97
+
98
+ // FindExistingBranch returns the first local or remote-tracking branch whose
99
+ // short ref contains ticketKey. The returned ref is suitable for Orca's
100
+ // --base-branch argument.
101
+ func FindExistingBranch(repoPath, ticketKey string) (string, bool, error) {
102
+ out, err := exec.Command("git", "-C", repoPath, "branch", "-a", "--list", "--format=%(refname:short)").CombinedOutput()
103
+ if err != nil {
104
+ return "", false, fmt.Errorf("git branch --list: %w: %s", err, strings.TrimSpace(string(out)))
105
+ }
106
+ match := regexp.MustCompile(regexp.QuoteMeta(ticketKey))
107
+ for _, line := range strings.Split(string(out), "\n") {
108
+ branch := strings.TrimSpace(line)
109
+ if branch != "" && match.MatchString(branch) {
110
+ return branch, true, nil
111
+ }
112
+ }
113
+ return "", false, nil
114
+ }
115
+
116
+ func (CLI) DeleteWorktree(ctx context.Context, worktreeID string) error {
117
+ return run(ctx, "worktree", "rm", "--worktree", "id:"+worktreeID, "--json")
118
+ }
119
+
120
+ func (CLI) ShowTerminal(ctx context.Context, handle string) (Terminal, error) {
121
+ var res struct {
122
+ Result struct {
123
+ Terminal struct {
124
+ Handle string `json:"handle"`
125
+ Title string `json:"title"`
126
+ Connected bool `json:"connected"`
127
+ Writable bool `json:"writable"`
128
+ } `json:"terminal"`
129
+ } `json:"result"`
130
+ }
131
+ if err := runJSON(ctx, &res, "terminal", "show", "--terminal", handle, "--json"); err != nil {
132
+ if strings.Contains(err.Error(), "terminal_handle_stale") {
133
+ return Terminal{}, ErrTerminalUnavailable
134
+ }
135
+ return Terminal{}, fmt.Errorf("orca terminal show: %w", err)
136
+ }
137
+ t := res.Result.Terminal
138
+ return Terminal{Handle: t.Handle, Title: t.Title, Connected: t.Connected && t.Writable}, nil
139
+ }
140
+
141
+ func (CLI) SendTerminal(ctx context.Context, handle, text string) error {
142
+ return run(ctx, "terminal", "send", "--terminal", handle, "--text", text, "--enter", "--json")
143
+ }
144
+
145
+ // ListTerminals returns tabs (with their persistent tab-level title) for a
146
+ // worktree, e.g. "name:PAY-101". --include-visual-layouts is mandatory:
147
+ // orca omits visualLayouts from JSON without it.
148
+ func (CLI) ListTerminals(ctx context.Context, worktree string) ([]Terminal, error) {
149
+ var res struct {
150
+ Result struct {
151
+ VisualLayouts []struct {
152
+ Root struct {
153
+ Tabs []struct {
154
+ Title string `json:"title"`
155
+ Panes struct {
156
+ Handle string `json:"handle"`
157
+ Connected bool `json:"connected"`
158
+ } `json:"panes"`
159
+ } `json:"tabs"`
160
+ } `json:"root"`
161
+ } `json:"visualLayouts"`
162
+ } `json:"result"`
163
+ }
164
+ if err := runJSON(ctx, &res, "terminal", "list", "--worktree", worktree, "--include-visual-layouts", "--json"); err != nil {
165
+ return nil, fmt.Errorf("orca terminal list: %w", err)
166
+ }
167
+ var terms []Terminal
168
+ for _, vl := range res.Result.VisualLayouts {
169
+ for _, tab := range vl.Root.Tabs {
170
+ terms = append(terms, Terminal{Handle: tab.Panes.Handle, Title: tab.Title, Connected: tab.Panes.Connected})
171
+ }
172
+ }
173
+ return terms, nil
174
+ }
175
+
176
+ // CreateTerminal launches the given shell command in a fresh terminal on
177
+ // the ticket's worktree.
178
+ func (CLI) CreateTerminal(ctx context.Context, ticketKey, title, command string) (string, error) {
179
+ var res struct {
180
+ Result struct {
181
+ Terminal struct {
182
+ Handle string `json:"handle"`
183
+ } `json:"terminal"`
184
+ } `json:"result"`
185
+ }
186
+ if err := runJSON(ctx, &res, "terminal", "create",
187
+ "--worktree", "name:"+ticketKey,
188
+ "--title", title,
189
+ "--command", command,
190
+ "--json"); err != nil {
191
+ return "", fmt.Errorf("orca terminal create: %w", err)
192
+ }
193
+ return res.Result.Terminal.Handle, nil
194
+ }
195
+
196
+ func (CLI) CloseTerminal(ctx context.Context, handle string) error {
197
+ return run(ctx, "terminal", "close", "--terminal", handle, "--json")
198
+ }
199
+
200
+ func run(ctx context.Context, args ...string) error {
201
+ cmd := exec.CommandContext(ctx, "orca", args...)
202
+ out, err := cmd.CombinedOutput()
203
+ if err != nil {
204
+ return fmt.Errorf("orca %v: %w: %s", args, err, strings.TrimSpace(string(out)))
205
+ }
206
+ return nil
207
+ }
208
+
209
+ func runJSON(ctx context.Context, dest any, args ...string) error {
210
+ cmd := exec.CommandContext(ctx, "orca", args...)
211
+ out, err := cmd.Output()
212
+ if err != nil {
213
+ // orca prints its JSON error envelope to stdout even on failure.
214
+ return fmt.Errorf("orca %v: %w: %s", args, err, strings.TrimSpace(string(out)))
215
+ }
216
+ if err := json.Unmarshal(out, dest); err != nil {
217
+ return fmt.Errorf("orca %v: parse json: %w", args, err)
218
+ }
219
+ return nil
220
+ }
@@ -0,0 +1,157 @@
1
+ package orcacli
2
+
3
+ import (
4
+ "context"
5
+ "os"
6
+ "os/exec"
7
+ "path/filepath"
8
+ "strings"
9
+ "testing"
10
+ )
11
+
12
+ func TestCLIContractsAgainstCapturedRealOutput(t *testing.T) {
13
+ installStrictFakeOrca(t)
14
+ ctx := context.Background()
15
+ cli := New()
16
+
17
+ repos, err := cli.ListRepos(ctx)
18
+ if err != nil {
19
+ t.Fatal(err)
20
+ }
21
+ if len(repos) != 1 || repos[0].ID != "repo-1" || repos[0].DisplayName != "app" || repos[0].Path != "/srv/app" {
22
+ t.Fatalf("ListRepos = %+v", repos)
23
+ }
24
+
25
+ worktrees, err := cli.ListWorktrees(ctx)
26
+ if err != nil {
27
+ t.Fatal(err)
28
+ }
29
+ if len(worktrees) != 1 || worktrees[0].ID != "wt-main" || worktrees[0].Branch != "refs/heads/master" || !worktrees[0].IsMainWorktree {
30
+ t.Fatalf("ListWorktrees = %+v", worktrees)
31
+ }
32
+
33
+ if err := cli.CreateWorktree(ctx, "PAY-101", "repo-1", "wt-main", "origin/alice/PAY-101"); err != nil {
34
+ t.Fatal(err)
35
+ }
36
+ if err := cli.SetWorktreeStatus(ctx, "wt-PAY-101", "in-review"); err != nil {
37
+ t.Fatal(err)
38
+ }
39
+ if err := cli.DeleteWorktree(ctx, "wt-PAY-101"); err != nil {
40
+ t.Fatal(err)
41
+ }
42
+
43
+ terminals, err := cli.ListTerminals(ctx, "id:wt-PAY-101")
44
+ if err != nil {
45
+ t.Fatal(err)
46
+ }
47
+ if len(terminals) != 1 {
48
+ t.Fatalf("ListTerminals = %+v", terminals)
49
+ }
50
+ if got := terminals[0]; got.Handle != "term-1" || got.Title != "PAY-101:implement" || !got.Connected {
51
+ t.Fatalf("ListTerminals[0] = %+v", got)
52
+ }
53
+ if terminals[0].Title == "opencode" {
54
+ t.Fatal("ListTerminals used mutable pane title instead of stable visualLayouts tab title")
55
+ }
56
+ direct, err := cli.ShowTerminal(ctx, "term-1")
57
+ if err != nil || direct.Handle != "term-1" || !direct.Connected {
58
+ t.Fatalf("ShowTerminal = %+v, %v", direct, err)
59
+ }
60
+ if err := cli.SendTerminal(ctx, "term-1", "hello"); err != nil {
61
+ t.Fatal(err)
62
+ }
63
+
64
+ handle, err := cli.CreateTerminal(ctx, "PAY-101", "PAY-101:implement", "echo hello")
65
+ if err != nil {
66
+ t.Fatal(err)
67
+ }
68
+ if handle != "term-1" {
69
+ t.Fatalf("CreateTerminal handle = %q", handle)
70
+ }
71
+ if err := cli.CloseTerminal(ctx, handle); err != nil {
72
+ t.Fatal(err)
73
+ }
74
+ }
75
+
76
+ func TestStrictFakeOrcaRejectsMissingFlags(t *testing.T) {
77
+ fake := installStrictFakeOrca(t)
78
+ if err := exec.Command(fake, "terminal", "list", "--worktree", "id:wt-PAY-101", "--json").Run(); err == nil {
79
+ t.Fatal("strict fake accepted terminal list without --include-visual-layouts")
80
+ }
81
+ }
82
+
83
+ func TestFindExistingBranchLocalOnly(t *testing.T) {
84
+ repo := newGitRepo(t)
85
+ runGit(t, repo, "branch", "alice/PAY-101")
86
+
87
+ got, ok, err := FindExistingBranch(repo, "PAY-101")
88
+ if err != nil {
89
+ t.Fatal(err)
90
+ }
91
+ if !ok || got != "alice/PAY-101" {
92
+ t.Fatalf("FindExistingBranch = %q, %v; want alice/PAY-101, true", got, ok)
93
+ }
94
+ }
95
+
96
+ func TestFindExistingBranchRemoteOnly(t *testing.T) {
97
+ repo := newGitRepo(t)
98
+ runGit(t, repo, "update-ref", "refs/remotes/origin/alice/PAY-102", "HEAD")
99
+
100
+ got, ok, err := FindExistingBranch(repo, "PAY-102")
101
+ if err != nil {
102
+ t.Fatal(err)
103
+ }
104
+ if !ok || got != "origin/alice/PAY-102" {
105
+ t.Fatalf("FindExistingBranch = %q, %v; want origin/alice/PAY-102, true", got, ok)
106
+ }
107
+ }
108
+
109
+ func TestFindExistingBranchMissing(t *testing.T) {
110
+ repo := newGitRepo(t)
111
+ runGit(t, repo, "branch", "alice/OTHER-1")
112
+
113
+ got, ok, err := FindExistingBranch(repo, "PAY-103")
114
+ if err != nil {
115
+ t.Fatal(err)
116
+ }
117
+ if ok || got != "" {
118
+ t.Fatalf("FindExistingBranch = %q, %v; want empty, false", got, ok)
119
+ }
120
+ }
121
+
122
+ func newGitRepo(t *testing.T) string {
123
+ t.Helper()
124
+ repo := t.TempDir()
125
+ runGit(t, repo, "init", "--quiet")
126
+ runGit(t, repo, "-c", "user.name=Relay Flow", "-c", "user.email=relay-flow@example.invalid", "commit", "--allow-empty", "--quiet", "-m", "initial")
127
+ return repo
128
+ }
129
+
130
+ func runGit(t *testing.T, repo string, args ...string) {
131
+ t.Helper()
132
+ cmdArgs := append([]string{"-C", repo}, args...)
133
+ out, err := exec.Command("git", cmdArgs...).CombinedOutput()
134
+ if err != nil {
135
+ t.Fatalf("git %s: %v: %s", strings.Join(args, " "), err, out)
136
+ }
137
+ }
138
+
139
+ func installStrictFakeOrca(t *testing.T) string {
140
+ t.Helper()
141
+ binDir := t.TempDir()
142
+ fake := filepath.Join(binDir, "orca")
143
+ script, err := os.ReadFile(filepath.Join("testdata", "strict-orca.sh"))
144
+ if err != nil {
145
+ t.Fatal(err)
146
+ }
147
+ if err := os.WriteFile(fake, script, 0o755); err != nil {
148
+ t.Fatal(err)
149
+ }
150
+ fixtureDir, err := filepath.Abs("testdata")
151
+ if err != nil {
152
+ t.Fatal(err)
153
+ }
154
+ t.Setenv("ORCA_FIXTURE_DIR", fixtureDir)
155
+ t.Setenv("PATH", binDir+string(os.PathListSeparator)+os.Getenv("PATH"))
156
+ return fake
157
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "id": "captured-repo-list",
3
+ "ok": true,
4
+ "result": {
5
+ "repos": [
6
+ {
7
+ "id": "repo-1",
8
+ "path": "/srv/app",
9
+ "displayName": "app",
10
+ "kind": "git",
11
+ "externalWorktreeVisibility": "hide",
12
+ "upstream": null,
13
+ "gitRemoteIdentity": null
14
+ }
15
+ ]
16
+ },
17
+ "_meta": {"runtimeId": "runtime-1"}
18
+ }
@@ -0,0 +1,32 @@
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ fixture=
5
+ if [ "$#" -eq 3 ] && [ "$1" = repo ] && [ "$2" = list ] && [ "$3" = --json ]; then
6
+ fixture=repo-list.json
7
+ elif [ "$#" -eq 3 ] && [ "$1" = worktree ] && [ "$2" = list ] && [ "$3" = --json ]; then
8
+ fixture=worktree-list.json
9
+ elif [ "$#" -eq 11 ] && [ "$1" = worktree ] && [ "$2" = create ] && [ "$3" = --name ] && [ "$4" = PAY-101 ] && [ "$5" = --repo ] && [ "$6" = id:repo-1 ] && [ "$7" = --parent-worktree ] && [ "$8" = worktree:wt-main ] && [ "$9" = --base-branch ] && [ "${10}" = origin/alice/PAY-101 ] && [ "${11}" = --json ]; then
10
+ fixture=worktree-create.json
11
+ elif [ "$#" -eq 7 ] && [ "$1" = worktree ] && [ "$2" = set ] && [ "$3" = --worktree ] && [ "$4" = id:wt-PAY-101 ] && [ "$5" = --workspace-status ] && [ "$6" = in-review ] && [ "$7" = --json ]; then
12
+ fixture=worktree-create.json
13
+ elif [ "$#" -eq 5 ] && [ "$1" = worktree ] && [ "$2" = rm ] && [ "$3" = --worktree ] && [ "$4" = id:wt-PAY-101 ] && [ "$5" = --json ]; then
14
+ fixture=worktree-remove.json
15
+ elif [ "$#" -eq 6 ] && [ "$1" = terminal ] && [ "$2" = list ] && [ "$3" = --worktree ] && [ "$4" = id:wt-PAY-101 ] && [ "$5" = --include-visual-layouts ] && [ "$6" = --json ]; then
16
+ fixture=terminal-list.json
17
+ elif [ "$#" -eq 5 ] && [ "$1" = terminal ] && [ "$2" = show ] && [ "$3" = --terminal ] && [ "$4" = term-1 ] && [ "$5" = --json ]; then
18
+ fixture=terminal-show.json
19
+ elif [ "$#" -eq 8 ] && [ "$1" = terminal ] && [ "$2" = send ] && [ "$3" = --terminal ] && [ "$4" = term-1 ] && [ "$5" = --text ] && [ "$6" = 'hello' ] && [ "$7" = --enter ] && [ "$8" = --json ]; then
20
+ fixture=terminal-send.json
21
+ elif [ "$#" -eq 9 ] && [ "$1" = terminal ] && [ "$2" = create ] && [ "$3" = --worktree ] && [ "$4" = name:PAY-101 ] && [ "$5" = --title ] && [ "$6" = PAY-101:implement ] && [ "$7" = --command ] && [ "$8" = 'echo hello' ] && [ "$9" = --json ]; then
22
+ fixture=terminal-create.json
23
+ elif [ "$#" -eq 5 ] && [ "$1" = terminal ] && [ "$2" = close ] && [ "$3" = --terminal ] && [ "$4" = term-1 ] && [ "$5" = --json ]; then
24
+ fixture=terminal-close.json
25
+ else
26
+ printf 'unsupported or malformed orca invocation:' >&2
27
+ printf ' <%s>' "$@" >&2
28
+ printf '\n' >&2
29
+ exit 64
30
+ fi
31
+
32
+ cat "$ORCA_FIXTURE_DIR/$fixture"
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "captured-terminal-close",
3
+ "ok": true,
4
+ "result": {
5
+ "close": {
6
+ "handle": "term-1",
7
+ "tabId": "tab-1",
8
+ "ptyKilled": true
9
+ }
10
+ },
11
+ "_meta": {"runtimeId": "runtime-1"}
12
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "id": "captured-terminal-create",
3
+ "ok": true,
4
+ "result": {
5
+ "terminal": {
6
+ "handle": "term-1",
7
+ "tabId": "tab-1",
8
+ "paneKey": "tab-1:leaf-1",
9
+ "ptyId": "wt-PAY-101@@pty-1",
10
+ "worktreeId": "wt-PAY-101",
11
+ "title": "PAY-101:implement",
12
+ "executionHostId": "local",
13
+ "hostPlatform": "linux",
14
+ "surface": "visible"
15
+ }
16
+ },
17
+ "_meta": {"runtimeId": "runtime-1"}
18
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "id": "captured-terminal-list",
3
+ "ok": true,
4
+ "result": {
5
+ "terminals": [
6
+ {
7
+ "handle": "term-1",
8
+ "ptyId": "wt-PAY-101@@pty-1",
9
+ "worktreeId": "wt-PAY-101",
10
+ "worktreePath": "/srv/worktrees/PAY-101",
11
+ "branch": "refs/heads/alice/PAY-101",
12
+ "tabId": "tab-1",
13
+ "leafId": "leaf-1",
14
+ "title": "opencode",
15
+ "connected": true,
16
+ "writable": true,
17
+ "preview": ""
18
+ }
19
+ ],
20
+ "visualLayouts": [
21
+ {
22
+ "worktreeId": "wt-PAY-101",
23
+ "worktreePath": "/srv/worktrees/PAY-101",
24
+ "root": {
25
+ "type": "group",
26
+ "groupId": "group-1",
27
+ "activeTabId": "tab-1",
28
+ "tabs": [
29
+ {
30
+ "tabId": "tab-1",
31
+ "title": "PAY-101:implement",
32
+ "activeLeafId": "leaf-1",
33
+ "panes": {
34
+ "type": "terminal",
35
+ "handle": "term-1",
36
+ "tabId": "tab-1",
37
+ "leafId": "leaf-1",
38
+ "title": "opencode",
39
+ "connected": true,
40
+ "active": true
41
+ }
42
+ }
43
+ ]
44
+ }
45
+ }
46
+ ],
47
+ "totalCount": 1,
48
+ "truncated": false
49
+ },
50
+ "_meta": {"runtimeId": "runtime-1"}
51
+ }
@@ -0,0 +1 @@
1
+ {"ok":true,"result":{}}
@@ -0,0 +1 @@
1
+ {"ok":true,"result":{"terminal":{"handle":"term-1","title":"PAY-101:implement","connected":true,"writable":true}}}
@@ -0,0 +1,22 @@
1
+ {
2
+ "id": "captured-worktree-create",
3
+ "ok": true,
4
+ "result": {
5
+ "worktree": {
6
+ "id": "wt-PAY-101",
7
+ "instanceId": "instance-PAY-101",
8
+ "repoId": "repo-1",
9
+ "path": "/srv/worktrees/PAY-101",
10
+ "head": "0123456789abcdef",
11
+ "branch": "refs/heads/alice/PAY-101",
12
+ "isBare": false,
13
+ "isMainWorktree": false,
14
+ "displayName": "PAY-101",
15
+ "baseRef": "origin/alice/PAY-101",
16
+ "parentWorktreeId": "wt-main",
17
+ "childWorktreeIds": []
18
+ },
19
+ "warnings": []
20
+ },
21
+ "_meta": {"runtimeId": "runtime-1"}
22
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "id": "captured-worktree-list",
3
+ "ok": true,
4
+ "result": {
5
+ "worktrees": [
6
+ {
7
+ "id": "wt-main",
8
+ "instanceId": "instance-main",
9
+ "repoId": "repo-1",
10
+ "path": "/srv/app",
11
+ "head": "0123456789abcdef",
12
+ "branch": "refs/heads/master",
13
+ "isBare": false,
14
+ "isMainWorktree": true,
15
+ "displayName": "master",
16
+ "parentWorktreeId": null,
17
+ "childWorktreeIds": [],
18
+ "git": {
19
+ "path": "/srv/app",
20
+ "head": "0123456789abcdef",
21
+ "branch": "refs/heads/master",
22
+ "isBare": false,
23
+ "isMainWorktree": true
24
+ }
25
+ }
26
+ ],
27
+ "totalCount": 1,
28
+ "truncated": false
29
+ },
30
+ "_meta": {"runtimeId": "runtime-1"}
31
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "id": "captured-worktree-remove",
3
+ "ok": true,
4
+ "result": {"removed": true},
5
+ "_meta": {"runtimeId": "runtime-1"}
6
+ }