Skip to content
Open
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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git
.venv
node_modules
dsh-plugin/node_modules
dist
build
*.db
*.sqlite
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
- run: uv sync --extra dev
- run: python3 scripts/release.py --root .
- run: uv run janus schema check
- run: uv run janus demo

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: astral-sh/setup-uv@v3
- run: python3 scripts/release.py --root .
- run: uv build
- run: npm ci && npm pack --pack-destination ../dist
working-directory: dsh-plugin
- run: docker build -t janus:${{ github.ref_name }} .
- uses: softprops/action-gh-release@v2
with:
files: dist/*
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## [0.1.0]

Initial local-first research agent scaffold: bitemporal memory, analysis,
forecast ledger, calibration, review, personas, MCP/CLI, BeliefBench, and the
DSH descriptors.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.12-slim

WORKDIR /app
COPY pyproject.toml README.md ./
COPY core ./core
RUN pip install --no-cache-dir .

ENTRYPOINT ["janus"]
CMD ["demo"]
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: install install-hooks test lint format demo merge-pr clean
.PHONY: install install-hooks test lint format demo merge-pr release release-image clean

install:
uv sync --extra dev
Expand Down Expand Up @@ -29,6 +29,14 @@ format:
demo:
uv run janus demo

release:
python3 scripts/release.py --root .
uv build
cd dsh-plugin && npm pack --pack-destination ../dist

release-image:
docker build -t janus:local .

clean:
rm -rf .pytest_cache .ruff_cache .mypy_cache dist build *.egg-info
find . -type d -name __pycache__ -prune -exec rm -rf {} +
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ local-first, point-in-time, and built to be audited.
- [Roadmap](#roadmap)
- [Evaluation](#evaluation)
- [Security and privacy](#security-and-privacy)
- [Releases](#releases)
- [FAQ](#faq)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -428,6 +429,22 @@ Point-in-time correctness and calibration. The LLM is not the hard part.
**Is it production-ready?**
No. It is a `v0.1.0` scaffold. Use it to explore, not to manage money.

## Releases

Version strings are checked across `pyproject.toml`, `core/janus/__init__.py`,
`dsh-plugin/package.json`, and `package-lock.json`.

```bash
python3 scripts/release.py --root . # check
python3 scripts/release.py --bump 0.2.0 # dry-run
python3 scripts/release.py --bump 0.2.0 --write --message "..." # apply
make release # check + wheel/sdist + DSH tarball
make release-image # local Docker image
```

The tag workflow rebuilds the Python distributions, the DSH plugin tarball, and
the container image, then uploads artifacts to the GitHub release.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md). The short version:
Expand Down
4 changes: 2 additions & 2 deletions docs/BACKLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ criteria.

## How to read this

**Current status (2026-11-24):** JAN-001, JAN-002, JAN-003, JAN-005, JAN-007,
**Current status (2026-11-24):** JAN-001, JAN-002, JAN-003, JAN-005, JAN-006, JAN-007,
JAN-008, JAN-009, JAN-010, JAN-015, JAN-016, JAN-019, JAN-023, JAN-024, JAN-025,
JAN-027, JAN-028, JAN-031 (tracker #39 / JAN-074), JAN-033, JAN-034, JAN-035,
JAN-037, JAN-040, JAN-041,
Expand All @@ -25,7 +25,7 @@ DSH UI wiring and cron are deferred to v0.2. See `schemas/janus.schema.json`,
`tests/test_debrief.py`, `tests/test_persona_weighting.py`,
`tests/test_mcp_service.py`, `tests/test_beliefbench.py`,
`tests/test_gdelt.py`, `tests/test_rss.py`, `tests/test_scheduler.py`,
`tests/test_quality.py`, and `tests/test_copy.py`.
`tests/test_quality.py`, `tests/test_release.py`, and `tests/test_copy.py`.

- **Milestones** are delivery windows, not promises: M0 foundation, M1 data and
memory, M2 analysis, M3 forecast and review, M4 interface, M5 evaluation and
Expand Down
152 changes: 152 additions & 0 deletions scripts/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/usr/bin/env python3
"""Check and bump Janus release versions without third-party imports."""

from __future__ import annotations

import argparse
import json
import re
import sys
from dataclasses import dataclass
from pathlib import Path

SEMVER = re.compile(r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:[-+][0-9A-Za-z.-]+)?$")
PYPROJECT_VERSION = re.compile(r'(?m)^version\s*=\s*"([^"]+)"')
INIT_VERSION = re.compile(r'(?m)^__version__\s*=\s*"([^"]+)"')


@dataclass(frozen=True)
class VersionHit:
path: Path
label: str
value: str


def read_versions(root: Path) -> list[VersionHit]:
hits = [
VersionHit(
root / "pyproject.toml",
"pyproject.toml [project].version",
_regex_version(root / "pyproject.toml", PYPROJECT_VERSION),
),
VersionHit(
root / "core/janus/__init__.py",
"core/janus/__init__.py __version__",
_regex_version(root / "core/janus/__init__.py", INIT_VERSION),
),
]
package = json.loads((root / "dsh-plugin/package.json").read_text(encoding="utf-8"))
hits.append(VersionHit(root / "dsh-plugin/package.json", "package.json", package["version"]))
lock = json.loads((root / "dsh-plugin/package-lock.json").read_text(encoding="utf-8"))
hits.append(
VersionHit(
root / "dsh-plugin/package-lock.json",
"package-lock.json",
lock.get("version") or lock["packages"][""]["version"],
)
)
return hits


def _regex_version(path: Path, pattern: re.Pattern[str]) -> str:
match = pattern.search(path.read_text(encoding="utf-8"))
if match is None:
raise ValueError(f"could not find version in {path}")
return match.group(1)


def check_versions(root: Path) -> list[str]:
hits = read_versions(root)
values = {hit.value for hit in hits}
if len(values) != 1:
return [
"version mismatch: " + ", ".join(f"{hit.label}={hit.value}" for hit in hits)
]
version = hits[0].value
if not SEMVER.match(version):
return [f"invalid semantic version: {version}"]
return []


def _replace_once(path: Path, pattern: re.Pattern[str], version: str) -> None:
text = path.read_text(encoding="utf-8")
replaced, count = pattern.subn(
lambda match: match.group(0).replace(match.group(1), version),
text,
count=1,
)
if count != 1:
raise ValueError(f"could not replace version in {path}")
path.write_text(replaced, encoding="utf-8")


def bump_version(
root: Path,
version: str,
*,
write: bool = False,
changelog_message: str = "",
) -> dict[str, str]:
if not SEMVER.match(version):
raise ValueError(f"invalid semantic version: {version}")
changes = {hit.label: f"{hit.value} -> {version}" for hit in read_versions(root)}
if write:
_replace_once(root / "pyproject.toml", PYPROJECT_VERSION, version)
_replace_once(root / "core/janus/__init__.py", INIT_VERSION, version)
for name in ("package.json", "package-lock.json"):
path = root / "dsh-plugin" / name
payload = json.loads(path.read_text(encoding="utf-8"))
if name == "package-lock.json":
payload["version"] = version
payload["packages"][""]["version"] = version
else:
payload["version"] = version
path.write_text(json.dumps(payload, indent=2) + "\n", encoding="utf-8")
_update_changelog(root / "CHANGELOG.md", version, changelog_message)
return changes


def _update_changelog(path: Path, version: str, message: str) -> None:
heading = f"## [{version}]"
text = path.read_text(encoding="utf-8") if path.exists() else "# Changelog\n"
if heading in text:
return
entry = f"{heading}\n\n{message or 'Release ' + version}\n\n"
lines = text.splitlines()
insert_at = 1 if lines and lines[0].startswith("# ") else 0
lines.insert(insert_at, "\n" + entry.rstrip())
path.write_text("\n".join(lines).rstrip() + "\n", encoding="utf-8")


def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--root", type=Path, default=Path("."))
parser.add_argument("--bump", metavar="VERSION")
parser.add_argument("--write", action="store_true", help="Actually modify files")
parser.add_argument("--message", default="", help="Changelog entry for the bump")
args = parser.parse_args(argv)
root = args.root.resolve()
try:
if args.bump:
changes = bump_version(
root, args.bump, write=args.write, changelog_message=args.message
)
for label, change in changes.items():
print(f"{label}: {change}")
if not args.write:
print("dry-run: pass --write to modify files")
return 0
errors = check_versions(root)
except (OSError, ValueError, KeyError) as exc:
print(f"release check failed: {exc}", file=sys.stderr)
return 1
if errors:
for error in errors:
print(error, file=sys.stderr)
return 1
print(f"versions ok: {read_versions(root)[0].value}")
return 0


if __name__ == "__main__":
raise SystemExit(main())
72 changes: 72 additions & 0 deletions tests/test_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from __future__ import annotations

import json

import pytest

from scripts.release import bump_version, check_versions, read_versions


def _root(tmp_path):
(tmp_path / "core/janus").mkdir(parents=True)
(tmp_path / "dsh-plugin").mkdir()
(tmp_path / "pyproject.toml").write_text('[project]\nversion = "0.1.0"\n')
(tmp_path / "core/janus/__init__.py").write_text('__version__ = "0.1.0"\n')
(tmp_path / "dsh-plugin/package.json").write_text(
json.dumps({"name": "@hugoxk/janus-dsh", "version": "0.1.0"}, indent=2) + "\n"
)
(tmp_path / "dsh-plugin/package-lock.json").write_text(
json.dumps(
{
"name": "@hugoxk/janus-dsh",
"version": "0.1.0",
"lockfileVersion": 3,
"packages": {"": {"name": "@hugoxk/janus-dsh", "version": "0.1.0"}},
},
indent=2,
)
+ "\n"
)
return tmp_path


def test_versions_are_in_sync(tmp_path) -> None:
root = _root(tmp_path)
assert check_versions(root) == []
assert {hit.value for hit in read_versions(root)} == {"0.1.0"}


def test_mismatch_is_reported(tmp_path) -> None:
root = _root(tmp_path)
package = root / "dsh-plugin/package.json"
payload = json.loads(package.read_text())
payload["version"] = "0.2.0"
package.write_text(json.dumps(payload))
errors = check_versions(root)
assert len(errors) == 1
assert "version mismatch" in errors[0]


def test_bump_writes_every_file_and_changelog(tmp_path) -> None:
root = _root(tmp_path)
changes = bump_version(root, "1.2.3", write=True, changelog_message="Big release")

assert check_versions(root) == []
assert all("-> 1.2.3" in value for value in changes.values())
assert "1.2.3" in (root / "CHANGELOG.md").read_text()
assert "Big release" in (root / "CHANGELOG.md").read_text()
lock = json.loads((root / "dsh-plugin/package-lock.json").read_text())
assert lock["version"] == "1.2.3"
assert lock["packages"][""]["version"] == "1.2.3"


def test_dry_run_does_not_write(tmp_path) -> None:
root = _root(tmp_path)
bump_version(root, "2.0.0", write=False)
assert {hit.value for hit in read_versions(root)} == {"0.1.0"}
assert not (root / "CHANGELOG.md").exists()


def test_invalid_version_is_rejected(tmp_path) -> None:
with pytest.raises(ValueError, match="semantic version"):
bump_version(_root(tmp_path), "v2", write=True)
Loading