opencode-prompt-logger 0.1.0 → 0.2.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.
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Every setting. The plugin's server storage is the only source of truth: the
3
+ * configuration file registers the plugin, but it never carries settings.
4
+ */
5
+ export type Settings = {
6
+ readonly enabled: boolean;
7
+ readonly http: boolean;
8
+ /** Total store budget in bytes. Zero means no byte budget. */
9
+ readonly diskBudget: number;
10
+ /** Remove sessions inactive for longer than this. Zero means unlimited. */
11
+ readonly retentionMaxAgeDays: number;
12
+ /** Keep at most this many sessions. Zero means unlimited. */
13
+ readonly retentionMaxSessions: number;
14
+ /** Store root. Empty means the platform default. */
15
+ readonly directory: string;
16
+ /** Allow destructive actions from the viewer. */
17
+ readonly maintenance: boolean;
18
+ };
19
+ /** Settings live under this key. */
20
+ export declare const SETTINGS_KEY = "settings";
21
+ /** A setting must stay sane; the UI offers presets well below these limits. */
22
+ export declare const MAX_SETTINGS_DISK_BUDGET: number;
23
+ export declare const MAX_SETTINGS_RETENTION_DAYS = 3650;
24
+ export declare const MAX_SETTINGS_RETENTION_SESSIONS = 10000;
25
+ export declare const MAX_SETTINGS_DIRECTORY = 4096;
26
+ export declare const DEFAULT_SETTINGS: Settings;
27
+ /** A fresh copy of the built-in settings, safe for an editor to mutate. */
28
+ export declare function defaultSettings(): Settings;
29
+ /**
30
+ * Read a stored value defensively. A value written by a newer version, a
31
+ * manual edit or a corrupted store is replaced field by field with a default
32
+ * instead of breaking logging.
33
+ */
34
+ export declare function sanitizeSettings(value: unknown): Settings;
35
+ /**
36
+ * Strict validation for a user action. Unlike `sanitizeSettings`, a malformed
37
+ * request fails loudly instead of being silently repaired.
38
+ */
39
+ export declare function isValidSettings(value: unknown): value is Settings;
40
+ /** Reads the `{ settings }` envelope used by the RPC methods and event. */
41
+ export declare function settingsFromEnvelope(value: unknown): Settings;
42
+ /**
43
+ * Strip the computed `retention` policy that only exists in the status view
44
+ * before writing a settings object back over the RPC.
45
+ */
46
+ export declare function pickSettings(value: Settings): Settings;
@@ -0,0 +1,28 @@
1
+ import type { Context } from "@opencode/plugin/tui/context";
2
+ import type { LogSummary } from "../log/types";
3
+ import type { DetailLine } from "../detail-lines";
4
+ import { type Section } from "../view-model";
5
+ export type DetailData = {
6
+ readonly entry: LogSummary;
7
+ readonly record: unknown | null;
8
+ readonly truncated: boolean;
9
+ readonly moreAvailable?: boolean;
10
+ readonly fullBytes?: number;
11
+ readonly httpEnabled?: boolean;
12
+ };
13
+ export type Detail = {
14
+ readonly entry: LogSummary;
15
+ readonly sections: readonly Section[];
16
+ };
17
+ /** The paged request detail, separated from the list/fetch state in LogView. */
18
+ export declare function DetailPane(props: {
19
+ readonly ctx: Context;
20
+ readonly detail: Detail;
21
+ readonly lines: readonly DetailLine[];
22
+ readonly page: readonly DetailLine[];
23
+ readonly offset: number;
24
+ readonly data: DetailData | undefined;
25
+ readonly loading: boolean;
26
+ readonly expanded: boolean;
27
+ readonly hasTruncated: boolean;
28
+ }): import("solid-js").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import type { Context } from "@opencode/plugin/tui/context";
2
+ /**
3
+ * The prompt log viewer, shared by the session panel and the global page.
4
+ *
5
+ * - With `sessionID`, it starts scoped to that session (the panel).
6
+ * - Without it, it starts on all sessions and works from Home, before any
7
+ * session exists; the settings dialog can then turn logging on.
8
+ *
9
+ * It owns the keyboard while mounted: j/k navigate, Enter opens one record,
10
+ * and every metadata change goes through the bounded RPC, never the file.
11
+ */
12
+ export declare function LogView(props: {
13
+ readonly ctx: Context;
14
+ readonly sessionID?: string;
15
+ readonly initialScope?: "session" | "all";
16
+ /** Open the settings dialog once the status is available (global page). */
17
+ readonly openSettings?: boolean;
18
+ /** Terminal columns available to the list; long rows are truncated. */
19
+ readonly width?: number;
20
+ readonly close: () => void;
21
+ }): import("solid-js").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import type { Context } from "@opencode/plugin/tui/context";
2
+ import { type LoggingState } from "./logging-indicator";
3
+ type Snapshot = LoggingState;
4
+ /**
5
+ * The logging state shared by the Home and session footer badges.
6
+ *
7
+ * The server emits `settingsChanged` for every settings or scope write, so a
8
+ * badge never polls. The one status read on startup covers a viewer opened
9
+ * after logging was already configured; `server.connected` retries it after a
10
+ * reconnect, when the first read may have raced the server.
11
+ */
12
+ export declare function createLoggingSnapshot(ctx: Context): {
13
+ readonly current: () => Snapshot | undefined;
14
+ readonly dispose: () => void;
15
+ };
16
+ /**
17
+ * The footer badge. It is absent while logging is off: presence itself is the
18
+ * signal, and a permanent "off" chip would only take room from the footer.
19
+ */
20
+ export declare function LoggingBadge(props: {
21
+ readonly snapshot: () => Snapshot | undefined;
22
+ readonly theme: Context["theme"];
23
+ readonly sessionID?: string;
24
+ }): import("solid-js").JSX.Element;
25
+ export {};
package/dist/tui.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ import { Plugin } from "@opencode/plugin/tui";
3
+ /**
4
+ * TUI side of the plugin.
5
+ *
6
+ * - In a session, `/prompt-log` or the palette command opens the session panel.
7
+ * - From Home, the same command opens the global page: all sessions, plus the
8
+ * settings dialog. Logging can therefore be turned on before any session
9
+ * exists, which is the whole point of a troubleshooting logger.
10
+ *
11
+ * Both views read the log through the server RPC, so they work against a local
12
+ * or a remote server and never open the file themselves.
13
+ */
14
+ declare const _default: Plugin.Definition;
15
+ export default _default;