mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
Fix dev
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import { loggerMock } from '@sim/testing'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { TOOL_RESULT_MAX_INLINE_CHARS } from '@/lib/copilot/constants'
|
||||
|
||||
const { getOrMaterializeVFS } = vi.hoisted(() => ({
|
||||
getOrMaterializeVFS: vi.fn(),
|
||||
@@ -24,6 +25,8 @@ vi.mock('./upload-file-reader', () => ({
|
||||
|
||||
import { executeVfsGrep, executeVfsRead } from './vfs'
|
||||
|
||||
const OVERSIZED_INLINE_CONTENT = 'x'.repeat(TOOL_RESULT_MAX_INLINE_CHARS + 1)
|
||||
|
||||
function makeVfs() {
|
||||
return {
|
||||
grep: vi.fn(),
|
||||
@@ -40,10 +43,7 @@ describe('vfs handlers oversize policy', () => {
|
||||
|
||||
it('fails oversized grep results with narrowing guidance', async () => {
|
||||
const vfs = makeVfs()
|
||||
vfs.grep.mockReturnValue([
|
||||
{ path: 'files/a.txt', line: 1, content: 'a'.repeat(60_000) },
|
||||
{ path: 'files/b.txt', line: 2, content: 'b'.repeat(60_000) },
|
||||
])
|
||||
vfs.grep.mockReturnValue([{ path: 'files/a.txt', line: 1, content: OVERSIZED_INLINE_CONTENT }])
|
||||
getOrMaterializeVFS.mockResolvedValue(vfs)
|
||||
|
||||
const result = await executeVfsGrep(
|
||||
@@ -57,7 +57,7 @@ describe('vfs handlers oversize policy', () => {
|
||||
|
||||
it('fails oversized read results with grep guidance', async () => {
|
||||
const vfs = makeVfs()
|
||||
vfs.read.mockReturnValue({ content: 'a'.repeat(100_001), totalLines: 1 })
|
||||
vfs.read.mockReturnValue({ content: OVERSIZED_INLINE_CONTENT, totalLines: 1 })
|
||||
getOrMaterializeVFS.mockResolvedValue(vfs)
|
||||
|
||||
const result = await executeVfsRead(
|
||||
|
||||
@@ -103,7 +103,9 @@ export const editContentServerTool: BaseServerTool<EditContentArgs, EditContentR
|
||||
case 'append': {
|
||||
const existing = intent.existingContent ?? ''
|
||||
finalContent = docInfo.isDoc
|
||||
? `${existing}\n{\n${content}\n}`
|
||||
? existing
|
||||
? `${existing}\n{\n${content}\n}`
|
||||
: content
|
||||
: existing
|
||||
? `${existing}\n${content}`
|
||||
: content
|
||||
|
||||
Reference in New Issue
Block a user