Skip to content

Commit 66db921

Browse files
committed
ix(lint): fix 10 TypeScript errors across 3 test files and example
sandbox-handle.test.ts: remove stale mockCtx second argument from all execute() calls — ToolDef.execute was refactored to single-arg in v1.3. cli-coordination-view.test.ts + cli-ui.test.ts: type stderrSpy as MockInstance<(...args: any[]) => any> to resolve overload conflict on process.stderr.write. examples/consensus-debate.ts: update to current v1.3 API — createOrchestrator returns { engine } not { orchestrator }, constructor no longer takes positional args, runDebate → executeClashDebate, engine.formatReport → formatDebateReport, provider 'grok' → 'xai'.
1 parent cfc31ec commit 66db921

4 files changed

Lines changed: 37 additions & 43 deletions

File tree

examples/consensus-debate.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* consensus-debate.ts — run a multi-persona debate programmatically.
33
*
4-
* Runs ClashEngine.runDebate with 3 personas × 2 rounds on a topic
4+
* Runs ClashEngine.executeClashDebate with 3 personas × 2 rounds on a topic
55
* passed as argv[2]. Prints the structured report at the end.
66
*
77
* ⚠ This calls the real LLM provider and will cost tokens.
@@ -12,7 +12,12 @@
1212
* pnpm tsx examples/consensus-debate.ts "Should we adopt Rust?"
1313
*/
1414

15-
import { ClashEngine, BUILT_IN_PERSONAS, createOrchestrator, resolveApiKey } from '../src/index.js'
15+
import {
16+
createOrchestrator,
17+
formatDebateReport,
18+
BUILT_IN_PERSONAS,
19+
resolveApiKey,
20+
} from '../src/index.js'
1621

