diff --git a/CHANGELOG.md b/CHANGELOG.md index 37ba21e3..9b65ac4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,21 @@ All notable changes to devkit. Versions follow CalVer `YY.MM.PATCH` (PATCH restarts at 0 each month); tags are `vYY.MM.PATCH`. Sections follow [Keep a Changelog](https://keepachangelog.com/). +## [26.11.11] - 2026-11-10 + +This release keeps `dev` working through updates and installs. An update could leave `dev` off the PATH, and a fresh +install could stop with "Permission denied" before anything was installed. + +### Fixed + +- **`dev update` could take `dev` off the PATH.** Once an update retired an older copy, `~/.local/bin/dev` reached the + new copy through that copy's `bin/dev`, so later installs left the link naming the older copy; three releases later + the cleanup of old copies removed it, and the link pointed at nothing. Every install now points the link at the + copy it installs, in one rename, and the cleanup keeps the copy the link names and the one `~/.zshrc` sources. +- **A fresh `dev install` could stop with "Permission denied" moving the new copy into place.** Some Macs refuse to + rename a folder its owner cannot write, and the copy was made read-only before it moved. It now moves while + writable and is read-only again once in place. + ## [26.11.10] - 2026-11-10 This release fixes what agents hit while shipping 26.11.9. `dev test prove` reports each case of a parametrized test diff --git a/VERSION b/VERSION index 2a64235e..9fdcdb1c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -26.11.10 +26.11.11 diff --git a/desktop/manifest.json b/desktop/manifest.json index 93de1fc7..165cfacf 100644 --- a/desktop/manifest.json +++ b/desktop/manifest.json @@ -2,7 +2,7 @@ "manifest_version": "0.4", "name": "devkit", "display_name": "devkit", - "version": "26.11.10", + "version": "26.11.11", "description": "Every repo in its place. Every agent on the same page. Your devkit portfolio, project status, tasks, CI and team, in Claude Desktop chat and Cowork.", "long_description": "devkit connects Claude Desktop to **devkit** from Firefly Software Solutions Inc.: every repository in its place under ~/Development, one handoff repository that keeps each project's status, tasks, plans, lessons and session log, and the same rules for Claude Code, Codex and the team. Claude Code already uses devkit through its plugin; this extension brings it to Desktop chat and Cowork.\n\n**What you can ask**\n\n- **Where things stand:** the portfolio overview, one project's status, its tasks, a standup of the last days, and a status report for the team or management.\n- **Delivery:** live CI/CD runs with job progress and an ETA, and a project's delivery policy (versioning, test gate, release flow) with its gaps.\n- **Team and history:** who is working on what, devkit's crew of specialist agents and the decisions waiting for you, lessons learned, devkit's audit trail, its scheduled jobs, and a health check of the whole setup.\n- **Tasks:** add a task, or start, finish, block, unblock or release one. Changes go through the `dev` command, so devkit's guard and audit trail apply exactly as they do in the terminal.\n\nWhen Claude reports a project's status, it starts with the devkit status block (**[Firefly> DevKit]**), the same one Claude Code and Codex use.\n\n**Setting it up.** devkit must be installed on this Mac: run `./install.sh` in the devkit repository, which runs `dev setup`. The extension finds devkit on its own; set the devkit folder only if devkit is not where `dev setup` put it. The tools come from your devkit checkout, so `dev update` updates them without reinstalling the extension. It needs Python 3.9 or later, which comes with the macOS Command Line Tools.\n\n**Privacy.** Everything runs on your Mac through the `dev` command and reads your workspace and handoff repository. The project status, CI status and doctor tools ask GitHub or your CI provider through your existing sign-in (for example `gh auth login`); task changes are pushed to your own handoff repository. No token is stored by the extension.", "author": { diff --git a/lib/devkit/setup.py b/lib/devkit/setup.py index 77746f2b..7f024111 100644 --- a/lib/devkit/setup.py +++ b/lib/devkit/setup.py @@ -321,10 +321,15 @@ def _build(source: Path, commit: str, tree: str, version: str, name: str, verifi (tmp / core.PIN_MANIFEST).write_text(json.dumps(man, indent=1, sort_keys=True) + "\n") _read_only(tmp) dest = root / name + # some Macs refuse to rename a folder its owner cannot write, even within one parent: each folder that moves + # is writable while it moves, and the copy is read-only again once it is in place if dest.exists(): old = root / f".{name}.old-{os.getpid()}" + os.chmod(dest, 0o755) # nosemgrep: python.lang.security.audit.insecure-file-permissions.insecure-file-permissions (the owner's write on a copy being replaced, only while it moves) os.rename(dest, old) + os.chmod(tmp, 0o755) # nosemgrep: python.lang.security.audit.insecure-file-permissions.insecure-file-permissions (the owner's write on the new copy, only while it moves) os.rename(tmp, dest) + os.chmod(dest, 0o555) except BaseException: _remove_tree(tmp) raise @@ -416,8 +421,9 @@ def pinned_copies() -> list: def pins_in_use() -> set: - """Real paths of the pinned copies something still runs: the installed one, this process, ~/.local/bin/dev, and - any copy that Claude's settings, Claude's managed settings, Codex's hooks or a launchd job names.""" + """Real paths of the pinned copies something still runs: the installed one, this process, ~/.local/bin/dev (the + copy it names and the one it reaches), and any copy that Claude's settings, Claude's managed settings, Codex's + hooks, a launchd job or ~/.zshrc (which puts ~/.local/bin on the PATH) names.""" from . import policy roots = {str(core.pin_root()), core.real(core.pin_root())} used = set() @@ -434,7 +440,9 @@ def add(p): link = core.HOME / ".local" / "bin" / "dev" if os.path.lexists(link): add(os.path.realpath(link)) - texts = [CLAUDE_HOME / "settings.json", CODEX_HOME / "hooks.json", policy.MANAGED_FILE] + if os.path.islink(link): # and the copy it names, though that copy's retired bin/dev leads on to another + add(Path(os.path.join(os.path.dirname(link), os.readlink(link))).parent.parent) + texts = [CLAUDE_HOME / "settings.json", CODEX_HOME / "hooks.json", policy.MANAGED_FILE, ZSHRC] texts += sorted((core.HOME / "Library" / "LaunchAgents").glob("com.devkit*.plist")) pat = re.compile("(" + "|".join(re.escape(r) for r in roots) + r")/([^/'\"\s<>]+)") for f in texts: @@ -625,11 +633,19 @@ def install_cli(): link = bindir / "dev" home = core.runtime_home() # the pinned copy: `dev` typed in a shell runs what the hooks run target = home / "bin" / "dev" - if link.is_symlink() or link.exists(): - if link.resolve() != target.resolve(): - backup(link) if not link.is_symlink() else None + if link.is_symlink(): + # the link itself must name this copy: one that reaches it only through a retired copy's bin/dev leaves + # `dev` pointing at nothing once that copy is pruned + if os.readlink(link) != str(target): + tmp = link.with_name(f".dev.{os.getpid()}.tmp") + if os.path.lexists(tmp): + tmp.unlink() + os.symlink(str(target), tmp) + os.replace(tmp, link) # one rename: a shell that runs `dev` now finds one link or the other, never none + else: + if link.exists(): + backup(link) link.unlink() - if not link.exists(): link.symlink_to(target) done(f"{tilde(link)} → {tilde(target)}") block = f'{BLOCK_START}\n[ -f "{home}/shell/devkit.zsh" ] && source "{home}/shell/devkit.zsh"\n{BLOCK_END}\n' diff --git a/plugin/.claude-plugin/plugin.json b/plugin/.claude-plugin/plugin.json index 34039397..f4e9fc21 100644 --- a/plugin/.claude-plugin/plugin.json +++ b/plugin/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "devkit", - "version": "26.11.10", + "version": "26.11.11", "description": "Every repo in its place, every agent on the same page: project context and handoff notes, tasks, a portfolio overview, local-first delivery (one push, one CI run), backend methodology, managed worktrees and a guard.", "icon": "./assets/icon.png", "author": { diff --git a/plugin/.codex-plugin/plugin.json b/plugin/.codex-plugin/plugin.json index a3aaf7af..c4007aed 100644 --- a/plugin/.codex-plugin/plugin.json +++ b/plugin/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "devkit", - "version": "26.11.10", + "version": "26.11.11", "description": "Every repo in its place, every agent on the same page: project context and handoff notes, tasks, a portfolio overview, local-first delivery (one push, one CI run), backend methodology, managed worktrees and a guard.", "author": { "name": "Firefly Software Solutions Inc.", diff --git a/tests/test_pinned_install.py b/tests/test_pinned_install.py index 8ec29b56..e6094174 100644 --- a/tests/test_pinned_install.py +++ b/tests/test_pinned_install.py @@ -307,6 +307,71 @@ def test_old_copies_are_pruned_but_never_one_in_use(self): self.assertEqual(sorted(d.name for d in core.pin_root().iterdir()), sorted(names[:2] + names[3:])) +class DevLinkTests(Sandbox): + # `dev update` took `dev` off the PATH: once an older copy was retired, ~/.local/bin/dev reached the new copy + # through that copy's bin/dev, so the install left the link naming the old copy, and the prune that removed the + # old copy three releases later left the link pointing at nothing + def update(self, version): + """What one `dev update` does to the copies and the link: pin, retire the others, link, prune.""" + commit(self.src, version) + pin = self.install(why=f"update to {version}") + core.retire_other_pins() + setup.install_cli() + setup.prune_pins() + return pin + + def test_every_update_keeps_dev_on_the_path_and_names_the_new_copy(self): + link = self.home / ".local" / "bin" / "dev" + self.update("26.11.4") + for version in ("26.11.5", "26.11.6", "26.11.7", "26.11.8", "26.11.9"): + pin = self.update(version) + self.assertTrue(os.path.exists(link), f"dev is gone after the update to {version}") + self.assertEqual(os.readlink(link), str(pin / "bin" / "dev"), version) + + def test_the_prune_keeps_the_copy_the_link_names_though_it_reaches_another(self): + # how an older install left it: the link names a retired copy, whose bin/dev leads to the pinned one + old = self.update("26.11.4") + link = self.home / ".local" / "bin" / "dev" + for version in ("26.11.5", "26.11.6", "26.11.7"): + commit(self.src, version) + self.install(why=f"update to {version}") + core.retire_other_pins() + self.assertEqual(os.readlink(link), str(old / "bin" / "dev")) + setup.prune_pins() + self.assertTrue(os.path.exists(link)) + + def test_the_prune_keeps_the_copy_zshrc_sources(self): + old = self.update("26.11.4") + zshrc = (self.home / ".zshrc").read_text() + for version in ("26.11.5", "26.11.6", "26.11.7"): + commit(self.src, version) + self.install(why=f"update to {version}") + (self.home / ".local" / "bin" / "dev").unlink() # only ~/.zshrc names the oldest copy now + self.assertIn(f'source "{old}/shell/devkit.zsh"', zshrc) + setup.prune_pins() + self.assertTrue(old.is_dir()) + + +class StrictRenameTests(Sandbox): + # a teammate's fresh `dev install` failed with Permission denied: their Mac refuses to rename a folder its owner + # cannot write, even within one parent folder, and the copy was made read-only before it was moved into place + def test_a_copy_is_moved_into_place_where_a_read_only_folder_cannot_be_renamed(self): + rename = os.rename + + def strict(src, dst, *a, **k): + if os.path.isdir(src) and not os.stat(src).st_mode & stat.S_IWUSR: + raise PermissionError(13, "Permission denied", str(src), None, str(dst)) + return rename(src, dst, *a, **k) + with mock.patch("os.rename", strict): + pin = self.install(why="a fresh install") + again = Path(setup.pin(self.src, unverified_why="the same commit, pinned again")["path"]) + self.assertEqual(again, pin) + self.assertTrue((pin / "bin" / "dev").is_file()) + self.assertEqual(stat.S_IMODE(pin.stat().st_mode), 0o555) # read-only once in place + self.assertEqual(setup.verify_pin(pin), []) + self.assertEqual([d.name for d in core.pin_root().iterdir()], [pin.name]) # no leftover of either rename + + class DoctorTests(Sandbox): def test_doctor_fails_on_a_tampered_file_and_install_rebuilds_the_copy(self): pin = self.install()