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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cr_proc
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: A tool for processing BYU CS code recording files.
5
5
  Author: Ethan Dye
6
6
  Author-email: mrtops03@gmail.com
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cr_proc"
3
- version = "0.1.6"
3
+ version = "0.1.7"
4
4
  description = "A tool for processing BYU CS code recording files."
5
5
  authors = [
6
6
  {name = "Ethan Dye",email = "mrtops03@gmail.com"}
@@ -348,16 +348,22 @@ def _detect_fullline_autocomplete(
348
348
  excluded_indices: set[int]
349
349
  ) -> list[dict[str, Any]]:
350
350
  """
351
- Detect full-line auto-complete events where the IDE/AI completes code.
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
- - Auto-complete: oldFragment="" (empty), newFragment="long_text" (10+ chars)
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
- Auto-complete is detected when:
362
+ Full-line auto-complete is detected when:
358
363
  - oldFragment is empty or very short (0-3 chars)
359
- - newFragment is substantial (10+ characters)
360
- - newFragment contains code structure (assignment, parens, brackets, etc.)
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 autocomplete triggers
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
- # Skip single-character additions (normal typing)
403
- # Auto-complete typically adds 10+ characters at once
404
- if new_len < 10:
405
- continue
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
- # Skip large multi-line pastes - those should be caught by multi-line paste detector
408
- # Auto-complete is typically 1-2 lines and under 100 chars
409
- # Anything larger is likely external copy-paste, not auto-complete
410
- new_lines = new_frag.split("\n")
411
- if len(new_lines) > 2 or new_len > 100:
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
- code_indicators = [
421
- "=", # Assignment (most common in autocomplete)
422
- "(", # Function call/definition
423
- ")", # Closing paren
424
- ":", # Block statement (if, for, def, etc.)
425
- "{", # Dictionary/block
426
- "}", # Closing brace
427
- "[", # List/index
428
- "]", # Closing bracket
429
- "=>", # Arrow function
430
- ";", # Statement end
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
- has_code_structure = any(indicator in new_frag for indicator in code_indicators)
442
+ has_complete_statement = any(indicator in new_frag for indicator in complete_statement_indicators)
434
443
 
435
- # Must have code structure to be considered auto-complete
436
- if has_code_structure:
437
- # Check if this content already existed in the document state BEFORE this event
438
- is_internal_copy = False
444
+ if not has_complete_statement:
445
+ # No complete statement - skip basic identifier completion
446
+ continue
439
447
 
440
- if idx > 0:
441
- prior_state = document_states[idx - 1]
442
- if new_frag in prior_state:
443
- is_internal_copy = True
448
+ # Minimum size for meaningful completion
449
+ if new_len < 10:
450
+ continue
444
451
 
445
- if not is_internal_copy:
446
- suspicious_events.append({
447
- "event_index": idx,
448
- "line_count": len(new_lines),
449
- "char_count": new_len,
450
- "reason": "full-line auto-complete",
451
- "newFragment": new_frag,
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