Lines 155-195typescript
155 if (realArgvPath.endsWith("/dist/cli.js")) {
156 candidates.push(join(dirname(realArgvPath), "index.js"));
161 join(dirname(process.execPath), "..", "lib", "node_modules", "@earendil-works", "pi-coding-agent", "dist", "index.js"),
165 candidates.push(maybeFileUrlToPath(import.meta.resolve("@earendil-works/pi-coding-agent")));
168 const entryPath = candidates.find((candidate) => existsSync(candidate));
169 if (!entryPath) throw new Error("Could not resolve pi-coding-agent entry path");
173async function installSilentHiddenThinkingPatch(): Promise<void> {
174 const entryPath = resolvePiCodingAgentEntryPath();
175 const componentPath = join(dirname(entryPath), "modes", "interactive", "components", "assistant-message.js");
176 const mod = await import(pathToFileURL(componentPath).href) as {
177 AssistantMessageComponent?: AssistantMessageComponentCtor;
MediumDynamic Require
Package source references dynamic require/import behavior.
packages/pi-extensions/extensions/xtrm-ui/index.tsView on unpkg · L175 179 const proto = mod.AssistantMessageComponent?.prototype as
180 | (AssistantMessageComponentCtor["prototype"] & { [PATCHED_ASSISTANT_MESSAGE]?: boolean })
182 if (!proto?.updateContent || proto[PATCHED_ASSISTANT_MESSAGE]) return;
184 const updateContent = proto.updateContent;
185 proto.updateContent = function patchedUpdateContent(this: PatchableAssistantMessage, message: AssistantMessageLike) {
186 if (this.hiddenThinkingLabel === "" && Array.isArray(message.content)) {
187 if (!this.__xtrmThinkingExpanded) {
188 updateContent.call(this, {
190 content: message.content.filter((block) => block.type !== "thinking" || !block.thinking?.trim()),
195 const previousHideThinking = this.hideThinkingBlock;