Skip to content

Conversation

@markijbema
Copy link
Contributor

  • Add supportsFim() method to check if model supports FIM (codestral models)
  • Add completeFim() method for non-streaming FIM completions
  • Add streamFim() method for streaming FIM completions
  • Include all KiloCode-specific headers (organization ID, task ID, version, tester suppression)
  • Add comprehensive test coverage with 6 new test cases
  • Implementation follows the same pattern as KiloCode.ts for consistency

All tests pass (14/14)

Context

Implementation

Screenshots

before after

How to Test

Get in Touch

@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2025

⚠️ No Changeset found

Latest commit: 7dbbad0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@markijbema markijbema force-pushed the feat/add-fim-support-to-kilocode-openrouter branch 5 times, most recently from 5187ec9 to 0cfe7ed Compare November 4, 2025 12:12
- Add supportsFim() method to check if model supports FIM (codestral models)
- Add completeFim() method for non-streaming FIM completions
- Add streamFim() method for streaming FIM completions
- Reuse customRequestOptions() for header management (DRY principle)
- Use DEFAULT_HEADERS for consistency with chat completions
- Add comprehensive test coverage with 6 new test cases
- Implementation follows the same pattern as KiloCode.ts for consistency

All tests pass (14/14)
@markijbema markijbema force-pushed the feat/add-fim-support-to-kilocode-openrouter branch from 0cfe7ed to 6374a1c Compare November 5, 2025 10:34
@markijbema markijbema marked this pull request as ready for review November 5, 2025 11:57
Comment on lines 219 to 262
it("completeFim makes request with correct parameters", async () => {
const handler = new KilocodeOpenrouterHandler({
...mockOptions,
kilocodeModel: "mistral/codestral-latest",
kilocodeOrganizationId: "test-org-id",
})

const mockStream = new ReadableStream({
start(controller) {
controller.enqueue(
new TextEncoder().encode('data: {"choices":[{"delta":{"content":"completed "}}]}\n'),
)
controller.enqueue(new TextEncoder().encode('data: {"choices":[{"delta":{"content":"code"}}]}\n'))
controller.enqueue(new TextEncoder().encode("data: [DONE]\n"))
controller.close()
},
})

const mockResponse = {
ok: true,
body: mockStream,
}

global.fetch = vitest.fn().mockResolvedValue(mockResponse)

const result = await handler.completeFim("prefix code", "suffix code", "test-task-id")

expect(result).toBe("completed code")
expect(global.fetch).toHaveBeenCalledWith(
expect.any(URL),
expect.objectContaining({
method: "POST",
headers: expect.objectContaining({
"Content-Type": "application/json",
Accept: "application/json",
"x-api-key": "test-token",
Authorization: "Bearer test-token",
[X_KILOCODE_TASKID]: "test-task-id",
[X_KILOCODE_ORGANIZATIONID]: "test-org-id",
}),
body: expect.stringContaining('"stream":true'),
}),
)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete test, I think?

@markijbema markijbema enabled auto-merge November 5, 2025 13:17
@markijbema markijbema merged commit f14a243 into main Nov 5, 2025
12 checks passed
@markijbema markijbema deleted the feat/add-fim-support-to-kilocode-openrouter branch November 5, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants