pi-ask-user 0.11.0 → 0.11.1
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/index.ts +32 -8
- package/package.json +3 -3
package/index.ts
CHANGED
|
@@ -52,6 +52,36 @@ function StringEnum<const T extends readonly string[]>(
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* `getMarkdownTheme()` returns a bag of closures that read through a Proxy
|
|
57
|
+
* over the host's theme singleton. The Proxy only throws on property access,
|
|
58
|
+
* not when the bag itself is constructed — so a naive
|
|
59
|
+
* `try { getMarkdownTheme() } catch {}` silently lets a broken bag escape
|
|
60
|
+
* and crashes mid-render the first time pi-tui's Markdown calls
|
|
61
|
+
* `mdTheme.bold(...)`.
|
|
62
|
+
*
|
|
63
|
+
* That broken-bag scenario shows up whenever this extension's bundled copy
|
|
64
|
+
* of `@earendil-works/pi-coding-agent` is a different module instance than
|
|
65
|
+
* the host's — e.g. an older Pi still on the legacy
|
|
66
|
+
* `@mariozechner/pi-coding-agent` scope (≤ 0.73.1) where npm cannot dedupe
|
|
67
|
+
* across scopes, so our copy's theme singleton is never initialised
|
|
68
|
+
* (`globalThis[Symbol.for("@earendil-works/pi-coding-agent:theme")]` is
|
|
69
|
+
* undefined). See https://github.com/edlsh/pi-ask-user/issues/17.
|
|
70
|
+
*
|
|
71
|
+
* Probe `bold("")` to force the Proxy lookup eagerly; on throw, callers
|
|
72
|
+
* fall back to plain `Text` rendering for context blocks.
|
|
73
|
+
*/
|
|
74
|
+
function safeMarkdownTheme(): MarkdownTheme | undefined {
|
|
75
|
+
try {
|
|
76
|
+
const md = getMarkdownTheme();
|
|
77
|
+
if (!md) return undefined;
|
|
78
|
+
md.bold("");
|
|
79
|
+
return md;
|
|
80
|
+
} catch {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
55
85
|
type AskOptionInput = QuestionOption | string;
|
|
56
86
|
|
|
57
87
|
type AskDisplayMode = "overlay" | "inline";
|
|
@@ -785,10 +815,7 @@ class WrappedSingleSelectList implements Component {
|
|
|
785
815
|
private buildPreviewLines(width: number, filteredOptions: QuestionOption[], maxLines: number): string[] {
|
|
786
816
|
if (maxLines <= 0) return [];
|
|
787
817
|
|
|
788
|
-
|
|
789
|
-
try {
|
|
790
|
-
mdTheme = getMarkdownTheme();
|
|
791
|
-
} catch { }
|
|
818
|
+
const mdTheme = safeMarkdownTheme();
|
|
792
819
|
|
|
793
820
|
let md = "";
|
|
794
821
|
|
|
@@ -1042,10 +1069,7 @@ class AskComponent extends Container {
|
|
|
1042
1069
|
|
|
1043
1070
|
if (this.context) {
|
|
1044
1071
|
this.addChild(new Spacer(1));
|
|
1045
|
-
|
|
1046
|
-
try {
|
|
1047
|
-
mdTheme = getMarkdownTheme();
|
|
1048
|
-
} catch { }
|
|
1072
|
+
const mdTheme = safeMarkdownTheme();
|
|
1049
1073
|
if (mdTheme) {
|
|
1050
1074
|
this.contextComponent = new Markdown("", 1, 0, mdTheme);
|
|
1051
1075
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-ask-user",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Interactive ask_user tool for pi-coding-agent with searchable split-pane selection UI, multi-select, and freeform input",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"check": "npm pack --dry-run"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@earendil-works/pi-coding-agent": "
|
|
48
|
-
"@earendil-works/pi-tui": "
|
|
47
|
+
"@earendil-works/pi-coding-agent": ">=0.74.0",
|
|
48
|
+
"@earendil-works/pi-tui": ">=0.74.0",
|
|
49
49
|
"@sinclair/typebox": "*"
|
|
50
50
|
}
|
|
51
51
|
}
|