@rejacky/opencode-insights 0.1.3 → 0.1.5

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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from '@opencode-ai/plugin';
2
2
  import { TuiPlugin } from '@opencode-ai/plugin/tui';
3
- export { a as CaptureKind, C as CaptureRecord, b as CaptureStore, I as InsightsOptions, J as JsonlCaptureStore, S as SqliteCaptureStore, c as createCaptureStore, d as defaultDataDir, n as normalizeChatHeadersCapture, e as normalizeChatMessageCapture, f as normalizeChatParamsCapture, g as normalizeEventCapture, h as normalizeExperimentalChatMessagesTransformCapture, i as normalizeExperimentalChatSystemTransformCapture, j as normalizeToolCapture, r as resolveCapturePath } from './capture-gQauLsdn.js';
3
+ export { a as CaptureKind, C as CaptureRecord, b as CaptureStore, I as InsightsOptions, J as JsonlCaptureStore, S as SqliteCaptureStore, c as SqliteDb, d as createCaptureStore, e as defaultDataDir, n as normalizeChatHeadersCapture, f as normalizeChatMessageCapture, g as normalizeChatParamsCapture, h as normalizeEventCapture, i as normalizeExperimentalChatMessagesTransformCapture, j as normalizeExperimentalChatSystemTransformCapture, k as normalizeToolCapture, o as openDatabase, r as resolveCapturePath, l as resolveRetentionDays } from './capture-B6sM1QQA.js';
4
4
 
