Removes tools from grouping.
This commit is contained in:
@@ -132,7 +132,7 @@ Creates a shim so the tool is available system-wide after
|
||||
|
||||
```yaml
|
||||
tool:
|
||||
source: tools/document/ # Source directory
|
||||
source: my-tool/ # Source directory
|
||||
version: "1.0.0"
|
||||
system_dependencies: [pandoc, poppler-utils]
|
||||
```
|
||||
@@ -143,8 +143,7 @@ It's separate from `install` (which handles PATH registration) and `run`
|
||||
|
||||
The install method (uv tool install vs symlink) is inferred from the source
|
||||
directory: if `pyproject.toml` exists, it's a Python package; if the source
|
||||
is a file, it's symlinked. Grouping for `castle tool list` and the dashboard
|
||||
is derived from the source directory name (e.g., `tools/document/` → "document").
|
||||
is a file, it's symlinked.
|
||||
|
||||
### `build` — How to build it
|
||||
|
||||
@@ -210,11 +209,8 @@ A component can have multiple roles. For example, `protonmail` is both a
|
||||
# Service — scaffolds project, assigns port, registers in castle.yaml
|
||||
castle create my-service --type service --description "Does something"
|
||||
|
||||
# Standalone tool — scaffolds at repo root
|
||||
# Tool — scaffolds at repo root
|
||||
castle create my-tool --type tool --description "Does something"
|
||||
|
||||
# Category tool — adds to existing tools/<category>/ package
|
||||
castle create my-tool --type tool --category document --description "Does something"
|
||||
```
|
||||
|
||||
### Manually
|
||||
|
||||
@@ -22,11 +22,9 @@ How to build CLI tools following Unix philosophy.
|
||||
| **Type checking** | pyright (shared `pyrightconfig.json` at repo root) |
|
||||
| **Python** | 3.11+ minimum |
|
||||
|
||||
## Two kinds of tools
|
||||
## Project layout
|
||||
|
||||
### Standalone tools
|
||||
|
||||
Independent projects at the repo root with their own `pyproject.toml`:
|
||||
Each tool is an independent project at the repo root with its own `pyproject.toml`:
|
||||
|
||||
```
|
||||
my-tool/
|
||||
@@ -39,31 +37,10 @@ my-tool/
|
||||
└── CLAUDE.md
|
||||
```
|
||||
|
||||
Examples: `devbox-connect/`, `mboxer/`, `protonmail/`
|
||||
|
||||
### Category tools
|
||||
|
||||
Multiple tools sharing a single package under `tools/<category>/`:
|
||||
|
||||
```
|
||||
tools/document/
|
||||
├── src/document/
|
||||
│ ├── __init__.py
|
||||
│ ├── pdf2md.py # Each tool is a module
|
||||
│ ├── docx2md.py
|
||||
│ ├── html2text.py
|
||||
│ └── md2pdf.py
|
||||
├── tests/
|
||||
├── pyproject.toml # One pyproject with multiple [project.scripts]
|
||||
└── CLAUDE.md
|
||||
```
|
||||
|
||||
Examples: `tools/document/`, `tools/search/`, `tools/system/`
|
||||
Examples: `pdf2md/`, `gpt/`, `protonmail/`
|
||||
|
||||
## Creating a new tool
|
||||
|
||||
### Standalone
|
||||
|
||||
```bash
|
||||
castle create my-tool --type tool --description "Does something"
|
||||
cd my-tool && uv sync
|
||||
@@ -71,20 +48,8 @@ cd my-tool && uv sync
|
||||
|
||||
This scaffolds the project and registers it in `castle.yaml`.
|
||||
|
||||
### Category tool
|
||||
|
||||
```bash
|
||||
castle create my-tool --type tool --category document --description "Does something"
|
||||
cd tools/document && uv sync
|
||||
```
|
||||
|
||||
This adds a `.py` file to the existing category package and updates its
|
||||
`pyproject.toml` entry points.
|
||||
|
||||
## pyproject.toml
|
||||
|
||||
### Standalone tool
|
||||
|
||||
```toml
|
||||
[project]
|
||||
name = "my-tool"
|
||||
@@ -110,27 +75,7 @@ dev = ["pytest>=7.0.0"]
|
||||
known-first-party = ["my_tool"]
|
||||
```
|
||||
|
||||
### Category package
|
||||
|
||||
```toml
|
||||
[project]
|
||||
name = "castle-document"
|
||||
version = "0.1.0"
|
||||
description = "Castle document conversion tools"
|
||||
requires-python = ">=3.11"
|
||||
dependencies = []
|
||||
|
||||
[project.scripts]
|
||||
docx2md = "document.docx2md:main"
|
||||
pdf2md = "document.pdf2md:main"
|
||||
html2text = "document.html2text:main"
|
||||
md2pdf = "document.md2pdf:main"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/document"]
|
||||
```
|
||||
|
||||
After `uv tool install --editable .`, all commands are in PATH.
|
||||
After `uv tool install --editable .`, the command is in PATH.
|
||||
|
||||
## Tool implementation patterns
|
||||
|
||||
@@ -368,8 +313,6 @@ uv run ruff format . # Format
|
||||
|
||||
## Registering in castle.yaml
|
||||
|
||||
Standalone tools:
|
||||
|
||||
```yaml
|
||||
components:
|
||||
my-tool:
|
||||
@@ -381,14 +324,14 @@ components:
|
||||
alias: my-tool
|
||||
```
|
||||
|
||||
Category tools get one entry per tool, all pointing to the same source:
|
||||
Tools with system dependencies declare them in the manifest:
|
||||
|
||||
```yaml
|
||||
components:
|
||||
pdf2md:
|
||||
description: Convert PDF files to Markdown
|
||||
tool:
|
||||
source: tools/document/
|
||||
source: pdf2md/
|
||||
system_dependencies: [pandoc, poppler-utils]
|
||||
install:
|
||||
path:
|
||||
|
||||
Reference in New Issue
Block a user