@heyhuynhgiabuu/pi-pretty 0.6.3 → 0.6.5

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 (88) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/autocomplete.d.ts +10 -0
  3. package/dist/autocomplete.d.ts.map +1 -0
  4. package/dist/autocomplete.js +64 -0
  5. package/dist/autocomplete.js.map +1 -0
  6. package/dist/config.d.ts +33 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +225 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/fff-helpers.d.ts +25 -0
  11. package/dist/fff-helpers.d.ts.map +1 -0
  12. package/dist/fff-helpers.js +83 -0
  13. package/dist/fff-helpers.js.map +1 -0
  14. package/dist/fff.d.ts +37 -0
  15. package/dist/fff.d.ts.map +1 -0
  16. package/dist/fff.js +135 -0
  17. package/dist/fff.js.map +1 -0
  18. package/dist/helpers.d.ts +21 -0
  19. package/dist/helpers.d.ts.map +1 -0
  20. package/dist/helpers.js +133 -0
  21. package/dist/helpers.js.map +1 -0
  22. package/dist/image.d.ts +24 -0
  23. package/dist/image.d.ts.map +1 -0
  24. package/dist/image.js +144 -0
  25. package/dist/image.js.map +1 -0
  26. package/dist/index.d.ts +16 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +223 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/multi-grep-fallback.d.ts +30 -0
  31. package/dist/multi-grep-fallback.d.ts.map +1 -0
  32. package/dist/multi-grep-fallback.js +205 -0
  33. package/dist/multi-grep-fallback.js.map +1 -0
  34. package/dist/render.d.ts +25 -0
  35. package/dist/render.d.ts.map +1 -0
  36. package/dist/render.js +366 -0
  37. package/dist/render.js.map +1 -0
  38. package/dist/tools/bash.d.ts +6 -0
  39. package/dist/tools/bash.d.ts.map +1 -0
  40. package/dist/tools/bash.js +101 -0
  41. package/dist/tools/bash.js.map +1 -0
  42. package/dist/tools/find.d.ts +6 -0
  43. package/dist/tools/find.d.ts.map +1 -0
  44. package/dist/tools/find.js +108 -0
  45. package/dist/tools/find.js.map +1 -0
  46. package/dist/tools/grep.d.ts +6 -0
  47. package/dist/tools/grep.d.ts.map +1 -0
  48. package/dist/tools/grep.js +121 -0
  49. package/dist/tools/grep.js.map +1 -0
  50. package/dist/tools/ls.d.ts +6 -0
  51. package/dist/tools/ls.d.ts.map +1 -0
  52. package/dist/tools/ls.js +63 -0
  53. package/dist/tools/ls.js.map +1 -0
  54. package/dist/tools/metrics.d.ts +10 -0
  55. package/dist/tools/metrics.d.ts.map +1 -0
  56. package/dist/tools/metrics.js +34 -0
  57. package/dist/tools/metrics.js.map +1 -0
  58. package/dist/tools/multi-grep.d.ts +7 -0
  59. package/dist/tools/multi-grep.d.ts.map +1 -0
  60. package/dist/tools/multi-grep.js +197 -0
  61. package/dist/tools/multi-grep.js.map +1 -0
  62. package/dist/tools/read.d.ts +6 -0
  63. package/dist/tools/read.d.ts.map +1 -0
  64. package/dist/tools/read.js +125 -0
  65. package/dist/tools/read.js.map +1 -0
  66. package/dist/types.d.ts +168 -0
  67. package/dist/types.d.ts.map +1 -0
  68. package/dist/types.js +6 -0
  69. package/dist/types.js.map +1 -0
  70. package/package.json +7 -1
  71. package/src/index.ts +1 -14
  72. package/biome.json +0 -22
  73. package/bun.lock +0 -598
  74. package/media/bash-and-read.png +0 -0
  75. package/media/icons-and-grep.png +0 -0
  76. package/media/inline-image.png +0 -0
  77. package/pi-pretty.example.json +0 -6
  78. package/release-notes/v0.3.2.md +0 -34
  79. package/release-notes/v0.3.3.md +0 -48
  80. package/release-notes/v0.4.0.md +0 -58
  81. package/release-notes/v0.4.1.md +0 -28
  82. package/release-notes/v0.4.2.md +0 -36
  83. package/release-notes/v0.4.4.md +0 -28
  84. package/release-notes/v0.5.3.md +0 -29
  85. package/test/bash-rendering.test.ts +0 -269
  86. package/test/fff-integration.test.ts +0 -800
  87. package/test/image-rendering.test.ts +0 -153
  88. package/tsconfig.json +0 -19