5
5
  type StreamSample = {
6
6
  at: number;
@@ -109,7 +109,6 @@ declare const id = "opencode-insights";
109
109
  declare const _default: {
110
110
  id: string;
111
111
  server: Plugin;
112
- tui: TuiPlugin;
113
112
  };
114
113
 
115
114
  export { type MessageTiming, type MetricsState, OpenCodeInsights, type SessionAverage, type StreamSample, type SubagentInfo, type SubagentSidebarModel, type SubagentSidebarRow, type SubagentState, type SubagentStatus, applySubagentEvent, createMetricsState, createSubagentState, _default as default, estimateStreamTokens, getSubagentItems, getSubagentSidebarModel, id, pruneStaleSubagents, recordAssistantDelta, recordAssistantMessage, recordToolActivity, renderMetricsText, renderSubagentFooter, renderSubagentSidebar, renderSubagentStatus, server, rootTui as tui };
package/dist/index.js CHANGED
@@ -26,11 +26,62 @@ import {
26
26
  normalizeExperimentalChatMessagesTransformCapture,
27
27
  normalizeExperimentalChatSystemTransformCapture,
28
28
  normalizeToolCapture,
29
- resolveCapturePath
30
- } from "./chunk-Q5ROKOOJ.js";
29
+ openDatabase,
30
+ resolveCapturePath,
31
+ resolveRetentionDays
32
+ } from "./chunk-PBX4AJCR.js";
33
+
34
+ // src/cli-shim.ts
35
+ import { existsSync } from "fs";
36
+ import { chmod, mkdir, readFile, writeFile } from "fs/promises";
37
+ import { dirname, join } from "path";
38
+ import { homedir } from "os";
39
+ import { fileURLToPath } from "url";
40
+ var SHIM_MARKER = "Generated by opencode-insights";
41
+ function resolveCliShimPath(options = {}) {
42
+ const home = options.homeDir ?? homedir();
43
+ const name = options.platform === "win32" ? "opencode-insights.cmd" : "opencode-insights";
44
+ return join(home, ".local", "bin", name);
45
+ }
46
+ function createCliShimContent(cliPath, platform = process.platform) {
47
+ if (platform === "win32") {
48
+ return [`@echo off`, `rem ${SHIM_MARKER}. Do not edit.`, `node ${JSON.stringify(cliPath)} %*`, ""].join("\r\n");
49
+ }
50
+ return [`#!/usr/bin/env sh`, `# ${SHIM_MARKER}. Do not edit.`, `exec node ${shellQuote(cliPath)} "$@"`, ""].join("\n");
51
+ }
52
+ async function ensureCliShim(options = {}) {
53
+ const platform = options.platform ?? process.platform;
54
+ const path = resolveCliShimPath({ homeDir: options.homeDir, platform });
55
+ if (options.enabled === false || process.env.OPENCODE_INSIGHTS_CLI_SHIM === "0") {
56
+ return { path, status: "skipped", reason: "disabled" };
57
+ }
58
+ const packageRoot = options.packageRoot ?? defaultPackageRoot();
59
+ const content = createCliShimContent(join(packageRoot, "dist", "cli.js"), platform);
60
+ const existed = existsSync(path);
61
+ if (existed) {
62
+ const existing = await readFile(path, "utf8");
63
+ if (existing === content) return { path, status: "unchanged" };
64
+ if (!existing.includes(SHIM_MARKER)) {
65
+ return { path, status: "skipped", reason: "existing command is not managed by opencode-insights" };
66
+ }
67
+ }
68
+ await mkdir(dirname(path), { recursive: true });
69
+ await writeFile(path, content, "utf8");
70
+ if (platform !== "win32") await chmod(path, 493);
71
+ return { path, status: existed ? "updated" : "created" };
72
+ }
73
+ function defaultPackageRoot() {
74
+ return dirname(dirname(fileURLToPath(import.meta.url)));
75
+ }
76
+ function shellQuote(value) {
77
+ return `'${value.replace(/'/g, `'\\''`)}'`;
78
+ }
31
79
 
32
80
  // src/index.ts
33
81
  var OpenCodeInsights = async (_input, options) => {
82
+ if (options?.cliShim !== false) {
83
+ void ensureCliShim().catch(() => void 0);
84
+ }
34
85
  const store = createCaptureStore(options);
35
86
  try {
36
87
  await store.initialize?.();
@@ -78,7 +129,7 @@ var rootTui = async (...args) => {
78
129
  return mod.tui(...args);
79
130
  };
80
131
  var id = "opencode-insights";
81
- var src_default = { id, server, tui: rootTui };
132
+ var src_default = { id, server };
82
133
  export {
83
134
  JsonlCaptureStore,
84
135
  OpenCodeInsights,
@@ -100,6 +151,7 @@ export {
100
151
  normalizeExperimentalChatMessagesTransformCapture,
101
152
  normalizeExperimentalChatSystemTransformCapture,
102
153
  normalizeToolCapture,
154
+ openDatabase,
103
155
  pruneStaleSubagents,
104
156
  recordAssistantDelta,
105
157
  recordAssistantMessage,
@@ -109,6 +161,7 @@ export {
109
161
  renderSubagentSidebar,
110
162
  renderSubagentStatus,
111
163
  resolveCapturePath,
164
+ resolveRetentionDays,
112
165
  server,
113
166
  rootTui as tui
114
167
  };
package/dist/tui.js CHANGED
@@ -6,8 +6,7 @@ import {
6
6
  recordAssistantDelta,
7
7
  recordAssistantMessage,
8
8
  recordToolActivity,
9
- renderMetricsText,
10
- renderSubagentFooter
9
+ renderMetricsText
11
10
  } from "./chunk-36ZNCLI3.js";
12
11
 
13
12
  // src/tui.tsx
@@ -41,27 +40,6 @@ function PromptRight(props) {
41
40
  }
42
41
  );
43
42
  }
44
- function ReactiveText(props) {
45
- let text;
46
- const sync = () => {
47
- if (!text) return;
48
- text.content = props.text();
49
- props.api.renderer.requestRender();
50
- };
51
- const unsubscribe = props.subscribe(sync);
52
- onCleanup(unsubscribe);
53
- return /* @__PURE__ */ jsx(
54
- "text",
55
- {
56
- ref: (ref) => {
57
- text = ref;
58
- sync();
59
- },
60
- fg: props.api.theme.current.textMuted,
61
- children: props.text()
62
- }
63
- );
64
- }
65
43
  function SubagentSidebar(props) {
66
44
  let text;
67
45
  const [collapsed, setCollapsed] = createSignal(false);
@@ -202,15 +180,6 @@ var tui = async (api) => {
202
180
  }
203
181
  }
204
182
  ),
205
- home_prompt_right: () => /* @__PURE__ */ jsx(
206
- PromptRight,
207
- {
208
- api,
209
- sessionID: "",
210
- subscribe,
211
- text: () => ""
212
- }
213
- ),
214
183
  sidebar_content: (_ctx, props) => /* @__PURE__ */ jsx(
215
184
  SubagentSidebar,
216
185
  {
@@ -219,14 +188,6 @@ var tui = async (api) => {
219
188
  state: subagents,
220
189
  subscribe
221
190
  }
222
- ),
223
- sidebar_footer: (_ctx, props) => /* @__PURE__ */ jsx(
224
- ReactiveText,
225
- {
226
- api,
227
- subscribe,
228
- text: () => renderSubagentFooter(subagents, props.session_id)
229
- }
230
191
  )
231
192
  }
232
193
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@rejacky/opencode-insights",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "description": "OpenCode plugin for local request capture, TPS metrics, and subagent status visibility.",
6
6
  "type": "module",
7
7
  "author": "opencode-insights contributors",
@@ -75,10 +75,16 @@
75
75
  "@opencode-ai/plugin": "^1.17.13",
76
76
  "@opentui/core": "^0.4.3",
77
77
  "@opentui/solid": "^0.4.3",
78
+ "@types/better-sqlite3": "^7.6.13",
78
79
  "@types/node": "^24.12.2",
80
+ "@types/sql.js": "^1.4.11",
79
81
  "solid-js": "1.9.12",
80
82
  "tsup": "^8.5.1",
81
83
  "typescript": "^6.0.3",
82
84
  "vitest": "^4.1.10"
85
+ },
86
+ "dependencies": {
87
+ "better-sqlite3": "^12.11.1",
88
+ "sql.js": "^1.14.1"
83
89
  }
84
90
  }