Skip to content

Commit 25d4028

Browse files
committed
Merge branch 'release/v1.3.0'
2 parents 6c5f9da + fdc556e commit 25d4028

50 files changed

Lines changed: 957 additions & 275 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export PYTHONPATH="$PWD:$PYTHONPATH"
2+
export PATH="$PWD/.venv/bin:$PATH"

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
8+
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
99
steps:
1010
- uses: actions/checkout@v4
1111
- name: Install Python ${{ matrix.python-version }}

.idea/tempren.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.pre-commit-config.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.6.0
5+
rev: v6.0.0
66
hooks:
77
- id: trailing-whitespace
88
- id: check-ast
@@ -16,19 +16,17 @@ repos:
1616
- id: check-toml
1717
- id: debug-statements
1818
- repo: https://github.com/PyCQA/isort
19-
rev: '5.13.2'
19+
rev: '8.0.1'
2020
hooks:
2121
- id: isort
22-
language_version: python3.8
2322
additional_dependencies:
2423
- toml
2524
- repo: https://github.com/awebdeveloper/pre-commit-stylelint
2625
rev: '0.0.2'
2726
hooks:
2827
- id: stylelint
2928
additional_dependencies: ['stylelint', 'stylelint-config-standard']
30-
- repo: https://github.com/psf/black
31-
rev: '24.8.0'
29+
- repo: https://github.com/psf/black-pre-commit-mirror
30+
rev: '26.3.0'
3231
hooks:
3332
- id: black
34-
language_version: python3.8

