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
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agentsmd",
"version": "17.5.0",
"version": "17.6.0",
"description": "Portable agent rules, Project Direction, Delivery System profiles, owned workflow Skills, and deterministic version control.",
"author": {
"name": "lukaszmaj"
Expand Down
2 changes: 1 addition & 1 deletion .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agentsmd",
"version": "17.5.0",
"version": "17.6.0",
"description": "Portable agent rules, Project Direction, Delivery System profiles, owned workflow Skills, and deterministic version control.",
"author": {
"name": "lukaszmaj",
Expand Down
2 changes: 1 addition & 1 deletion .grok-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agentsmd",
"version": "17.5.0",
"version": "17.6.0",
"description": "Portable agent rules, Project Direction, Delivery System profiles, owned workflow Skills, and deterministic version control.",
"author": {
"name": "lukaszmaj"
Expand Down
2 changes: 1 addition & 1 deletion .muse-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schemaVersion": 1,
"name": "agentsmd",
"displayName": "AgentsMD",
"version": "17.5.0",
"version": "17.6.0",
"description": "Portable agent rules, Project Direction, Delivery System profiles, owned workflow Skills, and deterministic version control.",
"compat": {
"source": "native",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All completed repository versions are recorded here. Release entries follow
SemVer and identify one user-consumable repository state.

## [17.6.0] - 2026-11-18

### Added

- versionctl lets one file declare several mirror pointers, so prepare, doctor and release-check keep both npm lockfile version fields in step (#273)

## [17.5.0] - 2026-11-18

### Added
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.5.0
17.6.0
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ channels and independently released monorepo components are deferred.

Each mirror has a repository-relative `path` and absolute JSON Pointer. JSON
and TOML are supported. TOML pointers map section tokens and a final key, such
as `/project/version` or `/tool/poetry/version`.
as `/project/version` or `/tool/poetry/version`. One file may declare several
pointers; each `path` and `pointer` pair must be unique. An npm lockfile carries
the package version twice, so declare both fields:

```json
{
"path": "package.json",
"pointer": "/version"
}
[
{ "path": "package.json", "pointer": "/version" },
{ "path": "package-lock.json", "pointer": "/version" },
{ "path": "package-lock.json", "pointer": "/packages//version" }
]
```

Only `versionctl adopt` or `versionctl prepare` may write the canonical version
Expand Down
2 changes: 1 addition & 1 deletion tools/versionctl/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "toolboxmd-versionctl"
version = "17.5.0"
version = "17.6.0"
description = "Deterministic repository version mechanics for coding agents"
readme = "README.md"
requires-python = ">=3.11"
Expand Down
8 changes: 6 additions & 2 deletions tools/versionctl/src/versionctl/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ def mirror_states(root: Path, mirrors: tuple[Mirror, ...], version: SemVer) -> l
return states


def updated_mirror_text(path: Path, pointer: str, version: str) -> tuple[str, str | None]:
text = path.read_text(encoding="utf-8")
def updated_mirror_text(
path: Path, pointer: str, version: str, text: str | None = None
) -> tuple[str, str | None]:
"""Return the mirror text with the pointer set; pass ``text`` to chain edits to one file."""
if text is None:
text = path.read_text(encoding="utf-8")
tokens = _pointer_tokens(pointer)
suffix = path.suffix.lower()
if suffix == ".json":
Expand Down
10 changes: 5 additions & 5 deletions tools/versionctl/src/versionctl/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def load(cls, root: Path) -> "Policy":
if not isinstance(raw_mirrors, list):
raise VersionCtlError(ExitCode.INVALID_POLICY, "mirrors must be an array")
mirrors: list[Mirror] = []
seen_paths: set[str] = set()
seen: set[tuple[str, str]] = set()
for index, item in enumerate(raw_mirrors):
if not isinstance(item, dict) or set(item) != {"path", "pointer"}:
raise VersionCtlError(
Expand All @@ -144,13 +144,13 @@ def load(cls, root: Path) -> "Policy":
"mirror pointer must be an absolute JSON Pointer",
details={"index": index, "pointer": pointer},
)
if mirror_path == version_source or mirror_path in seen_paths:
if mirror_path == version_source or (mirror_path, pointer) in seen:
raise VersionCtlError(
ExitCode.INVALID_POLICY,
"mirror paths must be unique and cannot equal versionSource",
details={"path": mirror_path},
"mirror path and pointer pairs must be unique and cannot use versionSource",
details={"path": mirror_path, "pointer": pointer},
)
seen_paths.add(mirror_path)
seen.add((mirror_path, pointer))
mirrors.append(Mirror(mirror_path, pointer))

return cls(
Expand Down
8 changes: 6 additions & 2 deletions tools/versionctl/src/versionctl/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ def adopt(self, version_value: str, *, reason: str, dry_run: bool = False) -> Co
]
for mirror in self.policy.mirrors:
path = self.repo.root / mirror.path
updated, normalization = updated_mirror_text(path, mirror.pointer, str(version))
updated, normalization = updated_mirror_text(
path, mirror.pointer, str(version), changes.get(path)
)
before = version_from_mirror_text(path, mirror.pointer, path.read_text(encoding="utf-8"))
changes[path] = updated
fields.append(
Expand Down Expand Up @@ -375,7 +377,9 @@ def prepare(self, impact: str, *, reason: str, dry_run: bool = False) -> Command
]
for mirror in self.policy.mirrors:
path = self.repo.root / mirror.path
updated, normalization = updated_mirror_text(path, mirror.pointer, str(target))
updated, normalization = updated_mirror_text(
path, mirror.pointer, str(target), changes.get(path)
)
before = read_version_file_from_mirror(path, mirror)
changes[path] = updated
fields.append(
Expand Down
59 changes: 54 additions & 5 deletions tools/versionctl/tests/test_versionctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ def seed(self, version: str = "0.1.0", *, tag: bool = True) -> str:
return sha

def _write_json_mirror(self, mirror: dict[str, str], version: str) -> None:
tokens = mirror["pointer"].strip("/").split("/")
document: dict[str, object] = {}
tokens = mirror["pointer"][1:].split("/")
path = self.root / mirror["path"]
document: dict[str, object] = json.loads(path.read_text(encoding="utf-8")) if path.exists() else {}
current = document
for token in tokens[:-1]:
child: dict[str, object] = {}
current[token] = child
current = child
current = current.setdefault(token, {}) # type: ignore[assignment]
current[tokens[-1]] = version
self.write(mirror["path"], json.dumps(document, indent=2) + "\n")

Expand Down Expand Up @@ -195,6 +194,56 @@ def test_node_python_plugin_and_nested_mirrors_move_together(self) -> None:
self.assertEqual(json.loads(repo.read("plugins/example/plugin.json"))["version"], "0.2.0")
self.assertEqual(json.loads(repo.read("packages/nested/package.json"))["version"], "0.2.0")

def test_npm_lockfile_declares_both_version_fields(self) -> None:
mirrors = [
{"path": "package.json", "pointer": "/version"},
{"path": "package-lock.json", "pointer": "/version"},
{"path": "package-lock.json", "pointer": "/packages//version"},
]
repo = self.repo(mirrors=mirrors)
repo.seed()
lockfile = json.loads(repo.read("package-lock.json"))
self.assertEqual(lockfile, {"version": "0.1.0", "packages": {"": {"version": "0.1.0"}}})

doctor = repo.run("doctor", "--json")
self.assertEqual(doctor.returncode, 0, doctor.stderr or doctor.stdout)

repo.write("feature.md", "Fix.\n")
result = repo.run("prepare", "patch", "--reason", "Fix lockfile drift", "--json")
self.assertEqual(result.returncode, 0, result.stderr or result.stdout)
self.assertEqual(json.loads(repo.read("package.json"))["version"], "0.1.1")
self.assertEqual(
json.loads(repo.read("package-lock.json")),
{"version": "0.1.1", "packages": {"": {"version": "0.1.1"}}},
)
repo.git("add", ".")
repo.git("commit", "-m", "fix: lockfile drift")
self.assertEqual(repo.run("release-check", "--json").returncode, 0)

# doctor and release-check each catch a stale nested lockfile field.
lockfile = json.loads(repo.read("package-lock.json"))
lockfile["packages"][""]["version"] = "0.1.0"
repo.write("package-lock.json", json.dumps(lockfile, indent=2) + "\n")
repo.git("commit", "-am", "chore: stale lockfile")
stale = [
item
for item in json.loads(repo.run("doctor", "--json").stdout)["mirrors"]
if not item["consistent"]
]
self.assertEqual([(m["path"], m["pointer"]) for m in stale], [("package-lock.json", "/packages//version")])
self.assertEqual(repo.run("release-check", "--json").returncode, 15)

def test_duplicate_mirror_pointer_is_rejected(self) -> None:
mirrors = [
{"path": "package.json", "pointer": "/version"},
{"path": "package.json", "pointer": "/version"},
]
repo = self.repo(mirrors=mirrors)
repo.seed()
doctor = repo.run("doctor", "--json")
self.assertNotEqual(doctor.returncode, 0)
self.assertIn("INVALID_POLICY", doctor.stdout + doctor.stderr)

def test_adoption_and_wip_hook_contract(self) -> None:
repo = self.repo()
repo.policy()
Expand Down
Loading