Skip to content

Commit cb4ca3a

Browse files
authored
Version tracking for pass-through commands (#8)
1 parent 62b4c5d commit cb4ca3a

File tree

22 files changed

+925
-386
lines changed

22 files changed

+925
-386
lines changed

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"name": "asta",
1212
"source": "./",
1313
"description": "Paper search, citations, literature reports, and Semantic Scholar API tools",
14-
"version": "0.2.1",
14+
"version": "0.3.0",
1515
"author": {
1616
"name": "AI2 Asta Team"
1717
},

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "asta",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"description": "Asta science tools for Claude Code - paper search, citations, and more",
55
"author": {
66
"name": "AI2 Asta Team"

DEVELOPER.md

Lines changed: 121 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ src/asta/ # Main CLI package
1515
│ └── client.py # AstaPaperFinder API client (stdlib only)
1616
├── utils/
1717
│ ├── __init__.py
18+
│ ├── config.py # Configuration management using HOCON
19+
│ ├── passthrough.conf # Passthrough tool configurations (HOCON format)
1820
│ └── passthrough.py # Generic passthrough utility for external tools
1921
├── documents/
2022
│ ├── __init__.py
@@ -45,12 +47,16 @@ hooks/ # Claude Code permission hooks
4547
3. **Generic passthrough architecture**: `asta.utils.passthrough` provides reusable utilities for external tool integration
4648
- `ensure_tool_installed()`: Checks for tool, auto-installs if missing
4749
- `create_passthrough_command()`: Factory function for creating passthrough commands
48-
4. **Pass-through commands**: Commands that delegate to external tools, auto-installed on first use
50+
4. **Configuration management**: `asta.utils.config` loads passthrough settings from HOCON
51+
- All passthrough configurations centralized in `src/asta/utils/passthrough.conf`
52+
- Uses pyhocon for flexible, hierarchical configuration
53+
- `get_passthrough_config()`: Retrieves settings for specific commands
54+
5. **Pass-through commands**: Commands that delegate to external tools, auto-installed on first use
4955
- `asta documents``asta-documents` CLI (document metadata management)
5056
- `asta experiment``panda` CLI (computational experiments)
51-
- Version pinning: Each passthrough defines a version constant (e.g., `ASTA_DOCUMENTS_VERSION`, `PANDA_VERSION`)
57+
- Configuration: Version pinning, install sources, and other settings in `passthrough.conf`
5258
- Future: will install from PyPI instead of git
53-
5. **Claude Code integration**: Uses the CLI via Bash tool for portability
59+
6. **Claude Code integration**: Uses the CLI via Bash tool for portability
5460

5561
## Development Setup
5662

@@ -379,18 +385,18 @@ The version number is stored in four locations and must be kept in sync:
379385
git push
380386
```
381387

382-
5. **Create GitHub release:**
388+
5. **Create and push version tag:**
383389
```bash
384-
make release
390+
make push-version-tag
385391
```
386392
This command will:
387393
- Verify all three version files are in sync (fails if they differ)
388394
- Check that the git tag doesn't already exist
389-
- Create and push the git tag (e.g., `v0.3.0`)
395+
- Create and push the git tag (e.g., `0.3.0`)
390396
- Provide a URL to create the GitHub release
391397

392398
6. **Create GitHub release notes:**
393-
- Visit the URL provided by `make release`
399+
- Visit the URL provided by `make push-version-tag`
394400
- Add release notes describing changes
395401
- Publish the release
396402

@@ -415,9 +421,9 @@ make set-version VERSION=x.y.z
415421
- Fails with error if VERSION parameter is not provided
416422
- Provides suggested commit command after success
417423

418-
**Create release:**
424+
**Push version tag:**
419425
```bash
420-
make release
426+
make push-version-tag
421427
```
422428
- Checks version consistency across all four files
423429
- Fails with clear error if versions don't match
@@ -427,10 +433,10 @@ make release
427433

428434
### Version Mismatch Example
429435

430-
If you try to release with mismatched versions:
436+
If you try to push a version tag with mismatched versions:
431437

432438
```bash
433-
$ make release
439+
$ make push-version-tag
434440
Checking version consistency...
435441
Error: Version mismatch detected:
436442
src/asta/__init__.py: 0.3.0
@@ -500,49 +506,79 @@ If Asta's API changes:
500506

501507
To add a new external tool as an `asta` passthrough command:
502508

503-
1. **Create the passthrough module:**
509+
1. **Add configuration** to `src/asta/utils/passthrough.conf`:
510+
```hocon
511+
passthrough {
512+
# ... existing configs ...
513+
514+
newtool {
515+
tool_name = "newtool-cli"
516+
install_type = "pypi" # or "git" or "local"
517+
install_source = "newtool-package" # package name, git URL, or filesystem path
518+
minimum_version = "1.0.0" # Must be x.y.z format
519+
command_name = "newtool"
520+
friendly_name = "NewTool"
521+
docstring = "Description for --help"
522+
}
523+
}
524+
```
525+
526+
**Installation source types:**
527+
- `pypi`: Install from PyPI (e.g., `install_source = "package-name"`)
528+
- `git`: Install from Git repository (e.g., `install_source = "git+https://github.com/user/repo"`)
529+
- `local`: Install from local filesystem (e.g., `install_source = "/path/to/package"` or `"~/dev/package"`)
530+
531+
2. **Create the passthrough module:**
504532
```python
505533
# src/asta/newtool/__init__.py
506534
from asta.newtool.passthrough import newtool
507535
__all__ = ["newtool"]
508536

509537
# src/asta/newtool/passthrough.py
538+
from asta.utils.config import get_passthrough_config
510539
from asta.utils.passthrough import create_passthrough_command
511540

512-
NEWTOOL_VERSION = "v1.0.0" # Pin to specific version
541+
# Load configuration from passthrough.conf
542+
config = get_passthrough_config("newtool")
513543

544+
# Create the passthrough command
514545
newtool = create_passthrough_command(
515-
tool_name="newtool-cli", # Executable name
516-
install_source="git+https://github.com/org/newtool",
517-
version=NEWTOOL_VERSION,
518-
command_name="newtool", # asta subcommand name
519-
friendly_name="NewTool", # Display name
520-
docstring="Description for --help"
546+
tool_name=config["tool_name"],
547+
install_type=config["install_type"],
548+
install_source=config["install_source"],
549+
minimum_version=config["minimum_version"],
550+
command_name=config["command_name"],
551+
friendly_name=config["friendly_name"],
552+
docstring=config["docstring"],
521553
)
522554
```
523555

524-
2. **Register in CLI:**
556+
3. **Register in CLI:**
525557
```python
526558
# src/asta/cli.py
527559
from asta.newtool import newtool
528560
cli.add_command(newtool)
529561
```
530562

531-
3. **Add tests:**
563+
4. **Add tests:**
532564
```python
533565
# tests/test_cli.py
534566
class TestNewToolCommand:
535-
def test_newtool_version_constant(self):
536-
from asta.newtool.passthrough import NEWTOOL_VERSION
537-
assert isinstance(NEWTOOL_VERSION, str)
538-
assert len(NEWTOOL_VERSION) > 0
567+
def test_newtool_config(self):
568+
from asta.utils.config import get_passthrough_config
569+
from asta.utils.passthrough import validate_semver
570+
571+
config = get_passthrough_config("newtool")
572+
assert config["tool_name"] == "newtool-cli"
573+
assert config["install_type"] in ("pypi", "git", "local")
574+
assert validate_semver(config["minimum_version"])
539575

540576
def test_newtool_passthrough_when_installed(self, runner, tmp_path):
541577
# Test passthrough behavior
542578
...
543579
```
544580

545-
4. **Create skill (optional):**
581+
5. **Create skill (optional):**
546582
```markdown
547583
# skills/newtool/SKILL.md
548584
---
@@ -561,40 +597,71 @@ To add a new external tool as an `asta` passthrough command:
561597

562598
### Updating Passthrough Tool Versions
563599

564-
When a new version of a passthrough tool is released:
565-
566-
**For asta-documents:**
567-
1. Update `ASTA_DOCUMENTS_VERSION` in `src/asta/documents/passthrough.py`
568-
```python
569-
ASTA_DOCUMENTS_VERSION = "v0.2.0" # Change to new tag
570-
```
571-
2. Test the installation works:
572-
```bash
573-
# Uninstall current version
574-
uv tool uninstall asta-documents
575-
# Test auto-installation with new version
576-
uv run python -m asta.cli documents --help
600+
The passthrough system automatically enforces minimum version requirements for external tools.
601+
602+
**How it works:**
603+
604+
1. When you run a passthrough command (e.g., `asta documents`), the system:
605+
- Checks if the tool is installed
606+
- If installed, runs `tool --version` to check the version
607+
- Compares with the `minimum_version` specified in `passthrough.conf`
608+
- Automatically reinstalls **only if the installed version is below the minimum**
609+
610+
2. Version requirements:
611+
- Must be in semantic version format: `x.y.z` (e.g., `0.1.0`, `1.2.3`)
612+
- The 'v' prefix is optional when parsing installed versions (both `1.0.0` and `v1.0.0` are accepted)
613+
- Versions are compared semantically: `1.0.1` > `1.0.0`, `1.1.0` > `1.0.9`, `2.0.0` > `1.99.99`
614+
- If the installed version is **greater than or equal** to minimum_version, it will be kept (no downgrade)
615+
616+
3. This allows users to:
617+
- Install newer versions manually and have them respected
618+
- Get automatic updates only when their version is too old
619+
- Avoid unnecessary reinstallations on every run
620+
621+
**To require a newer minimum version:**
622+
623+
1. **Update the configuration** in `src/asta/utils/passthrough.conf`:
624+
```hocon
625+
passthrough {
626+
documents {
627+
minimum_version = "0.2.0" # Require at least version 0.2.0
628+
# ... other settings
629+
}
630+
experiment {
631+
minimum_version = "1.0.0" # Require at least version 1.0.0
632+
# ... other settings
633+
}
634+
}
577635
```
578-
3. Update release notes mentioning the new version
579636

580-
**For panda (experiment command):**
581-
1. Update `PANDA_VERSION` in `src/asta/experiment/passthrough.py`
582-
```python
583-
PANDA_VERSION = "v1.0.0" # Change to new tag
584-
```
585-
2. Test similarly:
637+
2. **Next time someone runs the command**, it will automatically update if their version is too old:
586638
```bash
587-
uv tool uninstall panda
588-
uv run python -m asta.cli experiment --help
639+
# If installed version < 0.2.0, will reinstall
640+
# If installed version >= 0.2.0, will use existing installation
641+
asta documents --help
642+
asta experiment --help
589643
```
590644

591-
**Note**: In the future, when these tools are available on PyPI, update the installation source in the passthrough files:
592-
```python
593-
# Change from:
594-
install_source="git+https://github.com/org/repo"
645+
3. **Update release notes** mentioning the new minimum version requirement
646+
647+
**Switching installation sources:**
648+
649+
When a tool becomes available on PyPI, update `passthrough.conf`:
650+
```hocon
651+
# Change from Git:
652+
install_type = "git"
653+
install_source = "git+https://github.com/org/repo"
654+
655+
# To PyPI:
656+
install_type = "pypi"
657+
install_source = "package-name"
658+
```
595659

596-
# To:
597-
install_source="package-name" # Will use PyPI
660+
For local development:
661+
```hocon
662+
# Use local installation:
663+
install_type = "local"
664+
install_source = "~/dev/my-package"
598665
```
599666

600667
### Debugging

Makefile

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help install test test-unit test-integration test-coverage lint format format-check clean build publish publish-test release version set-version
1+
.PHONY: help install test test-unit test-integration test-coverage lint format format-check clean build publish publish-test push-version-tag version set-version
22

33
# Default target
44
help:
@@ -18,7 +18,7 @@ help:
1818
@echo " publish Publish to PyPI"
1919
@echo " publish-test Publish to TestPyPI"
2020
@echo " set-version Set version in all files (requires VERSION=x.y.z)"
21-
@echo " release Create GitHub release using current version"
21+
@echo " push-version-tag Create and push git tag using current version"
2222
@echo " version Show current version"
2323

2424
# Install with test dependencies
@@ -100,8 +100,8 @@ set-version:
100100
echo "Version updated to $(VERSION) in all files"; \
101101
echo "Review changes and commit with: git add -A && git commit -m 'chore: bump version to $(VERSION)'"
102102

103-
# Create GitHub release using version from code
104-
release:
103+
# Create and push git tag using version from code
104+
push-version-tag:
105105
@echo "Checking version consistency..."; \
106106
INIT_VERSION=$$(uv run python -c "from src.asta import __version__; print(__version__)"); \
107107
PYPROJECT_VERSION=$$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/'); \
@@ -118,15 +118,9 @@ release:
118118
exit 1; \
119119
fi; \
120120
VERSION=$$INIT_VERSION; \
121-
echo "Creating release v$$VERSION..."; \
122-
if git rev-parse v$$VERSION >/dev/null 2>&1; then \
123-
echo "Error: Tag v$$VERSION already exists"; \
124-
exit 1; \
125-
fi; \
126-
git tag v$$VERSION && \
127-
git push origin v$$VERSION && \
128-
echo "Release v$$VERSION created. Create GitHub release at:" && \
129-
echo "https://github.com/allenai/asta-plugins/releases/new?tag=v$$VERSION"
121+
git tag $$VERSION && \
122+
git push origin $$VERSION && \
123+
echo "Pushed tag v$$VERSION"
130124

131125
# Show current version
132126
version:

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "asta"
7-
version = "0.2.1"
7+
version = "0.3.0"
88
description = "Asta CLI for scientific literature review"
99
readme = "README.md"
1010
requires-python = ">=3.10"
1111
license = "Apache-2.0"
1212
dependencies = [
1313
"click>=8.0",
1414
"pydantic>=2.0",
15+
"pyhocon>=0.3.60",
1516
]
1617

1718
[project.scripts]
@@ -40,3 +41,6 @@ ignore = ["E501"] # line length handled by formatter
4041
testpaths = ["tests"]
4142
python_files = ["test_*.py"]
4243
asyncio_mode = "auto"
44+
filterwarnings = [
45+
"ignore::pyparsing.exceptions.PyparsingDeprecationWarning",
46+
]

skills/asta-documents/SKILL.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
2-
name: asta-documents
3-
description: Local document metadata index for files used by Asta skills and tools
2+
name: Asta Library
3+
description: Local document metadata index for files used by Asta skills and tools. Use this skill when the user asks to store a document "in Asta" or retrieve "from Asta". Use it when the
4+
user references an "Asta document" or anything with an `asta://` URI.
45
allowed-tools:
56
- Bash(asta documents *)
67
- Read(*)
@@ -10,9 +11,6 @@ allowed-tools:
1011

1112
# Asta Documents Management
1213

13-
Use this skill when the user asks to store a document "in Asta" or retrieve "from Asta". Use it when the
14-
user references an "Asta document" or anything with an `asta://` URI.
15-
1614
This skill provides complete document management functionality for tracking research papers, documentation, and resources using the `asta documents` CLI.
1715

1816
**What it does:** Track document metadata (URLs, summaries, tags) in a local index. Think of it as a smart bookmark manager with powerful search capabilities.
@@ -47,12 +45,10 @@ asta documents add "file://${REPORT_PATH}" \
4745

4846
## Installation
4947

50-
The `asta documents` command is a pass-through to the `asta-documents` CLI tool. It will be installed automatically on first use.
48+
If `asta` command is not available install it using `uv tool install git+ssh://git@github.com/allenai/asta-plugins.git`
5149

5250
**Prerequisites:** Python 3.10+ and [uv package manager](https://docs.astral.sh/uv/)
5351

54-
If manual installation is needed: `uv tool install git+ssh://git@github.com/allenai/asta-resource-repo.git`
55-
5652
Verify installation with `asta documents --help`
5753

5854
## Quick Command Reference

0 commit comments

Comments
 (0)