Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ pnpm dev

Runs on `http://localhost:3000` by default.

## Pre-commit setup

AstrBot uses [pre-commit](https://pre-commit.com/) hooks to automatically format and lint Python code before each commit. The hooks run `ruff check`, `ruff format`, and `pyupgrade` (see [`.pre-commit-config.yaml`](.pre-commit-config.yaml) for details).

To set it up:

```bash
pip install pre-commit
pre-commit install
Comment on lines +29 to +30
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since the project uses uv for environment management (as seen in the Setup commands section), it is more consistent to use uv for tool installation. This ensures that tools are managed in a way that's compatible with the rest of the setup and avoids potential conflicts with system-wide pip installations.

Suggested change
pip install pre-commit
pre-commit install
uv tool install pre-commit
pre-commit install

```

After installation, the hooks will run automatically on `git commit`. You can also run them manually at any time:

```bash
ruff format .
ruff check .
Comment on lines +36 to +37
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure the correct version of ruff (as managed by uv) is used, it is recommended to prefix these commands with uv run.

Suggested change
ruff format .
ruff check .
uv run ruff format .
uv run ruff check .

```

> **Note:** If you use VSCode, install the `Ruff` extension for real-time formatting and linting in the editor.

## Dev environment tips

1. When modifying the WebUI, be sure to maintain componentization and clean code. Avoid duplicate code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const getRowProps = ({ item }: { item: CommandItem }) => {
</template>

<template v-slot:item.description="{ item }">
<div class="text-body-2 text-medium-emphasis" style="max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
<div class="text-body-2 text-medium-emphasis" style="max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" :title="item.description">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Vuetify provides a utility class text-truncate that handles overflow, text-overflow, and white-space properties. Using it makes the code cleaner and adheres to the principle of avoiding duplicated logic/styles.

        <div class="text-body-2 text-medium-emphasis text-truncate" style="max-width: 280px;" :title="item.description">
References
  1. When implementing similar functionality for different cases, refactor the logic into a shared helper (or in this case, a shared CSS class) to avoid code duplication.

{{ item.description || '-' }}
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const enabledConfigTags = (tool: ToolItem): BuiltinToolConfigTag[] => {
</template>

<template #item.description="{ item }">
<div class="text-body-2 text-medium-emphasis" style="max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
<div class="text-body-2 text-medium-emphasis" style="max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" :title="item.description">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider using the Vuetify utility class text-truncate instead of hardcoding the ellipsis styles. This improves maintainability by using shared framework utilities.

        <div class="text-body-2 text-medium-emphasis text-truncate" style="max-width: 320px;" :title="item.description">
References
  1. Refactor similar logic/styles into shared utilities to avoid code duplication.

{{ item.description || '-' }}
</div>
</template>
Expand All @@ -133,7 +133,7 @@ const enabledConfigTags = (tool: ToolItem): BuiltinToolConfigTag[] => {
</template>

<template #item.origin_name="{ item }">
<div class="text-body-2 text-medium-emphasis" style="max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
<div class="text-body-2 text-medium-emphasis" style="max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" :title="item.origin_name">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider using the Vuetify utility class text-truncate instead of hardcoding the ellipsis styles.

        <div class="text-body-2 text-medium-emphasis text-truncate" style="max-width: 200px;" :title="item.origin_name">
References
  1. Refactor similar logic/styles into shared utilities to avoid code duplication.

{{ item.origin_name || '-' }}
</div>
</template>
Expand Down
Loading