.serena/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/cache
2+
/project.local.yml
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Tempren - Project Overview
2+
3+
## Purpose
4+
Tempren is a template-based file renaming CLI tool written in Python. It uses a custom template language (compiled via ANTLR4) with a plugin-based tag system to generate new filenames from file metadata.
5+
6+
## Tech Stack
7+
- **Language**: Python >=3.9 (mypy targets 3.10)
8+
- **Build/Dependency**: Poetry
9+
- **Template Engine**: ANTLR4 (lexer/parser grammars in `tempren/template/grammar/`)
10+
- **Testing**: pytest with pytest-cov
11+
- **Formatting**: black (line length 88), isort (compatible with black)
12+
- **Type Checking**: mypy
13+
- **Linting**: pylint
14+
- **Pre-commit**: hooks for black, isort, trailing whitespace, AST check, etc.
15+
- **License**: GPL-3.0-or-later
16+
17+
## Key Dependencies
18+
- antlr4-python3-runtime, mutagen (audio), Pillow/piexif (images), python-magic (MIME)
19+
- pymediainfo (optional, for video - requires system lib `libmediainfo0v5`)
20+
- geopy, fastkml, gpxpy (geo/GPS), pint (units), isodate, pathvalidate, Unidecode
21+
22+
## Entry Point
23+
`tempren.cli:throwing_main` (installed as `tempren` command)
24+
25+
## Project Structure
26+
```
27+
tempren/
28+
cli.py # CLI entry point and argument parsing
29+
pipeline.py # Core pipeline: gather -> filter -> sort -> generate -> resolve -> rename
30+
primitives.py # Core abstractions: File, Tag, TagFactory, Pattern, TagName, etc.
31+
factories.py # TagFactoryFromClass wrapping Tag classes
32+
discovery.py # Auto-discovers Tag subclasses in tempren/tags/
33+
evaluation.py # Expression evaluation
34+
path_generator.py # Generates new paths from templates
35+
file_filters.py # File filtering logic
36+
file_sorters.py # File sorting logic
37+
filesystem.py # Filesystem operations
38+
exceptions.py # Exception classes
39+
alias.py # Tag aliasing
40+
adhoc.py # Ad-hoc tag creation
41+
tags/ # Tag plugins (core, image, audio, video, text, hash, filesystem, geo, gpx)
42+
template/ # Template engine (AST, compiler, parser, registry, generators)
43+
grammar/ # ANTLR4 grammar files (DO NOT edit generated .py files)
44+
tests/ # Mirror of source structure
45+
tags/ # Tag tests
46+
template/ # Template engine tests
47+
e2e/ # End-to-end tests (subprocess)
48+
test_data/ # Real media files for testing
49+
```
50+
51+
## Tag Discovery Convention
52+
Classes in `tempren/tags/` are auto-discovered if they:
53+
1. Subclass `Tag`
54+
2. Are not abstract
55+
3. Class name ends with `Tag`
56+
Module name = category, class name minus `Tag` suffix = tag name.
57+
Example: `tempren/tags/image.py::WidthTag` -> `image.width`
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Code Style and Conventions
2+
3+
## Formatting
4+
- **black** with line length 88 (default)
5+
- **isort** with multi_line_output=3, trailing comma, line length 88
6+
7+
## Naming
8+
- Classes: PascalCase (e.g., `CountTag`, `TagFactory`, `PathGenerator`)
9+
- Functions/methods: snake_case (e.g., `process`, `configure`, `from_path`)
10+
- Tag classes: Must end with `Tag` suffix (e.g., `CountTag`, `WidthTag`)
11+
- Private methods: prefixed with underscore (e.g., `_get_counter_value_for`)
12+
- Variables: snake_case
13+
14+
## Type Hints
15+
- Used throughout the codebase
16+
- mypy configured for Python 3.10 target
17+
- `typing` module used for `Optional`, `Union`, `Any`, etc.
18+
- ANTLR4 generated grammar files are excluded from mypy checks
19+
20+
## Docstrings
21+
- Used on Tag.configure() methods to document parameters
22+
- Uses `:param name: description` format (parsed by docstring-parser)
23+
- Not required on every method
24+
25+
## Testing Conventions
26+
- Tests mirror source structure under `tests/`
27+
- Test classes named `TestXxx` (e.g., `TestCountTag`)
28+
- Test methods named `test_descriptive_name` with snake_case
29+
- Follows arrange-act-assert pattern with blank lines between sections
30+
- Fixtures used for test data (e.g., `nonexistent_file: File`)
31+
- Markers: `@pytest.mark.e2e`, `@pytest.mark.slow`
32+
- Test data in `tests/test_data/`
33+
34+
## Design Patterns
35+
- Abstract base classes (ABC) for interfaces (Tag, TagFactory, Pattern, PathGenerator)
36+
- Dataclasses for data containers (File, QualifiedTagName, Location)
37+
- Plugin discovery pattern for tags
38+
- Template pattern: `%TagName{context}(args)` with pipe `|` support
39+
40+
## Important Notes
41+
- DO NOT edit generated `.py` files in `tempren/template/grammar/`
42+
- coverage excludes: grammar files, `raise NotImplementedError`, `assert`, `__repr__`, `pass`
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Suggested Commands
2+
3+
## Setup
4+
```bash
5+
poetry install --all-extras # Install all dependencies (including optional pymediainfo)
6+
```
7+
8+
## Testing
9+
```bash
10+
poetry run pytest # Run all tests (coverage enabled by default)
11+
poetry run pytest tests/path/to/test.py::TestClass::test_method # Run single test
12+
poetry run pytest -m "not e2e" # Skip end-to-end tests
13+
poetry run pytest -m "not slow" # Skip slow tests
14+
```
15+
16+
## Code Quality
17+
```bash
18+
poetry run mypy # Type checking (config in mypy.ini)
19+
poetry run black tempren tests # Format code (line length 88)
20+
poetry run isort tempren tests # Sort imports (compatible with black)
21+
poetry run pylint tempren # Linting
22+
```
23+
24+
## Running
25+
```bash
26+
poetry run tempren # Run the CLI tool
27+
```
28+
29+
## ANTLR Grammar
30+
```bash
31+
# Generate parser from grammar (in tempren/template/grammar/)
32+
bash tempren/template/grammar/generate.sh
33+
```
34+
35+
## System Utils
36+
```bash
37+
git, ls, cd, grep, find # Standard Linux utils
38+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Task Completion Checklist
2+
3+
When a coding task is completed, run the following checks:
4+
5+
1. **Format code**:
6+
```bash
7+
poetry run black tempren tests
8+
poetry run isort tempren tests
9+
```
10+
11+
2. **Type check**:
12+
```bash
13+
poetry run mypy
14+
```
15+
16+
3. **Run tests**:
17+
```bash
18+
poetry run pytest
19+
```
20+
- For quick feedback, run only relevant tests first:
21+
```bash
22+
poetry run pytest tests/path/to/relevant_test.py
23+
```
24+
25+
4. **Verify pre-commit hooks pass** (will run on commit):
26+
- trailing-whitespace, check-ast, end-of-file-fixer, check-added-large-files
27+
- check-merge-conflict, check-case-conflict, check-docstring-first
28+
- check-shebang-scripts-are-executable, check-yaml, check-toml, debug-statements
29+
- isort, black

.serena/project.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# the name by which the project can be referenced within Serena
2+
project_name: "tempren"
3+
4+
5+
# list of languages for which language servers are started; choose from:
6+
# al bash clojure cpp csharp
7+
# csharp_omnisharp dart elixir elm erlang
8+
# fortran fsharp go groovy haskell
9+
# java julia kotlin lua markdown
10+
# matlab nix pascal perl php
11+
# php_phpactor powershell python python_jedi r
12+
# rego ruby ruby_solargraph rust scala
13+
# swift terraform toml typescript typescript_vts
14+
# vue yaml zig
15+
# (This list may be outdated. For the current list, see values of Language enum here:
16+
# https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py
17+
# For some languages, there are alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
18+
# Note:
19+
# - For C, use cpp
20+
# - For JavaScript, use typescript
21+
# - For Free Pascal/Lazarus, use pascal
22+
# Special requirements:
23+
# Some languages require additional setup/installations.
24+
# See here for details: https://oraios.github.io/serena/01-about/020_programming-languages.html#language-servers
25+
# When using multiple languages, the first language server that supports a given file will be used for that file.
26+
# The first language is the default language and the respective language server will be used as a fallback.
27+
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
28+
languages:
29+
- python
30+
- bash
31+
32+
# the encoding used by text files in the project
33+
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
34+
encoding: "utf-8"
35+
36+
# The language backend to use for this project.
37+
# If not set, the global setting from serena_config.yml is used.
38+
# Valid values: LSP, JetBrains
39+
# Note: the backend is fixed at startup. If a project with a different backend
40+
# is activated post-init, an error will be returned.
41+
language_backend:
42+
43+
# whether to use project's .gitignore files to ignore files
44+
ignore_all_files_in_gitignore: true
45+
46+
# list of additional paths to ignore in this project.
47+
# Same syntax as gitignore, so you can use * and **.
48+
# Note: global ignored_paths from serena_config.yml are also applied additively.
49+
ignored_paths: []
50+
51+
# whether the project is in read-only mode
52+
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
53+
# Added on 2025-04-18
54+
read_only: false
55+
56+
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
57+
# Below is the complete list of tools for convenience.
58+
# To make sure you have the latest list of tools, and to view their descriptions,
59+
# execute `uv run scripts/print_tool_overview.py`.
60+
#
61+
# * `activate_project`: Activates a project by name.
62+
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
63+
# * `create_text_file`: Creates/overwrites a file in the project directory.
64+
# * `delete_lines`: Deletes a range of lines within a file.
65+
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
66+
# * `execute_shell_command`: Executes a shell command.
67+
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
68+
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
69+
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
70+
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
71+
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
72+
# * `initial_instructions`: Gets the initial instructions for the current project.
73+
# Should only be used in settings where the system prompt cannot be set,
74+
# e.g. in clients you have no control over, like Claude Desktop.
75+
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
76+
# * `insert_at_line`: Inserts content at a given line in a file.
77+
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
78+
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
79+
# * `list_memories`: Lists memories in Serena's project-specific memory store.
80+
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
81+
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
82+
# * `read_file`: Reads a file within the project directory.
83+
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
84+
# * `remove_project`: Removes a project from the Serena configuration.
85+
# * `replace_lines`: Replaces a range of lines within a file with new content.
86+
# * `replace_symbol_body`: Replaces the full definition of a symbol.
87+
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
88+
# * `search_for_pattern`: Performs a search for a pattern in the project.
89+
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
90+
# * `switch_modes`: Activates modes by providing a list of their names
91+
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
92+
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
93+
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
94+
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
95+
excluded_tools: []
96+
97+
# list of tools to include that would otherwise be disabled (particularly optional tools that are disabled by default)
98+
included_optional_tools: []
99+
100+
# fixed set of tools to use as the base tool set (if non-empty), replacing Serena's default set of tools.
101+
# This cannot be combined with non-empty excluded_tools or included_optional_tools.
102+
fixed_tools: []
103+
104+
# list of mode names to that are always to be included in the set of active modes
105+
# The full set of modes to be activated is base_modes + default_modes.
106+
# If the setting is undefined, the base_modes from the global configuration (serena_config.yml) apply.
107+
# Otherwise, this setting overrides the global configuration.
108+
# Set this to [] to disable base modes for this project.
109+
# Set this to a list of mode names to always include the respective modes for this project.
110+
base_modes:
111+
112+
# list of mode names that are to be activated by default.
113+
# The full set of modes to be activated is base_modes + default_modes.
114+
# If the setting is undefined, the default_modes from the global configuration (serena_config.yml) apply.
115+
# Otherwise, this overrides the setting from the global configuration (serena_config.yml).
116+
# This setting can, in turn, be overridden by CLI parameters (--mode).
117+
default_modes:
118+
119+
# initial prompt for the project. It will always be given to the LLM upon activating the project
120+
# (contrary to the memories, which are loaded on demand).
121+
initial_prompt: ""
122+
123+
# time budget (seconds) per tool call for the retrieval of additional symbol information
124+
# such as docstrings or parameter information.
125+
# This overrides the corresponding setting in the global configuration; see the documentation there.
126+
# If null or missing, use the setting from the global configuration.
127+
symbol_info_budget:
128+
129+
# list of regex patterns which, when matched, mark a memory entry as read‑only.
130+
# Extends the list from the global configuration, merging the two lists.
131+
read_only_memory_patterns: []

0 commit comments

Comments
 (0)