[chore] run full pre-commit (#8104)

This commit is contained in:
Engel Nyst
2025-04-27 08:43:26 +02:00
committed by GitHub
parent 8a5c6d3bef
commit 70f469b0c1
17 changed files with 63 additions and 69 deletions

View File

@@ -4,7 +4,7 @@ const swaggerUiDist = require('swagger-ui-dist');
/**
* This script manually sets up Swagger UI for the Docusaurus documentation.
*
*
* Why we need this approach:
* 1. Docusaurus doesn't have a built-in way to integrate Swagger UI
* 2. We need to copy the necessary files from swagger-ui-dist to our static directory
@@ -26,15 +26,15 @@ const files = fs.readdirSync(swaggerUiDistPath);
files.forEach(file => {
const sourcePath = path.join(swaggerUiDistPath, file);
const targetPath = path.join(targetDir, file);
// Skip directories and non-essential files
if (fs.statSync(sourcePath).isDirectory() ||
file === 'package.json' ||
if (fs.statSync(sourcePath).isDirectory() ||
file === 'package.json' ||
file === 'README.md' ||
file.endsWith('.map')) {
return;
}
fs.copyFileSync(sourcePath, targetPath);
});
@@ -54,13 +54,13 @@ const indexHtml = `
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
background: #fafafa;
@@ -99,4 +99,4 @@ const indexHtml = `
fs.writeFileSync(path.join(targetDir, 'index.html'), indexHtml);
console.log('Swagger UI files generated successfully in static/swagger-ui/');
console.log('Swagger UI files generated successfully in static/swagger-ui/');

View File

@@ -5,7 +5,7 @@ You can customize how OpenHands interacts with your repository by creating a
## Microagents
Microagents allow you to extend OpenHands prompts with information specific to your project and define how OpenHands
Microagents allow you to extend OpenHands prompts with information specific to your project and define how OpenHands
should function. See [Microagents Overview](../prompting/microagents-overview) for more information.

View File

@@ -2,7 +2,7 @@
## Purpose
Keyword-triggered microagents provide OpenHands with specific instructions that are activated when certain keywords
Keyword-triggered microagents provide OpenHands with specific instructions that are activated when certain keywords
appear in the prompt. This is useful for tailoring behavior based on particular tools, languages, or frameworks.
## Microagent File
@@ -12,7 +12,7 @@ that activate only for prompts with specific keywords.
## Frontmatter Syntax
Frontmatter is required for keyword-triggered microagents. It must be placed at the top of the file,
Frontmatter is required for keyword-triggered microagents. It must be placed at the top of the file,
above the guidelines.
Enclose the frontmatter in triple dashes (---) and include the following fields:
@@ -22,7 +22,7 @@ Enclose the frontmatter in triple dashes (---) and include the following fields:
| `name` | A unique identifier for the microagent. | Yes | 'default' |
| `type` | Type of microagent. Must be set to `knowledge`. | Yes | 'repo' |
| `triggers` | A list of keywords that activate the microagent. | Yes | None |
| `agent` | The agent this microagent applies to. | No | 'CodeActAgent' |
| `agent` | The agent this microagent applies to. | No | 'CodeActAgent' |
## Example
@@ -46,4 +46,4 @@ Keyword-triggered microagents:
- Apply their specialized knowledge and capabilities.
- Follow defined guidelines and restrictions.
[See examples of microagents triggered by keywords in the official OpenHands repository](https://github.com/All-Hands-AI/OpenHands/tree/main/microagents/knowledge)
[See examples of microagents triggered by keywords in the official OpenHands repository](https://github.com/All-Hands-AI/OpenHands/tree/main/microagents/knowledge)

View File

@@ -1,6 +1,6 @@
# Microagents Overview
Microagents are specialized prompts that enhance OpenHands with domain-specific knowledge.
Microagents are specialized prompts that enhance OpenHands with domain-specific knowledge.
They provide expert guidance, automate common tasks, and ensure consistent practices across projects.
## Microagent Types
@@ -10,11 +10,11 @@ Currently OpenHands supports the following types of microagents:
- [General Repository Microagents](./microagents-repo): General guidelines for OpenHands about the repository.
- [Keyword-Triggered Microagents](./microagents-keyword): Guidelines activated by specific keywords in prompts.
To customize OpenHands' behavior, create a .openhands/microagents/ directory in the root of your repository and
To customize OpenHands' behavior, create a .openhands/microagents/ directory in the root of your repository and
add `<microagent_name>.md` files inside.
:::note
Loaded microagents take up space in the context window.
Loaded microagents take up space in the context window.
These microagents, alongside user messages, inform OpenHands about the task and the environment.
:::
@@ -31,7 +31,7 @@ some-repository/
## Microagents Frontmatter Requirements
Each microagent file may include frontmatter that provides additional information. In some cases, this frontmatter
Each microagent file may include frontmatter that provides additional information. In some cases, this frontmatter
is required:
| Microagent Type | Frontmatter Requirement |

View File

@@ -6,13 +6,13 @@ General guidelines for OpenHands to work more effectively with the repository.
## Microagent File
Create a general repository microagent (example: `.openhands/microagents/repo.md`) to include
project-specific instructions, team practices, coding standards, and architectural guidelines that are relevant for
Create a general repository microagent (example: `.openhands/microagents/repo.md`) to include
project-specific instructions, team practices, coding standards, and architectural guidelines that are relevant for
**all** prompts in that repository.
## Frontmatter Syntax
The frontmatter for this type of microagent is optional, unless you plan to include more than one general
The frontmatter for this type of microagent is optional, unless you plan to include more than one general
repository microagent.
Frontmatter should be enclosed in triple dashes (---) and may include the following fields:

View File

@@ -268,4 +268,4 @@ const sidebars: SidebarsConfig = {
],
};
export default sidebars;
export default sidebars;

View File

@@ -12,4 +12,4 @@ This file is used by the Swagger UI interface, which is accessible at `/swagger-
The OpenAPI specification is placed in the static directory so that it's accessible at a predictable URL in the deployed site. This allows the Swagger UI to reference it directly.
We only need one copy of the OpenAPI spec file, which is this one in the static directory.
We only need one copy of the OpenAPI spec file, which is this one in the static directory.

View File

@@ -35,6 +35,10 @@ export enum I18nKey {
CONVERSATION$START_NEW = "CONVERSATION$START_NEW",
ACCOUNT_SETTINGS$TITLE = "ACCOUNT_SETTINGS$TITLE",
WORKSPACE$TERMINAL_TAB_LABEL = "WORKSPACE$TERMINAL_TAB_LABEL",
WORKSPACE$BROWSER_TAB_LABEL = "WORKSPACE$BROWSER_TAB_LABEL",
WORKSPACE$JUPYTER_TAB_LABEL = "WORKSPACE$JUPYTER_TAB_LABEL",
WORKSPACE$CODE_EDITOR_TAB_LABEL = "WORKSPACE$CODE_EDITOR_TAB_LABEL",
WORKSPACE$TITLE = "WORKSPACE$TITLE",
TERMINAL$WAITING_FOR_CLIENT = "TERMINAL$WAITING_FOR_CLIENT",
CODE_EDITOR$FILE_SAVED_SUCCESSFULLY = "CODE_EDITOR$FILE_SAVED_SUCCESSFULLY",
CODE_EDITOR$SAVING_LABEL = "CODE_EDITOR$SAVING_LABEL",
@@ -281,6 +285,7 @@ export enum I18nKey {
BUTTON$CREATE = "BUTTON$CREATE",
BUTTON$DELETE = "BUTTON$DELETE",
BUTTON$COPY_TO_CLIPBOARD = "BUTTON$COPY_TO_CLIPBOARD",
BUTTON$REFRESH = "BUTTON$REFRESH",
ERROR$REQUIRED_FIELD = "ERROR$REQUIRED_FIELD",
PLANNER$EMPTY_MESSAGE = "PLANNER$EMPTY_MESSAGE",
FEEDBACK$PUBLIC_LABEL = "FEEDBACK$PUBLIC_LABEL",

View File

@@ -5,7 +5,6 @@ from typing import Any
from pydantic import BaseModel
from openhands.core.logger import openhands_logger as logger
from openhands.events import Event, EventSource
from openhands.events.serialization.action import action_from_dict
from openhands.events.serialization.observation import observation_from_dict

View File

@@ -1,5 +1,6 @@
import json
import os
from datetime import datetime
from typing import Any
import httpx
@@ -18,8 +19,6 @@ from openhands.integrations.service_types import (
)
from openhands.server.types import AppMode
from openhands.utils.import_utils import get_impl
from datetime import datetime
class GitHubService(BaseGitService, GitService):
@@ -159,12 +158,9 @@ class GitHubService(BaseGitService, GitService):
return repos[:max_repos] # Trim to max_repos if needed
def parse_pushed_at_date(self, repo):
ts = repo.get("pushed_at")
return datetime.strptime(ts, "%Y-%m-%dT%H:%M:%SZ") if ts else datetime.min
ts = repo.get('pushed_at')
return datetime.strptime(ts, '%Y-%m-%dT%H:%M:%SZ') if ts else datetime.min
async def get_repositories(self, sort: str, app_mode: AppMode) -> list[Repository]:
MAX_REPOS = 1000
@@ -192,11 +188,9 @@ class GitHubService(BaseGitService, GitService):
# If we've already reached MAX_REPOS, no need to check other installations
if len(all_repos) >= MAX_REPOS:
break
if sort == "pushed":
all_repos.sort(
key=self.parse_pushed_at_date, reverse=True
)
if sort == 'pushed':
all_repos.sort(key=self.parse_pushed_at_date, reverse=True)
else:
# Original behavior for non-SaaS mode
params = {'per_page': str(PER_PAGE), 'sort': sort}
@@ -205,7 +199,6 @@ class GitHubService(BaseGitService, GitService):
# Fetch user repositories
all_repos = await self._fetch_paginated_repos(url, params, MAX_REPOS)
# Convert to Repository objects
return [
Repository(

View File

@@ -108,7 +108,9 @@ class GitLabService(BaseGitService, GitService):
except httpx.HTTPError as e:
raise self.handle_http_error(e)
async def execute_graphql_query(self, query: str, variables: dict[str, Any] = {}) -> Any:
async def execute_graphql_query(
self, query: str, variables: dict[str, Any]|None = None
) -> Any:
"""
Execute a GraphQL query against the GitLab GraphQL API
@@ -119,6 +121,8 @@ class GitLabService(BaseGitService, GitService):
Returns:
The data portion of the GraphQL response
"""
if variables is None:
variables = {}
try:
async with httpx.AsyncClient() as client:
gitlab_headers = await self._get_gitlab_headers()
@@ -294,7 +298,7 @@ class GitLabService(BaseGitService, GitService):
try:
tasks: list[SuggestedTask] = []
# Get merge requests using GraphQL
response = await self.execute_graphql_query(query)
data = response.get('currentUser', {})
@@ -343,27 +347,27 @@ class GitLabService(BaseGitService, GitService):
title=title,
)
)
# Get assigned issues using REST API
url = f"{self.BASE_URL}/issues"
url = f'{self.BASE_URL}/issues'
params = {
"assignee_username": username,
"state": "opened",
"scope": "assigned_to_me"
'assignee_username': username,
'state': 'opened',
'scope': 'assigned_to_me',
}
issues_response, _ = await self._make_request(
method=RequestMethod.GET,
url=url,
params=params
method=RequestMethod.GET, url=url, params=params
)
# Process issues
for issue in issues_response:
repo_name = issue.get('references', {}).get('full', '').split('#')[0].strip()
repo_name = (
issue.get('references', {}).get('full', '').split('#')[0].strip()
)
issue_number = issue.get('iid')
title = issue.get('title', '')
tasks.append(
SuggestedTask(
git_provider=ProviderType.GITLAB,

View File

@@ -20,7 +20,9 @@ class ServerConfig(ServerConfigInterface):
)
conversation_manager_class: str = 'openhands.server.conversation_manager.standalone_conversation_manager.StandaloneConversationManager'
monitoring_listener_class: str = 'openhands.server.monitoring.MonitoringListener'
user_auth_class: str = 'openhands.server.user_auth.default_user_auth.DefaultUserAuth'
user_auth_class: str = (
'openhands.server.user_auth.default_user_auth.DefaultUserAuth'
)
def verify_config(self):
if self.config_cls:

View File

@@ -234,7 +234,7 @@ async def git_diff(
request: Request,
path: str,
conversation_id: str,
conversation_store = Depends(get_conversation_store),
conversation_store=Depends(get_conversation_store),
):
runtime: Runtime = request.state.conversation.runtime

View File

@@ -2,11 +2,9 @@ from fastapi import APIRouter, Depends, status
from fastapi.responses import JSONResponse
from pydantic import SecretStr
from openhands.integrations.github.github_service import GithubServiceImpl
from openhands.integrations.provider import (
PROVIDER_TOKEN_TYPE,
ProviderHandler,
ProviderType,
)
from openhands.integrations.service_types import (
AuthenticationError,
@@ -166,4 +164,4 @@ async def get_suggested_tasks(
return JSONResponse(
content='No providers set.',
status_code=status.HTTP_401_UNAUTHORIZED,
)
)

View File

@@ -344,9 +344,7 @@ async def update_conversation(
title: str = Body(embed=True),
user_id: str | None = Depends(get_user_id),
) -> bool:
conversation_store = await ConversationStoreImpl.get_instance(
config, user_id
)
conversation_store = await ConversationStoreImpl.get_instance(config, user_id)
metadata = await conversation_store.get_metadata(conversation_id)
if not metadata:
return False
@@ -369,9 +367,7 @@ async def delete_conversation(
conversation_id: str,
user_id: str | None = Depends(get_user_id),
) -> bool:
conversation_store = await ConversationStoreImpl.get_instance(
config, user_id
)
conversation_store = await ConversationStoreImpl.get_instance(config, user_id)
try:
await conversation_store.get_metadata(conversation_id)
except FileNotFoundError:

View File

@@ -1,4 +1,4 @@
from fastapi import APIRouter, Depends, Request, status
from fastapi import APIRouter, Depends, status
from fastapi.responses import JSONResponse
from pydantic import SecretStr
@@ -17,8 +17,7 @@ from openhands.server.settings import (
POSTSettingsModel,
Settings,
)
from openhands.server.shared import SettingsStoreImpl, config, server_config
from openhands.server.types import AppMode
from openhands.server.shared import config
from openhands.server.user_auth import (
get_provider_tokens,
get_user_id,
@@ -59,7 +58,8 @@ async def load_settings(
settings_with_token_data = GETSettingsModel(
**settings.model_dump(exclude='secrets_store'),
llm_api_key_set=settings.llm_api_key is not None and bool(settings.llm_api_key),
llm_api_key_set=settings.llm_api_key is not None
and bool(settings.llm_api_key),
provider_tokens_set=provider_tokens_set,
)
settings_with_token_data.llm_api_key = None
@@ -211,9 +211,7 @@ async def reset_settings() -> JSONResponse:
"""
Resets user settings. (Deprecated)
"""
logger.warning(
f"Deprecated endpoint /api/reset-settings called by user"
)
logger.warning('Deprecated endpoint /api/reset-settings called by user')
return JSONResponse(
status_code=status.HTTP_410_GONE,
content={'error': 'Reset settings functionality has been removed.'},

View File

@@ -1,6 +1,5 @@
from __future__ import annotations
import os
from abc import ABC, abstractmethod
from fastapi import Request