better configs
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "pi-extensions",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.7.0",
|
||||
"@mariozechner/pi-coding-agent": "^0.55.3",
|
||||
"@mariozechner/pi-tui": "^0.55.3",
|
||||
"@mariozechner/pi-ai": "^0.55.3",
|
||||
"@sinclair/typebox": "^0.34.0"
|
||||
}
|
||||
}
|
||||
Generated
+2653
File diff suppressed because it is too large
Load Diff
@@ -16,131 +16,146 @@ let turnStartTime: number | null = null;
|
||||
let lastTurnDuration: number | null = null;
|
||||
|
||||
function formatTime(date: Date): string {
|
||||
return date.toLocaleTimeString("en-US", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
hour12: false,
|
||||
});
|
||||
return date.toLocaleTimeString("en-US", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
hour12: false,
|
||||
});
|
||||
}
|
||||
|
||||
function formatElapsed(ms: number): string {
|
||||
const seconds = Math.floor(ms / 1000);
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const seconds = Math.floor(ms / 1000);
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const hours = Math.floor(minutes / 60);
|
||||
|
||||
if (hours > 0) return `${hours}h ${minutes % 60}m`;
|
||||
if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
|
||||
return `${seconds}s`;
|
||||
if (hours > 0) return `${hours}h ${minutes % 60}m`;
|
||||
if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
|
||||
return `${seconds}s`;
|
||||
}
|
||||
|
||||
function formatDuration(ms: number): string {
|
||||
if (ms < 1000) return `${ms}ms`;
|
||||
if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
|
||||
return `${(ms / 60000).toFixed(1)}m`;
|
||||
if (ms < 1000) return `${ms}ms`;
|
||||
if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
|
||||
return `${(ms / 60000).toFixed(1)}m`;
|
||||
}
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
const updateStatus = (ctx: { ui: { setStatus: (id: string, text: string | undefined) => void; theme: { fg: (color: string, text: string) => string } } }) => {
|
||||
const elapsed = Date.now() - sessionStart;
|
||||
let status = ctx.ui.theme.fg("dim", `⏱ ${formatElapsed(elapsed)}`);
|
||||
if (lastTurnDuration !== null) {
|
||||
status += ctx.ui.theme.fg("muted", ` | took ${formatDuration(lastTurnDuration)}`);
|
||||
}
|
||||
ctx.ui.setStatus("timestamps", status);
|
||||
};
|
||||
const updateStatus = (ctx: {
|
||||
ui: {
|
||||
setStatus: (id: string, text: string | undefined) => void;
|
||||
theme: { fg: (color: string, text: string) => string };
|
||||
};
|
||||
}) => {
|
||||
const elapsed = Date.now() - sessionStart;
|
||||
let status = ctx.ui.theme.fg("dim", `⏱ ${formatElapsed(elapsed)}`);
|
||||
if (lastTurnDuration !== null) {
|
||||
status += ctx.ui.theme.fg(
|
||||
"muted",
|
||||
` | took ${formatDuration(lastTurnDuration)}`,
|
||||
);
|
||||
}
|
||||
ctx.ui.setStatus("timestamps", status);
|
||||
};
|
||||
|
||||
// Renderer for user timestamp
|
||||
pi.registerMessageRenderer("timestamp-prefix", (message, _options, theme) => {
|
||||
const details = message.details as { timestamp: number; elapsed: string } | undefined;
|
||||
if (!details) return new Text("");
|
||||
// Renderer for user timestamp
|
||||
pi.registerMessageRenderer("timestamp-prefix", (message, _options, theme) => {
|
||||
const details = message.details as
|
||||
| { timestamp: number; elapsed: string }
|
||||
| undefined;
|
||||
if (!details) return new Text("");
|
||||
|
||||
const timeStr = formatTime(new Date(details.timestamp));
|
||||
const line = theme.fg("dim", `◆ ${timeStr} (+${details.elapsed})`);
|
||||
const box = new Box(0, 0, undefined);
|
||||
box.addChild(new Text(line, 0, 0));
|
||||
return box;
|
||||
});
|
||||
const timeStr = formatTime(new Date(details.timestamp));
|
||||
const line = theme.fg("dim", ` ◆ ${timeStr} (+${details.elapsed})`);
|
||||
const box = new Box(0, 0, undefined);
|
||||
box.addChild(new Text(line, 0, 0));
|
||||
return box;
|
||||
});
|
||||
|
||||
// Renderer for legacy timestamp-suffix messages (from old sessions)
|
||||
pi.registerMessageRenderer("timestamp-suffix", (message, _options, theme) => {
|
||||
const details = message.details as { timestamp: number; elapsed: string; duration?: number } | undefined;
|
||||
if (!details) return new Text("");
|
||||
// Renderer for legacy timestamp-suffix messages (from old sessions)
|
||||
pi.registerMessageRenderer("timestamp-suffix", (message, _options, theme) => {
|
||||
const details = message.details as
|
||||
| { timestamp: number; elapsed: string; duration?: number }
|
||||
| undefined;
|
||||
if (!details) return new Text("");
|
||||
|
||||
const timeStr = formatTime(new Date(details.timestamp));
|
||||
let line = `○ ${timeStr} (+${details.elapsed})`;
|
||||
if (details.duration && details.duration > 1000) {
|
||||
line += ` • took ${formatDuration(details.duration)}`;
|
||||
}
|
||||
const timeStr = formatTime(new Date(details.timestamp));
|
||||
let line = `○ ${timeStr} (+${details.elapsed})`;
|
||||
if (details.duration && details.duration > 1000) {
|
||||
line += ` • took ${formatDuration(details.duration)}`;
|
||||
}
|
||||
|
||||
const box = new Box(0, 0, undefined);
|
||||
box.addChild(new Text(theme.fg("dim", line), 0, 0));
|
||||
return box;
|
||||
});
|
||||
const box = new Box(0, 0, undefined);
|
||||
box.addChild(new Text(theme.fg("dim", line), 0, 0));
|
||||
return box;
|
||||
});
|
||||
|
||||
// Start timer on session start
|
||||
pi.on("session_start", async (_event, ctx) => {
|
||||
sessionStart = Date.now();
|
||||
turnStartTime = null;
|
||||
lastTurnDuration = null;
|
||||
// Start timer on session start
|
||||
pi.on("session_start", async (_event, ctx) => {
|
||||
sessionStart = Date.now();
|
||||
turnStartTime = null;
|
||||
lastTurnDuration = null;
|
||||
|
||||
if (timerHandle) clearInterval(timerHandle);
|
||||
timerHandle = setInterval(() => updateStatus(ctx), 1000);
|
||||
updateStatus(ctx);
|
||||
});
|
||||
if (timerHandle) clearInterval(timerHandle);
|
||||
timerHandle = setInterval(() => updateStatus(ctx), 1000);
|
||||
updateStatus(ctx);
|
||||
});
|
||||
|
||||
// Track turn timing
|
||||
pi.on("turn_start", async () => {
|
||||
turnStartTime = Date.now();
|
||||
});
|
||||
// Track turn timing
|
||||
pi.on("turn_start", async () => {
|
||||
turnStartTime = Date.now();
|
||||
});
|
||||
|
||||
pi.on("turn_end", async (_event, ctx) => {
|
||||
if (turnStartTime !== null) {
|
||||
lastTurnDuration = Date.now() - turnStartTime;
|
||||
turnStartTime = null;
|
||||
updateStatus(ctx);
|
||||
}
|
||||
pi.on("turn_end", async (_event, ctx) => {
|
||||
if (turnStartTime !== null) {
|
||||
lastTurnDuration = Date.now() - turnStartTime;
|
||||
turnStartTime = null;
|
||||
updateStatus(ctx);
|
||||
}
|
||||
|
||||
if (lastTurnDuration !== null) {
|
||||
const now = Date.now();
|
||||
const elapsed = formatElapsed(now - sessionStart);
|
||||
const timeStr = formatTime(new Date(now));
|
||||
let line = `○ ${timeStr} (+${elapsed})`;
|
||||
if (lastTurnDuration > 1000) {
|
||||
line += ` • took ${formatDuration(lastTurnDuration)}`;
|
||||
}
|
||||
ctx.ui.notify(line, "info");
|
||||
}
|
||||
});
|
||||
if (lastTurnDuration !== null) {
|
||||
const now = Date.now();
|
||||
const elapsed = formatElapsed(now - sessionStart);
|
||||
const timeStr = formatTime(new Date(now));
|
||||
let line = `○ ${timeStr} (+${elapsed})`;
|
||||
if (lastTurnDuration > 1000) {
|
||||
line += ` • took ${formatDuration(lastTurnDuration)}`;
|
||||
}
|
||||
ctx.ui.notify(line, "info");
|
||||
}
|
||||
});
|
||||
|
||||
// Strip old timestamp-suffix messages from LLM context
|
||||
pi.on("context", async (event) => {
|
||||
const messages = event.messages.filter(
|
||||
(m: any) => m.role !== "custom" || (m.customType !== "timestamp-prefix" && m.customType !== "timestamp-suffix")
|
||||
);
|
||||
return { messages };
|
||||
});
|
||||
// Strip old timestamp-suffix messages from LLM context
|
||||
pi.on("context", async (event) => {
|
||||
const messages = event.messages.filter(
|
||||
(m: any) =>
|
||||
m.role !== "custom" ||
|
||||
(m.customType !== "timestamp-prefix" &&
|
||||
m.customType !== "timestamp-suffix"),
|
||||
);
|
||||
return { messages };
|
||||
});
|
||||
|
||||
// Inject timestamp marker right before agent starts (inline, persistent)
|
||||
pi.on("before_agent_start", async () => {
|
||||
const now = Date.now();
|
||||
const elapsed = formatElapsed(now - sessionStart);
|
||||
// Inject timestamp marker right before agent starts (inline, persistent)
|
||||
pi.on("before_agent_start", async () => {
|
||||
const now = Date.now();
|
||||
const elapsed = formatElapsed(now - sessionStart);
|
||||
|
||||
return {
|
||||
message: {
|
||||
customType: "timestamp-prefix",
|
||||
content: ".",
|
||||
display: true,
|
||||
details: { timestamp: now, elapsed },
|
||||
},
|
||||
};
|
||||
});
|
||||
return {
|
||||
message: {
|
||||
customType: "timestamp-prefix",
|
||||
content: ".",
|
||||
display: true,
|
||||
details: { timestamp: now, elapsed },
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
// Clean up on shutdown
|
||||
pi.on("session_shutdown", async () => {
|
||||
if (timerHandle) {
|
||||
clearInterval(timerHandle);
|
||||
timerHandle = null;
|
||||
}
|
||||
});
|
||||
// Clean up on shutdown
|
||||
pi.on("session_shutdown", async () => {
|
||||
if (timerHandle) {
|
||||
clearInterval(timerHandle);
|
||||
timerHandle = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"skipLibCheck": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["**/*.ts"]
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"lastChangelogVersion": "0.55.4",
|
||||
"defaultProvider": "openrouter",
|
||||
"defaultModel": "openai/gpt-5.3-codex",
|
||||
"defaultThinkingLevel": "minimal",
|
||||
"defaultModel": "z-ai/glm-5",
|
||||
"defaultThinkingLevel": "off",
|
||||
"theme": "matugen",
|
||||
"lsp": {
|
||||
"hookMode": "edit_write"
|
||||
|
||||
Reference in New Issue
Block a user