1722
async function main(): Promise<void> {
1823
const topic = process.argv[2] ?? 'Should we prefer SQL over NoSQL for a new social network?'
@@ -27,23 +32,19 @@ async function main(): Promise<void> {
2732
console.log('Personas available:', Object.keys(BUILT_IN_PERSONAS).join(', '))
2833
console.log()
2934

30-
const { orchestrator } = createOrchestrator({
35+
const { engine } = createOrchestrator({
3136
defaultModel: 'grok-4',
32-
defaultProvider: 'grok',
37+
defaultProvider: 'xai',
3338
defaultApiKey: apiKey,
3439
})
35-
const engine = new ClashEngine('grok-4', 'grok')
36-
37-
const result = await engine.runDebate(
38-
{
39-
topic,
40-
rounds: 2,
41-
personas: ['pragmatist', 'elegance-purist', 'security-maximalist'],
42-
},
43-
orchestrator,
44-
)
45-
46-
console.log('\n' + engine.formatReport(result))
40+
41+
const result = await engine.executeClashDebate({
42+
topic,
43+
rounds: 2,
44+
personas: ['pragmatist', 'elegance-purist', 'security-maximalist'],
45+
})
46+
47+
console.log('\n' + formatDebateReport(result))
4748
}
4849

4950
main().catch((err) => {

test/cli-coordination-view.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* freezeCoordinationView) in non-interactive mode where output goes to
77
* stderr as line logs.
88
*/
9-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
9+
import { describe, it, expect, vi, beforeEach, afterEach, type MockInstance } from 'vitest'
1010

1111
// Force non-interactive mode so no ANSI cursor control happens.
1212
process.env['CLASHCODE_NO_TUI'] = '1'
@@ -21,7 +21,8 @@ import {
2121
} from '../src/cli/coordination-view.js'
2222

2323
describe('coordination-view (non-interactive)', () => {
24-
let stderrSpy: ReturnType<typeof vi.spyOn>
24+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
25+
let stderrSpy: MockInstance<(...args: any[]) => any>
2526

2627
beforeEach(() => {
2728
stderrSpy = vi.spyOn(process.stderr, 'write').mockImplementation(() => true)

test/cli-ui.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Unit tests for src/cli/ui.ts — ANSI helpers, Spinner, box, formatResponse.
33
*/
4-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
4+
import { describe, it, expect, vi, beforeEach, afterEach, type MockInstance } from 'vitest'
55
import {
66
c,
77
VERSION,
@@ -44,7 +44,8 @@ describe('banner', () => {
4444
})
4545

4646
describe('Spinner', () => {
47-
let stderrSpy: ReturnType<typeof vi.spyOn>
47+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
48+
let stderrSpy: MockInstance<(...args: any[]) => any>
4849

4950
beforeEach(() => {
5051
stderrSpy = vi.spyOn(process.stderr, 'write').mockImplementation(() => true)

test/sandbox-handle.test.ts

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ vi.mock('../src/sandbox/backends/shuru-bootstrap.js', () => ({
99
ensureBootstrapCheckpoint: vi.fn().mockResolvedValue(undefined),
1010
}))
1111

12-
// Mock ToolUseContext for execute() calls
13-
const mockCtx = { agent: { name: 'test', model: 'test' } } as any
14-
1512
vi.mock('../src/logger.js', () => ({
1613
logger: {
1714
info: vi.fn(),
@@ -262,7 +259,7 @@ describe('createSandboxTools — tool definitions', () => {
262259

263260
const handle = new SandboxHandle()
264261
const tools = createSandboxTools(handle)
265-
const result = await tools.sandboxExecTool.execute({ command: 'echo hello world' }, mockCtx)
262+
const result = await tools.sandboxExecTool.execute({ command: 'echo hello world' })
266263

267264
expect(result.data).toContain('hello world')
268265
expect(result.isError).toBeUndefined()
@@ -276,7 +273,7 @@ describe('createSandboxTools — tool definitions', () => {
276273

277274
const handle = new SandboxHandle()
278275
const tools = createSandboxTools(handle)
279-
const result = await tools.sandboxExecTool.execute({ command: 'cmd' }, mockCtx)
276+
const result = await tools.sandboxExecTool.execute({ command: 'cmd' })
280277

281278
expect(result.data).toContain('out')
282279
expect(result.data).toContain('err')
@@ -290,7 +287,7 @@ describe('createSandboxTools — tool definitions', () => {
290287

291288
const handle = new SandboxHandle()
292289
const tools = createSandboxTools(handle)
293-
const result = await tools.sandboxExecTool.execute({ command: 'true' }, mockCtx)
290+
const result = await tools.sandboxExecTool.execute({ command: 'true' })
294291

295292
expect(result.data).toBe('(no output)')
296293
})
@@ -306,7 +303,7 @@ describe('createSandboxTools — tool definitions', () => {
306303
await handle.get()
307304

308305
const tools = createSandboxTools(handle)
309-
const result = await tools.sandboxExecTool.execute({ command: 'fail' }, mockCtx)
306+
const result = await tools.sandboxExecTool.execute({ command: 'fail' })
310307

311308
expect(result.isError).toBe(true)
312309
expect(result.data).toContain('container died')
@@ -318,13 +315,10 @@ describe('createSandboxTools — tool definitions', () => {
318315

319316
const handle = new SandboxHandle()
320317
const tools = createSandboxTools(handle)
321-
const result = await tools.sandboxWriteTool.execute(
322-
{
323-
path: '/workspace/test.txt',
324-
content: 'hello',
325-
},
326-
mockCtx,
327-
)
318+
const result = await tools.sandboxWriteTool.execute({
319+
path: '/workspace/test.txt',
320+
content: 'hello',
321+
})
328322

329323
expect(result.data).toContain('5 bytes')
330324
expect(result.data).toContain('/workspace/test.txt')
@@ -339,13 +333,10 @@ describe('createSandboxTools — tool definitions', () => {
339333
const handle = new SandboxHandle()
340334
await handle.get()
341335
const tools = createSandboxTools(handle)
342-
const result = await tools.sandboxWriteTool.execute(
343-
{
344-
path: '/tmp/x',
345-
content: 'data',
346-
},
347-
mockCtx,
348-
)
336+
const result = await tools.sandboxWriteTool.execute({
337+
path: '/tmp/x',
338+
content: 'data',
339+
})
349340

350341
expect(result.isError).toBe(true)
351342
expect(result.data).toContain('write failed')
@@ -359,7 +350,7 @@ describe('createSandboxTools — tool definitions', () => {
359350

360351
const handle = new SandboxHandle()
361352
const tools = createSandboxTools(handle)
362-
const result = await tools.sandboxReadTool.execute({ path: '/workspace/file.txt' }, mockCtx)
353+
const result = await tools.sandboxReadTool.execute({ path: '/workspace/file.txt' })
363354

364355
expect(result.data).toBe('the file contents')
365356
})
@@ -373,7 +364,7 @@ describe('createSandboxTools — tool definitions', () => {
373364
const handle = new SandboxHandle()
374365
await handle.get()
375366
const tools = createSandboxTools(handle)
376-
const result = await tools.sandboxReadTool.execute({ path: '/tmp/nope' }, mockCtx)
367+
const result = await tools.sandboxReadTool.execute({ path: '/tmp/nope' })
377368

378369
expect(result.isError).toBe(true)
379370
expect(result.data).toContain('no such file')

0 commit comments

Comments
 (0)