Luigit
repositories / will

will

owned by admin

src/agent/pi-session.test.ts

Raw
import assert from 'node:assert/strict'
import { mkdtemp, readFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { test } from 'node:test'
import { createWorktreeTools } from './pi-session.ts'
import type { Tool } from './tools-shape.ts'

test('all coding tools are bound to the editable worktree', async () => {
  const workDir = await mkdtemp(join(tmpdir(), 'will-tools-'))
  const tools = createWorktreeTools(workDir, {}) as Tool[]
  assert.deepEqual(tools.map((tool) => tool.name).sort(), [
    'bash',
    'edit',
    'find',
    'grep',
    'ls',
    'read',
    'write',
  ])

  const write = tools.find((tool) => tool.name === 'write')
  assert.ok(write)
  await write.execute(
    'write-probe',
    { path: 'probe.txt', content: 'inside genome\n' },
    new AbortController().signal,
  )
  assert.equal(await readFile(join(workDir, 'probe.txt'), 'utf8'), 'inside genome\n')
})