Add mechanicus-thinking-label extension
Monkey-patches AssistantMessageComponent.updateContent to swap the default "Thinking..." label for "Cogitating..." when reasoning blocks are folded. Only replaces the default — if any code path sets its own label, we leave it alone. Override via PI_THINKING_LABEL env var. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,5 +13,6 @@
|
||||
!/local-llama.ts
|
||||
!/markdown-body-color.ts
|
||||
!/mechanicus-banner.ts
|
||||
!/mechanicus-thinking-label.ts
|
||||
!/scripts/
|
||||
!/themes/
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* mechanicus-thinking-label — replace pi's "Thinking..." label with a
|
||||
* dark-mechanicum one when assistant reasoning blocks are folded.
|
||||
*
|
||||
* pi's AssistantMessageComponent stores the label as an instance field
|
||||
* initialised from the constructor default. pi-coding-agent never
|
||||
* overrides it in its own code paths, so we can monkey-patch
|
||||
* updateContent() to swap the default before rendering.
|
||||
*
|
||||
* Override via env var: PI_THINKING_LABEL="Cogitating…"
|
||||
*/
|
||||
|
||||
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||
import { AssistantMessageComponent } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
const DEFAULT_LABEL = "Thinking...";
|
||||
const LABEL = process.env.PI_THINKING_LABEL ?? "Cogitating...";
|
||||
|
||||
let patched = false;
|
||||
|
||||
export default function (_pi: ExtensionAPI) {
|
||||
if (patched) return;
|
||||
patched = true;
|
||||
|
||||
const proto = AssistantMessageComponent.prototype as any;
|
||||
const origUpdate = proto.updateContent;
|
||||
|
||||
proto.updateContent = function (message: unknown) {
|
||||
if (this.hiddenThinkingLabel === DEFAULT_LABEL) {
|
||||
this.hiddenThinkingLabel = LABEL;
|
||||
}
|
||||
return origUpdate.call(this, message);
|
||||
};
|
||||
|
||||
console.log(`[mechanicus-thinking-label] "${DEFAULT_LABEL}" -> "${LABEL}"`);
|
||||
}
|
||||
Reference in New Issue
Block a user