@heyhuynhgiabuu/pi-pretty 0.3.2 → 0.4.0
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/README.md +82 -2
- package/package.json +2 -4
- package/release-notes/v0.3.3.md +48 -0
- package/release-notes/v0.4.0.md +58 -0
- package/src/fff-helpers.ts +7 -6
- package/src/index.ts +444 -300
- package/test/fff-integration.test.ts +16 -3
- package/test/image-rendering.test.ts +6 -0
|
@@ -175,6 +175,9 @@ describe("piPrettyExtension integration", () => {
|
|
|
175
175
|
|
|
176
176
|
function makeDeps(withFFF: boolean, finderOverrides?: Record<string, any>): PiPrettyDeps {
|
|
177
177
|
const finder = mkFinder(finderOverrides);
|
|
178
|
+
const fffModule = finderOverrides?.FileFinder
|
|
179
|
+
? { FileFinder: finderOverrides.FileFinder }
|
|
180
|
+
: { FileFinder: { create: vi.fn().mockReturnValue({ ok: true, value: finder }) } };
|
|
178
181
|
return {
|
|
179
182
|
sdk: {
|
|
180
183
|
createReadToolDefinition: mockToolFactory(readExec),
|
|
@@ -185,9 +188,7 @@ describe("piPrettyExtension integration", () => {
|
|
|
185
188
|
getAgentDir: () => "/tmp/pi-pretty-test",
|
|
186
189
|
},
|
|
187
190
|
TextComponent: class { private t = ""; setText(v: string) { this.t = v; } getText() { return this.t; } },
|
|
188
|
-
fffModule: withFFF
|
|
189
|
-
? { FileFinder: { create: vi.fn().mockReturnValue({ ok: true, value: finder }) } }
|
|
190
|
-
: undefined,
|
|
191
|
+
fffModule: withFFF ? fffModule : undefined,
|
|
191
192
|
};
|
|
192
193
|
}
|
|
193
194
|
|
|
@@ -445,6 +446,18 @@ describe("piPrettyExtension integration", () => {
|
|
|
445
446
|
// ---- session lifecycle ---------------------------------------------
|
|
446
447
|
|
|
447
448
|
describe("session lifecycle", () => {
|
|
449
|
+
it("stores FFF data under a pi-pretty-specific directory", async () => {
|
|
450
|
+
const create = vi.fn().mockReturnValue({ ok: true, value: mkFinder() });
|
|
451
|
+
load(true, { FileFinder: { create } });
|
|
452
|
+
const start = events.get("session_start")!;
|
|
453
|
+
expect(start, "session_start not registered").toBeDefined();
|
|
454
|
+
await start({}, { cwd: "/tmp/test" });
|
|
455
|
+
expect(create).toHaveBeenCalledWith(expect.objectContaining({
|
|
456
|
+
frecencyDbPath: "/tmp/pi-pretty-test/pi-pretty/fff/frecency.mdb",
|
|
457
|
+
historyDbPath: "/tmp/pi-pretty-test/pi-pretty/fff/history.mdb",
|
|
458
|
+
}));
|
|
459
|
+
});
|
|
460
|
+
|
|
448
461
|
it("shutdown → subsequent find falls back to SDK", async () => {
|
|
449
462
|
await loadWithFFF();
|
|
450
463
|
await events.get("session_shutdown")!();
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { mkdirSync, rmSync } from "node:fs";
|
|
2
|
+
|
|
1
3
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
2
4
|
|
|
3
5
|
import piPrettyExtension, { __imageInternals } from "../src/index.js";
|
|
@@ -63,8 +65,11 @@ function loadReadTool(readExec: any) {
|
|
|
63
65
|
|
|
64
66
|
describe("image rendering terminal detection", () => {
|
|
65
67
|
const envSnapshot = new Map<string, string | undefined>();
|
|
68
|
+
const agentDir = "/tmp/pi-pretty-test";
|
|
66
69
|
|
|
67
70
|
beforeEach(() => {
|
|
71
|
+
rmSync(agentDir, { recursive: true, force: true });
|
|
72
|
+
mkdirSync(agentDir, { recursive: true });
|
|
68
73
|
for (const key of ENV_KEYS) {
|
|
69
74
|
envSnapshot.set(key, process.env[key]);
|
|
70
75
|
delete process.env[key];
|
|
@@ -73,6 +78,7 @@ describe("image rendering terminal detection", () => {
|
|
|
73
78
|
});
|
|
74
79
|
|
|
75
80
|
afterEach(() => {
|
|
81
|
+
rmSync(agentDir, { recursive: true, force: true });
|
|
76
82
|
for (const key of ENV_KEYS) {
|
|
77
83
|
const value = envSnapshot.get(key);
|
|
78
84
|
if (value === undefined) delete process.env[key];
|