The Stop scalar never dispatched on macOS or Linux (the PowerShell branch was always selected because check-complete.ps1 ships on every platform) and was a silent no-op anywhere CLAUDE_SKILL_DIR was unset (the :- install path fallback can never substitute because the probed variable is always a non-empty string). Both the legacy completion advisory and the v3 completion gate were dead in those environments. The scalar now selects targets by file existence and dispatches by platform, PowerShell only under MINGW/MSYS/CYGWIN, sh elsewhere. Windows output is unchanged. Patched in all 14 SKILL.md variants that carry the scalar. session-catchup probed a ~/.claude/projects name that Claude Code never writes for POSIX paths (leading dash stripped) or paths containing an underscore (replaced with a dash), so recovery after /clear silently found nothing there. The mapper now probes the exact spelling first, keeps both legacy spellings for stores created by older versions, and settles ambiguity via the cwd recorded in the newest session file. Propagated to every shipped copy including the older-generation root, .hermes, and .mastracode scripts. Also: the attestation SHA cache is keyed on the absolute plan path so two projects can no longer share a slot and report a false PLAN TAMPERED; resolve-plan-dir.ps1 reaches parity with the sh resolver (slug filter, task_plan.md requirement in the newest-dir scan, fail-closed containment); ledger-append.sh no longer truncates summaries mid-codepoint (UTF-8-safe trim via iconv with a pure-sh fallback). New long-run features, all opt-in or additive: structure-aware injection (PWF_INJECT=smart or an inject-smart .mode token) keeps the active phase, phase counts, and the last three decisions in the window late in long plans; a Next Step section in both plan templates plus a sixth reboot question; session-catchup annotates tool results (ok or FAILED with the first error line) instead of only listing attempts. Infrastructure: macos-latest joins the CI matrix, a BSD-userland simulation harness runs the script fleet without realpath, readlink, flock, or sha256sum on the Linux leg, and .gitattributes pins LF for scripts. SEO surfaces: llms.txt rewritten as a Q&A page, three problem-query docs pages, plugin.json and CITATION.cff keyword hygiene. Suite grows from 217 to 301 passed, 11 skipped, on Windows and both existing CI legs; default hook output stays byte-identical to v2.43 (legacy invariant proven by the existing invariant tests).
115 lines
4.0 KiB
Python
115 lines
4.0 KiB
Python
"""get_claude_project_dir mapping tests (v3.8.0 regression fix).
|
|
|
|
Claude Code keeps underscores and the leading dash of POSIX absolute paths
|
|
in ~/.claude/projects/ names. The pre-v3.8.0 mapper replaced '_' with '-'
|
|
and stripped the leading dash, silently missing the real store on every
|
|
macOS/Linux install and on any project path with an underscore (verified
|
|
against real stores on disk). These tests pin the corrected candidate-set
|
|
mapping and its legacy fallbacks.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
import json
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
|
|
SCRIPT_SOURCE = (
|
|
Path(__file__).resolve().parents[1]
|
|
/ "skills/planning-with-files/scripts/session-catchup.py"
|
|
)
|
|
|
|
|
|
def load_module(script_path: Path):
|
|
spec = importlib.util.spec_from_file_location(
|
|
"session_catchup_projdir", script_path
|
|
)
|
|
assert spec is not None and spec.loader is not None
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
class ClaudeProjectDirMappingTests(unittest.TestCase):
|
|
def setUp(self):
|
|
self.tempdir = tempfile.TemporaryDirectory()
|
|
self.home = Path(self.tempdir.name)
|
|
self.projects = self.home / ".claude" / "projects"
|
|
self.projects.mkdir(parents=True)
|
|
self.module = load_module(SCRIPT_SOURCE)
|
|
self.home_patch = mock.patch.object(
|
|
self.module.Path, "home", return_value=self.home
|
|
)
|
|
self.home_patch.start()
|
|
# The surface under test is sanitize+probe, not path resolution.
|
|
self.norm_patch = mock.patch.object(
|
|
self.module, "normalize_path", side_effect=lambda p: p
|
|
)
|
|
self.norm_patch.start()
|
|
|
|
def tearDown(self):
|
|
self.norm_patch.stop()
|
|
self.home_patch.stop()
|
|
self.tempdir.cleanup()
|
|
|
|
def _mk(self, name: str) -> Path:
|
|
d = self.projects / name
|
|
d.mkdir()
|
|
return d
|
|
|
|
def test_windows_underscore_path_kept(self):
|
|
real = self._mk("C--Users-dev-Documents-My_Repo")
|
|
got = self.module.get_claude_project_dir("C:\\Users\\dev\\Documents\\My_Repo")
|
|
self.assertEqual(real, got)
|
|
|
|
def test_posix_leading_dash_kept(self):
|
|
real = self._mk("-home-dev-project")
|
|
got = self.module.get_claude_project_dir("/home/dev/project")
|
|
self.assertEqual(real, got)
|
|
|
|
def test_posix_underscore_and_dash_kept(self):
|
|
real = self._mk("-home-dev-Ayseu_Visa_2026")
|
|
got = self.module.get_claude_project_dir("/home/dev/Ayseu_Visa_2026")
|
|
self.assertEqual(real, got)
|
|
|
|
def test_dot_becomes_dash(self):
|
|
real = self._mk("-home-dev-my-app-v2")
|
|
got = self.module.get_claude_project_dir("/home/dev/my.app.v2")
|
|
self.assertEqual(real, got)
|
|
|
|
def test_legacy_underscore_spelling_still_found(self):
|
|
legacy = self._mk("C--Users-dev-My-Repo")
|
|
got = self.module.get_claude_project_dir("C:\\Users\\dev\\My_Repo")
|
|
self.assertEqual(legacy, got)
|
|
|
|
def test_legacy_stripped_dash_still_found(self):
|
|
legacy = self._mk("home-dev-project")
|
|
got = self.module.get_claude_project_dir("/home/dev/project")
|
|
self.assertEqual(legacy, got)
|
|
|
|
def test_collision_resolved_by_session_cwd(self):
|
|
primary = self._mk("-home-dev-foo_bar")
|
|
legacy = self._mk("-home-dev-foo-bar")
|
|
(legacy / "s1.jsonl").write_text(
|
|
json.dumps({"cwd": "/home/dev/foo-bar"}) + "\n", encoding="utf-8"
|
|
)
|
|
(primary / "s1.jsonl").write_text(
|
|
json.dumps({"cwd": "/home/dev/foo_bar"}) + "\n", encoding="utf-8"
|
|
)
|
|
self.assertEqual(
|
|
primary, self.module.get_claude_project_dir("/home/dev/foo_bar")
|
|
)
|
|
self.assertEqual(
|
|
legacy, self.module.get_claude_project_dir("/home/dev/foo-bar")
|
|
)
|
|
|
|
def test_missing_store_returns_primary_spelling(self):
|
|
got = self.module.get_claude_project_dir("/home/dev/absent_proj")
|
|
self.assertEqual(self.projects / "-home-dev-absent_proj", got)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|