poe-code 3.0.394 → 3.0.395

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/dist/index.js CHANGED
@@ -8329,13 +8329,15 @@ function computeExplorerLayout(opts) {
8329
8329
  footer
8330
8330
  };
8331
8331
  }
8332
- const listWidth = mode === "wide" ? Math.floor(cols * 5 / 12) : Math.floor(cols * 2 / 5);
8333
- const detailWidth = cols - listWidth;
8332
+ const gutterWidth = 1;
8333
+ const availableWidth = Math.max(0, cols - gutterWidth);
8334
+ const listWidth = mode === "wide" ? Math.floor(availableWidth * 5 / 12) : Math.floor(availableWidth * 2 / 5);
8335
+ const detailWidth = availableWidth - listWidth;
8334
8336
  return {
8335
8337
  mode,
8336
8338
  header,
8337
8339
  list: { x: 0, y: contentY, width: listWidth, height: contentHeight },
8338
- detail: { x: listWidth, y: contentY, width: detailWidth, height: contentHeight },
8340
+ detail: { x: listWidth + gutterWidth, y: contentY, width: detailWidth, height: contentHeight },
8339
8341
  footer
8340
8342
  };
8341
8343
  }
@@ -8950,6 +8952,48 @@ var init_text2 = __esm({
8950
8952
  }
8951
8953
  });
8952
8954
 
8955
+ // packages/toolcraft-design/src/explorer/render/pane.ts
8956
+ function drawPaneFrame(screen, rect, title2, style = {}) {
8957
+ if (rect.width <= 0 || rect.height <= 0) {
8958
+ return;
8959
+ }
8960
+ if (rect.width === 1) {
8961
+ for (let y = 0; y < rect.height; y += 1) {
8962
+ screen.put(rect.x, rect.y + y, "\u2502", style);
8963
+ }
8964
+ return;
8965
+ }
8966
+ const innerWidth = Math.max(0, rect.width - 2);
8967
+ const titleSegment = padEndCells(
8968
+ fitToWidth(`\u2500 ${title2} `, innerWidth, rect.x + 1),
8969
+ innerWidth,
8970
+ "\u2500",
8971
+ rect.x + 1
8972
+ );
8973
+ screen.put(rect.x, rect.y, `\u250C${titleSegment}\u2510`, style);
8974
+ for (let y = 1; y < rect.height - 1; y += 1) {
8975
+ screen.put(rect.x, rect.y + y, "\u2502", style);
8976
+ screen.put(rect.x + rect.width - 1, rect.y + y, "\u2502", style);
8977
+ }
8978
+ if (rect.height > 1) {
8979
+ screen.put(rect.x, rect.y + rect.height - 1, `\u2514${"\u2500".repeat(innerWidth)}\u2518`, style);
8980
+ }
8981
+ }
8982
+ function paneBodyRect(rect) {
8983
+ return {
8984
+ x: rect.x + 2,
8985
+ y: rect.y + 1,
8986
+ width: Math.max(0, rect.width - 4),
8987
+ height: Math.max(0, rect.height - 2)
8988
+ };
8989
+ }
8990
+ var init_pane = __esm({
8991
+ "packages/toolcraft-design/src/explorer/render/pane.ts"() {
8992
+ "use strict";
8993
+ init_text2();
8994
+ }
8995
+ });
8996
+
8953
8997
  // packages/toolcraft-design/src/explorer/render/detail.ts
8954
8998
  function renderDetail(state, screen, layout) {
8955
8999
  const rect = layout.detail;
@@ -8960,18 +9004,37 @@ function renderDetail(state, screen, layout) {
8960
9004
  }
8961
9005
  const row = state.rows.find((r) => r.id === state.detail.rowId) ?? null;
8962
9006
  if (layout.mode === "narrow-vertical") {
8963
- screen.put(rect.x, rect.y, `\u251C\u2500 Detail ${"\u2500".repeat(Math.max(0, rect.width - 11))}\u2524`, styles.border);
8964
- renderDetailBody(state, screen, { ...rect, y: rect.y + 1, height: rect.height - 1 }, row);
9007
+ drawPaneFrame(
9008
+ screen,
9009
+ rect,
9010
+ "Preview",
9011
+ state.focused === "detail" ? styles.borderFocused : styles.border
9012
+ );
9013
+ renderDetailBody(state, screen, paneBodyRect(rect), row);
8965
9014
  return;
8966
9015
  }
8967
- screen.put(rect.x, rect.y, "\u2502", styles.border);
8968
- renderDetailBody(state, screen, { ...rect, x: rect.x + 1, width: rect.width - 1 }, row);
9016
+ drawPaneFrame(
9017
+ screen,
9018
+ rect,
9019
+ "Preview",
9020
+ state.focused === "detail" ? styles.borderFocused : styles.border
9021
+ );
9022
+ renderDetailBody(state, screen, paneBodyRect(rect), row);
8969
9023
  }
