pi-extension-utils 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { connect, type FullscreenComponentFactory, type FullscreenLease, type RemindersClient, type UtilsClient, type UtilsClientOptions, type WidgetSetOptions } from "./client/index.ts";
|
|
2
2
|
export { defineConfig, type DeepPartial, type DefinedConfig, type DefineConfigOptions } from "./config/index.ts";
|
|
3
|
-
export { createLogger, LOG_LEVELS, loggerLevelSchema, loggingConfigSchema, type Logger, type LoggerLevel, type LoggerOptions, type LoggingConfig, type LogLevel } from "./logger/index.ts";
|
|
3
|
+
export { createLogger, LOG_LEVELS, loggerLevelSchema, loggingConfigSchema, type Logger, type LoggerLevel, type LoggerOptions, type LoggerRecord, type LoggingConfig, type LogLevel } from "./logger/index.ts";
|
|
4
4
|
export { utilsConfigSchema, type UtilsConfig } from "./utils-config.ts";
|
|
5
5
|
export * from "./pane/key-dispatch.ts";
|
|
6
6
|
export * from "./pane/state.ts";
|
|
@@ -3,7 +3,7 @@ export { LOG_LEVELS, loggerLevelSchema, loggingConfigSchema, type LoggerLevel, t
|
|
|
3
3
|
export interface LoggerOptions {
|
|
4
4
|
dir?: string;
|
|
5
5
|
maxBytes?: number;
|
|
6
|
-
/** Number of rotated files to retain: name.
|
|
6
|
+
/** Number of rotated files to retain: name.jsonl.1, name.jsonl.2, ... */
|
|
7
7
|
maxFiles?: number;
|
|
8
8
|
/** Minimum level to write. Defaults to utilsConfig.logging.level. */
|
|
9
9
|
level?: LoggerLevel;
|
|
@@ -17,4 +17,9 @@ export interface Logger {
|
|
|
17
17
|
setLevel(level: LoggerLevel): void;
|
|
18
18
|
isEnabled(level: LogLevel): boolean;
|
|
19
19
|
}
|
|
20
|
+
export interface LoggerRecord {
|
|
21
|
+
ts: string;
|
|
22
|
+
level: LogLevel;
|
|
23
|
+
message: string;
|
|
24
|
+
}
|
|
20
25
|
export declare function createLogger(name: string, opts?: LoggerOptions): Logger;
|
package/dist/src/logger/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export function createLogger(name, opts = {}) {
|
|
|
21
21
|
const maxBytes = Math.max(0, Math.floor(opts.maxBytes ?? configured?.maxBytes ?? 1024 * 1024));
|
|
22
22
|
const maxFiles = Math.max(0, Math.floor(opts.maxFiles ?? configured?.maxFiles ?? 3));
|
|
23
23
|
let level = opts.level ?? configured?.level ?? "info";
|
|
24
|
-
const file = join(dir, `${name}.
|
|
24
|
+
const file = join(dir, `${name}.jsonl`);
|
|
25
25
|
mkdirSync(dirname(file), { recursive: true });
|
|
26
26
|
function rotateIfNeeded(nextBytes) {
|
|
27
27
|
if (maxBytes <= 0 || !existsSync(file))
|
|
@@ -49,7 +49,7 @@ export function createLogger(name, opts = {}) {
|
|
|
49
49
|
function log(candidate, message) {
|
|
50
50
|
if (!isEnabled(candidate))
|
|
51
51
|
return;
|
|
52
|
-
const line = `${new Date().toISOString()
|
|
52
|
+
const line = `${JSON.stringify({ ts: new Date().toISOString(), level: candidate, message })}\n`;
|
|
53
53
|
mkdirSync(dirname(file), { recursive: true });
|
|
54
54
|
rotateIfNeeded(Buffer.byteLength(line));
|
|
55
55
|
appendFileSync(file, line);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
1
2
|
export declare const PROTOCOL_VERSION = 1;
|
|
2
3
|
export declare const EVENT_PREFIX = "pi-extension-utils";
|
|
3
4
|
export declare const HELLO_EVENT = "pi-extension-utils:hello";
|
|
@@ -15,12 +16,7 @@ export declare const EVENTS: {
|
|
|
15
16
|
readonly fullscreenRelease: "pi-extension-utils:fullscreen-release";
|
|
16
17
|
};
|
|
17
18
|
export type WidgetPlacement = "aboveEditor" | "belowEditor";
|
|
18
|
-
export
|
|
19
|
-
render(width: number): string[];
|
|
20
|
-
invalidate(): void;
|
|
21
|
-
dispose?(): void;
|
|
22
|
-
}
|
|
23
|
-
export type WidgetFactory = (tui: unknown, theme: unknown) => WidgetComponent;
|
|
19
|
+
export type WidgetFactory = NonNullable<Parameters<ExtensionContext["ui"]["setWidget"]>[1]>;
|
|
24
20
|
export interface ProtocolPayload {
|
|
25
21
|
protocolVersion: number;
|
|
26
22
|
clientId: string;
|
package/docs/client.md
CHANGED
|
@@ -82,7 +82,7 @@ log.warn("slow path");
|
|
|
82
82
|
log.error("failed");
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
`createLogger(name)` writes to `getAgentDir()/log/<name>.
|
|
85
|
+
`createLogger(name)` writes JSONL to `getAgentDir()/log/<name>.jsonl` by default. Each line is `{"ts":"...","level":"info","message":"started"}`. `level` is typed as `"debug" | "info" | "warn" | "error" | "silent"`; `maxFiles` controls retained rotations (`.1`, `.2`, ...). If `level`, `maxFiles`, or `maxBytes` are omitted, the value comes from `getAgentDir()/config/utils.jsonc` `logging` defaults. Explicit options always win.
|
|
86
86
|
|
|
87
87
|
Override when needed:
|
|
88
88
|
|