pi-harness-runtime 1.1.135 → 1.1.138

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 (131) hide show
  1. package/harness/langchain/daemon.ts +128 -25
  2. package/harness/langchain/run.ts +1 -1
  3. package/index.ts +41 -2
  4. package/package.json +1 -1
  5. package/packages/a2a-adapter/package.json +1 -1
  6. package/packages/architecture-generator/package.json +1 -1
  7. package/packages/auth/package.json +1 -1
  8. package/packages/autonomous-refactor/package.json +1 -1
  9. package/packages/autonomous-runtime/package.json +1 -1
  10. package/packages/cache-strategy/package.json +1 -1
  11. package/packages/capability-registry/package.json +1 -1
  12. package/packages/checkpoint/package.json +1 -1
  13. package/packages/cli-plugin-sdk/package.json +1 -1
  14. package/packages/clipboard/package.json +1 -1
  15. package/packages/clipboard-plugin/package.json +1 -1
  16. package/packages/code-generation/package.json +1 -1
  17. package/packages/code-review/package.json +1 -1
  18. package/packages/codex-adapter/package.json +1 -1
  19. package/packages/codex-watcher/dist/src/index.d.ts +42 -0
  20. package/packages/codex-watcher/dist/src/index.d.ts.map +1 -0
  21. package/packages/codex-watcher/dist/src/index.js +198 -0
  22. package/packages/codex-watcher/dist/src/index.js.map +1 -0
  23. package/packages/codex-watcher/dist/src/parser.d.ts +36 -0
  24. package/packages/codex-watcher/dist/src/parser.d.ts.map +1 -0
  25. package/packages/codex-watcher/dist/src/parser.js +151 -0
  26. package/packages/codex-watcher/dist/src/parser.js.map +1 -0
  27. package/packages/codex-watcher/dist/src/session.d.ts +9 -0
  28. package/packages/codex-watcher/dist/src/session.d.ts.map +1 -0
  29. package/packages/codex-watcher/dist/src/session.js +131 -0
  30. package/packages/codex-watcher/dist/src/session.js.map +1 -0
  31. package/packages/codex-watcher/dist/src/types.d.ts +63 -0
  32. package/packages/codex-watcher/dist/src/types.d.ts.map +1 -0
  33. package/packages/codex-watcher/dist/src/types.js +17 -0
  34. package/packages/codex-watcher/dist/src/types.js.map +1 -0
  35. package/packages/codex-watcher/package.json +26 -0
  36. package/packages/codex-watcher/src/index.ts +244 -0
  37. package/packages/codex-watcher/src/parser.ts +210 -0
  38. package/packages/codex-watcher/src/session.ts +151 -0
  39. package/packages/codex-watcher/src/types.ts +67 -0
  40. package/packages/codex-watcher/test/watch.test.ts +150 -0
  41. package/packages/config-capture/package.json +1 -1
  42. package/packages/config-capture/src/index.ts +5 -16
  43. package/packages/context-compiler/package.json +1 -1
  44. package/packages/context-discovery/package.json +1 -1
  45. package/packages/context-manager/package.json +1 -1
  46. package/packages/cookie-sanitizer/package.json +1 -1
  47. package/packages/cost-optimizer/package.json +1 -1
  48. package/packages/dependency-analyzer/package.json +1 -1
  49. package/packages/django-plugin/package.json +1 -1
  50. package/packages/doc-generator/package.json +1 -1
  51. package/packages/evaluation-engine/package.json +1 -1
  52. package/packages/evaluation-runner/package.json +1 -1
  53. package/packages/event-bus/package.json +1 -1
  54. package/packages/event-store/package.json +1 -1
  55. package/packages/experience-replay/package.json +1 -1
  56. package/packages/feedback-collector/package.json +1 -1
  57. package/packages/file-copy-helper/package.json +1 -1
  58. package/packages/framework-detector/package.json +1 -1
  59. package/packages/framework-plugin-sdk/package.json +1 -1
  60. package/packages/frappe-plugin/package.json +1 -1
  61. package/packages/generic-web-plugin/package.json +1 -1
  62. package/packages/health-monitor/package.json +1 -1
  63. package/packages/intent-analyzer/package.json +1 -1
  64. package/packages/jev-judge/package.json +1 -1
  65. package/packages/knowledge-graph/package.json +1 -1
  66. package/packages/knowledge-retrieval/package.json +1 -1
  67. package/packages/laravel-plugin/package.json +1 -1
  68. package/packages/learning-engine/package.json +1 -1
  69. package/packages/mcp-adapter/package.json +1 -1
  70. package/packages/memory-engine/package.json +1 -1
  71. package/packages/milestone-manager/package.json +1 -1
  72. package/packages/model-registry/package.json +1 -1
  73. package/packages/nextjs-plugin/package.json +1 -1
  74. package/packages/notification/package.json +1 -1
  75. package/packages/observability/package.json +1 -1
  76. package/packages/okf-indexer/package.json +1 -1
  77. package/packages/performance-optimizer/package.json +1 -1
  78. package/packages/privilege-broker/package.json +1 -1
  79. package/packages/project-analyzer/package.json +1 -1
  80. package/packages/project-bootstrap/package.json +1 -1
  81. package/packages/projection-engine/package.json +1 -1
  82. package/packages/prompt-compiler/package.json +1 -1
  83. package/packages/prompt-versioning/package.json +1 -1
  84. package/packages/provider-adapter-sdk/package.json +1 -1
  85. package/packages/provider-router/package.json +1 -1
  86. package/packages/provider-selector/package.json +1 -1
  87. package/packages/providers/package.json +1 -1
  88. package/packages/qdrant-skills/package.json +1 -1
  89. package/packages/quota-manager/package.json +1 -1
  90. package/packages/rate-limiter/package.json +1 -1
  91. package/packages/react-vite-plugin/package.json +1 -1
  92. package/packages/release-manager/package.json +1 -1
  93. package/packages/requirement-compiler/package.json +1 -1
  94. package/packages/runtime/package.json +1 -1
  95. package/packages/scheduler/package.json +1 -1
  96. package/packages/scheduler-adapter/package.json +1 -1
  97. package/packages/session/package.json +1 -1
  98. package/packages/session-api/package.json +1 -1
  99. package/packages/session-export/package.json +1 -1
  100. package/packages/shared-context/package.json +1 -1
  101. package/packages/skill-mcp-client/package.json +1 -1
  102. package/packages/skill-registry/package.json +1 -1
  103. package/packages/skills/package.json +1 -1
  104. package/packages/sprint-planner/package.json +1 -1
  105. package/packages/subscription-engine/package.json +1 -1
  106. package/packages/task-compiler/package.json +1 -1
  107. package/packages/tencentdb-memory/package.json +1 -1
  108. package/packages/tencentdb-sync/package.json +1 -1
  109. package/packages/test-data-generator/package.json +1 -1
  110. package/packages/test-generator/package.json +1 -1
  111. package/packages/todo-bd-sync/package.json +1 -1
  112. package/packages/token-estimation/package.json +1 -1
  113. package/packages/token-optimizer/package.json +1 -1
  114. package/packages/trajectory/package.json +1 -1
  115. package/packages/tui/dist/harness-header.d.ts +17 -13
  116. package/packages/tui/dist/harness-header.d.ts.map +1 -1
  117. package/packages/tui/dist/harness-header.js +108 -62
  118. package/packages/tui/dist/harness-header.js.map +1 -1
  119. package/packages/tui/dist/index.d.ts +1 -2
  120. package/packages/tui/dist/index.d.ts.map +1 -1
  121. package/packages/tui/dist/index.js +1 -2
  122. package/packages/tui/dist/index.js.map +1 -1
  123. package/packages/tui/package.json +1 -1
  124. package/packages/tui/src/harness-header.ts +154 -75
  125. package/packages/tui/src/index.ts +6 -2
  126. package/packages/tui/test/harness-header.test.ts +590 -0
  127. package/packages/types/package.json +1 -1
  128. package/packages/workflow-events/package.json +1 -1
  129. package/packages/workspace-scanner/package.json +1 -1
  130. package/packages/worktree/package.json +1 -1
  131. package/packages/write-review/package.json +1 -1