8970
9024
  function renderDetailBody(state, screen, rect, row) {
8971
9025
  const styles = getExplorerStyles();
8972
9026
  const items = state.detail.items;
9027
+ if (rect.width <= 0 || rect.height <= 0) {
9028
+ return;
9029
+ }
8973
9030
  if (items === null) {
8974
- writeLine2(screen, rect, 0, state.detail.loading ? "Loading detail..." : state.emptyHint, styles.muted);
9031
+ writeLine2(
9032
+ screen,
9033
+ rect,
9034
+ 0,
9035
+ state.detail.loading ? "Loading detail..." : state.emptyHint,
9036
+ styles.muted
9037
+ );
8975
9038
  return;
8976
9039
  }
8977
9040
  if (items.length === 0) {
@@ -8979,7 +9042,7 @@ function renderDetailBody(state, screen, rect, row) {
8979
9042
  return;
8980
9043
  }
8981
9044
  if (items.length === 1 && items[0]?.title === void 0) {
8982
- renderBlob(screen, rect, renderItem(items[0], rect, row), state.detail.scroll);
9045
+ renderBlob(screen, rect, renderItemMarkdown(items[0], rect, row), state.detail.scroll);
8983
9046
  return;
8984
9047
  }
8985
9048
  renderListMode(state, screen, rect, items, row);
@@ -8994,13 +9057,19 @@ function renderListMode(state, screen, rect, items, row) {
8994
9057
  const title2 = item.title ?? item.id;
8995
9058
  const prefix = cursor2 ? "\u258C " : " ";
8996
9059
  const badge = item.badge ? ` ${item.badge.text}` : "";
8997
- writeLine2(screen, rect, y, `${prefix}${title2}${badge}`, cursor2 ? styles.borderFocused : styles.accent);
9060
+ writeLine2(
9061
+ screen,
9062
+ rect,
9063
+ y,
9064
+ `${prefix}${title2}${badge}`,
9065
+ cursor2 ? styles.borderFocused : styles.accent
9066
+ );
8998
9067
  y += 1;
8999
9068
  if (item.subtitle && y < rect.height) {
9000
9069
  writeLine2(screen, rect, y, ` ${item.subtitle}`, styles.muted);
9001
9070
  y += 1;
9002
9071
  }
9003
- for (const line of renderItem(item, rect, row).split("\n")) {
9072
+ for (const line of renderItemMarkdown(item, rect, row).split("\n")) {
9004
9073
  if (y >= rect.height) {
9005
9074
  break;
9006
9075
  }
@@ -9020,6 +9089,13 @@ function renderBlob(screen, rect, text5, scroll) {
9020
9089
  writeLine2(screen, rect, row, lines[row] ?? "");
9021
9090
  }
9022
9091
  }
9092
+ function renderItemMarkdown(item, rect, row) {
9093
+ const content = renderItem(item, rect, row);
9094
+ if (content.trim().length === 0) {
9095
+ return "";
9096
+ }
9097
+ return stripAnsi(renderMarkdown(content, { width: Math.max(1, rect.width) }).trimEnd());
9098
+ }
9023
9099
  function renderItem(item, rect, row) {
9024
9100
  if (item.renderedContent !== void 0) {
9025
9101
  return item.renderedContent;
@@ -9048,7 +9124,10 @@ function clamp3(value, min, max) {
9048
9124
  var init_detail = __esm({
9049
9125
  "packages/toolcraft-design/src/explorer/render/detail.ts"() {
9050
9126
  "use strict";
9127
+ init_strip_ansi();
9128
+ init_terminal_markdown();
9051
9129
  init_theme();
9130
+ init_pane();
9052
9131
  init_text2();
9053
9132
  }
9054
9133
  });
@@ -9199,36 +9278,52 @@ function renderList2(state, screen, layout) {
9199
9278
  writeLine3(screen, rect, 0, "Terminal too narrow", styles.muted);
9200
9279
  return;
9201
9280
  }
9202
- const rectKey = `${rect.x}:${rect.y}:${rect.width}:${rect.height}`;
9281
+ drawPaneFrame(
9282
+ screen,
9283
+ rect,
9284
+ "Plans",
9285
+ state.focused === "list" ? styles.borderFocused : styles.border
9286
+ );
9287
+ const bodyRect = paneBodyRect(rect);
9288
+ if (bodyRect.width <= 0 || bodyRect.height <= 0) {
9289
+ return;
9290
+ }
9291
+ const rectKey = `${bodyRect.x}:${bodyRect.y}:${bodyRect.width}:${bodyRect.height}`;
9203
9292
  const cached2 = listLineCache.get(screen);
9204
9293
  const cache2 = cached2?.rectKey === rectKey ? cached2.lines : /* @__PURE__ */ new Map();
9205
9294
  listLineCache.set(screen, { rectKey, lines: cache2 });
9206
9295
  if (state.filtered.length === 0) {
9207
9296
  const hint = state.emptyHint;
9208
- writeLine3(screen, rect, Math.floor(rect.height / 2), centerCells(hint, rect.width, rect.x), styles.muted);
9297
+ writeLine3(
9298
+ screen,
9299
+ bodyRect,
9300
+ Math.floor(bodyRect.height / 2),
9301
+ centerCells(hint, bodyRect.width, bodyRect.x),
9302
+ styles.muted
9303
+ );
9209
9304
  cache2.clear();
9210
9305
  return;
9211
9306
  }
9212
9307
  let lastGroup;
9213
9308
  let y = 0;
9214
9309
  for (const rowIndex of state.filtered) {
9215
- if (y >= rect.height) {
9310
+ if (y >= bodyRect.height) {
9216
9311
  break;
9217
9312
  }
9218
9313
  const row = state.rows[rowIndex];
9219
9314
  if (!row) {
9220
9315
  continue;
9221
9316
  }
9222
- if (row.group && row.group !== lastGroup && y < rect.height) {
9317
+ if (row.group && row.group !== lastGroup && y < bodyRect.height) {
9223
9318
  const hash2 = `group:${row.group}`;
9224
9319
  if (cache2.get(y) !== hash2) {
9225
- writeLine3(screen, rect, y, row.group, styles.muted);
9320
+ writeLine3(screen, bodyRect, y, row.group, styles.muted);
9226
9321
  cache2.set(y, hash2);
9227
9322
  }
9228
9323
  y += 1;
9229
9324
  lastGroup = row.group;
9230
9325
  }
9231
- if (y >= rect.height) {
9326
+ if (y >= bodyRect.height) {
9232
9327
  break;
9233
9328
  }
9234
9329
  const selected = state.multiSelect && state.selected.has(row.id);
@@ -9236,14 +9331,19 @@ function renderList2(state, screen, layout) {
9236
9331
  const positions = state.matchPositions.get(rowIndex) ?? [];
9237
9332
  const hash = lineHash(row, selected, cursor2, positions);
9238
9333
  if (cache2.get(y) !== hash) {
9239
- renderRow(screen, rect, y, row, { selected, cursor: cursor2, focused: state.focused === "list", positions });
9334
+ renderRow(screen, bodyRect, y, row, {
9335
+ selected,
9336
+ cursor: cursor2,
9337
+ focused: state.focused === "list",
9338
+ positions
9339
+ });
9240
9340
  cache2.set(y, hash);
9241
9341
  }
9242
9342
  y += 1;
9243
- if (row.subtitle && y < rect.height) {
9343
+ if (row.subtitle && y < bodyRect.height) {
9244
9344
  const subtitleHash = `${hash}:subtitle:${row.subtitle}`;
9245
9345
  if (cache2.get(y) !== subtitleHash) {
9246
- writeLine3(screen, rect, y, ` ${row.subtitle}`, styles.muted);
9346
+ writeLine3(screen, bodyRect, y, ` ${row.subtitle}`, styles.muted);
9247
9347
  cache2.set(y, subtitleHash);
9248
9348
  }
9249
9349
  y += 1;
@@ -9281,7 +9381,12 @@ function renderRow(screen, rect, rowY, row, opts) {
9281
9381
  x += segment.width;
9282
9382
  }
9283
9383
  if (row.badge) {
9284
- screen.put(rect.x + rect.width - badgeWidth - focusWidth, y, badge, styles.tones[row.badge.tone ?? "muted"]);
9384
+ screen.put(
9385
+ rect.x + rect.width - badgeWidth - focusWidth,
9386
+ y,
9387
+ badge,
9388
+ styles.tones[row.badge.tone ?? "muted"]
9389
+ );
9285
9390
  }
9286
9391
  if (focus) {
9287
9392
  screen.put(rect.x + rect.width - focusWidth, y, focus, styles.borderFocused);
@@ -9306,6 +9411,7 @@ var init_list = __esm({
9306
9411
  "packages/toolcraft-design/src/explorer/render/list.ts"() {
9307
9412
  "use strict";
9308
9413
  init_theme();
9414
+ init_pane();
9309
9415
  init_text2();
9310
9416
  listLineCache = /* @__PURE__ */ new WeakMap();
9311
9417
  }
@@ -9961,7 +10067,14 @@ function updateFilter(state, filter) {
9961
10067
  matchPositions,
9962
10068
  cursor: cursor2,
9963
10069
  detail,
9964
- actionState: recomputeActionState({ ...state, filter, filtered, matchPositions, cursor: cursor2, detail }),
10070
+ actionState: recomputeActionState({
10071
+ ...state,
10072
+ filter,
10073
+ filtered,
10074
+ matchPositions,
10075
+ cursor: cursor2,
10076
+ detail
10077
+ }),
9965
10078
  dirty: REGION_HEADER | REGION_LIST | REGION_DETAIL | REGION_FOOTER
9966
10079
  };
9967
10080
  const effect = detailEffect(next);
@@ -9992,7 +10105,11 @@ function escape(state, runtimeHandles) {
9992
10105
  if (state.filterFocused || state.filter.length > 0) {
9993
10106
  const cleared = updateFilter({ ...state, filterFocused: false }, "");
9994
10107
  return {
9995
- state: { ...cleared.state, filterFocused: false, dirty: cleared.state.dirty | REGION_HEADER | REGION_FOOTER },
10108
+ state: {
10109
+ ...cleared.state,
10110
+ filterFocused: false,
10111
+ dirty: cleared.state.dirty | REGION_HEADER | REGION_FOOTER
10112
+ },
9996
10113
  effects: cleared.effects
9997
10114
  };
9998
10115
  }
@@ -10106,9 +10223,9 @@ function detailBodyHeight(state) {
10106
10223
  if (state.layout === "narrow-vertical") {
10107
10224
  const listHeight = Math.ceil(contentHeight / 2);
10108
10225
  const detailHeight = contentHeight - listHeight;
10109
- return Math.max(0, detailHeight - 1);
10226
+ return Math.max(0, detailHeight - 2);
10110
10227
  }
10111
- return contentHeight;
10228
+ return Math.max(0, contentHeight - 2);
10112
10229
  }
10113
10230
  function extendSelection(state, delta2) {
10114
10231
  if (!state.multiSelect) {
@@ -10163,7 +10280,10 @@ function reorder(state, delta2) {
10163
10280
  actionState: recomputeActionState({ ...state, rows, filtered, matchPositions, cursor: cursor2 }),
10164
10281
  dirty: REGION_LIST | REGION_FOOTER
10165
10282
  };
10166
- return { state: next, effects: [{ type: "persistOrder", orderedIds: rows.map((row) => row.id) }] };
10283
+ return {
10284
+ state: next,
10285
+ effects: [{ type: "persistOrder", orderedIds: rows.map((row) => row.id) }]
10286
+ };
10167
10287
  }
10168
10288
  function paletteInput(state, key2) {
10169
10289
  if (state.modal?.kind !== "palette") {
@@ -10207,7 +10327,12 @@ function dispatchPaletteAction(state, runtimeHandles) {
10207
10327
  if (entry === void 0) {
10208
10328
  return mark(state, 0);
10209
10329
  }
10210
- return dispatchActionById({ ...state, modal: null, dirty: REGION_MODAL | REGION_FOOTER }, entry.id, false, runtimeHandles);
10330
+ return dispatchActionById(
10331
+ { ...state, modal: null, dirty: REGION_MODAL | REGION_FOOTER },
10332
+ entry.id,
10333
+ false,
10334
+ runtimeHandles
10335
+ );
10211
10336
  }
10212
10337
  function dispatchPrimary(state, runtimeHandles) {
10213
10338
  for (const [id, entry] of state.actionState.entries()) {
@@ -10250,13 +10375,15 @@ function dispatchAction(state, action, confirmed, runtimeHandles, modalRows) {
10250
10375
  effects: [
10251
10376
  {
10252
10377
  type: "suspend",
10253
- fn: async () => action.handler(buildActionContext(
10254
- next,
10255
- action,
10256
- current?.source ?? actionSource(next, action),
10257
- runtimeHandles,
10258
- rows
10259
- )),
10378
+ fn: async () => action.handler(
10379
+ buildActionContext(
10380
+ next,
10381
+ action,
10382
+ current?.source ?? actionSource(next, action),
10383
+ runtimeHandles,
10384
+ rows
10385
+ )
10386
+ ),
10260
10387
  resumeWith: () => ({ type: "actionResolved", actionId: action.id })
10261
10388
  }
10262
10389
  ]
@@ -138786,7 +138913,7 @@ var init_package2 = __esm({
138786
138913
  "package.json"() {
138787
138914
  package_default2 = {
138788
138915
  name: "poe-code",
138789
- version: "3.0.394",
138916
+ version: "3.0.395",
138790
138917
  description: "CLI tool to configure Poe API for developer workflows.",
138791
138918
  type: "module",
138792
138919
  main: "./dist/index.js",