Skip to content
Merged
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
27 changes: 12 additions & 15 deletions e2e/create-expert/create-expert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { spawn } from "node:child_process"
import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import { parsePerstackConfig } from "@perstack/perstack-toml"
import { assertEventSequenceContains } from "../lib/assertions.js"
import { extractToolCalls, filterEventsByType } from "../lib/event-parser.js"
import { injectProviderArgs } from "../lib/round-robin.js"
Expand Down Expand Up @@ -123,14 +122,13 @@ describe("create-expert", () => {
expect(toolNames).toContain("writeTextFile")
expect(toolNames).toContain("addDelegateFromConfig")

// Verify perstack.toml was created with valid expert definitions
// Verify perstack.toml was created with at least one expert definition
const tomlPath = path.join(tempDir, "perstack.toml")
expect(fs.existsSync(tomlPath)).toBe(true)
const parsed = parsePerstackConfig(fs.readFileSync(tomlPath, "utf-8"))
expect(parsed.experts).toBeDefined()
expect(Object.keys(parsed.experts as Record<string, unknown>).length).toBeGreaterThanOrEqual(
1,
)
const tomlContent = fs.readFileSync(tomlPath, "utf-8")
const expertMatches = tomlContent.match(/\[experts\."[^"]+"\]/g)
expect(expertMatches).not.toBeNull()
expect(expertMatches!.length).toBeGreaterThanOrEqual(1)
},
LLM_TIMEOUT,
)
Expand Down Expand Up @@ -174,16 +172,15 @@ pick = ["attemptCompletion"]
expect(toolNames).toContain("writeTextFile")
expect(toolNames).toContain("addDelegateFromConfig")

// Verify perstack.toml was updated
// Verify perstack.toml was updated with existing + new experts
const tomlPath = path.join(tempDir, "perstack.toml")
const parsed = parsePerstackConfig(fs.readFileSync(tomlPath, "utf-8"))
expect(parsed.experts).toBeDefined()

const experts = parsed.experts as Record<string, unknown>
const tomlContent = fs.readFileSync(tomlPath, "utf-8")
// Original expert should be preserved
expect(experts["existing-expert"]).toBeDefined()
// New expert should be added
expect(Object.keys(experts).length).toBeGreaterThanOrEqual(2)
expect(tomlContent).toContain('[experts."existing-expert"]')
// New expert should be added (at least 2 expert sections)
const expertMatches = tomlContent.match(/\[experts\."[^"]+"\]/g)
expect(expertMatches).not.toBeNull()
expect(expertMatches!.length).toBeGreaterThanOrEqual(2)
},
LLM_TIMEOUT,
)
Expand Down