Skip to content

Commit 74cbfaa

Browse files
authored
chore: cleanup dependencies and dev commands (#316)
1 parent 81ff780 commit 74cbfaa

14 files changed

Lines changed: 453 additions & 597 deletions

File tree

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Thank you for your contribution! Before submitting your PR, please make sure you
1212

1313
## Available Checks
1414

15-
- [ ] Code has passed local tests
15+
- [ ] `just build` has passed
1616
- [ ] Relevant documentation has been updated (if necessary)

.github/workflows/mkdocs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ jobs:
3030
cache-dependency-glob: uv.lock
3131
python-version: ${{ matrix.python-version }}
3232

33+
- name: Install just
34+
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
35+
3336
# - name: Debug
3437
# uses: mxschmitt/action-tmate@v3
3538

3639
- name: Build raw docs
37-
run: make docs
40+
run: just docs
3841

3942
- name: Deploy docs
4043
uses: mhausenblas/mkdocs-deploy-gh-pages@master

.github/workflows/pr.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ jobs:
5858
cache-dependency-glob: uv.lock
5959
python-version: "3.12"
6060

61+
- name: Install just
62+
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
63+
6164
- name: Run checks
62-
run: make check
65+
run: just check
6366

6467
test:
6568
name: Test

.github/workflows/pypi_publish.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ jobs:
7070
cache-dependency-glob: uv.lock
7171
python-version: "3.12"
7272

73+
- name: Install just
74+
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
75+
7376
- name: Build distributions
74-
run: make build
77+
run: just build
7578

7679
- name: Upload distributions
7780
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ jobs:
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030

31+
- name: Install just
32+
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
33+
3134
- name: Setup dify-plugin-cli
3235
run: ./scripts/setup-dify-plugin-cli.sh
3336

3437
- name: Install dependencies
35-
run: make dev
38+
run: just dev
3639

3740
- name: Run tests
38-
run: make test
41+
run: just test

AGENTS.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,38 @@ This file provides guidance for agents working with code in this repository.
77
### Python SDK Development
88

99
**Testing:**
10+
1011
```bash
11-
make test # Run all tests
12+
just test # Run all tests
1213
uv run pytest tests/specific_test.py # Run specific test
1314
```
1415

1516
**Linting and Formatting:**
17+
1618
```bash
17-
make check # Check lockfile, formatting, and linting
18-
make lint # Check linting only
19-
make format # Apply formatting fixes
19+
just check # Check lockfile, formatting, and linting
20+
just lint # Check linting only
21+
just format # Apply formatting fixes
2022
```
2123

2224
**Documentation Generation:**
25+
2326
```bash
24-
make docs # Generate schema documentation
27+
just docs # Generate schema documentation
2528
```
2629

2730
**Build and Environment:**
31+
2832
```bash
29-
make dev # Sync default dev dependencies
30-
make build # Build source and wheel distributions
31-
make clean # Remove local build/test artifacts
33+
just dev # Sync default dev dependencies
34+
just build # Build source and wheel distributions
35+
just clean # Remove local build/test artifacts
3236
```
3337

3438
## Project Architecture
3539

3640
### Repository Structure
41+
3742
- **Root Level:** Python SDK package, project metadata, tests, and examples
3843
- **`src/dify_plugin/`:** Main Python SDK implementation
3944
- **`examples/`:** Complete plugin examples (GitHub, OpenAI, Jina, etc.)
@@ -43,48 +48,56 @@ make clean # Remove local build/test artifacts
4348
The Dify Plugin SDK follows a modular architecture with clear separation of concerns:
4449

4550
#### Core Components (`src/dify_plugin/core/`)
51+
4652
- **`runtime.py`:** Session management and backwards invocation system
4753
- **`plugin_executor.py`:** Main execution engine for plugin operations
4854
- **`plugin_registration.py`:** Plugin discovery and registration system
4955
- **`server/`:** Multi-protocol communication layer (stdio, TCP, serverless)
5056

5157
#### Plugin Types (`src/dify_plugin/interfaces/`)
58+
5259
- **`model/`:** AI model integrations (LLM, embedding, TTS, etc.)
5360
- **`tool/`:** Tool providers and individual tools
5461
- **`agent/`:** Agent strategy implementations
5562
- **`endpoint/`:** HTTP endpoint handlers
5663
- **`trigger/`:** Event trigger handlers
5764

5865
#### Communication Patterns
66+
5967
1. **Local Install:** stdio-based communication for development
6068
2. **Remote Install:** TCP-based communication for production deployment
6169
3. **Serverless:** HTTP-based communication for serverless environments
6270

6371
#### Plugin Manifest System
72+
6473
- **`manifest.yaml`:** Plugin metadata and configuration
6574
- **Version Management:** Semantic versioning with compatibility matrix
6675
- **Runtime Configuration:** Memory limits, permissions, language requirements
6776

6877
### Key Architectural Patterns
6978

7079
#### Session-based Runtime
80+
7181
- Each plugin operation runs in a `Session` context
7282
- Sessions provide access to invocations (model, tool, app, storage, file)
7383
- Backwards invocation allows plugins to call Dify services
7484

7585
#### Multi-Modal Communication
86+
7687
- **Full-duplex:** Real-time bidirectional communication (Local/Remote)
7788
- **HTTP streaming:** Server-sent events for serverless environments
7889
- **Blob handling:** Chunked transfer for large binary data
7990

8091
#### Provider-Tool Architecture
92+
8193
- **Providers:** Authentication and configuration management
8294
- **Tools:** Individual operations within a provider
8395
- **Credentials:** OAuth and API key management with validation
8496

8597
## Plugin Examples Structure
8698

8799
Each example in `examples/` follows a consistent structure:
100+
88101
- **`manifest.yaml`:** Plugin metadata
89102
- **`main.py`:** Plugin entry point
90103
- **`provider/`:** Provider configuration and implementation
@@ -102,5 +115,5 @@ Each example in `examples/` follows a consistent structure:
102115

103116
1. Use existing examples as templates for new plugins
104117
2. Implement plugin interfaces in the appropriate category
105-
3. Run `make check` before submitting code changes
106-
4. Run `make test` when changes affect runtime behavior, SDK interfaces, or examples
118+
3. Run `just check` before submitting code changes
119+
4. Run `just test` when changes affect runtime behavior, SDK interfaces, or examples

Makefile

Lines changed: 0 additions & 38 deletions
This file was deleted.

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ A Python SDK for building plugins for Dify.
44

55
Here is a short introduction to Dify Plugin: <https://docs.dify.ai/plugins/introduction>
66

7+
## Development
8+
9+
This repository uses [`just`](https://github.com/casey/just) as its command runner.
10+
Install it with your preferred package manager, or with uv:
11+
12+
```bash
13+
uv tool install rust-just
14+
```
15+
16+
Common development commands:
17+
18+
```bash
19+
just dev # Sync default dev dependencies
20+
just check # Check lockfile, formatting, and linting
21+
just test # Run all tests
22+
just build # Build source and wheel distributions
23+
```
24+
725
## Version Management
826

927
This SDK follows Semantic Versioning (a.b.c):
@@ -22,7 +40,7 @@ When depending on this SDK, it's recommended to specify version constraints that
2240
Example in your project's dependency management:
2341

2442
```python
25-
dify_plugin~=0.7
43+
dify_plugin >= 0.8
2644
```
2745

2846
## Manifest Version Reference
@@ -54,3 +72,4 @@ For the manifest specification, we've introduced two versioning fields:
5472
| 1.9.0 | 0.5.0 | Support Datasource functionality for plugins |
5573
| 1.10.0 | 0.6.0 | Support Trigger functionality for plugins |
5674
| 1.11.0 | 0.7.0 | Support Multimodal Reranking / Embeddings |
75+
| 1.14.0 | 0.8.0 | Dependency and project structure cleanup |

justfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
dev:
2+
uv sync
3+
4+
format:
5+
uv run ruff format
6+
7+
lint:
8+
uv run ruff check
9+
10+
check:
11+
uv lock --check
12+
uv run ruff format --check --diff
13+
uv run ruff check
14+
15+
test:
16+
uv run pytest
17+
18+
docs:
19+
uv run python -m dify_plugin.cli generate-docs
20+
mkdir -p .mkdocs/docs
21+
mv docs.md .mkdocs/docs/schema.md
22+
23+
build:
24+
uv build --no-create-gitignore --no-sources
25+
26+
clean:
27+
find . -type d -name '__pycache__' -prune -exec rm -rf {} +
28+
rm -rf dist/ .pytest_cache/ .ruff_cache/
29+
rm -f docs.md langgenius-openai.difypkg
30+
uv run ruff clean

prek.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
minimum_prek_version = "0.3.8"
1+
minimum_prek_version = "0.3.13"
22

33
[[repos]]
44
repo = 'builtin'
@@ -28,9 +28,9 @@ hooks = [
2828
repo = 'local'
2929

3030
[[repos.hooks]]
31-
id = 'make-check'
32-
name = 'make check'
33-
entry = 'make check'
31+
id = 'just-check'
32+
name = 'just check'
33+
entry = 'just check'
3434
language = 'system'
3535
always_run = true
3636
pass_filenames = false

0 commit comments

Comments
 (0)