Summary
getProjectName() appends a 6-character path hash so that two directories with the same package.json name get separate ~/.d3k/<project>/ directories (logs, Chrome profile, session.json). The 50-character limit is applied after the hash is appended, so any sanitized name longer than 43 characters loses part or all of the hash.
For example, @acme-corp/marketing-website-frontend-application becomes acme-corp-marketing-website-frontend-application- plus only the first hex character of the hash, so two worktrees of that package collide 1 time in 16. A sanitized name of 49 characters or more drops the hash entirely, and every checkout collides. Colliding d3k instances share one project directory, one Chrome profile and one session.json, which is the collision the path hash exists to prevent.
Changes
- Sanitize and truncate the base name to
50 - 7characters first, then append-<hash>. The result is still at most 50 characters. - Names of 43 characters or fewer produce exactly the same output as before, so existing project directories don't move.
- Add a test for a long scoped package name in two directories.
Testing
bunx vitest run src/utils/project-name.test.ts: 12 passed. With the source change reverted, the new test fails (1 failed, 11 passed).bunx vitest run: 350 tests, 349 passed, 1 skipped.biome check srcandtsc --noEmitare clean.
Fixes #121
@RaphaelFakhri is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.