espennilsen/pi / extensions/pi-a2a
pi-a2a
Flaggedlogger.ts
View on GitHub/**
* pi-a2a — Structured logger via pi-logger event bus.
*/
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
export type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR";
export type LogFn = (action: string, detail?: Record<string, unknown>, level?: LogLevel) => void;
/** Replace credential material before it reaches any log transport. */
export function redactLogDetail(detail: Record<string, unknown>): Record<string, unknown> {
return redactValue(detail) as Record<string, unknown>;
}
const SECRET_FIELD = /(?:api[_-]?key|credential|authorization|token|secret|private[_-]?key|(?:certificate|cert|key)(?:[_-]?(?:content|data|pem))?)$/i;
const PEM_CONTENT = /-----BEGIN (?:[A-Z ]*PRIVATE KEY|CERTIFICATE)-----/;
function redactValue(value: unknown, fieldName?: string): unknown {
if (fieldName && SECRET_FIELD.test(fieldName)) return "[REDACTED]";
if (typeof value === "string") return PEM_CONTENT.test(value) ? "[REDACTED]" : value;
if (Array.isArray(value)) return value.map((item) => redactValue(item));
if (value && typeof value === "object") {
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactValue(item, key)]));
}
return value;
}
export function createLogger(pi: ExtensionAPI): LogFn {
return (action: string, detail?: Record<string, unknown>, level: LogLevel = "INFO") => {
pi.events.emit("log", {
source: "pi-a2a",
level,
action,
detail: redactLogDetail(detail ?? {}),
ts: new Date().toISOString(),
});
};
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |