@alexgsdev/claude-code-transcript-export 0.1.3 → 0.1.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/discover.d.ts +25 -5
- package/dist/discover.d.ts.map +1 -1
- package/dist/discover.js +31 -8
- package/dist/discover.js.map +1 -1
- package/package.json +1 -1
package/dist/discover.d.ts
CHANGED
|
@@ -35,12 +35,32 @@ export declare function readIdentity(path: string, records: RawRecord[]): LogIde
|
|
|
35
35
|
/**
|
|
36
36
|
* True when a log belongs to the project rooted at `root`.
|
|
37
37
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
38
|
+
* Two signals, either of which is sufficient.
|
|
39
|
+
*
|
|
40
|
+
* **The containing directory.** Claude Code groups a project's logs in
|
|
41
|
+
* `<logRoot>/<encoded path>`, and it *moves them* when the project is renamed.
|
|
42
|
+
* That makes the directory the more current claim about which project a log
|
|
43
|
+
* belongs to. Note this compares an encoding of the known root against the
|
|
44
|
+
* directory name — it never decodes a name, which is not recoverable.
|
|
45
|
+
*
|
|
46
|
+
* **A recorded `cwd`.** Needed because a session launched from a subdirectory
|
|
47
|
+
* lands in a differently-named directory, and because `relocated` records point
|
|
48
|
+
* at worktrees beneath the project.
|
|
49
|
+
*
|
|
50
|
+
* Neither alone is enough, and the reason is a rename. When a project is
|
|
51
|
+
* renamed the directory follows, but the `cwd` inside already-written records
|
|
52
|
+
* does not: the older logs still name the old path forever. Matching on `cwd`
|
|
53
|
+
* alone silently drops every session from before the rename — 23 of 29 in the
|
|
54
|
+
* corpus this was found in — and the damage is not that they vanish (they do
|
|
55
|
+
* not; nothing is ever synced away) but that they fall out of the generated
|
|
56
|
+
* index while remaining on disk, which is precisely the shape of evidence
|
|
57
|
+
* nobody can audit.
|
|
58
|
+
*
|
|
59
|
+
* The one cost: the encoding is not injective, so `/Users/a/b-c` and
|
|
60
|
+
* `/Users/a/b/c` share a directory name. Two projects related that way would
|
|
61
|
+
* see each other's logs. That is rare, and it is the lesser failure.
|
|
42
62
|
*/
|
|
43
|
-
export declare function belongsToProject(identity: LogIdentity, root: string): boolean;
|
|
63
|
+
export declare function belongsToProject(identity: LogIdentity, root: string, projectDirName?: string): boolean;
|
|
44
64
|
export interface DiscoveredLog extends LogIdentity {
|
|
45
65
|
records: RawRecord[];
|
|
46
66
|
}
|
package/dist/discover.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,+DAA+D;IAC/D,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,CAY1D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CAErD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAwBtD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,WAAW,CAgB5E;AAED
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,+DAA+D;IAC/D,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,CAY1D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CAErD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAwBtD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,WAAW,CAgB5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAMT;AAED,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAWvE"}
|
package/dist/discover.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
2
|
+
import { basename, dirname, join } from 'node:path';
|
|
3
3
|
import { UsageError } from './config.js';
|
|
4
|
-
import { isWithin } from './paths.js';
|
|
4
|
+
import { encodeProjectDir, isWithin } from './paths.js';
|
|
5
5
|
/** How many records to read before giving up on finding identity fields. */
|
|
6
6
|
const IDENTITY_SCAN_LIMIT = 50;
|
|
7
7
|
/** Parses a JSONL file, skipping unparseable lines. */
|
|
@@ -85,14 +85,37 @@ export function readIdentity(path, records) {
|
|
|
85
85
|
/**
|
|
86
86
|
* True when a log belongs to the project rooted at `root`.
|
|
87
87
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
88
|
+
* Two signals, either of which is sufficient.
|
|
89
|
+
*
|
|
90
|
+
* **The containing directory.** Claude Code groups a project's logs in
|
|
91
|
+
* `<logRoot>/<encoded path>`, and it *moves them* when the project is renamed.
|
|
92
|
+
* That makes the directory the more current claim about which project a log
|
|
93
|
+
* belongs to. Note this compares an encoding of the known root against the
|
|
94
|
+
* directory name — it never decodes a name, which is not recoverable.
|
|
95
|
+
*
|
|
96
|
+
* **A recorded `cwd`.** Needed because a session launched from a subdirectory
|
|
97
|
+
* lands in a differently-named directory, and because `relocated` records point
|
|
98
|
+
* at worktrees beneath the project.
|
|
99
|
+
*
|
|
100
|
+
* Neither alone is enough, and the reason is a rename. When a project is
|
|
101
|
+
* renamed the directory follows, but the `cwd` inside already-written records
|
|
102
|
+
* does not: the older logs still name the old path forever. Matching on `cwd`
|
|
103
|
+
* alone silently drops every session from before the rename — 23 of 29 in the
|
|
104
|
+
* corpus this was found in — and the damage is not that they vanish (they do
|
|
105
|
+
* not; nothing is ever synced away) but that they fall out of the generated
|
|
106
|
+
* index while remaining on disk, which is precisely the shape of evidence
|
|
107
|
+
* nobody can audit.
|
|
108
|
+
*
|
|
109
|
+
* The one cost: the encoding is not injective, so `/Users/a/b-c` and
|
|
110
|
+
* `/Users/a/b/c` share a directory name. Two projects related that way would
|
|
111
|
+
* see each other's logs. That is rare, and it is the lesser failure.
|
|
92
112
|
*/
|
|
93
|
-
export function belongsToProject(identity, root) {
|
|
113
|
+
export function belongsToProject(identity, root, projectDirName) {
|
|
94
114
|
if (identity.sidechain)
|
|
95
115
|
return false;
|
|
116
|
+
if (projectDirName !== undefined && projectDirName === encodeProjectDir(root)) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
96
119
|
return identity.cwds.some((dir) => isWithin(root, dir));
|
|
97
120
|
}
|
|
98
121
|
/**
|
|
@@ -107,7 +130,7 @@ export function discover(logRoot, root) {
|
|
|
107
130
|
for (const path of listLogFiles(logRoot)) {
|
|
108
131
|
const records = readLogFile(path);
|
|
109
132
|
const identity = readIdentity(path, records);
|
|
110
|
-
if (!belongsToProject(identity, root))
|
|
133
|
+
if (!belongsToProject(identity, root, basename(dirname(path))))
|
|
111
134
|
continue;
|
|
112
135
|
found.push({ ...identity, records });
|
|
113
136
|
}
|
package/dist/discover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGxD,4EAA4E;AAC5E,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAW/B,uDAAuD;AACvD,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,OAAO,GAAgB,EAAE,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,SAAS;QAC3B,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAc,CAAC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