cr-proc 0.1.6__tar.gz → 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cr_proc-0.1.6 → cr_proc-0.1.7}/PKG-INFO +1 -1
- {cr_proc-0.1.6 → cr_proc-0.1.7}/pyproject.toml +1 -1
- {cr_proc-0.1.6 → cr_proc-0.1.7}/src/code_recorder_processor/api/verify.py +72 -45
- {cr_proc-0.1.6 → cr_proc-0.1.7}/README.md +0 -0
- {cr_proc-0.1.6 → cr_proc-0.1.7}/src/code_recorder_processor/__init__.py +0 -0
- {cr_proc-0.1.6 → cr_proc-0.1.7}/src/code_recorder_processor/api/build.py +0 -0
- {cr_proc-0.1.6 → cr_proc-0.1.7}/src/code_recorder_processor/api/load.py +0 -0
- {cr_proc-0.1.6 → cr_proc-0.1.7}/src/code_recorder_processor/cli.py +0 -0
|
@@ -348,16 +348,22 @@ def _detect_fullline_autocomplete(
|
|
|
348
348
|
excluded_indices: set[int]
|
|
349
349
|
) -> list[dict[str, Any]]:
|
|
350
350
|
"""
|
|
351
|
-
Detect
|
|
351
|
+
Detect multi-line auto-complete events where the IDE/AI generates multiple complete lines.
|
|
352
|
+
|
|
353
|
+
Focuses on significant AI assistance where the system generates entire functions or blocks
|
|
354
|
+
(2+ lines) in a single completion event. This is distinct from basic IDE autocomplete
|
|
355
|
+
(e.g., finishing a function name).
|
|
352
356
|
|
|
353
357
|
At keystroke level, events show:
|
|
354
358
|
- Normal typing: oldFragment="" (empty), newFragment="X" (1 char)
|
|
355
|
-
-
|
|
359
|
+
- Basic autocomplete: oldFragment="" (empty), newFragment="function_name" (IDE suggests identifier)
|
|
360
|
+
- Full-line AI completion: oldFragment="" (empty), newFragment="def foo():\n pass" (entire function)
|
|
356
361
|
|
|
357
|
-
|
|
362
|
+
Full-line auto-complete is detected when:
|
|
358
363
|
- oldFragment is empty or very short (0-3 chars)
|
|
359
|
-
- newFragment
|
|
360
|
-
- newFragment contains
|
|
364
|
+
- newFragment generates 2+ complete lines
|
|
365
|
+
- newFragment contains complete statements (not just identifiers)
|
|
366
|
+
- Content represents meaningful code structure
|
|
361
367
|
- newFragment does NOT already exist in the document state
|
|
362
368
|
- Event not already flagged as external copy-paste
|
|
363
369
|
|
|
@@ -375,7 +381,7 @@ def _detect_fullline_autocomplete(
|
|
|
375
381
|
Returns
|
|
376
382
|
-------
|
|
377
383
|
list[dict[str, Any]]
|
|
378
|
-
List of suspected auto-complete events.
|
|
384
|
+
List of suspected multi-line auto-complete events.
|
|
379
385
|
"""
|
|
380
386
|
suspicious_events = []
|
|
381
387
|
|
|
@@ -395,20 +401,22 @@ def _detect_fullline_autocomplete(
|
|
|
395
401
|
new_len = len(new_frag)
|
|
396
402
|
|
|
397
403
|
# At keystroke level, oldFragment is typically empty for insertions
|
|
398
|
-
# Allow up to 3 chars for prefix-based
|
|
404
|
+
# Allow up to 3 chars for prefix-based triggers (e.g., "de" -> "def")
|
|
399
405
|
if old_len > 3:
|
|
400
406
|
continue
|
|
401
407
|
|
|
402
|
-
#
|
|
403
|
-
#
|
|
404
|
-
if
|
|
405
|
-
|
|
408
|
+
# Check line count - we care about complete statements
|
|
409
|
+
# Multi-line is obviously concerning, but single-line with a complete statement
|
|
410
|
+
# (like "if x: return True") is also suspicious if it came from autocomplete
|
|
411
|
+
new_lines = [n for n in new_frag.split("\n") if n.strip() != ""]
|
|
406
412
|
|
|
407
|
-
#
|
|
408
|
-
#
|
|
409
|
-
#
|
|
410
|
-
|
|
411
|
-
|
|
413
|
+
# For single-line completions, be more strict about what we flag
|
|
414
|
+
# We only flag if it's a complete statement with keywords, not just identifier completion
|
|
415
|
+
is_single_line = len(new_lines) <= 2 # 2 elements = 1 line + trailing \n
|
|
416
|
+
is_multi_line = len(new_lines) >= 3 # 3+ elements = 2+ actual lines
|
|
417
|
+
|
|
418
|
+
if not (is_single_line or is_multi_line):
|
|
419
|
+
# Shouldn't happen, but skip if malformed
|
|
412
420
|
continue
|
|
413
421
|
|
|
414
422
|
# The new fragment should not be just whitespace
|
|
@@ -416,40 +424,59 @@ def _detect_fullline_autocomplete(
|
|
|
416
424
|
continue
|
|
417
425
|
|
|
418
426
|
# Check if the new fragment contains code structure indicators
|
|
419
|
-
# These strongly suggest IDE/AI auto-completion of code
|
|
420
|
-
|
|
421
|
-
"
|
|
422
|
-
"
|
|
423
|
-
"
|
|
424
|
-
"
|
|
425
|
-
"
|
|
426
|
-
"
|
|
427
|
-
"
|
|
428
|
-
"
|
|
429
|
-
"
|
|
430
|
-
"
|
|
427
|
+
# These strongly suggest IDE/AI auto-completion of actual code (not just identifiers)
|
|
428
|
+
complete_statement_indicators = [
|
|
429
|
+
":", # Block statement (if:, for:, def:, class:, while:, with:, etc.)
|
|
430
|
+
"return", # Return statement
|
|
431
|
+
"def ", # Function definition
|
|
432
|
+
"class ", # Class definition
|
|
433
|
+
"if ", # If statement
|
|
434
|
+
"for ", # For loop
|
|
435
|
+
"while ", # While loop
|
|
436
|
+
"try:", # Try block
|
|
437
|
+
"except", # Exception handling
|
|
438
|
+
"import ", # Import statement
|
|
439
|
+
"=", # Assignment
|
|
431
440
|
]
|
|
432
441
|
|
|
433
|
-
|
|
442
|
+
has_complete_statement = any(indicator in new_frag for indicator in complete_statement_indicators)
|
|
434
443
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
is_internal_copy = False
|
|
444
|
+
if not has_complete_statement:
|
|
445
|
+
# No complete statement - skip basic identifier completion
|
|
446
|
+
continue
|
|
439
447
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
is_internal_copy = True
|
|
448
|
+
# Minimum size for meaningful completion
|
|
449
|
+
if new_len < 10:
|
|
450
|
+
continue
|
|
444
451
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
452
|
+
# For multi-line: maximum size to distinguish from external pastes
|
|
453
|
+
# External pastes are typically much larger (100+ chars)
|
|
454
|
+
# Multi-line completions are usually 20-300 chars for a small function/block
|
|
455
|
+
if is_multi_line and new_len > 300:
|
|
456
|
+
continue
|
|
457
|
+
|
|
458
|
+
# For single-line: could be larger due to chained methods or long statements
|
|
459
|
+
# but cap at 200 chars to avoid flagging user-typed long lines
|
|
460
|
+
if is_single_line and new_len > 200:
|
|
461
|
+
continue
|
|
462
|
+
|
|
463
|
+
# Check if this content already existed in the document state BEFORE this event
|
|
464
|
+
is_internal_copy = False
|
|
465
|
+
|
|
466
|
+
if idx > 0:
|
|
467
|
+
prior_state = document_states[idx - 1]
|
|
468
|
+
if new_frag in prior_state:
|
|
469
|
+
is_internal_copy = True
|
|
470
|
+
|
|
471
|
+
if not is_internal_copy:
|
|
472
|
+
line_desc = "line" if is_single_line else "lines"
|
|
473
|
+
suspicious_events.append({
|
|
474
|
+
"event_index": idx,
|
|
475
|
+
"line_count": len(new_lines),
|
|
476
|
+
"char_count": new_len,
|
|
477
|
+
"reason": f"complete statement auto-complete (AI assistance)",
|
|
478
|
+
"newFragment": new_frag,
|
|
479
|
+
})
|
|
453
480
|
|
|
454
481
|
return suspicious_events
|
|
455
482
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|