@@ -0,0 +1,590 @@
1
+ /**
2
+ * Unit tests for harness-header.ts
3
+ *
4
+ * Tests cover:
5
+ * - ANSI reset after every colored logo segment
6
+ * - Visible logo width (4 cells)
7
+ * - Compact/expanded expansion (both logo rows preserved)
8
+ * - Narrow-width rendering with truncation
9
+ * - No emoji in output
10
+ * - Fallback for non-truecolor modes
11
+ *
12
+ * Run with: bun test packages/tui/test/harness-header.test.ts
13
+ */
14
+
15
+ // @ts-expect-error: bun:test types are provided by bun runtime
16
+ import { beforeAll, describe, expect, it } from "bun:test";
17
+ import { initTheme, type Theme } from "@earendil-works/pi-coding-agent";
18
+ import {
19
+ createHarnessHeader,
20
+ type HarnessHeaderOptions,
21
+ stripAnsi,
22
+ visibleWidth,
23
+ } from "../src/harness-header.js";
24
+
25
+ // ---------------------------------------------------------------------------
26
+ // Initialize pi-coding-agent theme (required for keyText/keyHint)
27
+ // ---------------------------------------------------------------------------
28
+
29
+ let trueColorTheme: Theme;
30
+ let color256Theme: Theme;
31
+ let headlessTheme: Theme;
32
+
33
+ beforeAll(() => {
34
+ // Initialize with dark theme so the global theme proxy works for keyText/keyHint
35
+ initTheme("dark");
36
+
37
+ // Minimal mock Theme for the harness header's logo rendering.
38
+ // getColorMode() returns "truecolor" to test half-block mode.
39
+ trueColorTheme = {
40
+ fg(color: string, text: string): string {
41
+ const codes: Record<string, string> = {
42
+ accent: "\x1b[36m",
43
+ success: "\x1b[32m",
44
+ muted: "\x1b[90m",
45
+ dim: "\x1b[90m",
46
+ text: "\x1b[37m",
47
+ };
48
+ return `${codes[color] ?? ""}${text}\x1b[39m`;
49
+ },
50
+ bg(): string {
51
+ return "";
52
+ },
53
+ style(): string {
54
+ return "";
55
+ },
56
+ bold(): string {
57
+ return "";
58
+ },
59
+ italic(): string {
60
+ return "";
61
+ },
62
+ underline(): string {
63
+ return "";
64
+ },
65
+ inverse(): string {
66
+ return "";
67
+ },
68
+ strikethrough(): string {
69
+ return "";
70
+ },
71
+ getFgAnsi(): string {
72
+ return "";
73
+ },
74
+ getBgAnsi(): string {
75
+ return "";
76
+ },
77
+ getColorMode(): string {
78
+ return "truecolor";
79
+ },
80
+ getThinkingBorderColor() {
81
+ return () => "";
82
+ },
83
+ getBashModeBorderColor() {
84
+ return () => "";
85
+ },
86
+ get appearance(): string {
87
+ return "dark";
88
+ },
89
+ get colors(): Record<string, unknown> {
90
+ return {};
91
+ },
92
+ } as unknown as Theme;
93
+
94
+ // 256-color theme — ColorMode is "truecolor" | "256color" in real usage.
95
+ // Both truecolor and 256color render the same half-block logo (ANSI 256 works for both).
96
+ color256Theme = {
97
+ ...trueColorTheme,
98
+ getColorMode(): string {
99
+ return "256color";
100
+ },
101
+ } as unknown as Theme;
102
+
103
+ // Headless/no-color theme — only reachable in true headless environments where
104
+ // getColorMode() returns undefined/null (not in ColorMode type but defensively handled).
105
+ // In this mode the logo renders as empty lines and the product name shows normally.
106
+ headlessTheme = {
107
+ ...trueColorTheme,
108
+ getColorMode(): string {
109
+ return ""; // empty = no color support
110
+ },
111
+ } as unknown as Theme;
112
+ });
113
+
114
+ // ---------------------------------------------------------------------------
115
+ // Test data
116
+ // ---------------------------------------------------------------------------
117
+
118
+ const TEST_OPTIONS: HarnessHeaderOptions = {
119
+ version: "1.0.0",
120
+ productName: "Harness",
121
+ onboardingText: "Test onboarding.",
122
+ };
123
+
124
+ function mockTui(): object {
125
+ return {};
126
+ }
127
+
128
+ // ---------------------------------------------------------------------------
129
+ // visibleWidth
130
+ // ---------------------------------------------------------------------------
131
+
132
+ describe("visibleWidth", () => {
133
+ it("returns 0 for empty string", () => {
134
+ expect(visibleWidth("")).toBe(0);
135
+ });
136
+
137
+ it("returns correct length for plain text", () => {
138
+ expect(visibleWidth("hello")).toBe(5);
139
+ });
140
+
141
+ it("subtracts ANSI escape sequences from length", () => {
142
+ const colored = "\x1b[31mhello\x1b[39m";
143
+ expect(visibleWidth(colored)).toBe(5);
144
+ });
145
+
146
+ it("handles multiple escape sequences", () => {
147
+ const colored = "\x1b[1m\x1b[31mbold red\x1b[39m\x1b[22m";
148
+ // "bold red" = 8 visible chars
149
+ expect(visibleWidth(colored)).toBe(8);
150
+ });
151
+ });
152
+
153
+ // ---------------------------------------------------------------------------
154
+ // stripAnsi
155
+ // ---------------------------------------------------------------------------
156
+
157
+ describe("stripAnsi", () => {
158
+ it("returns empty string for empty input", () => {
159
+ expect(stripAnsi("")).toBe("");
160
+ });
161
+
162
+ it("returns original string if no escapes", () => {
163
+ expect(stripAnsi("hello world")).toBe("hello world");
164
+ });
165
+
166
+ it("strips all ANSI escapes", () => {
167
+ const colored = "\x1b[1m\x1b[31mbold red\x1b[39m\x1b[22m";
168
+ expect(stripAnsi(colored)).toBe("bold red");
169
+ });
170
+ });
171
+
172
+ // ---------------------------------------------------------------------------
173
+ // ANSI balance
174
+ // ---------------------------------------------------------------------------
175
+
176
+ describe("ANSI balance", () => {
177
+ it("all ANSI sequences are complete (balanced opens/closes)", () => {
178
+ const header = createHarnessHeader(
179
+ mockTui() as never,
180
+ trueColorTheme,
181
+ TEST_OPTIONS,
182
+ );
183
+ const lines = header.render(80);
184
+
185
+ for (const line of lines) {
186
+ // Check that visible length + ANSI overhead = total length
187
+ // Any incomplete CSI sequence would make this unequal
188
+ const stripped = stripAnsi(line);
189
+ const overhead = line.length - stripped.length;
190
+ // Each complete escape takes at least 3 chars ("\x1b[" + letter)
191
+ const estimatedCompleteSeqs = Math.floor(overhead / 3);
192
+ // Overhead should be a multiple of complete sequences
193
+ expect(overhead).toBeGreaterThanOrEqual(estimatedCompleteSeqs * 3);
194
+ }
195
+ });
196
+
197
+ it("each fg() call produces exactly one reset", () => {
198
+ const header = createHarnessHeader(
199
+ mockTui() as never,
200
+ trueColorTheme,
201
+ TEST_OPTIONS,
202
+ );
203
+ const lines = header.render(80);
204
+ const allText = lines.join("");
205
+
206
+ // After stripping ANSI, every colored segment should have matching reset
207
+ // If we strip and join, the result should be clean (no dangling resets)
208
+ const stripped = stripAnsi(allText);
209
+ // Stripped text should not contain any raw escape bytes
210
+ expect(stripped.includes("\x1b")).toBe(false);
211
+ // At minimum, the logo has 8 fg() calls (4 chars × 2 rows)
212
+ const resetSeq = "\x1b[39m";
213
+ const resets = allText.split(resetSeq).length - 1;
214
+ expect(resets).toBeGreaterThanOrEqual(8);
215
+ });
216
+ });
217
+
218
+ // ---------------------------------------------------------------------------
219
+ // Logo geometry
220
+ // ---------------------------------------------------------------------------
221
+
222
+ describe("logo geometry", () => {
223
+ it("logo occupies exactly 4 visible cells per row", () => {
224
+ const header = createHarnessHeader(
225
+ mockTui() as never,
226
+ trueColorTheme,
227
+ TEST_OPTIONS,
228
+ );
229
+ const lines = header.render(80);
230
+
231
+ const logoLine = lines.find(
232
+ (l: string) => stripAnsi(l).includes("▀") || stripAnsi(l).includes("█"),
233
+ );
234
+ if (!logoLine) return; // guarded by expect above
235
+
236
+ const plain = stripAnsi(logoLine);
237
+ const logoMatch = plain.match(/^([▀▄█]+)/);
238
+ expect(logoMatch?.[1].length ?? 0).toBe(4);
239
+ });
240
+
241
+ it("logo renders on exactly 2 rows in compact mode", () => {
242
+ const header = createHarnessHeader(
243
+ mockTui() as never,
244
+ trueColorTheme,
245
+ TEST_OPTIONS,
246
+ );
247
+ const lines = header.render(80);
248
+
249
+ const logoLines = lines.filter(
250
+ (l: string) => stripAnsi(l).includes("▀") || stripAnsi(l).includes("█"),
251
+ );
252
+ expect(logoLines.length).toBe(2);
253
+ });
254
+
255
+ it("logo renders on exactly 2 rows in expanded mode", () => {
256
+ const header = createHarnessHeader(
257
+ mockTui() as never,
258
+ trueColorTheme,
259
+ TEST_OPTIONS,
260
+ );
261
+ header.setExpanded(true);
262
+ const lines = header.render(80);
263
+
264
+ const logoLines = lines.filter(
265
+ (l: string) => stripAnsi(l).includes("▀") || stripAnsi(l).includes("█"),
266
+ );
267
+ // Both logo rows should be present in expanded mode
268
+ expect(logoLines.length).toBe(2);
269
+ });
270
+ });
271
+
272
+ // ---------------------------------------------------------------------------
273
+ // Fallback mode
274
+ // ---------------------------------------------------------------------------
275
+
276
+ describe("fallback mode", () => {
277
+ it("uses plain text when getColorMode() returns 'mono'", () => {
278
+ const header = createHarnessHeader(
279
+ mockTui() as never,
280
+ color256Theme,
281
+ TEST_OPTIONS,
282
+ );
283
+ const lines = header.render(80);
284
+
285
+ const allText = stripAnsi(lines.join("\n"));
286
+ // Should contain "Harness" but NOT block characters
287
+ expect(allText).toContain("Harness");
288
+ expect(allText).not.toContain("▀");
289
+ expect(allText).not.toContain("█");
290
+ });
291
+
292
+ it("falls back when getColorMode() returns 'none'", () => {
293
+ const noColorTheme = {
294
+ ...headlessTheme,
295
+ getColorMode(): string {
296
+ return "none";
297
+ },
298
+ } as unknown as Theme;
299
+
300
+ const header = createHarnessHeader(
301
+ mockTui() as never,
302
+ noColorTheme,
303
+ TEST_OPTIONS,
304
+ );
305
+ const lines = header.render(80);
306
+ const allText = stripAnsi(lines.join("\n"));
307
+
308
+ expect(allText).toContain("Harness");
309
+ expect(allText).not.toContain("▀");
310
+ });
311
+ });
312
+
313
+ // ---------------------------------------------------------------------------
314
+ // Width-aware truncation
315
+ // ---------------------------------------------------------------------------
316
+
317
+ describe("width-aware truncation", () => {
318
+ it("truncates lines longer than width", () => {
319
+ const header = createHarnessHeader(
320
+ mockTui() as never,
321
+ trueColorTheme,
322
+ TEST_OPTIONS,
323
+ );
324
+ const lines = header.render(20); // narrow width
325
+
326
+ for (const line of lines) {
327
+ expect(visibleWidth(line)).toBeLessThanOrEqual(20);
328
+ }
329
+ });
330
+
331
+ it("does not split ANSI escape sequences at truncation boundary", () => {
332
+ const header = createHarnessHeader(
333
+ mockTui() as never,
334
+ trueColorTheme,
335
+ TEST_OPTIONS,
336
+ );
337
+ const lines = header.render(10); // very narrow
338
+
339
+ for (const line of lines) {
340
+ // No incomplete CSI sequences: each escape ends with a letter
341
+ // A truncated line would end mid-escape, visible in stripAnsi output
342
+ const stripped = stripAnsi(line);
343
+ // If a line ends mid-escape, visibleWidth would not match stripAnsi length
344
+ expect(visibleWidth(line)).toBe(stripped.length);
345
+ }
346
+ });
347
+
348
+ it("appends ellipsis when truncating", () => {
349
+ const header = createHarnessHeader(
350
+ mockTui() as never,
351
+ trueColorTheme,
352
+ TEST_OPTIONS,
353
+ );
354
+ const lines = header.render(5);
355
+
356
+ const hasEllipsis = lines.some((l: string) => stripAnsi(l).endsWith("…"));
357
+ // At least some lines should be truncated at width 5
358
+ expect(hasEllipsis).toBe(true);
359
+ });
360
+
361
+ it("every line ends with ANSI reset after truncation", () => {
362
+ // At narrow widths, truncate() must not leave open color sequences.
363
+ // Every line must end with \x1b[39m (default foreground reset).
364
+ const header = createHarnessHeader(
365
+ mockTui() as never,
366
+ trueColorTheme,
367
+ TEST_OPTIONS,
368
+ );
369
+ const lines = header.render(20); // forces truncation on most lines
370
+
371
+ for (const line of lines) {
372
+ if (line === "") continue; // blank lines are safe
373
+ // Must end with foreground reset
374
+ expect(line.endsWith("\x1b[39m")).toBe(true);
375
+ }
376
+ });
377
+
378
+ it("renders without error at width 1", () => {
379
+ const header = createHarnessHeader(
380
+ mockTui() as never,
381
+ trueColorTheme,
382
+ TEST_OPTIONS,
383
+ );
384
+ expect(() => header.render(1)).not.toThrow();
385
+ });
386
+ });
387
+
388
+ // ---------------------------------------------------------------------------
389
+ // setExpanded
390
+ // ---------------------------------------------------------------------------
391
+
392
+ describe("setExpanded", () => {
393
+ it("starts in compact mode", () => {
394
+ const header = createHarnessHeader(
395
+ mockTui() as never,
396
+ trueColorTheme,
397
+ TEST_OPTIONS,
398
+ );
399
+ const lines = header.render(80);
400
+
401
+ // Compact should have hints with "·" separator
402
+ const compactText = stripAnsi(lines.join("\n"));
403
+ expect(compactText.toLowerCase()).toContain("interrupt");
404
+ });
405
+
406
+ it("switches to expanded mode when setExpanded(true)", () => {
407
+ const header = createHarnessHeader(
408
+ mockTui() as never,
409
+ trueColorTheme,
410
+ TEST_OPTIONS,
411
+ );
412
+ header.setExpanded(true);
413
+ const lines = header.render(80);
414
+ const expandedText = stripAnsi(lines.join("\n"));
415
+
416
+ // Expanded has full descriptions
417
+ expect(expandedText.toLowerCase()).toContain("abort");
418
+ expect(expandedText.toLowerCase()).toContain("clear");
419
+ expect(expandedText.toLowerCase()).toContain("slash");
420
+ });
421
+
422
+ it("switches back to compact when setExpanded(false)", () => {
423
+ const header = createHarnessHeader(
424
+ mockTui() as never,
425
+ trueColorTheme,
426
+ TEST_OPTIONS,
427
+ );
428
+ header.setExpanded(true);
429
+ header.setExpanded(false);
430
+ const lines = header.render(80);
431
+
432
+ const hasDotSeparator = lines.some((l: string) =>
433
+ stripAnsi(l).includes(" · "),
434
+ );
435
+ expect(hasDotSeparator).toBe(true);
436
+ });
437
+
438
+ it("is idempotent when setting same state twice", () => {
439
+ const header = createHarnessHeader(
440
+ mockTui() as never,
441
+ trueColorTheme,
442
+ TEST_OPTIONS,
443
+ );
444
+ header.setExpanded(true);
445
+ const lines1 = header.render(80);
446
+ header.setExpanded(true); // same state again
447
+ const lines2 = header.render(80);
448
+ expect(lines1).toEqual(lines2);
449
+ });
450
+ });
451
+
452
+ // ---------------------------------------------------------------------------
453
+ // No emoji
454
+ // ---------------------------------------------------------------------------
455
+
456
+ describe("no emoji", () => {
457
+ it("output contains no emoji code points", () => {
458
+ const header = createHarnessHeader(
459
+ mockTui() as never,
460
+ trueColorTheme,
461
+ TEST_OPTIONS,
462
+ );
463
+ const lines = header.render(80);
464
+ const allText = lines.join("\n");
465
+
466
+ const emojiRanges = [
467
+ /[\u{1F300}-\u{1F9FF}]/u,
468
+ /[\u{2600}-\u{26FF}]/u,
469
+ /[\u{2700}-\u{27BF}]/u,
470
+ /[\u{1F600}-\u{1F64F}]/u,
471
+ /[\u{1F680}-\u{1F6FF}]/u,
472
+ ];
473
+
474
+ for (const range of emojiRanges) {
475
+ const matches = allText.match(range);
476
+ expect(matches).toBeNull();
477
+ }
478
+ });
479
+
480
+ it("uses only allowed Unicode block characters", () => {
481
+ const header = createHarnessHeader(
482
+ mockTui() as never,
483
+ trueColorTheme,
484
+ TEST_OPTIONS,
485
+ );
486
+ const lines = header.render(80);
487
+
488
+ for (const line of lines) {
489
+ const plain = stripAnsi(line);
490
+
491
+ for (const char of plain) {
492
+ const code = char.charCodeAt(0);
493
+
494
+ // ASCII printable
495
+ if (code >= 0x20 && code <= 0x7e) continue;
496
+ // Space
497
+ if (code === 0x20) continue;
498
+ // Block elements: ▀ (U+2580) ▄ (U+2584) █ (U+2588)
499
+ if (char === "▀" || char === "▄" || char === "█") continue;
500
+ // Middle dot U+00B7 used in shortcuts
501
+ if (char === "·") continue;
502
+ // Ellipsis U+2026
503
+ if (char === "…") continue;
504
+ // Newline handled by line iteration
505
+ if (char === "\n") continue;
506
+
507
+ expect(
508
+ `Unexpected character: ${char} (U+${code.toString(16).padStart(4, "0")})`,
509
+ ).toBe("");
510
+ }
511
+ }
512
+ });
513
+ });
514
+
515
+ // ---------------------------------------------------------------------------
516
+ // Version and text display
517
+ // ---------------------------------------------------------------------------
518
+
519
+ describe("version display", () => {
520
+ it("displays correct version from options", () => {
521
+ const customOptions: HarnessHeaderOptions = {
522
+ ...TEST_OPTIONS,
523
+ version: "2.5.10-test",
524
+ };
525
+ const header = createHarnessHeader(
526
+ mockTui() as never,
527
+ trueColorTheme,
528
+ customOptions,
529
+ );
530
+ const lines = header.render(80);
531
+
532
+ const text = stripAnsi(lines.join("\n"));
533
+ expect(text).toContain("v2.5.10-test");
534
+ });
535
+
536
+ it("defaults product name to 'Harness'", () => {
537
+ const optionsWithoutName: HarnessHeaderOptions = { version: "1.0.0" };
538
+ const header = createHarnessHeader(
539
+ mockTui() as never,
540
+ trueColorTheme,
541
+ optionsWithoutName,
542
+ );
543
+ const lines = header.render(80);
544
+
545
+ const text = stripAnsi(lines.join("\n"));
546
+ expect(text).toContain("Harness");
547
+ });
548
+ });
549
+
550
+ // ---------------------------------------------------------------------------
551
+ // Dynamic key hints
552
+ // ---------------------------------------------------------------------------
553
+
554
+ describe("dynamic key hints", () => {
555
+ it("renders hint text for shortcuts", () => {
556
+ const header = createHarnessHeader(
557
+ mockTui() as never,
558
+ trueColorTheme,
559
+ TEST_OPTIONS,
560
+ );
561
+ const lines = header.render(80);
562
+
563
+ const text = stripAnsi(lines.join("\n"));
564
+
565
+ expect(text.toLowerCase()).toContain("interrupt");
566
+ expect(text.toLowerCase()).toContain("command");
567
+ });
568
+ });
569
+
570
+ // ---------------------------------------------------------------------------
571
+ // Onboarding text
572
+ // ---------------------------------------------------------------------------
573
+
574
+ describe("onboarding text", () => {
575
+ it("displays custom onboarding text", () => {
576
+ const customOptions: HarnessHeaderOptions = {
577
+ ...TEST_OPTIONS,
578
+ onboardingText: "Custom onboarding message.",
579
+ };
580
+ const header = createHarnessHeader(
581
+ mockTui() as never,
582
+ trueColorTheme,
583
+ customOptions,
584
+ );
585
+ const lines = header.render(80);
586
+
587
+ const text = stripAnsi(lines.join("\n"));
588
+ expect(text).toContain("Custom onboarding message.");
589
+ });
590
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/types",
3
- "version": "1.1.135",
3
+ "version": "1.1.138",
4
4
  "description": "Shared TypeScript types for pi-harness-runtime packages",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/workflow-events",
3
- "version": "1.1.135",
3
+ "version": "1.1.138",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/workspace-scanner",
3
- "version": "1.1.135",
3
+ "version": "1.1.138",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/worktree",
3
- "version": "1.1.135",
3
+ "version": "1.1.138",
4
4
  "description": "pi-harness-runtime — worktree",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/write-review",
3
- "version": "1.1.135",
3
+ "version": "1.1.138",
4
4
  "description": "Two-agent write-review loop with blackboard coordination",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",