mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-19 10:02:04 +08:00
Merge branch 'dev' into mark/readme-gif
This commit is contained in:
@@ -6,9 +6,7 @@ import type { GitContext } from "../types"
|
||||
let mockGitContext: GitContext = {
|
||||
branch: "main",
|
||||
recentCommits: ["abc1234 initial commit"],
|
||||
files: [
|
||||
{ status: "modified" as const, path: "src/index.ts", diff: "+console.log('hello')" },
|
||||
],
|
||||
files: [{ status: "modified" as const, path: "src/index.ts", diff: "+console.log('hello')" }],
|
||||
}
|
||||
|
||||
mock.module("../git-context", () => ({
|
||||
@@ -58,9 +56,7 @@ describe("commit-message.generate", () => {
|
||||
mockGitContext = {
|
||||
branch: "main",
|
||||
recentCommits: ["abc1234 initial commit"],
|
||||
files: [
|
||||
{ status: "modified" as const, path: "src/index.ts", diff: "+console.log('hello')" },
|
||||
],
|
||||
files: [{ status: "modified" as const, path: "src/index.ts", diff: "+console.log('hello')" }],
|
||||
}
|
||||
mockStreamText = "feat(src): add hello world logging"
|
||||
})
|
||||
|
||||
@@ -76,10 +76,7 @@ describe("commit-message.git-context", () => {
|
||||
})
|
||||
|
||||
test("filters lock files in subdirectories", async () => {
|
||||
setGitOutput(
|
||||
"diff --name-status --cached",
|
||||
"M\tpackages/api/package-lock.json\nM\tpackages/api/src/index.ts",
|
||||
)
|
||||
setGitOutput("diff --name-status --cached", "M\tpackages/api/package-lock.json\nM\tpackages/api/src/index.ts")
|
||||
setGitOutput("diff --cached -- packages/api/package-lock.json", "+lock stuff")
|
||||
setGitOutput("diff --cached -- packages/api/src/index.ts", "+code")
|
||||
|
||||
@@ -232,10 +229,7 @@ describe("commit-message.git-context", () => {
|
||||
describe("binary file detection", () => {
|
||||
test("detects 'Binary files' in diff output", async () => {
|
||||
setGitOutput("diff --name-status --cached", "M\tassets/logo.png")
|
||||
setGitOutput(
|
||||
"diff --cached -- assets/logo.png",
|
||||
"Binary files a/assets/logo.png and b/assets/logo.png differ",
|
||||
)
|
||||
setGitOutput("diff --cached -- assets/logo.png", "Binary files a/assets/logo.png and b/assets/logo.png differ")
|
||||
|
||||
const ctx = await getGitContext("/repo")
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import type {
|
||||
AuthSetErrors,
|
||||
AuthSetResponses,
|
||||
CommandListResponses,
|
||||
CommitMessageGenerateErrors,
|
||||
CommitMessageGenerateResponses,
|
||||
Config as Config3,
|
||||
ConfigGetResponses,
|
||||
ConfigProvidersResponses,
|
||||
@@ -2217,6 +2219,51 @@ export class Telemetry extends HeyApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
export class CommitMessage extends HeyApiClient {
|
||||
/**
|
||||
* Generate commit message
|
||||
*
|
||||
* Generate a commit message using AI based on the current git diff.
|
||||
*/
|
||||
public generate<ThrowOnError extends boolean = false>(
|
||||
parameters?: {
|
||||
directory?: string
|
||||
path?: string
|
||||
selectedFiles?: Array<string>
|
||||
previousMessage?: string
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams(
|
||||
[parameters],
|
||||
[
|
||||
{
|
||||
args: [
|
||||
{ in: "query", key: "directory" },
|
||||
{ in: "body", key: "path" },
|
||||
{ in: "body", key: "selectedFiles" },
|
||||
{ in: "body", key: "previousMessage" },
|
||||
],
|
||||
},
|
||||
],
|
||||
)
|
||||
return (options?.client ?? this.client).post<
|
||||
CommitMessageGenerateResponses,
|
||||
CommitMessageGenerateErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/commit-message",
|
||||
...options,
|
||||
...params,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
...params.headers,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class Organization extends HeyApiClient {
|
||||
/**
|
||||
* Update Kilo Gateway organization
|
||||
@@ -3439,6 +3486,11 @@ export class OpencodeClient extends HeyApiClient {
|
||||
return (this._telemetry ??= new Telemetry({ client: this.client }))
|
||||
}
|
||||
|
||||
private _commitMessage?: CommitMessage
|
||||
get commitMessage(): CommitMessage {
|
||||
return (this._commitMessage ??= new CommitMessage({ client: this.client }))
|
||||
}
|
||||
|
||||
private _kilo?: Kilo
|
||||
get kilo(): Kilo {
|
||||
return (this._kilo ??= new Kilo({ client: this.client }))
|
||||
|
||||
@@ -4258,6 +4258,48 @@ export type TelemetryCaptureResponses = {
|
||||
|
||||
export type TelemetryCaptureResponse = TelemetryCaptureResponses[keyof TelemetryCaptureResponses]
|
||||
|
||||
export type CommitMessageGenerateData = {
|
||||
body?: {
|
||||
/**
|
||||
* Workspace/repo path
|
||||
*/
|
||||
path: string
|
||||
/**
|
||||
* Optional subset of files to include
|
||||
*/
|
||||
selectedFiles?: Array<string>
|
||||
/**
|
||||
* Previously generated message — triggers regeneration with a different result
|
||||
*/
|
||||
previousMessage?: string
|
||||
}
|
||||
path?: never
|
||||
query?: {
|
||||
directory?: string
|
||||
}
|
||||
url: "/commit-message"
|
||||
}
|
||||
|
||||
export type CommitMessageGenerateErrors = {
|
||||
/**
|
||||
* Bad request
|
||||
*/
|
||||
400: BadRequestError
|
||||
}
|
||||
|
||||
export type CommitMessageGenerateError = CommitMessageGenerateErrors[keyof CommitMessageGenerateErrors]
|
||||
|
||||
export type CommitMessageGenerateResponses = {
|
||||
/**
|
||||
* Generated commit message
|
||||
*/
|
||||
200: {
|
||||
message: string
|
||||
}
|
||||
}
|
||||
|
||||
export type CommitMessageGenerateResponse = CommitMessageGenerateResponses[keyof CommitMessageGenerateResponses]
|
||||
|
||||
export type KiloProfileData = {
|
||||
body?: never
|
||||
path?: never
|
||||
|
||||
@@ -4122,6 +4122,83 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/commit-message": {
|
||||
"post": {
|
||||
"operationId": "commitMessage.generate",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "query",
|
||||
"name": "directory",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"summary": "Generate commit message",
|
||||
"description": "Generate a commit message using AI based on the current git diff.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Generated commit message",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["message"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/BadRequestError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"description": "Workspace/repo path",
|
||||
"type": "string"
|
||||
},
|
||||
"selectedFiles": {
|
||||
"description": "Optional subset of files to include",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"previousMessage": {
|
||||
"description": "Previously generated message — triggers regeneration with a different result",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["path"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"x-codeSamples": [
|
||||
{
|
||||
"lang": "js",
|
||||
"source": "import { createOpencodeClient } from \"@kilocode/sdk\n\nconst client = createOpencodeClient()\nawait client.commitMessage.generate({\n ...\n})"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/kilo/profile": {
|
||||
"get": {
|
||||
"operationId": "kilo.profile",
|
||||
|
||||
Reference in New Issue
Block a user