Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/little-wombats-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Add AI Attribution line tracking to the EditFileTool
15 changes: 15 additions & 0 deletions src/core/tools/EditFileTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { EXPERIMENT_IDS, experiments } from "../../shared/experiments"
import { sanitizeUnifiedDiff, computeDiffStats } from "../diff/stats"
import { BaseTool, ToolCallbacks } from "./BaseTool"
import type { ToolUse } from "../../shared/tools"
import { trackContribution } from "../../services/contribution-tracking/ContributionTrackingService" // kilocode_change

interface EditFileParams {
file_path: string
Expand Down Expand Up @@ -285,6 +286,20 @@ export class EditFileTool extends BaseTool<"edit_file"> {

const didApprove = await askApproval("tool", completeMessage, undefined, isWriteProtected)

// kilocode_change start
// Track contribution (fire-and-forget)
trackContribution({
cwd: task.cwd,
filePath: relPath,
originalContent: currentContent || "",
newContent: newContent,
status: didApprove ? "accepted" : "rejected",
taskId: task.taskId,
organizationId: state?.apiConfiguration?.kilocodeOrganizationId,
kilocodeToken: state?.apiConfiguration?.kilocodeToken || "",
})
// kilocode_change end

if (!didApprove) {
// Revert changes if diff view was shown
if (!isPreventFocusDisruptionEnabled) {
Expand Down
5 changes: 2 additions & 3 deletions src/core/tools/kilocode/editFileTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { type ClineProviderState } from "../../webview/ClineProvider"
import { ClineSayTool } from "../../../shared/ExtensionMessage"
import { X_KILOCODE_ORGANIZATIONID, X_KILOCODE_TASKID, X_KILOCODE_TESTER } from "../../../shared/kilocode/headers"
import { trackContribution } from "../../../services/contribution-tracking/ContributionTrackingService"
import { sanitizeUnifiedDiff } from "../../diff/stats"

const FAST_APPLY_MODEL_PRICING = {
"morph-v3-fast": {
Expand Down Expand Up @@ -181,11 +180,10 @@ export async function editFileTool(
cline.rooProtectedController?.isWriteProtected(relPath) || false,
)

// kilocode_change start
// Track contribution (fire-and-forget, never blocks user workflow)
const provider = cline.providerRef.deref()
const state = await provider?.getState()
const unifiedPatchRaw = formatResponse.createPrettyPatch(relPath, originalContent, newContent)
const unifiedPatch = sanitizeUnifiedDiff(unifiedPatchRaw)
trackContribution({
cwd: cline.cwd,
filePath: relPath,
Expand All @@ -196,6 +194,7 @@ export async function editFileTool(
organizationId: state?.apiConfiguration?.kilocodeOrganizationId,
kilocodeToken: state?.apiConfiguration?.kilocodeToken || "",
})
// kilocode_change end

if (!approved) {
await cline.diffViewProvider.revertChanges()
Expand Down