meow 2
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* Model cost display extension - shows cost info in status bar.
|
||||||
|
*
|
||||||
|
* Format: "$X.XX (Y.YY) in" where Y.YY is cache write cost if present.
|
||||||
|
*
|
||||||
|
* Usage: pi -e ./model-cost.ts
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type {
|
||||||
|
ExtensionAPI,
|
||||||
|
ModelSelectEvent,
|
||||||
|
UIContext,
|
||||||
|
} from "@earendil-works/pi-coding-agent";
|
||||||
|
|
||||||
|
export default function (pi: ExtensionAPI) {
|
||||||
|
const modelSelectHandler = async (
|
||||||
|
event: ModelSelectEvent,
|
||||||
|
ctx: UIContext,
|
||||||
|
) => {
|
||||||
|
const { model } = event;
|
||||||
|
|
||||||
|
// Get cost data from model config
|
||||||
|
const cost = getModelCost(model);
|
||||||
|
|
||||||
|
if (cost) {
|
||||||
|
ctx.ui.setStatus("model", cost);
|
||||||
|
} else {
|
||||||
|
ctx.ui.setStatus("model", "");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
pi.on("model_select", modelSelectHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getModelCost(model: any): string {
|
||||||
|
if (!model?.cost) return "";
|
||||||
|
|
||||||
|
const { input, output, cacheRead, cacheWrite } = model.cost;
|
||||||
|
|
||||||
|
// Only show if there's actual cost data
|
||||||
|
const hasCost =
|
||||||
|
input !== 0 || output !== 0 || cacheRead !== 0 || cacheWrite !== 0;
|
||||||
|
if (!hasCost) return "";
|
||||||
|
|
||||||
|
// Format: "$X.XX (Y.YY) in"
|
||||||
|
const parts: string[] = [];
|
||||||
|
|
||||||
|
if (input !== 0) {
|
||||||
|
const cachePrefix = cacheRead > 0 ? ` (↙${cacheRead}) ` : "";
|
||||||
|
parts.push(`$${input}${cachePrefix}in`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output !== 0) {
|
||||||
|
const cachePrefix = cacheWrite > 0 ? ` (↗${cacheWrite}) ` : "";
|
||||||
|
parts.push(`$${output}${cachePrefix}out`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parts.length === 0) return "";
|
||||||
|
|
||||||
|
return parts.join(" / ");
|
||||||
|
}
|
||||||
@@ -188,7 +188,12 @@
|
|||||||
home.file.".pi/agent/extensions/model-filter.ts" = {
|
home.file.".pi/agent/extensions/model-filter.ts" = {
|
||||||
source = ./model-filter.ts;
|
source = ./model-filter.ts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Show model cost in status bar
|
||||||
|
home.file.".pi/agent/extensions/model-cost.ts" = {
|
||||||
|
source = ./model-cost.ts;
|
||||||
|
};
|
||||||
|
|
||||||
# Model filter config: per-provider filters applied by model-filter.ts
|
# Model filter config: per-provider filters applied by model-filter.ts
|
||||||
home.file.".pi/agent/model-filters.json" = {
|
home.file.".pi/agent/model-filters.json" = {
|
||||||
text = builtins.toJSON {
|
text = builtins.toJSON {
|
||||||
|
|||||||
Reference in New Issue
Block a user