pi-goosedump 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/index.ts +47 -51
- package/package.json +2 -2
package/index.ts
CHANGED
|
@@ -17,20 +17,17 @@ import { join } from 'node:path';
|
|
|
17
17
|
import { Key, matchesKey, truncateToWidth, visibleWidth } from '@earendil-works/pi-tui';
|
|
18
18
|
import { Type } from '@sinclair/typebox';
|
|
19
19
|
|
|
20
|
-
const GOOSEDUMP_VERSION = [0, 1,
|
|
20
|
+
const GOOSEDUMP_VERSION = [0, 1, 4] as const;
|
|
21
21
|
|
|
22
22
|
interface GoosedumpListing {
|
|
23
23
|
id: string;
|
|
24
|
-
created: string;
|
|
25
|
-
modified: string;
|
|
26
|
-
entryCount: number;
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
interface GoosedumpMessage {
|
|
30
27
|
id: string;
|
|
31
28
|
role: string;
|
|
32
29
|
content: string;
|
|
33
|
-
|
|
30
|
+
score?: number;
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
interface GoosedumpContextResult {
|
|
@@ -91,17 +88,14 @@ function hasMinimumVersion(version: string, minimum: readonly [number, number, n
|
|
|
91
88
|
|
|
92
89
|
function parseListings(output: string): GoosedumpListing[] {
|
|
93
90
|
const listings: GoosedumpListing[] = [];
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
id: match[1]
|
|
101
|
-
|
|
102
|
-
entryCount: parseInt(match[3], 10),
|
|
103
|
-
modified: match[4],
|
|
104
|
-
});
|
|
91
|
+
const lines = output.split('\n');
|
|
92
|
+
|
|
93
|
+
for (const line of lines) {
|
|
94
|
+
if (line === 'Sessions:' || line.trim() === '') continue;
|
|
95
|
+
const match = line.match(/^ (\S+)/);
|
|
96
|
+
if (match) {
|
|
97
|
+
listings.push({ id: match[1] });
|
|
98
|
+
}
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
return listings;
|
|
@@ -109,41 +103,46 @@ function parseListings(output: string): GoosedumpListing[] {
|
|
|
109
103
|
|
|
110
104
|
function parseMessages(output: string): GoosedumpMessage[] {
|
|
111
105
|
const messages: GoosedumpMessage[] = [];
|
|
112
|
-
// Format from goosedump plain output: [id] role: content
|
|
113
106
|
const lines = output.split('\n');
|
|
114
|
-
let
|
|
115
|
-
let currentRole = '';
|
|
107
|
+
let currentMsg: GoosedumpMessage | null = null;
|
|
116
108
|
let contentLines: string[] = [];
|
|
117
|
-
let currentTimestamp = '';
|
|
118
109
|
|
|
119
110
|
for (const line of lines) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
111
|
+
if (line.startsWith('results for ')) continue;
|
|
112
|
+
|
|
113
|
+
const entryMatch = line.match(/^entryId:\s+(\S+)\s+\((.+)\)$/);
|
|
114
|
+
if (entryMatch) {
|
|
115
|
+
if (currentMsg) {
|
|
116
|
+
currentMsg.content = contentLines.join('\n').trim();
|
|
117
|
+
messages.push(currentMsg);
|
|
118
|
+
}
|
|
119
|
+
currentMsg = {
|
|
120
|
+
id: entryMatch[1],
|
|
121
|
+
role: entryMatch[2],
|
|
122
|
+
content: '',
|
|
123
|
+
};
|
|
124
|
+
contentLines = [];
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (currentMsg) {
|
|
129
|
+
const indentedMatch = line.match(/^ (.+)$/);
|
|
130
|
+
if (indentedMatch) {
|
|
131
|
+
const content = indentedMatch[1];
|
|
132
|
+
if (content.startsWith('score: ')) {
|
|
133
|
+
const scoreVal = parseFloat(content.slice(7));
|
|
134
|
+
if (!isNaN(scoreVal)) currentMsg.score = scoreVal;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (/^\.\.\.\(\d+ lines (?:above|below)\)$/.test(content)) continue;
|
|
138
|
+
contentLines.push(content);
|
|
129
139
|
}
|
|
130
|
-
currentId = headerMatch[1];
|
|
131
|
-
currentRole = headerMatch[2];
|
|
132
|
-
currentTimestamp = headerMatch[3]?.replace(/[()]/g, '') ?? '';
|
|
133
|
-
contentLines = [line.slice(headerMatch[0].length).trim()];
|
|
134
|
-
} else if (currentId) {
|
|
135
|
-
if (line.startsWith('---') && messages.length > 0) continue;
|
|
136
|
-
contentLines.push(line);
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
142
|
|
|
140
|
-
if (
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
role: currentRole,
|
|
144
|
-
content: contentLines.join('\n').trim(),
|
|
145
|
-
timestamp: currentTimestamp,
|
|
146
|
-
});
|
|
143
|
+
if (currentMsg) {
|
|
144
|
+
currentMsg.content = contentLines.join('\n').trim();
|
|
145
|
+
messages.push(currentMsg);
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
return messages;
|
|
@@ -215,7 +214,7 @@ function goosedumpContext(
|
|
|
215
214
|
|
|
216
215
|
function goosedumpExpand(
|
|
217
216
|
contextId: string,
|
|
218
|
-
entryIds:
|
|
217
|
+
entryIds: string[],
|
|
219
218
|
scope: string = 'lineage',
|
|
220
219
|
): GoosedumpMessage[] {
|
|
221
220
|
const ids = entryIds.join(',');
|
|
@@ -472,7 +471,7 @@ export function createGoosedumpIntegration(
|
|
|
472
471
|
}),
|
|
473
472
|
),
|
|
474
473
|
ids: Type.Optional(
|
|
475
|
-
Type.Array(Type.
|
|
474
|
+
Type.Array(Type.String(), {
|
|
476
475
|
description: 'Entry IDs to expand (show full content)',
|
|
477
476
|
}),
|
|
478
477
|
),
|
|
@@ -510,9 +509,7 @@ export function createGoosedumpIntegration(
|
|
|
510
509
|
|
|
511
510
|
const lines = ['Available sessions:', ''];
|
|
512
511
|
for (const listing of listings) {
|
|
513
|
-
lines.push(
|
|
514
|
-
` ${listing.id} — ${listing.entryCount} entries (modified ${listing.modified})`,
|
|
515
|
-
);
|
|
512
|
+
lines.push(` ${listing.id}`);
|
|
516
513
|
}
|
|
517
514
|
|
|
518
515
|
return {
|
|
@@ -755,9 +752,8 @@ export function createGoosedumpIntegration(
|
|
|
755
752
|
const listing = listings[i];
|
|
756
753
|
const isSelected = i === selectedIndex;
|
|
757
754
|
const cursor = isSelected ? accent('▶') : ' ';
|
|
758
|
-
const
|
|
759
|
-
const
|
|
760
|
-
const line = ` ${cursor} ${idText} ${entryInfo}`;
|
|
755
|
+
const idText = isSelected ? accent(listing.id) : text(listing.id);
|
|
756
|
+
const line = ` ${cursor} ${idText}`;
|
|
761
757
|
lines.push(makeRow(truncateToWidth(line, innerW), innerW, border));
|
|
762
758
|
}
|
|
763
759
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-goosedump",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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.1.
|
|
32
|
+
"@jarkkojs/goosedump": "^0.1.4",
|
|
33
33
|
"@sinclair/typebox": "^0.34.49"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|