pi-goosedump 0.5.1 → 0.5.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.
- package/index.ts +43 -11
- package/package.json +2 -2
package/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
import { defineTool } from '@earendil-works/pi-coding-agent';
|
|
14
14
|
|
|
15
15
|
import { execFileSync } from 'node:child_process';
|
|
16
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
16
|
+
import { type Dirent, existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
17
17
|
import { createRequire } from 'node:module';
|
|
18
18
|
import { homedir } from 'node:os';
|
|
19
19
|
import { basename, join } from 'node:path';
|
|
@@ -23,7 +23,7 @@ import { Type } from '@sinclair/typebox';
|
|
|
23
23
|
|
|
24
24
|
const require = createRequire(import.meta.url);
|
|
25
25
|
|
|
26
|
-
const GOOSEDUMP_VERSION = [0, 5,
|
|
26
|
+
const GOOSEDUMP_VERSION = [0, 5, 1] as const;
|
|
27
27
|
|
|
28
28
|
interface GoosedumpListing {
|
|
29
29
|
id: string;
|
|
@@ -43,10 +43,6 @@ interface GoosedumpSearchResult {
|
|
|
43
43
|
totalPages: number;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
interface ListJson {
|
|
47
|
-
sessions: { id: string; path?: string | null }[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
46
|
interface ToolCallJson {
|
|
51
47
|
name: string;
|
|
52
48
|
arguments: unknown;
|
|
@@ -243,11 +239,47 @@ function runGoosedump(args: string[]): string {
|
|
|
243
239
|
}
|
|
244
240
|
|
|
245
241
|
function goosedumpList(): GoosedumpListing[] {
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
242
|
+
const ids = runGoosedump(['list', 'pi:*'])
|
|
243
|
+
.split('\n')
|
|
244
|
+
.map((line) => line.trim())
|
|
245
|
+
.filter((line) => line.startsWith('pi:'))
|
|
246
|
+
.map((line) => line.slice('pi:'.length));
|
|
247
|
+
|
|
248
|
+
const paths = indexPiSessionPaths();
|
|
249
|
+
return ids.map((id) => ({ id, path: paths.get(id) ?? null }));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function piSessionsDir(): string {
|
|
253
|
+
const explicit = process.env.PI_CODING_AGENT_SESSION_DIR;
|
|
254
|
+
if (explicit) return explicit;
|
|
255
|
+
const agentDir = process.env.PI_CODING_AGENT_DIR ?? join(homedir(), '.pi', 'agent');
|
|
256
|
+
return join(agentDir, 'sessions');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// goosedump's `list` no longer reports session file paths, so map each pi
|
|
260
|
+
// session id back to its file by scanning the sessions tree, matching the same
|
|
261
|
+
// id goosedump derives from the session header.
|
|
262
|
+
function indexPiSessionPaths(): Map<string, string> {
|
|
263
|
+
const paths = new Map<string, string>();
|
|
264
|
+
const walk = (dir: string): void => {
|
|
265
|
+
let entries: Dirent[];
|
|
266
|
+
try {
|
|
267
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
268
|
+
} catch {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
for (const entry of entries) {
|
|
272
|
+
const full = join(dir, entry.name);
|
|
273
|
+
if (entry.isDirectory()) {
|
|
274
|
+
walk(full);
|
|
275
|
+
} else if (entry.isFile() && entry.name.endsWith('.jsonl')) {
|
|
276
|
+
const id = sessionFileContextId(full);
|
|
277
|
+
if (id && !paths.has(id)) paths.set(id, full);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
walk(piSessionsDir());
|
|
282
|
+
return paths;
|
|
251
283
|
}
|
|
252
284
|
|
|
253
285
|
function goosedumpSearch(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-goosedump",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Coding agent context data browser plugin for pi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"goosedump",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@earendil-works/pi-tui": "^0.78.0",
|
|
32
|
-
"@jarkkojs/goosedump": "^0.5.
|
|
32
|
+
"@jarkkojs/goosedump": "^0.5.1",
|
|
33
33
|
"@sinclair/typebox": "^0.34.49"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|