@dex-ai/pi-compat 0.1.2

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.
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Tests for the extension status bar feature.
3
+ */
4
+ import { describe, test, expect } from 'bun:test';
5
+ import { createShimApi, createPiContext, type CollectedExtension } from '../src/shim-api';
6
+
7
+ describe('Extension Status Bar', () => {
8
+ function makeCollected(): CollectedExtension {
9
+ return { tools: [], handlers: [], commands: [], flags: [], skillPaths: [] };
10
+ }
11
+
12
+ test('setStatus writes to statusMap', () => {
13
+ const statusMap = new Map<string, string>();
14
+ const ctx = createPiContext({ cwd: '/tmp', statusMap });
15
+
16
+ ctx.ui.setStatus('my-ext-lsp', 'LSP Active (2)');
17
+ expect(statusMap.get('my-ext-lsp')).toBe('LSP Active (2)');
18
+
19
+ ctx.ui.setStatus('my-ext-lsp', 'LSP Active (3)');
20
+ expect(statusMap.get('my-ext-lsp')).toBe('LSP Active (3)');
21
+ });
22
+
23
+ test('setStatus with undefined removes from statusMap', () => {
24
+ const statusMap = new Map<string, string>();
25
+ const ctx = createPiContext({ cwd: '/tmp', statusMap });
26
+
27
+ ctx.ui.setStatus('key', 'value');
28
+ expect(statusMap.has('key')).toBe(true);
29
+
30
+ ctx.ui.setStatus('key', undefined);
31
+ expect(statusMap.has('key')).toBe(false);
32
+ });
33
+
34
+ test('setStatus is no-op without statusMap', () => {
35
+ const ctx = createPiContext({ cwd: '/tmp' });
36
+ // Should not throw
37
+ expect(() => ctx.ui.setStatus('key', 'value')).not.toThrow();
38
+ });
39
+
40
+ test('multiple status keys work independently', () => {
41
+ const statusMap = new Map<string, string>();
42
+ const ctx = createPiContext({ cwd: '/tmp', statusMap });
43
+
44
+ ctx.ui.setStatus('lsp', 'Active (3)');
45
+ ctx.ui.setStatus('format', 'biome');
46
+ ctx.ui.setStatus('lint', '0 errors');
47
+
48
+ expect(statusMap.size).toBe(3);
49
+ expect(statusMap.get('lsp')).toBe('Active (3)');
50
+ expect(statusMap.get('format')).toBe('biome');
51
+ expect(statusMap.get('lint')).toBe('0 errors');
52
+ });
53
+
54
+ test('ANSI strings are preserved as-is', () => {
55
+ const statusMap = new Map<string, string>();
56
+ const ctx = createPiContext({ cwd: '/tmp', statusMap });
57
+
58
+ const ansiGreen = '\x1b[32mLSP Active (3)\x1b[0m';
59
+ ctx.ui.setStatus('pi-lens-lsp', ansiGreen);
60
+
61
+ expect(statusMap.get('pi-lens-lsp')).toBe(ansiGreen);
62
+ });
63
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "rootDir": "src",
11
+ "declaration": true,
12
+ "declarationMap": true,
13
+ "sourceMap": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "noEmit": true,
18
+ "types": ["bun-types"]
19
+ },
20
+ "include": ["src/**/*.ts"],
21
+ "exclude": ["node_modules", "dist"]
22
+ }