Skip to content

Commit 684c676

Browse files
committed
Clone cookiecutter template
0 parents  commit 684c676

File tree

8 files changed

+221
-0
lines changed

8 files changed

+221
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_call:
9+
10+
permissions:
11+
contents: none
12+
13+
jobs:
14+
ci:
15+
permissions:
16+
contents: read
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca
24+
25+
- name: Install dependencies
26+
run: uv sync --dev
27+
28+
- name: Lint code
29+
run: uv run ruff check
30+
31+
- name: Check formatting
32+
run: uv run ruff format --check
33+
34+
- name: Run type checking
35+
run: uv run mypy --strict .
36+
37+
- name: Run tests
38+
run: uv run pytest -v

.github/workflows/publish.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
permissions:
8+
contents: none
9+
10+
jobs:
11+
ci:
12+
permissions:
13+
contents: read
14+
uses: rbharvs/llm-tools-readonly-fs/.github/workflows/ci.yaml@main
15+
16+
publish:
17+
permissions:
18+
contents: read
19+
id-token: write
20+
environment: release
21+
runs-on: ubuntu-latest
22+
needs: ci
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
26+
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca
29+
30+
- name: Build package
31+
run: uv build
32+
33+
- name: Publish package
34+
run: uv publish

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.venv
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
venv
6+
.eggs
7+
.pytest_cache
8+
*.egg-info
9+
.DS_Store
10+
.vscode
11+
dist
12+
build

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Brett Harvey
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# llm-tools-readonly-fs
2+
3+
[![PyPI](https://img.shields.io/pypi/v/llm-tools-readonly-fs.svg)](https://pypi.org/project/llm-tools-readonly-fs/)
4+
[![Changelog](https://img.shields.io/github/v/release/rbharvs/llm-tools-readonly-fs?include_prereleases&label=changelog)](https://github.com/rbharvs/llm-tools-readonly-fs/releases)
5+
[![Tests](https://github.com/rbharvs/llm-tools-readonly-fs/actions/workflows/test.yml/badge.svg)](https://github.com/rbharvs/llm-tools-readonly-fs/actions/workflows/test.yml)
6+
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/rbharvs/llm-tools-readonly-fs/blob/main/LICENSE)
7+
8+
Grants LLM the ability to list, view, and search across files within a directory
9+
10+
## Installation
11+
12+
Install this plugin in the same environment as [LLM](https://llm.datasette.io/).
13+
```bash
14+
llm install llm-tools-readonly-fs
15+
```
16+
## Usage
17+
18+
To use this with the [LLM command-line tool](https://llm.datasette.io/en/stable/usage.html):
19+
20+
```bash
21+
llm --tool view "Example prompt goes here" --tools-debug
22+
```
23+
24+
With the [LLM Python API](https://llm.datasette.io/en/stable/python-api.html):
25+
26+
```python
27+
import llm
28+
from llm_tools_readonly_fs import view
29+
30+
model = llm.get_model("gpt-4.1-mini")
31+
32+
result = model.chain(
33+
"Example prompt goes here",
34+
tools=[view]
35+
).text()
36+
```
37+
38+
## Development
39+
40+
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
41+
```bash
42+
cd llm-tools-readonly-fs
43+
python -m venv venv
44+
source venv/bin/activate
45+
```
46+
Now install the dependencies and test dependencies:
47+
```bash
48+
llm install -e '.[test]'
49+
```
50+
To run the tests:
51+
```bash
52+
python -m pytest
53+
```

llm_tools_readonly_fs.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import llm
2+
3+
4+
def view(input: str) -> str:
5+
"""
6+
Description of tool goes here.
7+
"""
8+
return f"hello {input}"
9+
10+
11+
@llm.hookimpl
12+
def register_tools(register):
13+
register(view)

pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[project]
2+
name = "llm-tools-readonly-fs"
3+
version = "0.1"
4+
description = "Grants LLM the ability to glob, grep, and view files within a directory"
5+
readme = "README.md"
6+
authors = [{name = "Brett Harvey"}]
7+
license = "Apache-2.0"
8+
classifiers = []
9+
requires-python = ">=3.9"
10+
dependencies = [
11+
"llm>=0.26"
12+
]
13+
14+
[build-system]
15+
requires = ["setuptools"]
16+
build-backend = "setuptools.build_meta"
17+
18+
[project.urls]
19+
Homepage = "https://github.com/rbharvs/llm-tools-readonly-fs"
20+
Changelog = "https://github.com/rbharvs/llm-tools-readonly-fs/releases"
21+
Issues = "https://github.com/rbharvs/llm-tools-readonly-fs/issues"
22+
CI = "https://github.com/rbharvs/llm-tools-readonly-fs/actions"
23+
24+
[project.entry-points.llm]
25+
llm_tools_readonly_fs = "llm_tools_readonly_fs"
26+
27+
[project.optional-dependencies]
28+
test = ["pytest", "llm-echo>=0.3a1"]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import llm
2+
import json
3+
from llm_tools_readonly_fs import view
4+
5+
6+
def test_tool():
7+
model = llm.get_model("echo")
8+
chain_response = model.chain(
9+
json.dumps(
10+
{
11+
"tool_calls": [
12+
{"name": "view", "arguments": {"input": "pelican"}}
13+
]
14+
}
15+
),
16+
tools=[view],
17+
)
18+
responses = list(chain_response.responses())
19+
tool_results = json.loads(responses[-1].text())["tool_results"]
20+
assert tool_results == [
21+
{"name": "view", "output": "hello pelican", "tool_call_id": None}
22+
]

0 commit comments

Comments
 (0)