Skip to content

Commit 11afe11

Browse files
committed
Add planner schema
1 parent ffe8c60 commit 11afe11

File tree

16 files changed

+1203
-101
lines changed

16 files changed

+1203
-101
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,38 @@ To add MCP servers to clue:
3333
clue mcp --server-cmd "my-server:npx @modelcontextprotocol/server-everything"
3434
```
3535

36+
## Breaking Changes
37+
38+
> **⚠️ WARNING**: If you have a running clue daemon from a previous version, you must purge it before installing the new version:
39+
40+
1. Disable the systemd service:
41+
42+
```bash
43+
sudo systemctl disable clue
44+
sudo systemctl stop clue
45+
```
46+
47+
2. Identify the clue process:
48+
49+
```bash
50+
ps aux | grep clue
51+
```
52+
53+
3. Kill the process entirely (replace `<PID>` with the actual process ID):
54+
55+
```bash
56+
kill -9 <PID>
57+
```
58+
59+
4. Remove the service file:
60+
61+
```bash
62+
sudo rm /etc/systemd/system/clue.service
63+
sudo systemctl daemon-reload
64+
```
65+
66+
5. Move the existing `conversation.db` from `~/.local/.clue` to `~/.clue` and rename the database to `clue.db`
67+
3668
## Development
3769

3870
```bash
@@ -41,3 +73,4 @@ make # Run the agent
4173
```
4274

4375
[References](./docs/References.md)
76+

agent/agent.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,16 @@ func (a *Agent) executeLocalTool(id, name string, input json.RawMessage) message
195195
if toolDef.IsSubTool {
196196
// Make the subagent invoke tools
197197
toolResultMsg, err := a.runSubagent(id, name, toolDef.Description, input)
198+
// TODO: Exceed limit of 200k tool result. Trying truncation
199+
// 25k is best practice from Anthropic
200+
truncatedResult := a.Sub.llm.TruncateMessage(toolResultMsg, 25000)
198201
if err != nil {
199202
return message.NewToolResultBlock(id, name, err.Error(), true)
200203
}
201204

202205
var final strings.Builder
203206
// Iterating over block type is quite tiring?
204-
for _, content := range toolResultMsg.Content {
207+
for _, content := range truncatedResult.Content {
205208
switch blk := content.(type) {
206209
case message.TextBlock:
207210
final.WriteString(blk.Text)

api/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,4 @@ func (c *Client) GetLatestConversationID() (string, error) {
137137

138138
return conversations[0].ID, nil
139139
}
140+

cmd/interactive.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func interactive(ctx context.Context, convID string, llmClient, llmClientSub inf
5454
}
5555

5656
subllm, err := inference.Init(ctx, llmClientSub)
57-
5857
if err != nil {
5958
return fmt.Errorf("failed to initialize sub-agent LLM: %w", err)
6059
}

cmd/tui.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ import (
2020
)
2121

2222
func tui(ctx context.Context, agent *agent.Agent, conv *conversation.Conversation) error {
23+
ctx, cancel := context.WithCancel(ctx)
24+
defer cancel()
25+
2326
app := tview.NewApplication()
2427

2528
conversationView := tview.NewTextView().
2629
SetDynamicColors(true).
2730
SetWordWrap(true).
2831
SetChangedFunc(func() {
2932
app.Draw()
30-
})
33+
}).ScrollToEnd()
3134

3235
isFirstInput := len(conv.Messages) == 0
3336
if isFirstInput {
@@ -36,14 +39,19 @@ func tui(ctx context.Context, agent *agent.Agent, conv *conversation.Conversatio
3639
} else {
3740
displayConversationHistory(conversationView, conv)
3841
}
39-
4042
relPath := displayRelativePath()
4143

4244
questionInput := tview.NewTextArea()
4345
questionInput.SetTitle("[blue::]Enter to send (ESC to focus conversation)").
4446
SetTitleAlign(tview.AlignLeft).
4547
SetBorder(true).
4648
SetDrawFunc(renderRelativePath(relPath))
49+
questionInput.SetFocusFunc(func() {
50+
questionInput.SetBorderColor(tcell.ColorGreen)
51+
})
52+
questionInput.SetBlurFunc(func() {
53+
questionInput.SetBorderColor(tcell.ColorWhite)
54+
})
4755

4856
spinnerView := tview.NewTextView().
4957
SetDynamicColors(true).
@@ -94,6 +102,8 @@ func tui(ctx context.Context, agent *agent.Agent, conv *conversation.Conversatio
94102
defer ticker.Stop()
95103
for {
96104
select {
105+
case <-ctx.Done():
106+
return
97107
case stop := <-spinCh:
98108
if stop {
99109
// Clear the spinner text to hide it from the UI when the agent finishes processing
@@ -151,7 +161,11 @@ func tui(ctx context.Context, agent *agent.Agent, conv *conversation.Conversatio
151161
return event
152162
})
153163

154-
return app.SetRoot(mainLayout, true).SetFocus(questionInput).Run()
164+
if err := app.SetRoot(mainLayout, true).EnableMouse(true).SetFocus(questionInput).Run(); err != nil {
165+
panic(err)
166+
}
167+
168+
return nil
155169
}
156170

157171
func formatMessage(msg *message.Message) string {

0 commit comments

Comments
 (0)