scream-code 0.5.2 → 0.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scream-code",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "The Starting Point for Next-Gen Agents",
5
5
  "license": "MIT",
6
6
  "author": "ScreamCli",
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Patches @earendil-works/pi-tui's tui.js to add fixedBottomLineCount support.
4
+ * This pins the editor + footer to the bottom of the terminal.
5
+ *
6
+ * Safe to run multiple times — skips if already patched.
7
+ */
8
+
9
+ import { readFileSync, writeFileSync } from 'node:fs';
10
+ import { createRequire } from 'node:module';
11
+
12
+ const MARKER = 'this.fixedBottomLineCount';
13
+
14
+ const CONSTRUCTOR_OLD = ` constructor(terminal, showHardwareCursor) {
15
+ super();
16
+ this.terminal = terminal;`;
17
+
18
+ const CONSTRUCTOR_NEW = ` constructor(terminal, showHardwareCursor) {
19
+ super();
20
+ this.fixedBottomLineCount = 0;
21
+ this.terminal = terminal;`;
22
+
23
+ const RENDER_OLD = ` let newLines = this.render(width);
24
+ // Composite overlays`;
25
+
26
+ const RENDER_NEW = ` let newLines = this.render(width);
27
+ // Fixed-bottom region: pin the last N lines (editor + footer) and apply
28
+ // viewport scrolling only to the remaining top portion.
29
+ if (this.fixedBottomLineCount > 0) {
30
+ const bottomCount = Math.min(this.fixedBottomLineCount, height);
31
+ const topCount = height - bottomCount;
32
+ if (topCount > 0) {
33
+ const topLines = newLines.length > bottomCount ? newLines.slice(0, -bottomCount) : [];
34
+ const bottomLines = newLines.slice(-bottomCount);
35
+ const topStart = Math.max(0, topLines.length - topCount);
36
+ const visibleTop = topLines.slice(topStart, topStart + topCount);
37
+ while (visibleTop.length < topCount) visibleTop.push("");
38
+ newLines = [...visibleTop, ...bottomLines];
39
+ }
40
+ }
41
+ // Composite overlays`;
42
+
43
+ export function patchPiTui() {
44
+ let tuiPath;
45
+ try {
46
+ const require = createRequire(import.meta.url);
47
+ tuiPath = require.resolve('@earendil-works/pi-tui/dist/tui.js');
48
+ } catch {
49
+ // pi-tui not found — likely a dev install where pnpm handles patches.
50
+ return;
51
+ }
52
+
53
+ let src = readFileSync(tuiPath, 'utf8');
54
+
55
+ // Already patched?
56
+ if (src.includes(MARKER)) return;
57
+
58
+ src = src.replace(CONSTRUCTOR_OLD, CONSTRUCTOR_NEW);
59
+ src = src.replace(RENDER_OLD, RENDER_NEW);
60
+
61
+ if (!src.includes(MARKER)) {
62
+ // Patch targets not found — pi-tui version may have changed.
63
+ console.warn('[scream-code] warning: could not patch pi-tui (structure changed?)');
64
+ return;
65
+ }
66
+
67
+ writeFileSync(tuiPath, src, 'utf8');
68
+ }
@@ -113,6 +113,7 @@ import {
113
113
  detectLegacyShims,
114
114
  renameInPlace,
115
115
  } from './postinstall/migrate.mjs';
116
+ import { patchPiTui } from './postinstall/patch-pi-tui.mjs';
116
117
  import { createDesktopShortcut } from './postinstall/shortcut.mjs';
117
118
  import {
118
119
  logForeignScreamInTheWay,
@@ -123,6 +124,9 @@ import {
123
124
  } from './postinstall/ui.mjs';
124
125
 
125
126
  async function main() {
127
+ // Patch pi-tui for fixedBottomLineCount support (all installs).
128
+ try { patchPiTui(); } catch { /* non-fatal */ }
129
+
126
130
  // Step 1: skip non-global installs (npx, local project deps,
127
131
  // workspace bootstraps). Windows is supported natively; the
128
132
  // platform-specific bits (PATHEXT-aware PATH walk, whole-file