@wasabeef/agentnote 0.1.0 → 0.1.2
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/cli.js +25 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -33,6 +33,7 @@ async function repoRoot() {
|
|
|
33
33
|
|
|
34
34
|
// src/paths.ts
|
|
35
35
|
var _root = null;
|
|
36
|
+
var _gitDir = null;
|
|
36
37
|
async function root() {
|
|
37
38
|
if (!_root) {
|
|
38
39
|
try {
|
|
@@ -44,8 +45,17 @@ async function root() {
|
|
|
44
45
|
}
|
|
45
46
|
return _root;
|
|
46
47
|
}
|
|
48
|
+
async function gitDir() {
|
|
49
|
+
if (!_gitDir) {
|
|
50
|
+
_gitDir = await git(["rev-parse", "--git-dir"]);
|
|
51
|
+
if (!_gitDir.startsWith("/")) {
|
|
52
|
+
_gitDir = join(await root(), _gitDir);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return _gitDir;
|
|
56
|
+
}
|
|
47
57
|
async function agentnoteDir() {
|
|
48
|
-
return join(await
|
|
58
|
+
return join(await gitDir(), "agentnote");
|
|
49
59
|
}
|
|
50
60
|
async function sessionFile() {
|
|
51
61
|
return join(await agentnoteDir(), "session");
|
|
@@ -53,7 +63,7 @@ async function sessionFile() {
|
|
|
53
63
|
|
|
54
64
|
// src/agents/claude-code.ts
|
|
55
65
|
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
56
|
-
import { existsSync,
|
|
66
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
57
67
|
import { join as join2 } from "node:path";
|
|
58
68
|
import { homedir } from "node:os";
|
|
59
69
|
var HOOK_COMMAND = "$(npm bin 2>/dev/null)/agentnote hook 2>/dev/null || agentnote hook 2>/dev/null || npx --yes @wasabeef/agentnote hook";
|
|
@@ -186,11 +196,19 @@ var claudeCode = {
|
|
|
186
196
|
findTranscript(sessionId) {
|
|
187
197
|
if (!isValidSessionId(sessionId)) return null;
|
|
188
198
|
const claudeDir = join2(homedir(), ".claude", "projects");
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
199
|
+
if (!existsSync(claudeDir)) return null;
|
|
200
|
+
try {
|
|
201
|
+
for (const project of readdirSync(claudeDir)) {
|
|
202
|
+
const sessionsDir = join2(claudeDir, project, "sessions");
|
|
203
|
+
if (!existsSync(sessionsDir)) continue;
|
|
204
|
+
const candidate = join2(sessionsDir, `${sessionId}.jsonl`);
|
|
205
|
+
if (existsSync(candidate) && isValidTranscriptPath(candidate)) {
|
|
206
|
+
return candidate;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
} catch {
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
194
212
|
},
|
|
195
213
|
async extractInteractions(transcriptPath) {
|
|
196
214
|
if (!isValidTranscriptPath(transcriptPath) || !existsSync(transcriptPath)) return [];
|