whydid 1.0.2 → 1.0.4
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.
- package/dist/adapters/claude-code.js +32 -4
- package/package.json +1 -1
|
@@ -1,12 +1,40 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Claude Code replaces EACH non-alphanumeric character with its own hyphen
|
|
6
|
+
* — it does not collapse adjacent ones into a single hyphen. A POSIX path
|
|
7
|
+
* never has two special characters back to back (every segment is
|
|
8
|
+
* separated by exactly one '/'), so this was indistinguishable from
|
|
9
|
+
* collapsing-runs against real macOS data — only a Windows drive letter
|
|
10
|
+
* ("C:\" — colon then backslash, two adjacent specials) exposes the
|
|
11
|
+
* difference: Claude Code's real output doubles the hyphen there
|
|
12
|
+
* ("C--Users..."), confirmed against documented real Windows examples.
|
|
13
|
+
*/
|
|
4
14
|
export function claudeCodeProjectSlug(projectRoot) {
|
|
5
|
-
return projectRoot.replace(/[^a-zA-Z0-9]
|
|
15
|
+
return projectRoot.replace(/[^a-zA-Z0-9]/g, "-");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Claude Code keys its ~/.claude/projects/<slug> folder on the full
|
|
19
|
+
* absolute path on macOS (verified directly against a real local install —
|
|
20
|
+
* see claudeCodeProjectSlug's test). But a real Windows install was
|
|
21
|
+
* observed naming the folder from the project directory's own basename
|
|
22
|
+
* only — no drive letter, no parent segments at all (e.g. "enrollverse-
|
|
23
|
+
* landing" for C:\Users\...\enrollverse_landing). This is an undocumented
|
|
24
|
+
* format that evidently differs by platform or version, so
|
|
25
|
+
* findClaudeCodeSessionDir tries both rather than assuming one.
|
|
26
|
+
*/
|
|
27
|
+
export function claudeCodeBasenameSlug(projectRoot, basenameImpl = nodeBasename) {
|
|
28
|
+
return claudeCodeProjectSlug(basenameImpl(projectRoot));
|
|
6
29
|
}
|
|
7
30
|
export function findClaudeCodeSessionDir(projectRoot, claudeProjectsDir = join(homedir(), ".claude", "projects")) {
|
|
8
|
-
const
|
|
9
|
-
|
|
31
|
+
const fullPathDir = join(claudeProjectsDir, claudeCodeProjectSlug(projectRoot));
|
|
32
|
+
if (existsSync(fullPathDir))
|
|
33
|
+
return fullPathDir;
|
|
34
|
+
const basenameDir = join(claudeProjectsDir, claudeCodeBasenameSlug(projectRoot));
|
|
35
|
+
if (existsSync(basenameDir))
|
|
36
|
+
return basenameDir;
|
|
37
|
+
return null;
|
|
10
38
|
}
|
|
11
39
|
export function findLatestSessionFile(sessionDir) {
|
|
12
40
|
let latestFile = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whydid",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
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.",
|