Reference
This section provides a comprehensive reference for all functions and classes in our project.
lampe
cli
commands
check_reviewed
check_reviewed(repo: Path = typer.Option(..., exists=True, file_okay=False, dir_okay=True, readable=True), repo_full_name: str | None = typer.Option(None, help='Repository full name (e.g. owner/repo)'), output: str = typer.Option('auto', help='Output provider (auto|console|github|gitlab|bitbucket)'), pr_number: int | None = typer.Option(None, '--pr', help='Pull request number (required for non-console providers)'))
Check if the token user has already reviewed this PR.
Returns exit code 0 if reviewed, 1 if not reviewed.
Source code in packages/lampe-cli/src/lampe/cli/commands/check_reviewed.py
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 | |
describe
describe(repo: Path = typer.Option(..., exists=True, file_okay=False, dir_okay=True, readable=True), repo_full_name: str | None = typer.Option(None, help='Repository full name (e.g. owner/repo)'), base: str = typer.Option(..., help='Base commit SHA'), head: str = typer.Option(..., help='Head commit SHA'), title: str = typer.Option('Pull Request', help='PR title (local runs)'), output: str = typer.Option('auto', help='Output provider (auto|console|github|gitlab|bitbucket)'), variant: str = typer.Option('default', help='default|agentic'), files_exclude: list[str] | None = typer.Option(None, '--exclude'), files_reinclude: list[str] | None = typer.Option(None, '--reinclude'), truncation_tokens: int = typer.Option(DEFAULT_MAX_TOKENS, '--max-tokens'), timeout: int | None = typer.Option(None, '--timeout-seconds'), verbose: bool = typer.Option(False, '--verbose/--no-verbose'))
Generate a PR description and deliver it to the specified output provider.
Source code in packages/lampe-cli/src/lampe/cli/commands/describe.py
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 | |
healthcheck
healthcheck() -> None
Check if the CLI is healthy and can connect to the configured provider.
Source code in packages/lampe-cli/src/lampe/cli/commands/healthcheck.py
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 | |
review
review(repo: Path = typer.Option(..., exists=True, file_okay=False, dir_okay=True, readable=True), repo_full_name: str | None = typer.Option(None, help='Repository full name (e.g. owner/repo)'), base: str = typer.Option(..., help='Base commit SHA'), head: str = typer.Option(..., help='Head commit SHA'), title: str = typer.Option('Pull Request', help='PR title (local runs)'), output: str = typer.Option('auto', help='Output provider (auto|console|github|gitlab|bitbucket)'), review_depth: ReviewDepth = typer.Option(ReviewDepth.STANDARD, help='Review depth (basic|standard|comprehensive)'), variant: str = typer.Option('multi-agent', help='Review variant (multi-agent|diff-by-diff)'), guidelines: list[str] | None = typer.Option(None, '--guideline', help='Custom review guidelines (can be repeated)'), files_exclude: list[str] | None = typer.Option(None, '--exclude'), timeout: int | None = typer.Option(None, '--timeout-seconds'), verbose: bool = typer.Option(False, '--verbose/--no-verbose'))
Generate a PR code review and deliver it to the specified output provider.
Model selection is automatic based on review_depth: - basic: gpt-5-nano - standard: gpt-5 - comprehensive: gpt-5.1
Source code in packages/lampe-cli/src/lampe/cli/commands/review.py
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 71 72 73 | |
entrypoint
version() -> None
Show version information.
Source code in packages/lampe-cli/src/lampe/cli/entrypoint.py
18 19 20 21 22 23 24 25 | |
providers
base
Provider(repository: Repository, pull_request: PullRequest)
Bases: ABC
Abstract provider for delivering workflow outputs.
Source code in packages/lampe-cli/src/lampe/cli/providers/base.py
78 79 80 | |
create_provider(provider_name: ProviderType | str, repository: Repository, pull_request: PullRequest) -> 'Provider'
staticmethod
Create a provider instance based on the specified type.
Source code in packages/lampe-cli/src/lampe/cli/providers/base.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
deliver_pr_description(payload: PRDescriptionPayload) -> None
abstractmethod
Deliver a PR description to the configured destination.
Source code in packages/lampe-cli/src/lampe/cli/providers/base.py
82 83 84 85 | |
deliver_pr_review(payload: PRReviewPayload) -> None
abstractmethod
Deliver a PR review to the configured destination.
Source code in packages/lampe-cli/src/lampe/cli/providers/base.py
87 88 89 90 | |
detect_provider_type() -> ProviderType
staticmethod
Detect the appropriate provider type based on available environment variables.
Source code in packages/lampe-cli/src/lampe/cli/providers/base.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
has_reviewed() -> bool
abstractmethod
Check if the token user has already reviewed this PR.
Source code in packages/lampe-cli/src/lampe/cli/providers/base.py
97 98 99 100 | |
healthcheck() -> None
abstractmethod
Check if the provider is healthy and can connect to the service.
Source code in packages/lampe-cli/src/lampe/cli/providers/base.py
92 93 94 95 | |
ProviderType
Bases: StrEnum
Available provider types.
update_or_add_text_between_tags(text: str, new_text: str, feature: str) -> str
Update the text between the tags and with new_text. If the tags don't exist, add them at the bottom of the text. The tags and new_text are preserved in the output.
Source code in packages/lampe-cli/src/lampe/cli/providers/base.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
bitbucket
BitbucketProvider(repository: Repository, pull_request: PullRequest)
Bases: Provider
Bitbucket provider for delivering PR descriptions to Bitbucket Cloud API.
Source code in packages/lampe-cli/src/lampe/cli/providers/bitbucket.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
deliver_pr_description(payload: PRDescriptionPayload) -> None
Update the PR description on Bitbucket.
Source code in packages/lampe-cli/src/lampe/cli/providers/bitbucket.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
deliver_pr_review(payload: PRReviewPayload) -> None
Post PR review comments on Bitbucket.
Source code in packages/lampe-cli/src/lampe/cli/providers/bitbucket.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
has_reviewed() -> bool
Check if the token user has already reviewed this PR.
Source code in packages/lampe-cli/src/lampe/cli/providers/bitbucket.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
healthcheck() -> None
Check if the Bitbucket provider is healthy and can connect to Bitbucket.
Source code in packages/lampe-cli/src/lampe/cli/providers/bitbucket.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
console
ConsoleProvider(repository: Repository, pull_request: PullRequest)
Bases: Provider
Console provider for delivering PR descriptions to stdout.
Source code in packages/lampe-cli/src/lampe/cli/providers/console.py
16 17 | |
deliver_pr_description(payload: PRDescriptionPayload) -> None
Print the PR description to console.
Source code in packages/lampe-cli/src/lampe/cli/providers/console.py
19 20 21 | |
deliver_pr_review(payload: PRReviewPayload) -> None
Print the PR review to console.
Source code in packages/lampe-cli/src/lampe/cli/providers/console.py
23 24 25 | |
has_reviewed() -> bool
Check if the token user has already reviewed this PR.
Source code in packages/lampe-cli/src/lampe/cli/providers/console.py
31 32 33 34 | |
healthcheck() -> None
Check if the console provider is healthy and can connect to the service.
Source code in packages/lampe-cli/src/lampe/cli/providers/console.py
27 28 29 | |
github
GitHubProvider(repository: Repository, pull_request: PullRequest)
Bases: Provider
GitHub provider for delivering PR descriptions to GitHub API.
Source code in packages/lampe-cli/src/lampe/cli/providers/github.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
deliver_pr_description(payload: PRDescriptionPayload) -> None
Update the PR description on GitHub.
Source code in packages/lampe-cli/src/lampe/cli/providers/github.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
deliver_pr_review(payload: PRReviewPayload) -> None
Post PR review comments on GitHub.
Source code in packages/lampe-cli/src/lampe/cli/providers/github.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
has_reviewed() -> bool
Check if the token user has already reviewed this PR.
Source code in packages/lampe-cli/src/lampe/cli/providers/github.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
healthcheck() -> None
Check if the GitHub provider is healthy and can connect to GitHub.
Source code in packages/lampe-cli/src/lampe/cli/providers/github.py
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
core
data_models
Issue
Bases: BaseModel
Individual issue to be resolved.
PullRequest
Bases: BaseModel
Pull request information.
Repository
Bases: BaseModel
Repository information.
issue
Issue
Bases: BaseModel
Individual issue to be resolved.
pull_request
PullRequest
Bases: BaseModel
Pull request information.
repository
Repository
Bases: BaseModel
Repository information.
gitconfig
init_git()
Initialize Git configuration and check version requirements.
Source code in src/lampe/core/gitconfig.py
58 59 60 61 | |
valid_git_version_available() -> bool
Check if the installed Git version meets the minimum requirement.
Returns:
| Type | Description |
|---|---|
bool
|
True if Git version meets requirement, False otherwise |
Source code in src/lampe/core/gitconfig.py
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 | |
parsers
MarkdownCodeBlockRemoverOutputParser
Bases: BaseOutputParser
Output parser that extracts and returns the content of markdown code blocks marked with 'md' or 'markdown'.
This parser is designed to process LLM outputs or other text that may contain markdown code blocks.
It specifically targets code blocks with the language tag 'md' or 'markdown', removing the code block
markers and returning only the inner content. If no such block is found, it falls back to extracting
a generic code block (```). If the result still contains any other code block (with a language tag),
it is preserved as-is. If no code block is found, the original text (stripped of leading/trailing whitespace)
is returned.
Edge Cases:
- If the input is an empty string, returns an empty string.
- If the input contains a code block with a language other than 'md' or 'markdown', it is preserved.
- If the input contains text before or after a markdown code block, only the content inside the block is returned.
- If the input contains an incomplete code block, returns the input with the trailing backticks removed if present.
Examples
Examples
>>> parser = MarkdownCodeBlockRemoverOutputParser()
>>> text = '''```md
... This is inside md block.
... ```'''
>>> parser.parse(text)
'This is inside md block.'
>>> text = '''```python
... Multiple lines
... are here.
... ```'''
>>> parser.parse(text)
'```python
Multiple lines are here. ```'
>>> text = 'No code block here.'
>>> parser.parse(text)
'No code block here.'
parse(output: str) -> str
Extracts and returns the content of a markdown code block marked with md ormarkdown from the input text.
If the input contains a markdown code block with language tag 'md' or 'markdown', the content inside that block is returned, with the code block markers removed. If no such block is found, but a generic code block (```) is present, its content is returned. If the result still contains any other code block (with a language tag), it is preserved as-is. If no code block is found, the original text (stripped of leading/trailing whitespace) is returned.
Source code in src/lampe/core/parsers/markdown_code_block_remover_output.py
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 | |
YAMLPydanticOutputParser
Bases: PydanticOutputParser[Model], Generic[Model]
A parser that extracts and validates YAML content using Pydantic models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_cls
|
Pydantic output class used for validation |
required | |
excluded_schema_keys_from_format
|
Schema keys to exclude from format string, by default None |
required | |
pydantic_format_tmpl
|
Template for format string, by default PYDANTIC_FORMAT_TMPL |
required |
Notes
This parser extracts YAML content from markdown code blocks, validates the structure using a Pydantic model, and returns the validated data. It first looks for YAML-specific code blocks, then falls back to any code block if needed.
format_string: str
property
Get the format string that instructs the LLM how to output YAML.
This method will provide a format string that includes the Pydantic model's JSON schema converted to a YAML example, helping the LLM understand the expected output structure.
Returns:
| Type | Description |
|---|---|
str
|
Format string with YAML schema example |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
The method is not yet implemented |
parse(text: str) -> Model
Extract, parse and validate YAML content using the configured Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Raw text containing YAML content in markdown code blocks |
required |
Returns:
| Type | Description |
|---|---|
Model
|
Validated data matching the Pydantic model structure |
Raises:
| Type | Description |
|---|---|
YAMLParsingError
|
If no valid YAML content is found in the text or if the YAML parsing fails due to syntax errors |
ValidationError
|
If the data does not match the Pydantic model schema |
Source code in src/lampe/core/parsers/yaml_pydantic_output.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
markdown_code_block_remover_output
MarkdownCodeBlockRemoverOutputParser
Bases: BaseOutputParser
Output parser that extracts and returns the content of markdown code blocks marked with 'md' or 'markdown'.
This parser is designed to process LLM outputs or other text that may contain markdown code blocks.
It specifically targets code blocks with the language tag 'md' or 'markdown', removing the code block
markers and returning only the inner content. If no such block is found, it falls back to extracting
a generic code block (```). If the result still contains any other code block (with a language tag),
it is preserved as-is. If no code block is found, the original text (stripped of leading/trailing whitespace)
is returned.
Edge Cases:
- If the input is an empty string, returns an empty string.
- If the input contains a code block with a language other than 'md' or 'markdown', it is preserved.
- If the input contains text before or after a markdown code block, only the content inside the block is returned.
- If the input contains an incomplete code block, returns the input with the trailing backticks removed if present.
Examples
Examples
>>> parser = MarkdownCodeBlockRemoverOutputParser()
>>> text = '''```md
... This is inside md block.
... ```'''
>>> parser.parse(text)
'This is inside md block.'
>>> text = '''```python
... Multiple lines
... are here.
... ```'''
>>> parser.parse(text)
'```python
Multiple lines are here. ```'
>>> text = 'No code block here.'
>>> parser.parse(text)
'No code block here.'
parse(output: str) -> str
Extracts and returns the content of a markdown code block marked with md ormarkdown from the input text.
If the input contains a markdown code block with language tag 'md' or 'markdown', the content inside that block is returned, with the code block markers removed. If no such block is found, but a generic code block (```) is present, its content is returned. If the result still contains any other code block (with a language tag), it is preserved as-is. If no code block is found, the original text (stripped of leading/trailing whitespace) is returned.
Source code in src/lampe/core/parsers/markdown_code_block_remover_output.py
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 | |
utils
extract_md_code_block(output: str, language: str = '', match_any_language: bool = False) -> str | None
Extract markdown code block content from a string, handling nested code blocks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
The string to extract code block content from. |
required |
language
|
str
|
The language identifier for the code block (e.g., 'yaml', 'python', 'json'). |
''
|
match_any_language
|
bool
|
If True, the language of the code block is optional and the function will return the first code block found. |
False
|
Returns:
| Type | Description |
|---|---|
str | None
|
The extracted code block content, or the entire input if no language is specified or no matching code block is found. |
Notes
This function extracts content between {language} tags, preserving any nested
code blocks within the content. The regex pattern handles:
- Optional text before the code block
- Nested code blocks (e.g.json, python, inside the main block)
- Proper indentation of nested content
- Case-insensitive language tag matching
Examples:
>>> text = '''
... Some text
... ```yaml
... key: value
... nested: |
... ```python
... print("Hello")
... ```
... ```
... '''
>>> result = extract_md_code_block(text, 'yaml')
>>> print(result)
key: value
nested: |
```python
print("Hello")
```
Source code in src/lampe/core/parsers/utils.py
9 10 11 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 | |
yaml_pydantic_output
YAMLParsingError
Bases: Exception
Raised when YAML parsing or validation fails.
YAMLPydanticOutputParser
Bases: PydanticOutputParser[Model], Generic[Model]
A parser that extracts and validates YAML content using Pydantic models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_cls
|
Pydantic output class used for validation |
required | |
excluded_schema_keys_from_format
|
Schema keys to exclude from format string, by default None |
required | |
pydantic_format_tmpl
|
Template for format string, by default PYDANTIC_FORMAT_TMPL |
required |
Notes
This parser extracts YAML content from markdown code blocks, validates the structure using a Pydantic model, and returns the validated data. It first looks for YAML-specific code blocks, then falls back to any code block if needed.
format_string: str
property
Get the format string that instructs the LLM how to output YAML.
This method will provide a format string that includes the Pydantic model's JSON schema converted to a YAML example, helping the LLM understand the expected output structure.
Returns:
| Type | Description |
|---|---|
str
|
Format string with YAML schema example |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
The method is not yet implemented |
parse(text: str) -> Model
Extract, parse and validate YAML content using the configured Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Raw text containing YAML content in markdown code blocks |
required |
Returns:
| Type | Description |
|---|---|
Model
|
Validated data matching the Pydantic model structure |
Raises:
| Type | Description |
|---|---|
YAMLParsingError
|
If no valid YAML content is found in the text or if the YAML parsing fails due to syntax errors |
ValidationError
|
If the data does not match the Pydantic model schema |
Source code in src/lampe/core/parsers/yaml_pydantic_output.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
tools
TempGitRepository(repo_url: str, head_ref: str | None = None, base_ref: str | None = None, folder_name: str | None = None, sparse: bool = True, shallow: bool = True, blob_filter: bool = True, remove_existing: bool = True)
Context Manager for cloning and cleaning up a local clone of a repository
Uses partial clone optimizations including shallow clone, sparse checkout, and blob filtering to efficiently fetch only required content. Upon exit, will attempt to delete the cloned repository.
Attributes:
| Name | Type | Description |
|---|---|---|
repo_url |
Repository URL to clone |
|
head_ref |
Optional head ref to check out. |
|
folder_name |
Optional name prefix for temp directory |
|
sparse |
Enable sparse checkout mode to avoid populating all files initially. |
|
shallow |
Enable shallow clone (depth=1) to fetch only the target commit. |
|
blob_filter |
Enable blob filtering (--filter=blob:none) to fetch file contents on-demand |
|
remove_existing |
Remove existing directory if it exists |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If Git version check fails |
GitCommandError
|
If clone operation fails |
UnableToDeleteError
|
If unable to delete the cloned repository |
Source code in src/lampe/core/tools/repository/management.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
clone_repo(repo_url: str, head_ref: str | None = None, base_ref: str | None = None, folder_name: str | None = None, sparse: bool = True, shallow: bool = True, blob_filter: bool = True, remove_existing: bool = True) -> str
Clone a repository optimized for PR review.
Uses partial clone optimizations including shallow clone, sparse checkout, and blob filtering to efficiently fetch only required content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_url
|
str
|
Repository URL to clone |
required |
head_ref
|
str | None
|
Head ref to checkout |
None
|
base_ref
|
str | None
|
Base ref to fetch for diff computation |
None
|
folder_name
|
str | None
|
Optional name prefix for temp directory |
None
|
sparse
|
bool
|
Enable sparse checkout mode to avoid populating all files initially |
True
|
shallow
|
bool
|
Enable shallow clone (depth=1) to fetch only the target commit |
True
|
blob_filter
|
bool
|
Enable blob filtering (--filter=blob:none) to fetch file contents on-demand |
True
|
remove_existing
|
bool
|
Remove existing directory if it exists |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the cloned repository |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If Git version check fails |
GitCommandError
|
If clone operation fails |
Source code in src/lampe/core/tools/repository/management.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
get_diff_between_commits(base_hash: str, head_hash: str = 'HEAD', files_exclude_patterns: list[str] | None = None, files_include_patterns: list[str] | None = None, files_reinclude_patterns: list[str] | None = None, batch_size: int = 50, include_line_numbers: bool = False, repo_path: str = '/tmp/') -> str
Get the diff between two commits, optionally filtering files by glob patterns.
The filtering is done in a specific order to ensure correct pattern application: 1. First, if include patterns are provided, only files matching those patterns are kept 2. Then, exclude patterns are applied to filter out matching files 3. Finally, reinclude patterns can override the exclude patterns to bring back specific files
This order ensures that reinclude patterns only affect files that were actually excluded, preventing the reinclude of files that weren't matched by include patterns in the first place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_hash
|
str
|
Base commit hash to compare from |
required |
head_hash
|
str
|
Head commit hash to compare to. If not provided, uses HEAD |
'HEAD'
|
files_exclude_patterns
|
list[str] | None
|
List of glob patterns to exclude from the diff (relative to repo root). These patterns take precedence over include patterns. |
None
|
files_include_patterns
|
list[str] | None
|
List of glob patterns to include in the diff (relative to repo root). Note that exclude patterns will override these if there are conflicts. |
None
|
files_reinclude_patterns
|
list[str] | None
|
List of glob patterns to re-include files that were excluded by the exclude patterns. These patterns will only affect files that were previously excluded. |
None
|
repo_path
|
str
|
Path to the git repository |
'/tmp/'
|
batch_size
|
int
|
Number of files to process in each batch. |
50
|
include_line_numbers
|
bool
|
Whether to include line numbers in diff output (default: False) |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Diff as a string |
Raises:
| Type | Description |
|---|---|
DiffNotFoundError
|
If there is an unexpected git error |
Source code in src/lampe/core/tools/repository/diff.py
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
view_file(commit_hash: str, file_path: str, line_start: int | None = None, line_end: int | None = None, include_line_numbers: bool = False, repo_path: str = '/tmp/') -> str
Get file content from a specific commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit_hash
|
str
|
Commit reference (e.g., "main", commit hash) |
required |
file_path
|
str
|
Path to the file within the repository |
required |
line_start
|
int | None
|
Line range start index (0-based) of head_content to extract content from |
None
|
line_end
|
int | None
|
Line range end index (0-based) of head_content to extract content to |
None
|
include_line_numbers
|
bool
|
Whether to prefix each line with its line number (default: False) |
False
|
repo_path
|
str
|
Path to the git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
File content as a string, empty string if file doesn't exist or line range is invalid |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If the file doesn't exist or any other git error occurs |
Source code in src/lampe/core/tools/repository/content.py
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 71 72 73 74 75 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 | |
repository
FileDiffInfo
Bases: BaseModel
Information about a single file diff.
LocalCommitsAvailability(repo_path: str, commits: list[str])
Context manager to check if commits are available locally before git operations.
Checks if specified commits exist locally using git fsck --root and fetches
them if they're not present. This is useful for ensuring all required commits
are available before performing git operations that depend on them.
Attributes:
| Name | Type | Description |
|---|---|---|
repo_path |
Path to the git repository |
|
commits |
List of commit references to check and fetch if needed |
Source code in src/lampe/core/tools/repository/management.py
219 220 221 222 223 | |
TempGitRepository(repo_url: str, head_ref: str | None = None, base_ref: str | None = None, folder_name: str | None = None, sparse: bool = True, shallow: bool = True, blob_filter: bool = True, remove_existing: bool = True)
Context Manager for cloning and cleaning up a local clone of a repository
Uses partial clone optimizations including shallow clone, sparse checkout, and blob filtering to efficiently fetch only required content. Upon exit, will attempt to delete the cloned repository.
Attributes:
| Name | Type | Description |
|---|---|---|
repo_url |
Repository URL to clone |
|
head_ref |
Optional head ref to check out. |
|
folder_name |
Optional name prefix for temp directory |
|
sparse |
Enable sparse checkout mode to avoid populating all files initially. |
|
shallow |
Enable shallow clone (depth=1) to fetch only the target commit. |
|
blob_filter |
Enable blob filtering (--filter=blob:none) to fetch file contents on-demand |
|
remove_existing |
Remove existing directory if it exists |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If Git version check fails |
GitCommandError
|
If clone operation fails |
UnableToDeleteError
|
If unable to delete the cloned repository |
Source code in src/lampe/core/tools/repository/management.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
clone_repo(repo_url: str, head_ref: str | None = None, base_ref: str | None = None, folder_name: str | None = None, sparse: bool = True, shallow: bool = True, blob_filter: bool = True, remove_existing: bool = True) -> str
Clone a repository optimized for PR review.
Uses partial clone optimizations including shallow clone, sparse checkout, and blob filtering to efficiently fetch only required content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_url
|
str
|
Repository URL to clone |
required |
head_ref
|
str | None
|
Head ref to checkout |
None
|
base_ref
|
str | None
|
Base ref to fetch for diff computation |
None
|
folder_name
|
str | None
|
Optional name prefix for temp directory |
None
|
sparse
|
bool
|
Enable sparse checkout mode to avoid populating all files initially |
True
|
shallow
|
bool
|
Enable shallow clone (depth=1) to fetch only the target commit |
True
|
blob_filter
|
bool
|
Enable blob filtering (--filter=blob:none) to fetch file contents on-demand |
True
|
remove_existing
|
bool
|
Remove existing directory if it exists |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the cloned repository |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If Git version check fails |
GitCommandError
|
If clone operation fails |
Source code in src/lampe/core/tools/repository/management.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
fetch_commit_ref(repo_path: str, commit_ref: str) -> None
Fetch a base reference from the remote repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_path
|
str
|
Path to the git repository |
required |
commit_ref
|
str
|
Commit reference to fetch (e.g., branch name, commit hash) |
required |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If the fetch operation fails |
Source code in src/lampe/core/tools/repository/management.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
find_files_by_pattern(pattern: str, repo_path: str = '/tmp/') -> str
Search for files using git ls-files and pattern matching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern to search for (e.g. ".py", "src//.md") |
required |
repo_path
|
str
|
Path to git repository |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string containing matching file paths |
Source code in src/lampe/core/tools/repository/search.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
get_diff_between_commits(base_hash: str, head_hash: str = 'HEAD', files_exclude_patterns: list[str] | None = None, files_include_patterns: list[str] | None = None, files_reinclude_patterns: list[str] | None = None, batch_size: int = 50, include_line_numbers: bool = False, repo_path: str = '/tmp/') -> str
Get the diff between two commits, optionally filtering files by glob patterns.
The filtering is done in a specific order to ensure correct pattern application: 1. First, if include patterns are provided, only files matching those patterns are kept 2. Then, exclude patterns are applied to filter out matching files 3. Finally, reinclude patterns can override the exclude patterns to bring back specific files
This order ensures that reinclude patterns only affect files that were actually excluded, preventing the reinclude of files that weren't matched by include patterns in the first place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_hash
|
str
|
Base commit hash to compare from |
required |
head_hash
|
str
|
Head commit hash to compare to. If not provided, uses HEAD |
'HEAD'
|
files_exclude_patterns
|
list[str] | None
|
List of glob patterns to exclude from the diff (relative to repo root). These patterns take precedence over include patterns. |
None
|
files_include_patterns
|
list[str] | None
|
List of glob patterns to include in the diff (relative to repo root). Note that exclude patterns will override these if there are conflicts. |
None
|
files_reinclude_patterns
|
list[str] | None
|
List of glob patterns to re-include files that were excluded by the exclude patterns. These patterns will only affect files that were previously excluded. |
None
|
repo_path
|
str
|
Path to the git repository |
'/tmp/'
|
batch_size
|
int
|
Number of files to process in each batch. |
50
|
include_line_numbers
|
bool
|
Whether to include line numbers in diff output (default: False) |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Diff as a string |
Raises:
| Type | Description |
|---|---|
DiffNotFoundError
|
If there is an unexpected git error |
Source code in src/lampe/core/tools/repository/diff.py
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
get_diff_for_files(base_reference: str, file_paths: list[str] | None = None, head_reference: str = 'HEAD', repo_path: str = '/tmp/', batch_size: int = 50) -> str
Get the diff between two commits, optionally for specific files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_reference
|
str
|
Base commit reference (e.g., "main", commit hash) |
required |
file_paths
|
list[str] | None
|
List of file paths to get diff for |
None
|
head_reference
|
str
|
Head commit reference (e.g., "feature", commit hash). Defaults to "HEAD" |
'HEAD'
|
repo_path
|
str
|
Path to git repository, by default "/tmp/" |
'/tmp/'
|
batch_size
|
int
|
Number of files to process in each batch. |
50
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string containing diffs for specified files or all changed files |
Source code in src/lampe/core/tools/repository/diff.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
get_file_content_at_commit(commit_hash: str, file_path: str, line_start: int | None = None, line_end: int | None = None, include_line_numbers: bool = False, repo_path: str = '/tmp/') -> str
Get file content from a specific commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit_hash
|
str
|
Commit reference (e.g., "main", commit hash) |
required |
file_path
|
str
|
Path to the file within the repository |
required |
line_start
|
int | None
|
Line range start index (0-based) of head_content to extract content from |
None
|
line_end
|
int | None
|
Line range end index (0-based) of head_content to extract content to |
None
|
include_line_numbers
|
bool
|
Whether to prefix each line with its line number (default: False) |
False
|
repo_path
|
str
|
Path to the git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
File content as a string, empty string if file doesn't exist or line range is invalid |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If the file doesn't exist or any other git error occurs |
Source code in src/lampe/core/tools/repository/content.py
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 71 72 73 74 75 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 | |
is_sparse_clone(repo_path: str) -> bool
Check if a repository is a sparse clone.
A sparse clone is detected by checking multiple indicators: 1. If core.sparseCheckout is enabled 2. If .git/info/sparse-checkout file exists and has content
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_path
|
str
|
Path to the git repository |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the repository appears to be a sparse clone, False otherwise |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If git commands fail |
Source code in src/lampe/core/tools/repository/management.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
list_changed_files(base_reference: str, head_reference: str = 'HEAD', repo_path: str = '/tmp/') -> str
List files changed between base reference and HEAD, with change stats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_reference
|
str
|
Git reference (commit hash, branch name, etc.) to compare against HEAD |
required |
head_reference
|
str
|
Git reference (commit hash, branch name, etc.) to compare against base reference. Defaults to "HEAD" |
'HEAD'
|
repo_path
|
str
|
Path to git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string listing changed files with status, additions/deletions and size Format: "[STATUS] filepath | +additions -deletions | sizeKB" STATUS is one of: A (added), D (deleted), M (modified) |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If there is an error executing git commands |
Source code in src/lampe/core/tools/repository/diff.py
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 71 72 73 74 75 76 | |
list_changed_files_as_objects(base_reference: str, head_reference: str = 'HEAD', repo_path: str = '/tmp/') -> list[FileDiffInfo]
List files changed between base reference and HEAD as structured objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_reference
|
str
|
Git reference (commit hash, branch name, etc.) to compare against HEAD |
required |
head_reference
|
str
|
Git reference (commit hash, branch name, etc.) to compare against base reference. Defaults to "HEAD" |
'HEAD'
|
repo_path
|
str
|
Path to git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
list[FileDiffInfo]
|
List of FileDiffInfo objects for each changed file |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If there is an error executing git commands |
Source code in src/lampe/core/tools/repository/diff.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
search_in_files(pattern: str, relative_dir_path: str, commit_reference: str, include_line_numbers: bool = False, repo_path: str = '/tmp/') -> str
Search for a pattern in files within a directory at a specific commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern to search for |
required |
relative_dir_path
|
str
|
Directory path to search in |
required |
commit_reference
|
str
|
Commit reference to search at |
required |
include_line_numbers
|
bool
|
Whether to include line numbers in search results (default: False) |
False
|
repo_path
|
str
|
Path to the git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
Search results as a string |
Source code in src/lampe/core/tools/repository/search.py
11 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 | |
show_commit(commit_reference: str, repo_path: str = '/tmp/') -> str
Show the contents of a commit.
This function shows the contents of a commit, including the commit details and diffs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit_reference
|
str
|
Commit reference (e.g., "main", commit hash) |
required |
repo_path
|
str
|
Path to git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string containing commit details and diffs |
Source code in src/lampe/core/tools/repository/history.py
11 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 | |
content
file_exists(file_path: str, commit_hash: str = 'HEAD', repo_path: str = '/tmp/') -> bool
Check if a file exists in a specific commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the file within the repository |
required |
commit_hash
|
str
|
Commit reference to check (e.g., commit hash, branch name, tag). Defaults to "HEAD" |
'HEAD'
|
repo_path
|
str
|
Path to git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
bool
|
True if file exists in the commit, False otherwise |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If there is an unexpected git error |
Source code in src/lampe/core/tools/repository/content.py
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 | |
get_file_content_at_commit(commit_hash: str, file_path: str, line_start: int | None = None, line_end: int | None = None, include_line_numbers: bool = False, repo_path: str = '/tmp/') -> str
Get file content from a specific commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit_hash
|
str
|
Commit reference (e.g., "main", commit hash) |
required |
file_path
|
str
|
Path to the file within the repository |
required |
line_start
|
int | None
|
Line range start index (0-based) of head_content to extract content from |
None
|
line_end
|
int | None
|
Line range end index (0-based) of head_content to extract content to |
None
|
include_line_numbers
|
bool
|
Whether to prefix each line with its line number (default: False) |
False
|
repo_path
|
str
|
Path to the git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
File content as a string, empty string if file doesn't exist or line range is invalid |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If the file doesn't exist or any other git error occurs |
Source code in src/lampe/core/tools/repository/content.py
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 71 72 73 74 75 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 | |
get_file_size_at_commit(file_path: str, commit_hash: str = 'HEAD', repo_path: str = '/tmp/') -> int
Get the size of a file at a specific commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the file within the repository |
required |
commit_hash
|
str
|
Commit reference (e.g., "main", commit hash). Defaults to "HEAD" |
'HEAD'
|
repo_path
|
str
|
Path to the git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
int
|
Size of the file in bytes |
Source code in src/lampe/core/tools/repository/content.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
diff
FileDiffInfo
Bases: BaseModel
Information about a single file diff.
get_diff_between_commits(base_hash: str, head_hash: str = 'HEAD', files_exclude_patterns: list[str] | None = None, files_include_patterns: list[str] | None = None, files_reinclude_patterns: list[str] | None = None, batch_size: int = 50, include_line_numbers: bool = False, repo_path: str = '/tmp/') -> str
Get the diff between two commits, optionally filtering files by glob patterns.
The filtering is done in a specific order to ensure correct pattern application: 1. First, if include patterns are provided, only files matching those patterns are kept 2. Then, exclude patterns are applied to filter out matching files 3. Finally, reinclude patterns can override the exclude patterns to bring back specific files
This order ensures that reinclude patterns only affect files that were actually excluded, preventing the reinclude of files that weren't matched by include patterns in the first place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_hash
|
str
|
Base commit hash to compare from |
required |
head_hash
|
str
|
Head commit hash to compare to. If not provided, uses HEAD |
'HEAD'
|
files_exclude_patterns
|
list[str] | None
|
List of glob patterns to exclude from the diff (relative to repo root). These patterns take precedence over include patterns. |
None
|
files_include_patterns
|
list[str] | None
|
List of glob patterns to include in the diff (relative to repo root). Note that exclude patterns will override these if there are conflicts. |
None
|
files_reinclude_patterns
|
list[str] | None
|
List of glob patterns to re-include files that were excluded by the exclude patterns. These patterns will only affect files that were previously excluded. |
None
|
repo_path
|
str
|
Path to the git repository |
'/tmp/'
|
batch_size
|
int
|
Number of files to process in each batch. |
50
|
include_line_numbers
|
bool
|
Whether to include line numbers in diff output (default: False) |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Diff as a string |
Raises:
| Type | Description |
|---|---|
DiffNotFoundError
|
If there is an unexpected git error |
Source code in src/lampe/core/tools/repository/diff.py
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
get_diff_for_files(base_reference: str, file_paths: list[str] | None = None, head_reference: str = 'HEAD', repo_path: str = '/tmp/', batch_size: int = 50) -> str
Get the diff between two commits, optionally for specific files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_reference
|
str
|
Base commit reference (e.g., "main", commit hash) |
required |
file_paths
|
list[str] | None
|
List of file paths to get diff for |
None
|
head_reference
|
str
|
Head commit reference (e.g., "feature", commit hash). Defaults to "HEAD" |
'HEAD'
|
repo_path
|
str
|
Path to git repository, by default "/tmp/" |
'/tmp/'
|
batch_size
|
int
|
Number of files to process in each batch. |
50
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string containing diffs for specified files or all changed files |
Source code in src/lampe/core/tools/repository/diff.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
list_changed_files(base_reference: str, head_reference: str = 'HEAD', repo_path: str = '/tmp/') -> str
List files changed between base reference and HEAD, with change stats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_reference
|
str
|
Git reference (commit hash, branch name, etc.) to compare against HEAD |
required |
head_reference
|
str
|
Git reference (commit hash, branch name, etc.) to compare against base reference. Defaults to "HEAD" |
'HEAD'
|
repo_path
|
str
|
Path to git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string listing changed files with status, additions/deletions and size Format: "[STATUS] filepath | +additions -deletions | sizeKB" STATUS is one of: A (added), D (deleted), M (modified) |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If there is an error executing git commands |
Source code in src/lampe/core/tools/repository/diff.py
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 71 72 73 74 75 76 | |
list_changed_files_as_objects(base_reference: str, head_reference: str = 'HEAD', repo_path: str = '/tmp/') -> list[FileDiffInfo]
List files changed between base reference and HEAD as structured objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_reference
|
str
|
Git reference (commit hash, branch name, etc.) to compare against HEAD |
required |
head_reference
|
str
|
Git reference (commit hash, branch name, etc.) to compare against base reference. Defaults to "HEAD" |
'HEAD'
|
repo_path
|
str
|
Path to git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
list[FileDiffInfo]
|
List of FileDiffInfo objects for each changed file |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If there is an error executing git commands |
Source code in src/lampe/core/tools/repository/diff.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
encoding
Encoding utilities for git command outputs.
sanitize_utf8(text: str) -> str
Sanitize a string to ensure it contains only valid UTF-8 characters.
This function handles surrogate pairs and other invalid UTF-8 sequences that can occur when processing file content from git commands. Surrogate pairs are common in binary files or files with incorrect encoding.
The function uses 'replace' error handling which replaces invalid sequences with the Unicode replacement character (U+FFFD).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to sanitize (may contain surrogate pairs or invalid UTF-8) |
required |
Returns:
| Type | Description |
|---|---|
str
|
Sanitized text containing only valid UTF-8 characters |
Examples:
>>> sanitize_utf8("Valid text")
'Valid text'
>>> sanitize_utf8("Text with surrogates: \udcff\udcfe")
'Text with surrogates:'
Source code in src/lampe/core/tools/repository/encoding.py
4 5 6 7 8 9 10 11 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 | |
history
get_commit_log(max_count: int, repo_path: str = '/tmp/') -> str
Get the log of commits for a repository.
This function gets the log of commits for a repository, including the commit details and the list of files path that were changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_count
|
int
|
Maximum number of commits to return |
required |
repo_path
|
str
|
Path to git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string containing commit details and list of files that were changed |
Source code in src/lampe/core/tools/repository/history.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
show_commit(commit_reference: str, repo_path: str = '/tmp/') -> str
Show the contents of a commit.
This function shows the contents of a commit, including the commit details and diffs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commit_reference
|
str
|
Commit reference (e.g., "main", commit hash) |
required |
repo_path
|
str
|
Path to git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string containing commit details and diffs |
Source code in src/lampe/core/tools/repository/history.py
11 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 | |
management
LocalCommitsAvailability(repo_path: str, commits: list[str])
Context manager to check if commits are available locally before git operations.
Checks if specified commits exist locally using git fsck --root and fetches
them if they're not present. This is useful for ensuring all required commits
are available before performing git operations that depend on them.
Attributes:
| Name | Type | Description |
|---|---|---|
repo_path |
Path to the git repository |
|
commits |
List of commit references to check and fetch if needed |
Source code in src/lampe/core/tools/repository/management.py
219 220 221 222 223 | |
TempGitRepository(repo_url: str, head_ref: str | None = None, base_ref: str | None = None, folder_name: str | None = None, sparse: bool = True, shallow: bool = True, blob_filter: bool = True, remove_existing: bool = True)
Context Manager for cloning and cleaning up a local clone of a repository
Uses partial clone optimizations including shallow clone, sparse checkout, and blob filtering to efficiently fetch only required content. Upon exit, will attempt to delete the cloned repository.
Attributes:
| Name | Type | Description |
|---|---|---|
repo_url |
Repository URL to clone |
|
head_ref |
Optional head ref to check out. |
|
folder_name |
Optional name prefix for temp directory |
|
sparse |
Enable sparse checkout mode to avoid populating all files initially. |
|
shallow |
Enable shallow clone (depth=1) to fetch only the target commit. |
|
blob_filter |
Enable blob filtering (--filter=blob:none) to fetch file contents on-demand |
|
remove_existing |
Remove existing directory if it exists |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If Git version check fails |
GitCommandError
|
If clone operation fails |
UnableToDeleteError
|
If unable to delete the cloned repository |
Source code in src/lampe/core/tools/repository/management.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
clone_repo(repo_url: str, head_ref: str | None = None, base_ref: str | None = None, folder_name: str | None = None, sparse: bool = True, shallow: bool = True, blob_filter: bool = True, remove_existing: bool = True) -> str
Clone a repository optimized for PR review.
Uses partial clone optimizations including shallow clone, sparse checkout, and blob filtering to efficiently fetch only required content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_url
|
str
|
Repository URL to clone |
required |
head_ref
|
str | None
|
Head ref to checkout |
None
|
base_ref
|
str | None
|
Base ref to fetch for diff computation |
None
|
folder_name
|
str | None
|
Optional name prefix for temp directory |
None
|
sparse
|
bool
|
Enable sparse checkout mode to avoid populating all files initially |
True
|
shallow
|
bool
|
Enable shallow clone (depth=1) to fetch only the target commit |
True
|
blob_filter
|
bool
|
Enable blob filtering (--filter=blob:none) to fetch file contents on-demand |
True
|
remove_existing
|
bool
|
Remove existing directory if it exists |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the cloned repository |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If Git version check fails |
GitCommandError
|
If clone operation fails |
Source code in src/lampe/core/tools/repository/management.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
fetch_commit_ref(repo_path: str, commit_ref: str) -> None
Fetch a base reference from the remote repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_path
|
str
|
Path to the git repository |
required |
commit_ref
|
str
|
Commit reference to fetch (e.g., branch name, commit hash) |
required |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If the fetch operation fails |
Source code in src/lampe/core/tools/repository/management.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
is_sparse_clone(repo_path: str) -> bool
Check if a repository is a sparse clone.
A sparse clone is detected by checking multiple indicators: 1. If core.sparseCheckout is enabled 2. If .git/info/sparse-checkout file exists and has content
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_path
|
str
|
Path to the git repository |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the repository appears to be a sparse clone, False otherwise |
Raises:
| Type | Description |
|---|---|
GitCommandError
|
If git commands fail |
Source code in src/lampe/core/tools/repository/management.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
search
find_files_by_pattern(pattern: str, repo_path: str = '/tmp/') -> str
Search for files using git ls-files and pattern matching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern to search for (e.g. ".py", "src//.md") |
required |
repo_path
|
str
|
Path to git repository |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string containing matching file paths |
Source code in src/lampe/core/tools/repository/search.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
search_in_files(pattern: str, relative_dir_path: str, commit_reference: str, include_line_numbers: bool = False, repo_path: str = '/tmp/') -> str
Search for a pattern in files within a directory at a specific commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern to search for |
required |
relative_dir_path
|
str
|
Directory path to search in |
required |
commit_reference
|
str
|
Commit reference to search at |
required |
include_line_numbers
|
bool
|
Whether to include line numbers in search results (default: False) |
False
|
repo_path
|
str
|
Path to the git repository, by default "/tmp/" |
'/tmp/'
|
Returns:
| Type | Description |
|---|---|
str
|
Search results as a string |
Source code in src/lampe/core/tools/repository/search.py
11 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 | |
utils
truncate_to_token_limit(content: str, max_tokens: int) -> str
Truncate the content to the maximum number of tokens.
If the content is too long, truncate it to 200000 characters (3-4 characters per token)
before encoding for performance reasons.
We allow endoftext token to be encoded, since in the past we encountered issues with the tokenizer.
Args: content (str): The content to truncate. max_tokens (int): The maximum number of tokens to keep.
Returns: str: The truncated content.
Source code in src/lampe/core/utils/token.py
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 | |
token
truncate_to_token_limit(content: str, max_tokens: int) -> str
Truncate the content to the maximum number of tokens.
If the content is too long, truncate it to 200000 characters (3-4 characters per token)
before encoding for performance reasons.
We allow endoftext token to be encoded, since in the past we encountered issues with the tokenizer.
Args: content (str): The content to truncate. max_tokens (int): The maximum number of tokens to keep.
Returns: str: The truncated content.
Source code in src/lampe/core/utils/token.py
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 | |
describe
PRDescriptionWorkflow(truncation_tokens=MAX_TOKENS, *args, **kwargs)
Bases: Workflow
A workflow that generates a PR description.
Based on the pull request's diff generate a clear, concise description explaining what are the changes being made and why.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
truncation_tokens
|
Maximum number of tokens to use for the diff content, by default MAX_TOKENS |
MAX_TOKENS
|
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
47 48 49 50 51 | |
generate_description(ev: PRDescriptionPromptEvent) -> StopEvent
async
Generate a PR description.
This step generates a PR description using the LLM. It uses the truncated diff of all the changes between 2 commits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ev
|
PRDescriptionPromptEvent
|
The prompt event containing the prepared diff and prompt. |
required |
Returns:
| Type | Description |
|---|---|
StopEvent
|
The stop event containing the generated description. |
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
prepare_diff_and_prompt(ev: PRDescriptionStartEvent) -> PRDescriptionPromptEvent
async
Prepare the diff and prompt for the LLM.
This step prepares the diff and prompt for the LLM. It truncates the diff to the maximum number of tokens and formats the prompt. The diff is filtered using files_exclude_patterns, files_include_patterns and files_reinclude_patterns. The files_reinclude_patterns allow overriding files_exclude_patterns, which is useful for patterns like "!readme.txt" that should override "*.txt" exclusions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ev
|
PRDescriptionStartEvent
|
The start event containing the PR details. |
required |
Returns:
| Type | Description |
|---|---|
PRDescriptionPromptEvent
|
The prompt event containing the prepared diff and prompt. |
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
generate_pr_description(repository: Repository, pull_request: PullRequest, files_exclude_patterns: list[str] | None = None, files_reinclude_patterns: list[str] | None = None, truncation_tokens: int = MAX_TOKENS, timeout: int | None = None, verbose: bool = False, metadata: dict | None = None) -> PRDescriptionOutput
async
Generate a PR description.
This function generates a PR description for a given pull request. It uses the PRDescriptionWorkflow to generate the description.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repository
|
Repository
|
The repository to generate the PR description for. |
required |
pull_request
|
PullRequest
|
The pull request to generate the PR description for. |
required |
files_exclude_patterns
|
list[str] | None
|
The glob matching patterns to exclude from the diff, by default None |
None
|
files_reinclude_patterns
|
list[str] | None
|
The glob matching patterns to re-include in the diff, by default None |
None
|
truncation_tokens
|
int
|
The maximum number of tokens to use for the diff content, by default MAX_TOKENS |
MAX_TOKENS
|
timeout
|
int | None
|
The timeout for the workflow, by default None |
None
|
verbose
|
bool
|
Whether to print verbose output, by default False |
False
|
metadata
|
dict | None
|
The metadata to use for the workflow, by default None |
None
|
Returns:
| Type | Description |
|---|---|
PRDescriptionOutput
|
The output containing the generated description. |
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
workflows
PRDescriptionWorkflow(truncation_tokens=MAX_TOKENS, *args, **kwargs)
Bases: Workflow
A workflow that generates a PR description.
Based on the pull request's diff generate a clear, concise description explaining what are the changes being made and why.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
truncation_tokens
|
Maximum number of tokens to use for the diff content, by default MAX_TOKENS |
MAX_TOKENS
|
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
47 48 49 50 51 | |
generate_description(ev: PRDescriptionPromptEvent) -> StopEvent
async
Generate a PR description.
This step generates a PR description using the LLM. It uses the truncated diff of all the changes between 2 commits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ev
|
PRDescriptionPromptEvent
|
The prompt event containing the prepared diff and prompt. |
required |
Returns:
| Type | Description |
|---|---|
StopEvent
|
The stop event containing the generated description. |
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
prepare_diff_and_prompt(ev: PRDescriptionStartEvent) -> PRDescriptionPromptEvent
async
Prepare the diff and prompt for the LLM.
This step prepares the diff and prompt for the LLM. It truncates the diff to the maximum number of tokens and formats the prompt. The diff is filtered using files_exclude_patterns, files_include_patterns and files_reinclude_patterns. The files_reinclude_patterns allow overriding files_exclude_patterns, which is useful for patterns like "!readme.txt" that should override "*.txt" exclusions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ev
|
PRDescriptionStartEvent
|
The start event containing the PR details. |
required |
Returns:
| Type | Description |
|---|---|
PRDescriptionPromptEvent
|
The prompt event containing the prepared diff and prompt. |
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
pr_description
PRDescriptionWorkflow(truncation_tokens=MAX_TOKENS, *args, **kwargs)
Bases: Workflow
A workflow that generates a PR description.
Based on the pull request's diff generate a clear, concise description explaining what are the changes being made and why.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
truncation_tokens
|
Maximum number of tokens to use for the diff content, by default MAX_TOKENS |
MAX_TOKENS
|
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
47 48 49 50 51 | |
generate_description(ev: PRDescriptionPromptEvent) -> StopEvent
async
Generate a PR description.
This step generates a PR description using the LLM. It uses the truncated diff of all the changes between 2 commits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ev
|
PRDescriptionPromptEvent
|
The prompt event containing the prepared diff and prompt. |
required |
Returns:
| Type | Description |
|---|---|
StopEvent
|
The stop event containing the generated description. |
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
prepare_diff_and_prompt(ev: PRDescriptionStartEvent) -> PRDescriptionPromptEvent
async
Prepare the diff and prompt for the LLM.
This step prepares the diff and prompt for the LLM. It truncates the diff to the maximum number of tokens and formats the prompt. The diff is filtered using files_exclude_patterns, files_include_patterns and files_reinclude_patterns. The files_reinclude_patterns allow overriding files_exclude_patterns, which is useful for patterns like "!readme.txt" that should override "*.txt" exclusions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ev
|
PRDescriptionStartEvent
|
The start event containing the PR details. |
required |
Returns:
| Type | Description |
|---|---|
PRDescriptionPromptEvent
|
The prompt event containing the prepared diff and prompt. |
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
data_models
PRDescriptionInput
Bases: BaseModel
Input for PR description generation workflow.
generation
PRDescriptionWorkflow(truncation_tokens=MAX_TOKENS, *args, **kwargs)
Bases: Workflow
A workflow that generates a PR description.
Based on the pull request's diff generate a clear, concise description explaining what are the changes being made and why.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
truncation_tokens
|
Maximum number of tokens to use for the diff content, by default MAX_TOKENS |
MAX_TOKENS
|
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
47 48 49 50 51 | |
generate_description(ev: PRDescriptionPromptEvent) -> StopEvent
async
Generate a PR description.
This step generates a PR description using the LLM. It uses the truncated diff of all the changes between 2 commits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ev
|
PRDescriptionPromptEvent
|
The prompt event containing the prepared diff and prompt. |
required |
Returns:
| Type | Description |
|---|---|
StopEvent
|
The stop event containing the generated description. |
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
prepare_diff_and_prompt(ev: PRDescriptionStartEvent) -> PRDescriptionPromptEvent
async
Prepare the diff and prompt for the LLM.
This step prepares the diff and prompt for the LLM. It truncates the diff to the maximum number of tokens and formats the prompt. The diff is filtered using files_exclude_patterns, files_include_patterns and files_reinclude_patterns. The files_reinclude_patterns allow overriding files_exclude_patterns, which is useful for patterns like "!readme.txt" that should override "*.txt" exclusions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ev
|
PRDescriptionStartEvent
|
The start event containing the PR details. |
required |
Returns:
| Type | Description |
|---|---|
PRDescriptionPromptEvent
|
The prompt event containing the prepared diff and prompt. |
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
generate_pr_description(repository: Repository, pull_request: PullRequest, files_exclude_patterns: list[str] | None = None, files_reinclude_patterns: list[str] | None = None, truncation_tokens: int = MAX_TOKENS, timeout: int | None = None, verbose: bool = False, metadata: dict | None = None) -> PRDescriptionOutput
async
Generate a PR description.
This function generates a PR description for a given pull request. It uses the PRDescriptionWorkflow to generate the description.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repository
|
Repository
|
The repository to generate the PR description for. |
required |
pull_request
|
PullRequest
|
The pull request to generate the PR description for. |
required |
files_exclude_patterns
|
list[str] | None
|
The glob matching patterns to exclude from the diff, by default None |
None
|
files_reinclude_patterns
|
list[str] | None
|
The glob matching patterns to re-include in the diff, by default None |
None
|
truncation_tokens
|
int
|
The maximum number of tokens to use for the diff content, by default MAX_TOKENS |
MAX_TOKENS
|
timeout
|
int | None
|
The timeout for the workflow, by default None |
None
|
verbose
|
bool
|
Whether to print verbose output, by default False |
False
|
metadata
|
dict | None
|
The metadata to use for the workflow, by default None |
None
|
Returns:
| Type | Description |
|---|---|
PRDescriptionOutput
|
The output containing the generated description. |
Source code in packages/lampe-describe/src/lampe/describe/workflows/pr_description/generation.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
review
generate_multi_agent_pr_review(repository: Repository, pull_request: PullRequest, review_depth: ReviewDepth = ReviewDepth.STANDARD, custom_guidelines: list[str] | None = None, files_exclude_patterns: list[str] | None = None, timeout: int | None = None, verbose: bool = False, agents_required: list[type[SpecializedReviewAgent]] | None = None) -> PRReviewComplete
async
Generate a PR review using the multi-agent LlamaIndex workflow.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/multi_agent_pipeline.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
workflows
pr_review
MultiAgentPipelineWorkflow(agents: list[SpecializedReviewAgent], timeout: int | None = None, verbose: bool = False, *args: Any, **kwargs: Any)
Bases: Workflow
LlamaIndex Workflow for multi-agent PR review pipeline.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/multi_agent_pipeline.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
execute_pipeline(ctx: Context, ev: PRReviewStart) -> PRReviewComplete
async
Execute the complete multi-agent review pipeline.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/multi_agent_pipeline.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
agents
Specialized review agents for multi-agent PR review system.
APIUsageAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in validating API usage and library integration.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/api_usage_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
CodeQualityAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in code quality, readability, and maintainability.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/code_quality_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
DefaultAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in validating design patterns and architectural consistency.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/default_agent.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
setup_query_and_tools(ctx: Context, ev: SpecializedAgentStart) -> UserInputEvent
async
Setup the query and tools for the specialized agent.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/default_agent.py
31 32 33 34 35 36 37 38 39 40 41 | |
DesignPatternAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in validating design patterns and architectural consistency.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/design_pattern_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
DiffFocusedAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent that focuses on reviewing one specific diff to find bugs introduced by that change.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/diff_focused_agent.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
setup_query_and_tools(ctx: Context, ev: SpecializedAgentStart) -> UserInputEvent
async
Setup the query and tools for the diff-focused agent.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/diff_focused_agent.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
PerformanceAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in identifying performance issues and optimization opportunities.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/performance_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
SecurityAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in identifying security vulnerabilities and issues.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/security_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
TestingAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in testing strategy, coverage, and test quality.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/testing_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
api_usage_agent
API and library usage validation agent.
APIUsageAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in validating API usage and library integration.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/api_usage_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
api_usage_agent_prompt
API usage agent prompt for validating API usage and library integration.
code_quality_agent
Code quality and maintainability agent.
CodeQualityAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in code quality, readability, and maintainability.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/code_quality_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
code_quality_agent_prompt
Code quality agent prompt for ensuring code quality, readability, and maintainability.
default_agent
Design pattern and architectural consistency agent.
DefaultAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in validating design patterns and architectural consistency.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/default_agent.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
setup_query_and_tools(ctx: Context, ev: SpecializedAgentStart) -> UserInputEvent
async
Setup the query and tools for the specialized agent.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/default_agent.py
31 32 33 34 35 36 37 38 39 40 41 | |
design_pattern_agent
Design pattern and architectural consistency agent.
DesignPatternAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in validating design patterns and architectural consistency.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/design_pattern_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
design_pattern_agent_prompt
Design pattern agent prompt for validating design patterns and architectural consistency.
diff_focused_agent
Diff-focused agent that reviews one specific diff at a time to find bugs.
DiffFocusedAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent that focuses on reviewing one specific diff to find bugs introduced by that change.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/diff_focused_agent.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
setup_query_and_tools(ctx: Context, ev: SpecializedAgentStart) -> UserInputEvent
async
Setup the query and tools for the diff-focused agent.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/diff_focused_agent.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
diff_focused_agent_prompt
Prompt for diff-focused agent that reviews one specific diff at a time.
performance_agent
Performance analysis and optimization agent.
PerformanceAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in identifying performance issues and optimization opportunities.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/performance_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
performance_agent_prompt
Performance agent prompt for identifying performance issues and optimization opportunities.
security_agent
Security-focused review agent for identifying security vulnerabilities.
SecurityAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in identifying security vulnerabilities and issues.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/security_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
security_agent_prompt
Security agent prompt for identifying security vulnerabilities.
specialized_agent_base
SpecializedAgentComplete
Bases: StopEvent
Stop event for specialized review agent.
SpecializedAgentStart
Bases: StartEvent
Start event for specialized review agent.
SpecializedReviewAgent(agent_name: str = '', focus_areas: list[str] | None = None, system_prompt: str = '', *args: Any, **kwargs: Any)
Bases: FunctionCallingAgent
Base class for specialized review agents.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/specialized_agent_base.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
handle_agent_completion(ctx: Context, ev: AgentCompleteEvent) -> SpecializedAgentComplete
async
Handle agent completion and generate structured output.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/specialized_agent_base.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
setup_query_and_tools(ctx: Context, ev: SpecializedAgentStart) -> UserInputEvent
async
Setup the query and tools for the specialized agent.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/specialized_agent_base.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
specialized_agent_base_prompt
Specialized agent base prompts for review depth guidelines and agent prompt template.
testing_agent
Testing strategy and coverage agent.
TestingAgent(*args, **kwargs)
Bases: SpecializedReviewAgent
Agent specialized in testing strategy, coverage, and test quality.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/agents/testing_agent.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
testing_agent_prompt
Testing agent prompt for testing strategy, coverage, and test quality.
aggregator
Review aggregator for merging and deduplicating agent findings.
ReviewAggregator
Aggregates reviews from multiple agents and deduplicates findings.
aggregate_reviews(agent_reviews: list[AgentReviewOutput]) -> list[FileReview]
Aggregate reviews from all agents into a cohesive output.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/aggregator.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
data_models
AgentResponseModel
Bases: BaseModel
Pydantic model for agent JSON response parsing.
AgentReviewInput
Bases: BaseModel
Input for individual specialized agents.
AgentReviewOutput
Bases: BaseModel
Output from individual specialized agents.
FileReview
Bases: BaseModel
Review for a specific file with inline comments.
PRReivewAggregatorOutput
Bases: BaseModel
Output model for PR review aggregation.
PRReviewInput
Bases: BaseModel
Input for PR review generation workflow.
ReviewComment
Bases: BaseModel
Structured comment with metadata.
ReviewDepth
Bases: str, Enum
Review depth levels for PR reviews.
ReviewType
Bases: str, Enum
Review strategy types for PR reviews.
diff_by_diff_pipeline
Diff-by-diff parallel review pipeline using BaseParallelWorkflow.
DiffByDiffPipelineWorkflow(timeout: int | None = None, verbose: bool = False, *args: Any, **kwargs: Any)
Bases: Workflow
Workflow that reviews each file diff in parallel, then aggregates results with LLM.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/diff_by_diff_pipeline.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
aggregate_reviews(ctx: Context, ev: ParallelDiffReviewsCompleteEvent) -> PRReviewComplete
async
Aggregate and clean reviews using LLM workflow.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/diff_by_diff_pipeline.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
start_pipeline(ctx: Context, ev: DiffByDiffStartEvent) -> ParallelDiffReviewsCompleteEvent | None
async
Start the diff-by-diff review pipeline.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/diff_by_diff_pipeline.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
DiffByDiffStartEvent
Bases: StartEvent
Start event for diff-by-diff pipeline workflow.
DiffReviewWrapperWorkflow(timeout: int | None = None, verbose: bool = False, *args: Any, **kwargs: Any)
Bases: Workflow
Wrapper workflow to run a single diff-focused agent review.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/diff_by_diff_pipeline.py
52 53 54 55 56 | |
run_agent_review(ev: SpecializedAgentStart) -> StopEvent
async
Run a single agent review and return the result.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/diff_by_diff_pipeline.py
58 59 60 61 62 63 64 65 66 67 68 | |
ParallelDiffReviewsCompleteEvent
Bases: Event
Event when all parallel diff reviews are complete.
generate_diff_by_diff_pr_review(repository: Repository, pull_request: PullRequest, review_depth: ReviewDepth = ReviewDepth.STANDARD, custom_guidelines: list[str] | None = None, files_exclude_patterns: list[str] | None = None, files_reinclude_patterns: list[str] | None = None, timeout: int | None = None, verbose: bool = False) -> PRReviewComplete
async
Generate a PR review using the diff-by-diff parallel pipeline.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/diff_by_diff_pipeline.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
llm_aggregation_prompt
Prompt for LLM-based review aggregation step.
llm_aggregation_step
LLM-based aggregation workflow for cleaning and deduplicating review comments.
AggregatedReviewsModel
Bases: BaseModel
Pydantic model for LLM aggregation output.
LLMAggregationCompleteEvent
Bases: StopEvent
Complete event for LLM aggregation workflow.
LLMAggregationStartEvent
Bases: StartEvent
Start event for LLM aggregation workflow.
LLMAggregationWorkflow(timeout: int | None = None, verbose: bool = False, *args: Any, **kwargs: Any)
Bases: Workflow
Workflow for aggregating and cleaning review comments using LLM.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/llm_aggregation_step.py
45 46 47 48 49 50 51 52 53 54 55 | |
aggregate_reviews(ctx: Context, ev: LLMAggregationStartEvent) -> LLMAggregationCompleteEvent
async
Aggregate and clean reviews using LLM.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/llm_aggregation_step.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 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 104 105 106 107 108 109 | |
multi_agent_pipeline
Multi-agent sequential pipeline for PR review using LlamaIndex Workflow.
AgentReviewEvent
Bases: Event
Event containing agent review results.
AggregationEvent
Bases: Event
Event containing aggregated reviews.
FilesChangedEvent
Bases: Event
Event containing the list of changed files.
MultiAgentPipelineWorkflow(agents: list[SpecializedReviewAgent], timeout: int | None = None, verbose: bool = False, *args: Any, **kwargs: Any)
Bases: Workflow
LlamaIndex Workflow for multi-agent PR review pipeline.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/multi_agent_pipeline.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
execute_pipeline(ctx: Context, ev: PRReviewStart) -> PRReviewComplete
async
Execute the complete multi-agent review pipeline.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/multi_agent_pipeline.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
PRReviewComplete
Bases: StopEvent
Complete event for PR review workflow.
PRReviewStart
Bases: StartEvent
Start event for PR review workflow.
generate_multi_agent_pr_review(repository: Repository, pull_request: PullRequest, review_depth: ReviewDepth = ReviewDepth.STANDARD, custom_guidelines: list[str] | None = None, files_exclude_patterns: list[str] | None = None, timeout: int | None = None, verbose: bool = False, agents_required: list[type[SpecializedReviewAgent]] | None = None) -> PRReviewComplete
async
Generate a PR review using the multi-agent LlamaIndex workflow.
Source code in packages/lampe-review/src/lampe/review/workflows/pr_review/multi_agent_pipeline.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
template
TemplateWorkflow
Bases: Workflow
A template workflow that demonstrates basic workflow structure.
This workflow is responsible for: - Demonstrating the basic workflow pattern - Showing how to handle events - Providing a template for new workflows
template_workflow
TemplateWorkflow
Bases: Workflow
A template workflow that demonstrates basic workflow structure.
This workflow is responsible for: - Demonstrating the basic workflow pattern - Showing how to handle events - Providing a template for new workflows