@@ -1,153 +0,0 @@
1
- import { mkdirSync, rmSync } from "node:fs";
2
-
3
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
4
-
5
- import piPrettyExtension, { __imageInternals } from "../src/index.js";
6
-
7
- const ENV_KEYS = [
8
- "TMUX",
9
- "TERM",
10
- "TERM_PROGRAM",
11
- "LC_TERMINAL",
12
- "GHOSTTY_RESOURCES_DIR",
13
- "KITTY_WINDOW_ID",
14
- "KITTY_PID",
15
- "WEZTERM_EXECUTABLE",
16
- "WEZTERM_CONFIG_DIR",
17
- "WEZTERM_CONFIG_FILE",
18
- "COLORTERM",
19
- "PRETTY_IMAGE_PROTOCOL",
20
- ] as const;
21
-
22
- class MockText {
23
- private text = "";
24
- constructor(_text = "", _x = 0, _y = 0) {}
25
- setText(value: string) {
26
- this.text = value;
27
- }
28
- getText() {
29
- return this.text;
30
- }
31
- }
32
-
33
- function mockToolFactory(exec: any) {
34
- return (_cwd: string) => ({
35
- name: "mock",
36
- description: "mock",
37
- parameters: { type: "object", properties: {} },
38
- execute: exec,
39
- });
40
- }
41
-
42
- function loadReadTool(readExec: any) {
43
- const noopExec = async () => ({ content: [{ type: "text", text: "" }] });
44
- const tools = new Map<string, any>();
45
- const pi = {
46
- registerTool: (tool: any) => tools.set(tool.name, tool),
47
- registerCommand: () => {},
48
- on: () => {},
49
- };
50
-
51
- piPrettyExtension(pi, {
52
- sdk: {
53
- createReadToolDefinition: mockToolFactory(readExec),
54
- createBashToolDefinition: mockToolFactory(noopExec),
55
- createLsToolDefinition: mockToolFactory(noopExec),
56
- createFindToolDefinition: mockToolFactory(noopExec),
57
- createGrepToolDefinition: mockToolFactory(noopExec),
58
- getAgentDir: () => "/tmp/pi-pretty-test",
59
- },
60
- TextComponent: MockText,
61
- });
62
-
63
- return tools.get("read");
64
- }
65
-
66
- describe("image rendering terminal detection", () => {
67
- const envSnapshot = new Map<string, string | undefined>();
68
- const agentDir = "/tmp/pi-pretty-test";
69
-
70
- beforeEach(() => {
71
- rmSync(agentDir, { recursive: true, force: true });
72
- mkdirSync(agentDir, { recursive: true });
73
- for (const key of ENV_KEYS) {
74
- envSnapshot.set(key, process.env[key]);
75
- delete process.env[key];
76
- }
77
- __imageInternals.resetCachesForTests();
78
- });
79
-
80
- afterEach(() => {
81
- rmSync(agentDir, { recursive: true, force: true });
82
- for (const key of ENV_KEYS) {
83
- const value = envSnapshot.get(key);
84
- if (value === undefined) delete process.env[key];
85
- else process.env[key] = value;
86
- }
87
- __imageInternals.resetCachesForTests();
88
- });
89
-
90
- it("detects kitty protocol inside tmux via KITTY_WINDOW_ID", () => {
91
- process.env.TMUX = "/tmp/tmux-1000/default,123,0";
92
- process.env.TERM_PROGRAM = "tmux";
93
- process.env.KITTY_WINDOW_ID = "1";
94
-
95
- expect(__imageInternals.getOuterTerminal()).toBe("kitty");
96
- expect(__imageInternals.detectImageProtocol()).toBe("kitty");
97
- });
98
-
99
- it("detects wezterm protocol inside tmux via WEZTERM_EXECUTABLE", () => {
100
- process.env.TMUX = "/tmp/tmux-1000/default,123,0";
101
- process.env.TERM_PROGRAM = "tmux";
102
- process.env.WEZTERM_EXECUTABLE = "/Applications/WezTerm.app/Contents/MacOS/wezterm";
103
-
104
- expect(__imageInternals.getOuterTerminal()).toBe("WezTerm");
105
- expect(__imageInternals.detectImageProtocol()).toBe("iterm2");
106
- });
107
-
108
- it("falls back to tmux client term for outer terminal detection", () => {
109
- process.env.TMUX = "/tmp/tmux-1000/default,123,0";
110
- process.env.TERM_PROGRAM = "tmux";
111
- __imageInternals.setTmuxClientTermOverrideForTests("xterm-kitty");
112
-
113
- expect(__imageInternals.getOuterTerminal()).toBe("kitty");
114
- expect(__imageInternals.detectImageProtocol()).toBe("kitty");
115
- });
116
-
117
- it("reports warning when tmux allow-passthrough is off", () => {
118
- process.env.TMUX = "/tmp/tmux-1000/default,123,0";
119
- __imageInternals.setTmuxAllowPassthroughOverrideForTests(false);
120
-
121
- expect(__imageInternals.getTmuxPassthroughWarning("kitty")).toContain("allow-passthrough is off");
122
- });
123
-
124
- it("does not warn when tmux allow-passthrough is enabled", () => {
125
- process.env.TMUX = "/tmp/tmux-1000/default,123,0";
126
- __imageInternals.setTmuxAllowPassthroughOverrideForTests(true);
127
-
128
- expect(__imageInternals.getTmuxPassthroughWarning("kitty")).toBeNull();
129
- });
130
-
131
- it("renders image metadata without a second inline preview", async () => {
132
- process.env.TERM_PROGRAM = "kitty";
133
-
134
- const readTool = loadReadTool(async () => ({
135
- content: [{ type: "image", data: Buffer.from("fake").toString("base64"), mimeType: "image/png" }],
136
- }));
137
-
138
- const result = await readTool.execute("t1", { path: "media/inline-image.png" }, null, null, {});
139
- const rendered = readTool.renderResult(result, {}, {}, {
140
- lastComponent: new MockText(),
141
- isError: false,
142
- state: {},
143
- expanded: false,
144
- invalidate: () => {},
145
- });
146
-
147
- expect(rendered.getText()).toContain("image/png");
148
- expect(rendered.getText()).not.toContain("\x1b_G");
149
- expect(result.content).toEqual([
150
- { type: "image", data: Buffer.from("fake").toString("base64"), mimeType: "image/png" },
151
- ]);
152
- });
153
- });
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "nodenext",
5
- "moduleResolution": "nodenext",
6
- "lib": ["ES2022"],
7
- "outDir": "./dist",
8
- "rootDir": "./src",
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "declaration": true,
14
- "declarationMap": true,
15
- "sourceMap": true
16
- },
17
- "include": ["src/**/*.ts"],
18
- "exclude": ["node_modules", "dist", "test"]
19
- }