Skip to content

Commit 0f8d500

Browse files
committed
(human) bunch-o-bug-fixes
1 parent 84f32b3 commit 0f8d500

File tree

13 files changed

+99
-51
lines changed

13 files changed

+99
-51
lines changed

.veg/agents.cue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
package veg
33

44
import (
5-
"github.com/hofstadter-io/hof/.veg/embed" // puke...
5+
"github.com/hofstadter-io/hof/.veg/embed"
66
)
77

8-
// embed the whole package (flat map of path->content)
9-
embeds: embed
10-
embedDir: "./.veg/embed"
8+
// embed the whole dir/package (flat map of path->content)
9+
embeds: embed & { @agentic(embed)}
1110

1211
agents: [string]~(n,_): {
1312
@agentic(agent)
@@ -28,7 +27,7 @@ agents: [string]~(n,_): {
2827

2928
agents: veggie: {
3029
description: string | *"Veggie, a general assistant helpful for any task"
31-
instruction: string | *"system/veggie.md"
30+
instruction: string | *"agents/veggie.md"
3231
tools: [
3332
"cache_put",
3433
"cache_del",

.veg/embed/agents/veggie.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
You are Veggie, a helpful AI assistant built by verdverm. I am going to ask you some questions. Your response should be accurate without hallucination. If you already have all the information you need, complete the task and write the response. When formatting the response, you may use Markdown for richer presentation when appropriate.
1+
You are Veggie, a helpful AI assistant built by verdverm. Your response should be accurate without hallucination. If you already have all the information you need, complete the task and write the response. When formatting the response, use Markdown for richer presentation when appropriate.
22

33
Further guidelines:
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<!-- Current Strategic Plan (Derived from cache key 'planning') -->
22
<planning>
3-
{{ .planning }}
3+
{{ with .planning }}{{.}}{{ end }}
44
</planning>

extensions/vscode/extension/src/comms/websocket.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function setupWebSocketHandlers(socket: WebSocket) {
7676
const messageStr = data.toString();
7777
try {
7878
const msg: Message<unknown> = JSON.parse(messageStr);
79-
// console.log(`[SERVER]:`, msg);
79+
console.log(`[SERVER]:`, msg);
8080
extensionEmitter.fire(msg);
8181
} catch (e) {
8282
console.error('Error parsing server message', e);
@@ -112,7 +112,7 @@ export function sendMessage<T>(msg: Message<T>) {
112112
vscode.window.showErrorMessage('Server not connected. (sendMessage)');
113113
return;
114114
}
115-
// console.log(`[VSCODE]:`, msg);
115+
console.log(`[VSCODE]:`, msg);
116116
ws.send(JSON.stringify(msg));
117117
}
118118

extensions/vscode/webviews/chat/src/components/Events/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export const Events = ({
4343
return (
4444
<div className="grow flex flex-col mx-2 gap-1 overflow-y">
4545
{merged?.map((e: any, pos: number) => {
46+
if (!e) {
47+
return null
48+
}
4649
return (
4750
<div className={cn(pos === currPos && "bg-violet-500/30 rounded")}>
4851
<Event pos={pos} key={e.ID} evt={e} />

extensions/vscode/webviews/chat/src/components/SessionSparklines.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const SessionSparklines: React.FC<SessionSparklinesProps> = ({ events })
1212
return null;
1313
}
1414

15-
const { usages } = processEvents(events);
15+
const { merged } = processEvents(events);
1616

1717
const cached: number[] = [];
1818
const prompt: number[] = [];
@@ -22,7 +22,13 @@ export const SessionSparklines: React.FC<SessionSparklinesProps> = ({ events })
2222
const output: number[] = [];
2323
const totals: number[] = [];
2424

25-
usages?.forEach((u) => {
25+
const verts: any[] = [];
26+
const ticks: any[] = [];
27+
const meta: any[] = [];
28+
let idx = 0;
29+
30+
merged?.forEach((e, originalIndex) => {
31+
const u = e?.UsageMetadata
2632
const c = u?.cachedContentTokenCount || 0;
2733
const p = u?.promptTokenCount || 0;
2834
const i = p - c;
@@ -37,18 +43,7 @@ export const SessionSparklines: React.FC<SessionSparklinesProps> = ({ events })
3743
writes.push(w);
3844
output.push(o);
3945
totals.push(T);
40-
});
41-
42-
if (totals.length < 2) {
43-
return null
44-
}
4546

46-
const verts: any[] = [];
47-
const ticks: any[] = [];
48-
const meta: any[] = [];
49-
let idx = 0;
50-
events?.forEach((e, originalIndex) => {
51-
// console.log("Sparklines.event", e)
5247
const isUser = e.Author === "user";
5348
const hasUsage = e.Author !== "user" && e.UsageMetadata;
5449
const parts = e.Content?.parts || [];
@@ -106,10 +101,20 @@ export const SessionSparklines: React.FC<SessionSparklinesProps> = ({ events })
106101
}
107102

108103
meta.push({ index: originalIndex, title, className: titleColor });
109-
idx++;
110104
}
105+
idx++;
111106
});
112107

108+
if (totals.length < 2) {
109+
return null
110+
}
111+
112+
// console.log("sparkline input:", {
113+
// verts,
114+
// ticks,
115+
// meta,
116+
// })
117+
113118
const lines = [
114119
{ value: 0, className: "stroke-white" },
115120
{ value: 25000, className: "stroke-yellow-400" },

extensions/vscode/webviews/chat/src/components/UserInput/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ export const UserInput = () => {
6565
useEffect(() =>{
6666
if (session.events && session.events.length > 1) {
6767
const last = session.events[session.events.length-1] as any
68-
console.log("considering last message...", last, last["TurnComplete"])
69-
if (last["TurnComplete"] === true) {
70-
setWorking(false)
68+
if (!!last) {
69+
console.log("considering last message...", last, last["TurnComplete"])
70+
if (last["TurnComplete"] === true) {
71+
setWorking(false)
72+
}
7173
}
7274
}
7375
}, [session?.events])

extensions/vscode/webviews/chat/src/lib/utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ export function processEvents(events: any[]):{
1515
var merged: any[] = []
1616
var usages: any[] = []
1717
events?.forEach((E1: any, e1: number) => {
18-
if (E1.Author !== "user" && E1.UsageMetadata) {
18+
if (E1?.Author !== "user" && E1?.UsageMetadata) {
1919
usages.push(E1.UsageMetadata)
2020
}
21+
var didMerge: boolean = false
2122
// loop over earlier events
2223
for (var e2 = e1-1; e2 >= 0; e2--) {
2324
const E2 = merged[e2]
@@ -26,7 +27,7 @@ export function processEvents(events: any[]):{
2627
continue
2728
}
2829
// if we have a matching invocation id, lets do some matching
29-
if (E1.InvocationID === E2.InvocationID) {
30+
if (E1?.InvocationID === E2?.InvocationID) {
3031
const P1 = E1?.Content?.parts
3132
if (!P1) {
3233
continue
@@ -43,6 +44,7 @@ export function processEvents(events: any[]):{
4344
continue
4445
}
4546
E2.Content.parts[pi2].functionResponse = p1.functionResponse
47+
didMerge = true
4648
// console.log("MATCH!", ej.InvocationID, ej, merged[j], pi[0], pj[0])
4749
break;
4850
}
@@ -51,7 +53,9 @@ export function processEvents(events: any[]):{
5153
break;
5254
}
5355
}
54-
merged.push(E1)
56+
if (!didMerge) {
57+
merged.push(E1)
58+
}
5559
})
5660

5761

lib/agent/agents/cue.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ func LoadAgent(cfg *config.Config, agentName string) (config.Agent, error) {
3434

3535
// merge MDs: global < agent
3636
mds := make(map[string]string)
37-
maps.Copy(mds, cfg.AgentsMD)
38-
maps.Copy(mds, agt.AgentsMD)
37+
maps.Copy(mds, cfg.AgentsMD) // from config (global)
38+
maps.Copy(mds, agt.AgentsMD) // from agent (per-agent)
3939
agt.AgentsMD = mds
4040

4141
return agt, nil
4242
}
4343

44-
// this needs to be supported through a heirachy of unification
44+
// this needs to be supported through a hierarchy of unification
4545
// dir, project, user, org... with modules and per-request
4646
// (hence the CUE, still todo for more CUEism in memory ^^)
4747

48-
// just cause this file is open... randome thought
48+
// just cause this file is open... random thought
4949
//
5050
// 1. I have left stuff like this all over the code, should build a specialized agent for this
5151
// 2. Why not build an agent (team) that can...
@@ -416,7 +416,7 @@ func RenderInstructionsWithNameAndState(cfg *config.Config, agt config.Agent, na
416416
return "", err
417417
}
418418

419-
// debugPrintData(data)
419+
debugPrintData(data)
420420

421421
// render instruction (first time) to get length
422422
b, err := t.Render(data)

lib/agent/config/types.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import (
77

88
func NewConfig() *Config {
99
return &Config{
10-
Models: make(map[string]Model),
11-
Agents: make(map[string]Agent),
12-
Tools: make(map[string]Tool),
13-
Toolsets: make(map[string]Toolset),
14-
Environs: make(map[string]Environ),
15-
Embeds: make(map[string]any),
16-
EmbedDir: ".veg/embed", // temp default, we need both local and imported through CUE (or maybe just the later)
17-
AgentsMD: make(map[string]string),
10+
Models: make(map[string]Model),
11+
Agents: make(map[string]Agent),
12+
Tools: make(map[string]Tool),
13+
Toolsets: make(map[string]Toolset),
14+
Environs: make(map[string]Environ),
15+
Embeds: make(map[string]string),
16+
EmbedDir: ".veg/embed", // temp default, we need both local and imported through CUE (or maybe just the later)
17+
AgentsMD: make(map[string]string),
18+
Templates: make(templates.TemplateMap),
1819
}
1920
}
2021

@@ -25,8 +26,8 @@ type Config struct {
2526
Toolsets map[string]Toolset `json:"toolsets"`
2627
Environs map[string]Environ `json:"environs"`
2728

28-
Embeds map[string]any `json:"embeds"`
29-
EmbedDir string `json:"embedDir"`
29+
Embeds map[string]string `json:"embeds"`
30+
EmbedDir string `json:"embedDir"`
3031

3132
// agents instruction files not tied to a project / dir / env?
3233
AgentsMD map[string]string `json:"agentsMD"`

0 commit comments

Comments
 (0)