Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
push:
branches: [main]

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.rp.outputs.release_created }}
tag_name: ${{ steps.rp.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: rp
with:
release-type: python

publish:
needs: release-please
if: needs.release-please.outputs.release_created
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Build package
run: uv build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
76 changes: 76 additions & 0 deletions py_src/drasill/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
from __future__ import annotations

import asyncio
import json
import os
import platform
import shutil
import subprocess
import sys
import tarfile
import tempfile
import textwrap
from pathlib import Path
from typing import Annotated
from urllib.request import urlopen

import typer
import uvicorn
Expand Down Expand Up @@ -287,6 +292,77 @@ def install_cloudflared(
typer.echo(" systemctl --user enable --now cloudflared")


_HM_REPO = "nazq/heimdall"
_HM_TARGETS = {
("Linux", "x86_64"): "x86_64-unknown-linux-gnu",
("Linux", "aarch64"): "aarch64-unknown-linux-gnu",
("Darwin", "x86_64"): "x86_64-apple-darwin",
("Darwin", "arm64"): "aarch64-apple-darwin",
}


@install_app.command("hm")
def install_hm(
version: Annotated[
str, typer.Option(help="Version tag (e.g. v1.0.0) or 'latest'.")
] = "latest",
dest: Annotated[
str, typer.Option(help="Destination directory for the hm binary.")
] = str(Path.home() / ".local/bin"),
) -> None: # pragma: no cover
"""Download and install the heimdall (hm) session supervisor."""
system = platform.system()
machine = platform.machine()
target = _HM_TARGETS.get((system, machine))
if not target:
typer.echo(f"Unsupported platform: {system}-{machine}", err=True)
raise typer.Exit(code=1)

# Resolve version tag.
if version == "latest":
url = f"https://api.github.com/repos/{_HM_REPO}/releases/latest"
with urlopen(url) as resp: # noqa: S310
tag = json.loads(resp.read())["tag_name"]
else:
tag = version

asset = f"heimdall-{target}.tar.gz"
download_url = f"https://github.com/{_HM_REPO}/releases/download/{tag}/{asset}"
typer.echo(f"Downloading hm {tag} for {target}...")

dest_path = Path(dest)
dest_path.mkdir(parents=True, exist_ok=True)

with tempfile.TemporaryDirectory() as tmpdir:
archive_path = Path(tmpdir) / asset
with urlopen(download_url) as resp, archive_path.open("wb") as f: # noqa: S310
f.write(resp.read())

with tarfile.open(archive_path) as tar:
# Find the hm binary in the archive.
for member in tar.getmembers():
if member.name.endswith("/hm") or member.name == "hm":
member.name = "hm" # flatten path
tar.extract(member, dest_path, filter="data")
break
else:
typer.echo("hm binary not found in archive", err=True)
raise typer.Exit(code=1)

hm_path = dest_path / "hm"
hm_path.chmod(0o755)
typer.echo(f"Installed: {hm_path}")

result = subprocess.run(
[str(hm_path), "--version"],
capture_output=True,
text=True,
check=False,
)
if result.returncode == 0:
typer.echo(result.stdout.strip())


@app.command("reset-state")
def reset_state(
config: _ConfigOpt = None,
Expand Down
24 changes: 24 additions & 0 deletions py_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typer.testing import CliRunner

from drasill.cli import (
_HM_TARGETS,
_cloudflared_unit,
_cloudflared_yml,
_drasill_bin,
Expand Down Expand Up @@ -430,3 +431,26 @@ def test_module_entry_point() -> None:
main_path = Path(__file__).parent.parent / "py_src" / "drasill" / "__main__.py"
content = main_path.read_text()
assert "from drasill.cli import main" in content


# ── install hm ───────────────────────────────────────────────────────


def test_install_hm_unsupported_platform() -> None:
"""install hm fails on unsupported platform."""
with (
patch("platform.system", return_value="Windows"),
patch("platform.machine", return_value="AMD64"),
):
result = runner.invoke(app, ["install", "hm"])
assert result.exit_code == 1
assert "Unsupported platform" in result.output


def test_install_hm_target_detection() -> None:
"""Correct target string for known platforms."""

assert _HM_TARGETS[("Linux", "x86_64")] == "x86_64-unknown-linux-gnu"
assert _HM_TARGETS[("Linux", "aarch64")] == "aarch64-unknown-linux-gnu"
assert _HM_TARGETS[("Darwin", "x86_64")] == "x86_64-apple-darwin"
assert _HM_TARGETS[("Darwin", "arm64")] == "aarch64-apple-darwin"
24 changes: 22 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
[project]
name = "drasill"
version = "0.1.0"
description = "Drasill — Claude Code Agent mesh control plane"
version = "0.2.0"
description = "Agent mesh control plane — coordinate AI coding agents from a live dashboard"
readme = "README.md"
license = {text = "Apache-2.0"}
authors = [{name = "Naz Quadri", email = "naz.quadri@gmail.com"}]
keywords = ["ai", "agents", "claude", "codex", "mesh", "dashboard", "heimdall"]
classifiers = [
"Development Status :: 4 - Beta",
"Framework :: FastAPI",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development",
]
requires-python = ">=3.13"
dependencies = [
"fastapi>=0.115.0",
Expand All @@ -17,6 +29,11 @@ dependencies = [
[project.scripts]
drasill = "drasill.cli:main"

[project.urls]
Homepage = "https://github.com/nazq/Drasill"
Repository = "https://github.com/nazq/Drasill"
Issues = "https://github.com/nazq/Drasill/issues"

[dependency-groups]
dev = [
"ruff>=0.9.0",
Expand Down Expand Up @@ -89,6 +106,9 @@ omit = ["py_src/drasill/__main__.py"]
[tool.hatch.build.targets.wheel]
packages = ["py_src/drasill"]

[tool.hatch.build.targets.wheel.force-include]
"scripts/fetch-hm.sh" = "drasill/scripts/fetch-hm.sh"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading