toolcraft 0.0.235 → 0.0.237

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/composition.json CHANGED
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.235",
116
+ "version": "0.0.237",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.235",
126
+ "version": "0.0.237",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.235",
116
+ "version": "0.0.237",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.235",
126
+ "version": "0.0.237",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  {
10
10
  "name": "toolcraft-schema",
11
- "version": "0.0.235",
11
+ "version": "0.0.237",
12
12
  "license": "MIT"
13
13
  }
14
14
  ]
@@ -1,8 +1,8 @@
1
1
  import { ScreenBuffer } from "../buffer.js";
2
- import type { Rect } from "../types.js";
2
+ import type { DashboardStats, Rect } from "../types.js";
3
3
  export type FooterHint = {
4
4
  key: string;
5
5
  label: string;
6
6
  };
7
- export declare function renderFooter(buffer: ScreenBuffer, rect: Rect, hints: FooterHint[]): void;
7
+ export declare function renderFooter(buffer: ScreenBuffer, rect: Rect, hints: FooterHint[], session?: DashboardStats["session"]): void;
8
8
  export declare function defaultHints(): FooterHint[];
@@ -1,9 +1,26 @@
1
1
  import { getTheme } from "../../internal/theme-detect.js";
2
2
  import { displayWidth, graphemes, graphemeWidth, truncateToWidth } from "../terminal-width.js";
3
3
  import { plainTerminalText } from "../ansi.js";
4
- export function renderFooter(buffer, rect, hints) {
4
+ export function renderFooter(buffer, rect, hints, session) {
5
5
  buffer.clearRect(rect);
6
- if (rect.width <= 0 || rect.height <= 0 || hints.length === 0) {
6
+ if (rect.width <= 0 || rect.height <= 0)
7
+ return;
8
+ if (session) {
9
+ const directory = plainTerminalText(session.cwd);
10
+ const agentModel = plainTerminalText(`${session.agent} · ${session.model ?? "default model"}`);
11
+ const gap = Math.min(2, rect.width);
12
+ const available = Math.max(0, rect.width - gap);
13
+ const agentWidth = Math.min(displayWidth(agentModel), Math.ceil(available / 2));
14
+ const directoryWidth = Math.max(0, available - agentWidth);
15
+ const style = getTheme().styles.muted;
16
+ const y = rect.y + rect.height - 1;
17
+ buffer.put(rect.x, y, truncateToWidth(directory, directoryWidth || rect.width), style);
18
+ if (agentWidth > 0) {
19
+ const text = truncateToWidth(agentModel, agentWidth);
20
+ buffer.put(rect.x + rect.width - displayWidth(text), y, text, style);
21
+ }
22
+ }
23
+ if (hints.length === 0 || (session && rect.height === 1)) {
7
24
  return;
8
25
  }
9
26
  const fitted = [];
@@ -23,7 +40,7 @@ export function renderFooter(buffer, rect, hints) {
23
40
  }
24
41
  const cells = hintsToCells(fitted);
25
42
  let x = rect.x + Math.floor((rect.width - width) / 2);
26
- const y = rect.y + Math.floor(rect.height / 2);
43
+ const y = session ? rect.y : rect.y + Math.floor(rect.height / 2);
27
44
  cells.forEach((cell) => {
28
45
  buffer.put(x, y, cell.ch, cell.style);
29
46
  x += graphemeWidth(cell.ch);
@@ -37,6 +37,7 @@ export function createDashboard(opts = {}) {
37
37
  const performanceMonitor = createRenderPerformanceMonitor();
38
38
  let showPerformance = false;
39
39
  let scrollOffset = 0;
40
+ let outputViewportHeight = 0;
40
41
  let heldOutput;
41
42
  let renderTimer;
42
43
  function appendOutput(item) {
@@ -109,11 +110,7 @@ export function createDashboard(opts = {}) {
109
110
  command === "scroll-down" ||
110
111
  command === "page-up" ||
111
112
  command === "page-down") {
112
- const page = Math.max(1, computeDashboardLayout({
113
- totalWidth: driver.getSize().cols,
114
- totalHeight: driver.getSize().rows,
115
- rightPaneWidth
116
- }).leftPane.height);
113
+ const page = Math.max(1, outputViewportHeight);
117
114
  const amount = command === "page-up" || command === "page-down" ? page : 1;
118
115
  const direction = command === "scroll-up" || command === "page-up" ? 1 : -1;
119
116
  if (direction > 0)
@@ -178,13 +175,14 @@ export function createDashboard(opts = {}) {
178
175
  }
179
176
  const startedAt = performanceMonitor.begin();
180
177
  const { cols, rows } = driver.getSize();
178
+ const state = getStore().getState();
181
179
  const layout = computeDashboardLayout({
182
180
  totalWidth: cols,
183
181
  totalHeight: rows,
184
- rightPaneWidth
182
+ rightPaneWidth,
183
+ footerHeight: state.stats.session ? 2 : 1
185
184
  });
186
185
  const nextBuffer = new ScreenBuffer(cols, rows);
187
- const state = getStore().getState();
188
186
  renderBorder(nextBuffer, layout, {
189
187
  leftTitle: title,
190
188
  rightTitle: statsTitle,
@@ -211,13 +209,14 @@ export function createDashboard(opts = {}) {
211
209
  layout.rightPane.height -= height;
212
210
  }
213
211
  }
214
- scrollOffset = renderOutputPane(nextBuffer, { ...layout.leftPane, height: Math.max(0, layout.leftPane.height - (showPerformance ? 1 : 0)) }, heldOutput ?? state.output, scrollOffset);
212
+ outputViewportHeight = Math.max(0, layout.leftPane.height - (showPerformance ? 1 : 0));
213
+ scrollOffset = renderOutputPane(nextBuffer, { ...layout.leftPane, height: outputViewportHeight }, heldOutput ?? state.output, scrollOffset);
215
214
  if (scrollOffset === 0)
216
215
  heldOutput = undefined;
217
216
  renderStatsPane(nextBuffer, layout.rightPane, state.stats);
218
217
  if (layout.summary)
219
218
  renderCompactStatsPane(nextBuffer, layout.summary, state.stats);
220
- renderFooter(nextBuffer, layout.footer, footerHints);
219
+ renderFooter(nextBuffer, layout.footer, footerHints, state.stats.session);
221
220
  if (showPerformance && layout.leftPane.height > 0) {
222
221
  nextBuffer.putInRect(layout.leftPane, layout.leftPane.height - 1, formatRenderPerformance(performanceMonitor.snapshot(), layout.leftPane.width), { dim: true });
223
222
  }
@@ -16,6 +16,11 @@ export type DashboardStats = {
16
16
  tokensOut: number;
17
17
  elapsedMs: number;
18
18
  currentAction?: string;
19
+ session?: {
20
+ cwd: string;
21
+ agent: string;
22
+ model?: string;
23
+ };
19
24
  };
20
25
  export type Command = "quit" | "forceQuit" | "edit" | "pause" | "retry" | "view-log" | "scroll-up" | "scroll-down" | "page-up" | "page-down" | "follow" | "render-stats";
21
26
  export type DashboardState = {
@@ -0,0 +1,2 @@
1
+ /** Makes untrusted text safe to embed in a human-readable terminal field. */
2
+ export declare function escapeTerminalText(text: string): string;
@@ -0,0 +1,20 @@
1
+ /** Makes untrusted text safe to embed in a human-readable terminal field. */
2
+ export function escapeTerminalText(text) {
3
+ let result = "";
4
+ for (const character of text) {
5
+ const code = character.codePointAt(0);
6
+ if (code <= 0x1f ||
7
+ (code >= 0x7f && code <= 0x9f) ||
8
+ code === 0x061c ||
9
+ code === 0x200e ||
10
+ code === 0x200f ||
11
+ (code >= 0x202a && code <= 0x202e) ||
12
+ (code >= 0x2066 && code <= 0x2069)) {
13
+ result += `\\u${code.toString(16).padStart(4, "0")}`;
14
+ }
15
+ else {
16
+ result += character;
17
+ }
18
+ }
19
+ return result;
20
+ }
@@ -20,6 +20,10 @@
20
20
  "LICENSE"
21
21
  ],
22
22
  "exports": {
23
+ "./escape-terminal-text": {
24
+ "types": "./dist/escape-terminal-text.d.ts",
25
+ "import": "./dist/escape-terminal-text.js"
26
+ },
23
27
  ".": {
24
28
  "types": "./dist/index.d.ts",
25
29
  "import": "./dist/index.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.235",
3
+ "version": "0.0.237",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft",
3
- "version": "0.0.235",
3
+ "version": "0.0.237",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -158,7 +158,7 @@
158
158
  "yaml"
159
159
  ],
160
160
  "optionalDependencies": {
161
- "toolcraft-schema": "0.0.235",
161
+ "toolcraft-schema": "0.0.237",
162
162
  "toolcraft-design": "*",
163
163
  "@poe-code/frontmatter": "*",
164
164
  "@poe-code/agent-mcp-config": "*",