@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.
Files changed (2) hide show
  1. package/dist/cli.js +25 -7
  2. 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 root(), ".git", "agentnote");
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, globSync } from "node:fs";
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
- const pattern = join2(claudeDir, "**", "sessions", `${sessionId}.jsonl`);
190
- const matches = globSync(pattern);
191
- if (matches.length === 0) return null;
192
- const match = matches[0];
193
- return isValidTranscriptPath(match) ? match : null;
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 [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasabeef/agentnote",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Remember why your code changed. Link AI agent sessions to git commits.",
5
5
  "type": "module",
6
6
  "bin": {