pi-goosedump 0.1.1 → 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.
Files changed (2) hide show
  1. package/index.ts +49 -55
  2. 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, 0] as const;
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
- timestamp: string;
30
+ score?: number;
34
31
  }
35
32
 
36
33
  interface GoosedumpContextResult {
@@ -64,10 +61,8 @@ function binaryPath(): string {
64
61
 
65
62
  function goosedumpVersion(): string | null {
66
63
  try {
67
- const result = execFileSync(process.execPath, [binaryPath(), '--version'], {
68
- encoding: 'utf-8',
69
- });
70
- return result.trim();
64
+ const pkg = require('@jarkkojs/goosedump/package.json') as { version: string };
65
+ return pkg.version;
71
66
  } catch {
72
67
  return null;
73
68
  }
@@ -93,17 +88,14 @@ function hasMinimumVersion(version: string, minimum: readonly [number, number, n
93
88
 
94
89
  function parseListings(output: string): GoosedumpListing[] {
95
90
  const listings: GoosedumpListing[] = [];
96
- // Format: <id> <created> <entryCount> entries <modified>
97
- const regex = /^(\S+)\s+(\S+\s+\S+)\s+(\d+)\s+entries?\s+(.+)$/gm;
98
- let match: RegExpExecArray | null;
99
-
100
- while ((match = regex.exec(output)) !== null) {
101
- listings.push({
102
- id: match[1],
103
- created: match[2],
104
- entryCount: parseInt(match[3], 10),
105
- modified: match[4],
106
- });
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
+ }
107
99
  }
108
100
 
109
101
  return listings;
@@ -111,41 +103,46 @@ function parseListings(output: string): GoosedumpListing[] {
111
103
 
112
104
  function parseMessages(output: string): GoosedumpMessage[] {
113
105
  const messages: GoosedumpMessage[] = [];
114
- // Format from goosedump plain output: [id] role: content
115
106
  const lines = output.split('\n');
116
- let currentId = '';
117
- let currentRole = '';
107
+ let currentMsg: GoosedumpMessage | null = null;
118
108
  let contentLines: string[] = [];
119
- let currentTimestamp = '';
120
109
 
121
110
  for (const line of lines) {
122
- const headerMatch = line.match(/^\[([^\]]+)\]\s+(user|assistant|tool|system)\s*(\([^)]+\))?:/);
123
- if (headerMatch) {
124
- if (currentId) {
125
- messages.push({
126
- id: currentId,
127
- role: currentRole,
128
- content: contentLines.join('\n').trim(),
129
- timestamp: currentTimestamp,
130
- });
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);
131
139
  }
132
- currentId = headerMatch[1];
133
- currentRole = headerMatch[2];
134
- currentTimestamp = headerMatch[3]?.replace(/[()]/g, '') ?? '';
135
- contentLines = [line.slice(headerMatch[0].length).trim()];
136
- } else if (currentId) {
137
- if (line.startsWith('---') && messages.length > 0) continue;
138
- contentLines.push(line);
139
140
  }
140
141
  }
141
142
 
142
- if (currentId) {
143
- messages.push({
144
- id: currentId,
145
- role: currentRole,
146
- content: contentLines.join('\n').trim(),
147
- timestamp: currentTimestamp,
148
- });
143
+ if (currentMsg) {
144
+ currentMsg.content = contentLines.join('\n').trim();
145
+ messages.push(currentMsg);
149
146
  }
150
147
 
151
148
  return messages;
@@ -217,7 +214,7 @@ function goosedumpContext(
217
214
 
218
215
  function goosedumpExpand(
219
216
  contextId: string,
220
- entryIds: number[],
217
+ entryIds: string[],
221
218
  scope: string = 'lineage',
222
219
  ): GoosedumpMessage[] {
223
220
  const ids = entryIds.join(',');
@@ -474,7 +471,7 @@ export function createGoosedumpIntegration(
474
471
  }),
475
472
  ),
476
473
  ids: Type.Optional(
477
- Type.Array(Type.Integer(), {
474
+ Type.Array(Type.String(), {
478
475
  description: 'Entry IDs to expand (show full content)',
479
476
  }),
480
477
  ),
@@ -512,9 +509,7 @@ export function createGoosedumpIntegration(
512
509
 
513
510
  const lines = ['Available sessions:', ''];
514
511
  for (const listing of listings) {
515
- lines.push(
516
- ` ${listing.id} — ${listing.entryCount} entries (modified ${listing.modified})`,
517
- );
512
+ lines.push(` ${listing.id}`);
518
513
  }
519
514
 
520
515
  return {
@@ -757,9 +752,8 @@ export function createGoosedumpIntegration(
757
752
  const listing = listings[i];
758
753
  const isSelected = i === selectedIndex;
759
754
  const cursor = isSelected ? accent('▶') : ' ';
760
- const entryInfo = dim(`${listing.entryCount} entries`);
761
- const idText = isSelected ? accent(`[${listing.id}]`) : text(`[${listing.id}]`);
762
- const line = ` ${cursor} ${idText} ${entryInfo}`;
755
+ const idText = isSelected ? accent(listing.id) : text(listing.id);
756
+ const line = ` ${cursor} ${idText}`;
763
757
  lines.push(makeRow(truncateToWidth(line, innerW), innerW, border));
764
758
  }
765
759
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-goosedump",
3
- "version": "0.1.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.2",
32
+ "@jarkkojs/goosedump": "^0.1.4",
33
33
  "@sinclair/typebox": "^0.34.49"
34
34
  },
35
35
  "devDependencies": {