oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package fakeclaude
2
3import (
4 "reflect"
5 "testing"
6)
7
8// The Assistant's tool words: look with or without a query, describe an
9// operation, use one with a JSON input, and read an attached file.
10func TestAssistantToolWords(t *testing.T) {
11 for _, c := range []struct {
12 name, arg string
13 want map[string]any
14 }{
15 {"look", "", map[string]any{}},
16 {"look", "notes", map[string]any{"query": "notes"}},
17 {"describe", "team_request", map[string]any{"operation": "team_request"}},
18 {"use", `team_request|{"words":"fix it"}`, map[string]any{"operation": "team_request", "input": map[string]any{"words": "fix it"}}},
19 {"use", "base_people", map[string]any{"operation": "base_people", "input": map[string]any{}}},
20 {"read_attachment", "/workspace/attachments/at_abcdefgh/notes.md", map[string]any{"path": "/workspace/attachments/at_abcdefgh/notes.md"}},
21 } {
22 if got := ToolInput(c.name, c.arg); !reflect.DeepEqual(got, c.want) {
23 t.Errorf("%s:%s = %v, want %v", c.name, c.arg, got, c.want)
24 }
25 }
26}
27
28// A job's news steers the fake Assistant by what it says: a question is
29// answered with team_reply, a stop with nudges left is nudged with the
30// person's quoted words (and the rot13 context in them, decoded), a stop
31// it cannot get past is "It stopped.", and other news is left alone.
32func TestAssistantJobNews(t *testing.T) {
33 head := "[News about one of the person's jobs, from the system.]\nJob \"Fixing \\\"it\\\"\" (request h_abc123).\n"
34 words := "The person asked for it in these words: \"Do it nudge:gbby:ernq_gnfx:$gnfx gbby:fgneg_gnfx:$gnfx|Tb.\"\n"
35 for _, c := range []struct {
36 name, prompt, steer, reply string
37 ok bool
38 }{
39 {"options", head + words + "The work on it has a question: \"Which page?\"\nThe answer must be one of: \"Sign \\\"in\\\"\", \"Home\"\n", `tool:use:team_reply|{"answer":"Sign \"in\"","request":"h_abc123"}`, "", true},
40 {"free", head + words + "The work on it has a question: \"Which words? answer: Sign in now\"\n", `tool:use:team_reply|{"answer":"Sign in now","request":"h_abc123"}`, "", true},
41 {"no work", head + words + "It stopped before any work started. Push it through. Nudges left: 2. Say nothing.\n", `tool:use:team_nudge|{"context":"tool:read_task:\u0024task\ntool:start_task:\u0024task|Go.","request":"h_abc123","words":"Do it nudge:gbby:ernq_gnfx:\u0024gnfx gbby:fgneg_gnfx:\u0024gnfx|Tb."}`, "", true},
42 {"failed", head + "The person asked for it in these words: \"Fix it\"\nA step of it failed and can be tried again. Nudges left: 1.\n", `tool:use:team_nudge|{"request":"h_abc123","words":"Fix it"}`, "", true},
43 {"spent", head + words + "It stopped before any work started. Nudges left: 0.\n", "", "", false},
44 {"no nudges", head + words + "It stopped again and no nudges are left.\n", "", "It stopped.", true},
45 {"person", head + words + "It stopped, and only the person can move it on: it needs access.\n", "", "It stopped.", true},
46 {"ready", head + words + "It is ready for the person to try.\n", "", "", false},
47 {"not news", "Newest message:\nThe work on it has a question: \"x\"", "", "", false},
48 } {
49 steer, reply, ok := news(c.prompt)
50 if steer != c.steer || reply != c.reply || ok != c.ok {
51 t.Errorf("%s: news = %q, %q, %v; want %q, %q, %v", c.name, steer, reply, ok, c.steer, c.reply, c.ok)
52 }
53 // What the fake then calls is the operation with that input.
54 if m := toolWord.FindStringSubmatch(steer); steer != "" && (m == nil || m[1] != "use" || ToolInput(m[1], m[2])["input"] == nil) {
55 t.Errorf("%s: steer %q is no use word", c.name, steer)
56 }
57 }
58}
59