pi-goosedump 0.10.6 → 0.10.8
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 +44 -6
- package/package.json +2 -2
package/index.ts
CHANGED
|
@@ -271,6 +271,33 @@ function resolveGoosedumpBinary(): string {
|
|
|
271
271
|
return require.resolve('@jarkkojs/goosedump/bin/goosedump.js');
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
function resolveNativeGoosedumpBinary(): string {
|
|
275
|
+
const target = `${process.platform}-${process.arch}`;
|
|
276
|
+
let packageName: string;
|
|
277
|
+
let binaryName = 'goosedump';
|
|
278
|
+
|
|
279
|
+
switch (target) {
|
|
280
|
+
case 'linux-x64':
|
|
281
|
+
packageName = '@jarkkojs/goosedump-linux-x64';
|
|
282
|
+
break;
|
|
283
|
+
case 'darwin-arm64':
|
|
284
|
+
packageName = '@jarkkojs/goosedump-darwin-arm64';
|
|
285
|
+
break;
|
|
286
|
+
case 'win32-x64':
|
|
287
|
+
packageName = '@jarkkojs/goosedump-win32-x64';
|
|
288
|
+
binaryName = 'goosedump.exe';
|
|
289
|
+
break;
|
|
290
|
+
default:
|
|
291
|
+
throw new Error(`unsupported platform architecture: ${target}`);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const wrapperRequire = createRequire(resolveGoosedumpBinary());
|
|
295
|
+
const packageDir = dirname(wrapperRequire.resolve(`${packageName}/package.json`));
|
|
296
|
+
const binaryPath = join(packageDir, 'bin', binaryName);
|
|
297
|
+
if (!existsSync(binaryPath)) throw new Error(`binary not found: ${binaryPath}`);
|
|
298
|
+
return binaryPath;
|
|
299
|
+
}
|
|
300
|
+
|
|
274
301
|
function clip(value: string, max: number): string {
|
|
275
302
|
return value.length > max ? `${value.slice(0, max)}...` : value;
|
|
276
303
|
}
|
|
@@ -434,11 +461,15 @@ function runGoosedump(args: string[]): string {
|
|
|
434
461
|
// Non-blocking variant for the compact path: goosedump compact runs an ML
|
|
435
462
|
// model and can take many seconds, so execFileSync would freeze Pi's event
|
|
436
463
|
// loop (and its compaction spinner). execFile keeps the loop free to render.
|
|
437
|
-
function runGoosedumpAsync(
|
|
464
|
+
function runGoosedumpAsync(
|
|
465
|
+
args: string[],
|
|
466
|
+
signal?: AbortSignal,
|
|
467
|
+
executablePath = resolveNativeGoosedumpBinary(),
|
|
468
|
+
): Promise<GoosedumpCommandOutput> {
|
|
438
469
|
return new Promise((resolve, reject) => {
|
|
439
470
|
execFile(
|
|
440
|
-
|
|
441
|
-
|
|
471
|
+
executablePath,
|
|
472
|
+
args,
|
|
442
473
|
{
|
|
443
474
|
encoding: 'utf-8',
|
|
444
475
|
maxBuffer: 16 * 1024 * 1024,
|
|
@@ -515,11 +546,12 @@ async function goosedumpRecall(
|
|
|
515
546
|
query: string,
|
|
516
547
|
options: { provider?: string; path?: string; limit?: number } = {},
|
|
517
548
|
signal?: AbortSignal,
|
|
549
|
+
executablePath?: string,
|
|
518
550
|
): Promise<{ hits: GoosedumpMemoryHit[]; warning: string }> {
|
|
519
551
|
const args = ['recall', query, '--limit', String(options.limit ?? 5)];
|
|
520
552
|
if (options.provider) args.push('--provider', options.provider);
|
|
521
553
|
if (options.path) args.push('--path', options.path);
|
|
522
|
-
const output = await runGoosedumpAsync(args, signal);
|
|
554
|
+
const output = await runGoosedumpAsync(args, signal, executablePath);
|
|
523
555
|
return { hits: parseMemoryHits(output.stdout), warning: output.stderr.trim() };
|
|
524
556
|
}
|
|
525
557
|
|
|
@@ -577,13 +609,14 @@ async function goosedumpCompact(
|
|
|
577
609
|
target: string,
|
|
578
610
|
options: { scope?: string; from?: string; until: string },
|
|
579
611
|
signal?: AbortSignal,
|
|
612
|
+
executablePath?: string,
|
|
580
613
|
): Promise<{ summary: string; warning: string }> {
|
|
581
614
|
const scope = options.scope ?? 'lineage';
|
|
582
615
|
const args = ['compact', target, '--scope', scope];
|
|
583
616
|
if (options.from) args.push('--from', options.from);
|
|
584
617
|
args.push('--until', options.until);
|
|
585
618
|
|
|
586
|
-
const output = await runGoosedumpAsync(args, signal);
|
|
619
|
+
const output = await runGoosedumpAsync(args, signal, executablePath);
|
|
587
620
|
for (const line of output.stdout.split('\n')) {
|
|
588
621
|
if (!line) continue;
|
|
589
622
|
try {
|
|
@@ -601,6 +634,7 @@ async function goosedumpCompact(
|
|
|
601
634
|
export interface GoosedumpIntegrationOptions {
|
|
602
635
|
registerTool?: boolean;
|
|
603
636
|
overrideDefaultCompaction?: boolean;
|
|
637
|
+
nativeExecutablePath?: string;
|
|
604
638
|
}
|
|
605
639
|
|
|
606
640
|
interface GoosedumpCompactRange {
|
|
@@ -903,6 +937,7 @@ async function buildGoosedumpCompaction(
|
|
|
903
937
|
reserveTokens: number,
|
|
904
938
|
keep?: number,
|
|
905
939
|
signal?: AbortSignal,
|
|
940
|
+
executablePath?: string,
|
|
906
941
|
): Promise<
|
|
907
942
|
CompactionResult<GoosedumpCompactionDetails> | { cancel: true; reason: string } | undefined
|
|
908
943
|
> {
|
|
@@ -920,7 +955,7 @@ async function buildGoosedumpCompaction(
|
|
|
920
955
|
const range = buildCompactRange(branchEntries, firstKeptEntryId);
|
|
921
956
|
if (!range) return undefined;
|
|
922
957
|
|
|
923
|
-
const generated = await goosedumpCompact(target, range, signal);
|
|
958
|
+
const generated = await goosedumpCompact(target, range, signal, executablePath);
|
|
924
959
|
if (!generated.summary) return undefined;
|
|
925
960
|
const summary = mergeCompactionSummary(
|
|
926
961
|
preparation.previousSummary,
|
|
@@ -1399,6 +1434,7 @@ export function createGoosedumpIntegration(
|
|
|
1399
1434
|
): GoosedumpIntegration {
|
|
1400
1435
|
const shouldRegisterTool = options.registerTool ?? true;
|
|
1401
1436
|
const shouldOverrideDefaultCompaction = options.overrideDefaultCompaction ?? true;
|
|
1437
|
+
const nativeExecutablePath = options.nativeExecutablePath;
|
|
1402
1438
|
|
|
1403
1439
|
let goosedumpAvailable = false;
|
|
1404
1440
|
let compactSettings = DEFAULT_GOOSEDUMP_SETTINGS;
|
|
@@ -1526,6 +1562,7 @@ export function createGoosedumpIntegration(
|
|
|
1526
1562
|
limit: params.limit,
|
|
1527
1563
|
},
|
|
1528
1564
|
signal,
|
|
1565
|
+
nativeExecutablePath,
|
|
1529
1566
|
);
|
|
1530
1567
|
if (warning && ctx.hasUI) ctx.ui.notify(warning, 'warning');
|
|
1531
1568
|
if (hits.length === 0) return textResult(`No durable memory for "${params.query}"`);
|
|
@@ -1815,6 +1852,7 @@ export function createGoosedumpIntegration(
|
|
|
1815
1852
|
piReserveTokens(ctx.cwd),
|
|
1816
1853
|
keep,
|
|
1817
1854
|
event.signal,
|
|
1855
|
+
nativeExecutablePath,
|
|
1818
1856
|
);
|
|
1819
1857
|
if (compaction && 'cancel' in compaction) {
|
|
1820
1858
|
if (ctx.hasUI) ctx.ui.notify(compaction.reason, 'info');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-goosedump",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.8",
|
|
4
4
|
"description": "Pi extension for goosedump-backed session-history search, entry expansion, and compaction",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compaction",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@earendil-works/pi-tui": "^0.78.0",
|
|
36
|
-
"@jarkkojs/goosedump": "^0.10.
|
|
36
|
+
"@jarkkojs/goosedump": "^0.10.8",
|
|
37
37
|
"@sinclair/typebox": "^0.34.49"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|