diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 1d71d0df..01ddc56e 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -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" diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index 99f3ba1f..d4f0b8eb 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -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", diff --git a/.grok-plugin/plugin.json b/.grok-plugin/plugin.json index 97b5e6ae..11121aa7 100644 --- a/.grok-plugin/plugin.json +++ b/.grok-plugin/plugin.json @@ -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" diff --git a/.muse-plugin/plugin.json b/.muse-plugin/plugin.json index 2e721abe..d7380618 100644 --- a/.muse-plugin/plugin.json +++ b/.muse-plugin/plugin.json @@ -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", diff --git a/CHANGELOG.md b/CHANGELOG.md index b851efd2..e8f53faf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/VERSION b/VERSION index 6f0844e0..ea3bf215 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -17.5.0 +17.6.0 diff --git a/skills/operations/procedures/version-control/references/project-policy.md b/skills/operations/procedures/version-control/references/project-policy.md index 56a938ec..b560c17b 100644 --- a/skills/operations/procedures/version-control/references/project-policy.md +++ b/skills/operations/procedures/version-control/references/project-policy.md @@ -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 diff --git a/tools/versionctl/pyproject.toml b/tools/versionctl/pyproject.toml index 285bf064..9db83a3e 100644 --- a/tools/versionctl/pyproject.toml +++ b/tools/versionctl/pyproject.toml @@ -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" diff --git a/tools/versionctl/src/versionctl/files.py b/tools/versionctl/src/versionctl/files.py index 9290df1a..8a92f366 100644 --- a/tools/versionctl/src/versionctl/files.py +++ b/tools/versionctl/src/versionctl/files.py @@ -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": diff --git a/tools/versionctl/src/versionctl/policy.py b/tools/versionctl/src/versionctl/policy.py index 143969f5..0b551e69 100644 --- a/tools/versionctl/src/versionctl/policy.py +++ b/tools/versionctl/src/versionctl/policy.py @@ -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( @@ -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( diff --git a/tools/versionctl/src/versionctl/service.py b/tools/versionctl/src/versionctl/service.py index a80e7952..69ac1c94 100644 --- a/tools/versionctl/src/versionctl/service.py +++ b/tools/versionctl/src/versionctl/service.py @@ -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( @@ -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( diff --git a/tools/versionctl/tests/test_versionctl.py b/tools/versionctl/tests/test_versionctl.py index 1a77e038..a205b346 100644 --- a/tools/versionctl/tests/test_versionctl.py +++ b/tools/versionctl/tests/test_versionctl.py @@ -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") @@ -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()