whydid 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,30 @@
1
1
  import { existsSync, readdirSync, statSync, openSync, closeSync, readSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
- import { join } from "node:path";
3
+ import { join, basename as nodeBasename } from "node:path";
4
4
  export function claudeCodeProjectSlug(projectRoot) {
5
5
  return projectRoot.replace(/[^a-zA-Z0-9]+/g, "-");
6
6
  }
7
+ /**
8
+ * Claude Code keys its ~/.claude/projects/<slug> folder on the full
9
+ * absolute path on macOS (verified directly against a real local install —
10
+ * see claudeCodeProjectSlug's test). But a real Windows install was
11
+ * observed naming the folder from the project directory's own basename
12
+ * only — no drive letter, no parent segments at all (e.g. "enrollverse-
13
+ * landing" for C:\Users\...\enrollverse_landing). This is an undocumented
14
+ * format that evidently differs by platform or version, so
15
+ * findClaudeCodeSessionDir tries both rather than assuming one.
16
+ */
17
+ export function claudeCodeBasenameSlug(projectRoot, basenameImpl = nodeBasename) {
18
+ return claudeCodeProjectSlug(basenameImpl(projectRoot));
19
+ }
7
20
  export function findClaudeCodeSessionDir(projectRoot, claudeProjectsDir = join(homedir(), ".claude", "projects")) {
8
- const dir = join(claudeProjectsDir, claudeCodeProjectSlug(projectRoot));
9
- return existsSync(dir) ? dir : null;
21
+ const fullPathDir = join(claudeProjectsDir, claudeCodeProjectSlug(projectRoot));
22
+ if (existsSync(fullPathDir))
23
+ return fullPathDir;
24
+ const basenameDir = join(claudeProjectsDir, claudeCodeBasenameSlug(projectRoot));
25
+ if (existsSync(basenameDir))
26
+ return basenameDir;
27
+ return null;
10
28
  }
11
29
  export function findLatestSessionFile(sessionDir) {
12
30
  let latestFile = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whydid",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "description": "A local-first AI coding time machine — captures meaningful changes, reasoning, and session context so you can see what happened across your coding sessions, even days later.",