poe-code 5.0.2 → 5.0.4
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 +76 -85
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/dist/providers/poe-agent.js +14 -2
- package/dist/providers/poe-agent.js.map +4 -4
- package/package.json +1 -1
- package/packages/toolcraft-design/dist/explorer/detail-content.d.ts +6 -0
- package/packages/toolcraft-design/dist/explorer/detail-content.js +32 -0
- package/packages/toolcraft-design/dist/explorer/layout.d.ts +1 -0
- package/packages/toolcraft-design/dist/explorer/layout.js +8 -0
- package/packages/toolcraft-design/dist/explorer/reducer.js +8 -19
- package/packages/toolcraft-design/dist/explorer/render/detail.d.ts +1 -1
- package/packages/toolcraft-design/dist/explorer/render/detail.js +22 -54
- package/packages/toolcraft-design/dist/explorer/render/pane.d.ts +1 -1
- package/packages/toolcraft-design/dist/explorer/render/pane.js +1 -8
package/dist/index.js
CHANGED
|
@@ -10952,6 +10952,14 @@ function computeExplorerLayout(opts) {
|
|
|
10952
10952
|
footer
|
|
10953
10953
|
};
|
|
10954
10954
|
}
|
|
10955
|
+
function paneBodyRect(rect) {
|
|
10956
|
+
return {
|
|
10957
|
+
x: rect.x + 2,
|
|
10958
|
+
y: rect.y + 1,
|
|
10959
|
+
width: Math.max(0, rect.width - 4),
|
|
10960
|
+
height: Math.max(0, rect.height - 2)
|
|
10961
|
+
};
|
|
10962
|
+
}
|
|
10955
10963
|
function resolveMode(cols, rows) {
|
|
10956
10964
|
if (cols < 60 || rows < 8) {
|
|
10957
10965
|
return "too-narrow";
|
|
@@ -11302,6 +11310,43 @@ var init_ansi_text = __esm({
|
|
|
11302
11310
|
}
|
|
11303
11311
|
});
|
|
11304
11312
|
|
|
11313
|
+
// packages/toolcraft-design/src/explorer/detail-content.ts
|
|
11314
|
+
function prepareDetailContent(content, width) {
|
|
11315
|
+
if (content.trim().length === 0) {
|
|
11316
|
+
return { text: "", lines: [[]] };
|
|
11317
|
+
}
|
|
11318
|
+
width = Math.max(1, width);
|
|
11319
|
+
const key3 = `${contentHash(content)}:${width}`;
|
|
11320
|
+
const cached2 = markdownCache.get(key3);
|
|
11321
|
+
if (cached2 !== void 0) return cached2;
|
|
11322
|
+
const text5 = renderMarkdown(content, { width }).trimEnd();
|
|
11323
|
+
const lines = [[]];
|
|
11324
|
+
for (const cell2 of ansiToCells(text5)) {
|
|
11325
|
+
if (cell2.ch === "\n") lines.push([]);
|
|
11326
|
+
else lines.at(-1).push(cell2);
|
|
11327
|
+
}
|
|
11328
|
+
const prepared = { text: text5, lines };
|
|
11329
|
+
markdownCache.set(key3, prepared);
|
|
11330
|
+
return prepared;
|
|
11331
|
+
}
|
|
11332
|
+
function contentHash(content) {
|
|
11333
|
+
let hash = 2166136261;
|
|
11334
|
+
for (let index = 0; index < content.length; index += 1) {
|
|
11335
|
+
hash ^= content.charCodeAt(index);
|
|
11336
|
+
hash = Math.imul(hash, 16777619);
|
|
11337
|
+
}
|
|
11338
|
+
return hash >>> 0;
|
|
11339
|
+
}
|
|
11340
|
+
var markdownCache;
|
|
11341
|
+
var init_detail_content = __esm({
|
|
11342
|
+
"packages/toolcraft-design/src/explorer/detail-content.ts"() {
|
|
11343
|
+
"use strict";
|
|
11344
|
+
init_ansi_text();
|
|
11345
|
+
init_terminal_markdown();
|
|
11346
|
+
markdownCache = /* @__PURE__ */ new Map();
|
|
11347
|
+
}
|
|
11348
|
+
});
|
|
11349
|
+
|
|
11305
11350
|
// packages/toolcraft-design/src/explorer/render/text.ts
|
|
11306
11351
|
function cellWidth(value, startColumn = 0) {
|
|
11307
11352
|
return displayWidth2(value, startColumn);
|
|
@@ -11421,18 +11466,11 @@ function drawPaneFrame(screen, rect, title2, style = {}, options = {}) {
|
|
|
11421
11466
|
screen.put(rect.x, rect.y + rect.height - 1, `${options.focused ? "\u2517" : "\u2514"}${horizontal.repeat(innerWidth)}${options.focused ? "\u251B" : "\u2518"}`, style);
|
|
11422
11467
|
}
|
|
11423
11468
|
}
|
|
11424
|
-
function paneBodyRect(rect) {
|
|
11425
|
-
return {
|
|
11426
|
-
x: rect.x + 2,
|
|
11427
|
-
y: rect.y + 1,
|
|
11428
|
-
width: Math.max(0, rect.width - 4),
|
|
11429
|
-
height: Math.max(0, rect.height - 2)
|
|
11430
|
-
};
|
|
11431
|
-
}
|
|
11432
11469
|
var init_pane = __esm({
|
|
11433
11470
|
"packages/toolcraft-design/src/explorer/render/pane.ts"() {
|
|
11434
11471
|
"use strict";
|
|
11435
11472
|
init_text2();
|
|
11473
|
+
init_layout2();
|
|
11436
11474
|
}
|
|
11437
11475
|
});
|
|
11438
11476
|
|
|
@@ -11447,50 +11485,40 @@ function renderDetail(state, screen, layout) {
|
|
|
11447
11485
|
const row = state.rows.find((r) => r.id === state.detail.rowId) ?? null;
|
|
11448
11486
|
const pane = state.paneDefinitions[1];
|
|
11449
11487
|
const title2 = pane?.titleForRow?.(row ?? void 0) ?? pane?.title ?? "Preview";
|
|
11450
|
-
|
|
11451
|
-
drawPaneFrame(
|
|
11452
|
-
screen,
|
|
11453
|
-
rect,
|
|
11454
|
-
title2,
|
|
11455
|
-
state.focused === "detail" ? styles.borderFocused : styles.border,
|
|
11456
|
-
{ focused: state.focused === "detail", indicator: scrollIndicator(state) }
|
|
11457
|
-
);
|
|
11458
|
-
renderDetailBody(state, screen, paneBodyRect(rect), row);
|
|
11459
|
-
return;
|
|
11460
|
-
}
|
|
11488
|
+
const { start, max } = renderDetailBody(state, screen, paneBodyRect(rect), row);
|
|
11461
11489
|
drawPaneFrame(
|
|
11462
11490
|
screen,
|
|
11463
11491
|
rect,
|
|
11464
11492
|
title2,
|
|
11465
11493
|
state.focused === "detail" ? styles.borderFocused : styles.border,
|
|
11466
|
-
{ focused: state.focused === "detail", indicator: scrollIndicator(state) }
|
|
11494
|
+
{ focused: state.focused === "detail", indicator: scrollIndicator(state, start, max) }
|
|
11467
11495
|
);
|
|
11468
|
-
renderDetailBody(state, screen, paneBodyRect(rect), row);
|
|
11469
11496
|
}
|
|
11470
11497
|
function renderDetailBody(state, screen, rect, row) {
|
|
11471
11498
|
const styles = getExplorerStyles();
|
|
11472
11499
|
const items = state.detail.items;
|
|
11473
11500
|
if (rect.width <= 0 || rect.height <= 0) {
|
|
11474
|
-
return;
|
|
11501
|
+
return { start: 0, max: 0 };
|
|
11475
11502
|
}
|
|
11476
11503
|
if (items === null) {
|
|
11477
11504
|
writeLine2(screen, rect, 0, row === null ? state.emptyHint : "Loading detail...", styles.muted);
|
|
11478
|
-
return;
|
|
11505
|
+
return { start: 0, max: 0 };
|
|
11479
11506
|
}
|
|
11480
11507
|
if (items.length === 0) {
|
|
11481
11508
|
writeLine2(screen, rect, 0, state.emptyHint, styles.muted);
|
|
11482
|
-
return;
|
|
11509
|
+
return { start: 0, max: 0 };
|
|
11483
11510
|
}
|
|
11484
11511
|
if (items.length === 1 && items[0]?.title === void 0) {
|
|
11485
|
-
|
|
11486
|
-
return;
|
|
11512
|
+
const content = prepareDetailContent(renderItem(items[0], rect, row), rect.width);
|
|
11513
|
+
return renderBlob(screen, rect, content.lines, state.detail.scroll);
|
|
11487
11514
|
}
|
|
11488
|
-
renderListMode(state, screen, rect, items, row);
|
|
11515
|
+
return renderListMode(state, screen, rect, items, row);
|
|
11489
11516
|
}
|
|
11490
11517
|
function renderListMode(state, screen, rect, items, row) {
|
|
11491
11518
|
const styles = getExplorerStyles();
|
|
11492
11519
|
let y = 0;
|
|
11493
|
-
const
|
|
11520
|
+
const max = Math.max(0, items.length - 1);
|
|
11521
|
+
const start = clamp3(state.detail.scroll, 0, max);
|
|
11494
11522
|
for (let index = start; index < items.length && y < rect.height; index += 1) {
|
|
11495
11523
|
const item = items[index];
|
|
11496
11524
|
const cursor2 = index === state.detail.cursor;
|
|
@@ -11510,7 +11538,8 @@ function renderListMode(state, screen, rect, items, row) {
|
|
|
11510
11538
|
writeLine2(screen, rect, y, ` ${item.subtitle}`, styles.muted);
|
|
11511
11539
|
y += 1;
|
|
11512
11540
|
}
|
|
11513
|
-
|
|
11541
|
+
const content = prepareDetailContent(renderItem(item, rect, row), rect.width);
|
|
11542
|
+
for (const line of content.text.split("\n")) {
|
|
11514
11543
|
if (y >= rect.height) {
|
|
11515
11544
|
break;
|
|
11516
11545
|
}
|
|
@@ -11521,14 +11550,11 @@ function renderListMode(state, screen, rect, items, row) {
|
|
|
11521
11550
|
y += 1;
|
|
11522
11551
|
}
|
|
11523
11552
|
}
|
|
11553
|
+
return { start, max };
|
|
11524
11554
|
}
|
|
11525
|
-
function renderBlob(screen, rect,
|
|
11526
|
-
const
|
|
11527
|
-
|
|
11528
|
-
if (cell2.ch === "\n") allLines.push([]);
|
|
11529
|
-
else allLines.at(-1).push(cell2);
|
|
11530
|
-
}
|
|
11531
|
-
const start = clamp3(scroll, 0, Math.max(0, allLines.length - rect.height));
|
|
11555
|
+
function renderBlob(screen, rect, allLines, scroll) {
|
|
11556
|
+
const max = Math.max(0, allLines.length - rect.height);
|
|
11557
|
+
const start = clamp3(scroll, 0, max);
|
|
11532
11558
|
const lines = allLines.slice(start);
|
|
11533
11559
|
for (let row = 0; row < rect.height; row += 1) {
|
|
11534
11560
|
let x = rect.x;
|
|
@@ -11538,19 +11564,7 @@ function renderBlob(screen, rect, text5, scroll) {
|
|
|
11538
11564
|
x += cell2.width;
|
|
11539
11565
|
}
|
|
11540
11566
|
}
|
|
11541
|
-
}
|
|
11542
|
-
function renderItemMarkdown(item, rect, row) {
|
|
11543
|
-
const content = renderItem(item, rect, row);
|
|
11544
|
-
if (content.trim().length === 0) {
|
|
11545
|
-
return "";
|
|
11546
|
-
}
|
|
11547
|
-
const width = Math.max(1, rect.width);
|
|
11548
|
-
const key3 = `${contentHash(content)}:${width}`;
|
|
11549
|
-
const cached2 = markdownCache.get(key3);
|
|
11550
|
-
if (cached2 !== void 0) return cached2;
|
|
11551
|
-
const rendered = renderMarkdown(content, { width }).trimEnd();
|
|
11552
|
-
markdownCache.set(key3, rendered);
|
|
11553
|
-
return rendered;
|
|
11567
|
+
return { start, max };
|
|
11554
11568
|
}
|
|
11555
11569
|
function renderItem(item, rect, row) {
|
|
11556
11570
|
if (item.renderedContent !== void 0) {
|
|
@@ -11577,30 +11591,18 @@ function writeLine2(screen, rect, row, text5, style = {}) {
|
|
|
11577
11591
|
function clamp3(value, min, max) {
|
|
11578
11592
|
return Math.min(max, Math.max(min, value));
|
|
11579
11593
|
}
|
|
11580
|
-
function scrollIndicator(state) {
|
|
11594
|
+
function scrollIndicator(state, start, max) {
|
|
11581
11595
|
if (state.detail.loading) return "\u280B";
|
|
11582
|
-
|
|
11583
|
-
const total2 = Math.max(1, content.split("\n").length);
|
|
11584
|
-
return `${Math.min(100, Math.round(state.detail.scroll / Math.max(1, total2 - 1) * 100))}%`;
|
|
11585
|
-
}
|
|
11586
|
-
function contentHash(content) {
|
|
11587
|
-
let hash = 2166136261;
|
|
11588
|
-
for (let index = 0; index < content.length; index += 1) {
|
|
11589
|
-
hash ^= content.charCodeAt(index);
|
|
11590
|
-
hash = Math.imul(hash, 16777619);
|
|
11591
|
-
}
|
|
11592
|
-
return hash >>> 0;
|
|
11596
|
+
return `${max === 0 ? 0 : Math.round(start / max * 100)}%`;
|
|
11593
11597
|
}
|
|
11594
|
-
var markdownCache;
|
|
11595
11598
|
var init_detail = __esm({
|
|
11596
11599
|
"packages/toolcraft-design/src/explorer/render/detail.ts"() {
|
|
11597
11600
|
"use strict";
|
|
11598
|
-
|
|
11599
|
-
|
|
11601
|
+
init_detail_content();
|
|
11602
|
+
init_layout2();
|
|
11600
11603
|
init_theme();
|
|
11601
11604
|
init_pane();
|
|
11602
11605
|
init_text2();
|
|
11603
|
-
markdownCache = /* @__PURE__ */ new Map();
|
|
11604
11606
|
}
|
|
11605
11607
|
});
|
|
11606
11608
|
|
|
@@ -12937,31 +12939,18 @@ function maxDetailScroll(state) {
|
|
|
12937
12939
|
return 0;
|
|
12938
12940
|
}
|
|
12939
12941
|
if (items.length === 1 && items[0]?.title === void 0) {
|
|
12940
|
-
const
|
|
12941
|
-
|
|
12942
|
+
const body = paneBodyRect(computeExplorerLayout({ ...state.size, focused: state.focused }).detail);
|
|
12943
|
+
const content = items[0]?.renderedContent;
|
|
12944
|
+
if (body.width <= 0 || body.height <= 0 || content === void 0) {
|
|
12942
12945
|
return 0;
|
|
12943
12946
|
}
|
|
12944
|
-
return Math.max(0,
|
|
12947
|
+
return Math.max(0, prepareDetailContent(content, body.width).lines.length - body.height);
|
|
12945
12948
|
}
|
|
12946
12949
|
return Math.max(0, items.length - 1);
|
|
12947
12950
|
}
|
|
12948
|
-
function detailContentLineCount(item) {
|
|
12949
|
-
return (item.renderedContent ?? "").split("\n").length;
|
|
12950
|
-
}
|
|
12951
12951
|
function detailBodyHeight(state) {
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
}
|
|
12955
|
-
const rows = normalizeSize6(state.size.rows);
|
|
12956
|
-
const footerHeight = rows > 0 ? Math.min(1, rows) : 0;
|
|
12957
|
-
const headerHeight = Math.min(3, Math.max(0, rows - footerHeight));
|
|
12958
|
-
const contentHeight = Math.max(0, rows - headerHeight - footerHeight);
|
|
12959
|
-
if (state.layout === "narrow-vertical") {
|
|
12960
|
-
const listHeight = Math.ceil(contentHeight / 2);
|
|
12961
|
-
const detailHeight = contentHeight - listHeight;
|
|
12962
|
-
return Math.max(0, detailHeight - 2);
|
|
12963
|
-
}
|
|
12964
|
-
return Math.max(0, contentHeight - 2);
|
|
12952
|
+
const body = paneBodyRect(computeExplorerLayout({ ...state.size, focused: state.focused }).detail);
|
|
12953
|
+
return body.width > 0 ? body.height : 0;
|
|
12965
12954
|
}
|
|
12966
12955
|
function extendSelection(state, delta2) {
|
|
12967
12956
|
if (!state.multiSelect) {
|
|
@@ -13280,7 +13269,9 @@ var init_reducer = __esm({
|
|
|
13280
13269
|
"use strict";
|
|
13281
13270
|
init_terminal_width();
|
|
13282
13271
|
init_actions();
|
|
13272
|
+
init_detail_content();
|
|
13283
13273
|
init_filter();
|
|
13274
|
+
init_layout2();
|
|
13284
13275
|
init_state();
|
|
13285
13276
|
NO_EFFECTS = [];
|
|
13286
13277
|
DEFAULT_ACTION_HANDLES = {
|
|
@@ -154221,7 +154212,7 @@ var init_package2 = __esm({
|
|
|
154221
154212
|
"package.json"() {
|
|
154222
154213
|
package_default2 = {
|
|
154223
154214
|
name: "poe-code",
|
|
154224
|
-
version: "5.0.
|
|
154215
|
+
version: "5.0.4",
|
|
154225
154216
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
154226
154217
|
license: "MIT",
|
|
154227
154218
|
type: "module",
|