Saying a pull request was "built with AI" is vague. Did the agent generate 100% of the files from scratch, or did it write a 10-line helper while the human engineer structured the entire architecture? Qodewk's AI-Written Ratio delivers quantitative clarity.
Beyond Binary Attribution
In the early days of generative AI, attribution was treated as binary: either a human wrote the code, or an AI did.
In real-world agentic workflows, human engineers and autonomous agents pair program in tight feedback loops:
- The developer outlines an interface and writes type contracts.
- The agent generates the core implementation and unit tests.
- The developer edits variable names, fixes an edge-case condition, and refactors an internal helper function.
- The agent writes documentation comments and updates the exports.
If you label this commit as "100% AI", you erase the developer's critical design input. If you label it as "100% Human", you ignore the 45,000 LLM tokens that generated the bulk of the logic.
Qodewk computes an exact AI-Written Ratio (from 0.0% to 100.0%).
The Footprint Matching Algorithm
To calculate this ratio accurately without surveillance daemons or intrusive keystroke logging, Qodewk correlates two distinct signals:
1. Tool Call Line-Range Footprints
When agents like Claude Code or Cursor edit files, their session transcripts record tool execution footprints (EditFile, WriteFile, apply_diff):
- Target file path.
- Exact line ranges inserted, modified, or deleted.
- Generation timestamp.
2. Final Committed Git Diff
Qodewk parses the actual commit patch (git diff-tree -p HEAD) into hunks:
@@ -42,6 +42,14 @@ export function verifyToken(...) {
+ const decoded = jwt.decode(token);
+ if (!decoded) throw new AuthError("INVALID_TOKEN");
+ return decoded;The Intersection Calculation
Qodewk maps the final committed hunk line ranges against the agent's logged edit ranges:
AI Ratio = ( Σ Overlap(h, AgentFootprint) / Σ Lines(h) ) * 100%export function computeAiWrittenRatio(
gitHunks: DiffHunk[],
agentFootprints: AgentFootprint[]
): number {
let totalCommittedLines = 0;
let aiMatchedLines = 0;
for (const hunk of gitHunks) {
const hunkCount = hunk.addedLines.length;
totalCommittedLines += hunkCount;
const matchedInHunk = countOverlappingLines(hunk, agentFootprints);
aiMatchedLines += matchedInHunk;
}
if (totalCommittedLines === 0) return 0.0;
return Math.round((aiMatchedLines / totalCommittedLines) * 1000) / 10;
}Accounting for Human Refinement and Churn
What happens when a human developer modifies lines that were originally generated by an agent?
- Direct Preservation: If an agent wrote 100 lines and the developer committed them verbatim, the ratio is 100%.
- Human Refactoring: If the developer rewrote 30 of those lines, the overlapping intersection drops to 70%.
- Human Scaffold: If the developer manually typed the types and schemas (40 lines) and the agent filled in the body (60 lines), the ratio evaluates to 60%.
This produces an honest, nuanced metric that respects both human authorship and agent contribution.