Class: Ace::Docs::Prompts::CompactDiffPrompt

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/docs/prompts/compact_diff_prompt.rb

Overview

Builds prompts for LLM diff compaction

Class Method Summary collapse

Class Method Details

.build(diff, documents = []) ⇒ String

Build a prompt for compacting a diff

Parameters:

  • diff (String)

    The git diff to compact

  • documents (Array<Document>) (defaults to: [])

    Documents being analyzed

Returns:

  • (String)

    Complete prompt for LLM



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ace/docs/prompts/compact_diff_prompt.rb', line 12

def self.build(diff, documents = [])
  document_list = format_document_list(documents)

  <<~PROMPT
    # Task: Compact Git Diff for Documentation Updates

    You are analyzing code changes to help update documentation. Your task is to compact the following git diff by removing noise while preserving all relevant details that might affect documentation.

    ## Documents Being Updated
    #{document_list}

    ## Instructions

    1. **REMOVE** (noise that doesn't affect documentation):
       - Test file changes (test/, spec/, *_test.rb, *.test.*)
       - Formatting-only changes (whitespace, indentation)
       - Comment-only changes that don't alter functionality
       - Version bumps in lock files (Gemfile.lock, package-lock.json)
       - Generated files and build artifacts
       - Minor refactors that don't change behavior

    2. **KEEP** (relevant changes that affect documentation):
       - New features, classes, methods, or commands
       - Changed interfaces, parameters, or return values
       - New or modified configuration options
       - Architecture or structural changes
       - Behavioral changes
       - New dependencies or tools
       - Error handling changes
       - Performance improvements worth documenting
       - Deprecations or removals

    3. **ORGANIZE** the output by impact level:
       - HIGH: New features, removed features, breaking changes
       - MEDIUM: Interface changes, new options, behavioral changes
       - LOW: Performance improvements, minor enhancements

    ## Output Format

    Provide a markdown report with:
    - Summary section with key changes
    - Sections organized by impact (HIGH/MEDIUM/LOW)
    - For each change, include:
      * Component/gem name
      * Brief description
      * Relevant files
      * Which documents might need updates

    ## Git Diff to Analyze

    ```diff
    #{diff}
    ```

    ## Response

    Please provide the compacted analysis in markdown format.
  PROMPT
end

.build_general(diff, since: "recent changes") ⇒ String

Build a prompt for analyzing changes without documents

Parameters:

  • diff (String)

    The git diff to analyze

  • since (String) (defaults to: "recent changes")

    Time period for the diff

Returns:

  • (String)

    Complete prompt for LLM



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/ace/docs/prompts/compact_diff_prompt.rb', line 76

def self.build_general(diff, since: "recent changes")
  <<~PROMPT
    # Task: Analyze and Compact Git Diff

    Analyze the following git diff from #{since} and provide a compacted summary suitable for documentation updates.

    ## Instructions

    1. Remove noise (tests, formatting, lock files)
    2. Focus on changes that affect documentation
    3. Organize by impact level (HIGH/MEDIUM/LOW)
    4. Provide actionable insights for documentation updates

    ## Git Diff

    ```diff
    #{diff}
    ```

    ## Response

    Provide a structured markdown analysis with:
    - Executive summary
    - Significant changes by impact level
    - Files and components affected
    - Suggested documentation updates
  PROMPT
end