@rejacky/opencode-insights 0.1.4 → 0.1.6
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/README.md +80 -94
- package/dist/{capture-DkASdFpu.d.ts → capture-Dy799i3Z.d.ts} +18 -8
- package/dist/{chunk-Q5ROKOOJ.js → chunk-XCHFXQIL.js} +167 -49
- package/dist/cli.d.ts +7 -1
- package/dist/cli.js +622 -150
- package/dist/index.d.ts +1 -2
- package/dist/index.js +66 -14
- package/package.json +7 -1
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
|
|
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, f as extractEventType, n as normalizeChatHeadersCapture, g as normalizeChatMessageCapture, h as normalizeChatParamsCapture, i as normalizeEventCapture, j as normalizeExperimentalChatMessagesTransformCapture, k as normalizeExperimentalChatSystemTransformCapture, l as normalizeToolCapture, o as openDatabase, r as resolveCapturePath, m as resolveRetentionDays } from './capture-Dy799i3Z.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
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
SqliteCaptureStore,
|
|
20
20
|
createCaptureStore,
|
|
21
21
|
defaultDataDir,
|
|
22
|
+
extractEventType,
|
|
22
23
|
normalizeChatHeadersCapture,
|
|
23
24
|
normalizeChatMessageCapture,
|
|
24
25
|
normalizeChatParamsCapture,
|
|
@@ -26,13 +27,63 @@ import {
|
|
|
26
27
|
normalizeExperimentalChatMessagesTransformCapture,
|
|
27
28
|
normalizeExperimentalChatSystemTransformCapture,
|
|
28
29
|
normalizeToolCapture,
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
openDatabase,
|
|
31
|
+
resolveCapturePath,
|
|
32
|
+
resolveRetentionDays
|
|
33
|
+
} from "./chunk-XCHFXQIL.js";
|
|
34
|
+
|
|
35
|
+
// src/cli-shim.ts
|
|
36
|
+
import { existsSync } from "fs";
|
|
37
|
+
import { chmod, mkdir, readFile, writeFile } from "fs/promises";
|
|
38
|
+
import { dirname, join } from "path";
|
|
39
|
+
import { homedir } from "os";
|
|
40
|
+
import { fileURLToPath } from "url";
|
|
41
|
+
var SHIM_MARKER = "Generated by opencode-insights";
|
|
42
|
+
function resolveCliShimPath(options = {}) {
|
|
43
|
+
const home = options.homeDir ?? homedir();
|
|
44
|
+
const name = options.platform === "win32" ? "opencode-insights.cmd" : "opencode-insights";
|
|
45
|
+
return join(home, ".local", "bin", name);
|
|
46
|
+
}
|
|
47
|
+
function createCliShimContent(cliPath, platform = process.platform) {
|
|
48
|
+
if (platform === "win32") {
|
|
49
|
+
return [`@echo off`, `rem ${SHIM_MARKER}. Do not edit.`, `node ${JSON.stringify(cliPath)} %*`, ""].join("\r\n");
|
|
50
|
+
}
|
|
51
|
+
return [`#!/usr/bin/env sh`, `# ${SHIM_MARKER}. Do not edit.`, `exec node ${shellQuote(cliPath)} "$@"`, ""].join("\n");
|
|
52
|
+
}
|
|
53
|
+
async function ensureCliShim(options = {}) {
|
|
54
|
+
const platform = options.platform ?? process.platform;
|
|
55
|
+
const path = resolveCliShimPath({ homeDir: options.homeDir, platform });
|
|
56
|
+
if (options.enabled === false || process.env.OPENCODE_INSIGHTS_CLI_SHIM === "0") {
|
|
57
|
+
return { path, status: "skipped", reason: "disabled" };
|
|
58
|
+
}
|
|
59
|
+
const packageRoot = options.packageRoot ?? defaultPackageRoot();
|
|
60
|
+
const content = createCliShimContent(join(packageRoot, "dist", "cli.js"), platform);
|
|
61
|
+
const existed = existsSync(path);
|
|
62
|
+
if (existed) {
|
|
63
|
+
const existing = await readFile(path, "utf8");
|
|
64
|
+
if (existing === content) return { path, status: "unchanged" };
|
|
65
|
+
if (!existing.includes(SHIM_MARKER)) {
|
|
66
|
+
return { path, status: "skipped", reason: "existing command is not managed by opencode-insights" };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
await mkdir(dirname(path), { recursive: true });
|
|
70
|
+
await writeFile(path, content, "utf8");
|
|
71
|
+
if (platform !== "win32") await chmod(path, 493);
|
|
72
|
+
return { path, status: existed ? "updated" : "created" };
|
|
73
|
+
}
|
|
74
|
+
function defaultPackageRoot() {
|
|
75
|
+
return dirname(dirname(fileURLToPath(import.meta.url)));
|
|
76
|
+
}
|
|
77
|
+
function shellQuote(value) {
|
|
78
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
79
|
+
}
|
|
31
80
|
|
|
32
81
|
// src/index.ts
|
|
33
82
|
var OpenCodeInsights = async (_input, options) => {
|
|
83
|
+
if (options?.cliShim !== false) {
|
|
84
|
+
void ensureCliShim().catch(() => void 0);
|
|
85
|
+
}
|
|
34
86
|
const store = createCaptureStore(options);
|
|
35
|
-
const experimental = options?.experimental ?? false;
|
|
36
87
|
try {
|
|
37
88
|
await store.initialize?.();
|
|
38
89
|
} catch {
|
|
@@ -56,16 +107,14 @@ var OpenCodeInsights = async (_input, options) => {
|
|
|
56
107
|
"chat.params": async (input, output) => {
|
|
57
108
|
await capture(normalizeChatParamsCapture(input, output));
|
|
58
109
|
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
await capture(normalizeExperimentalChatSystemTransformCapture(input, output));
|
|
68
|
-
}
|
|
110
|
+
"chat.headers": async (input, output) => {
|
|
111
|
+
await capture(normalizeChatHeadersCapture(input, output));
|
|
112
|
+
},
|
|
113
|
+
"experimental.chat.messages.transform": async (input, output) => {
|
|
114
|
+
await capture(normalizeExperimentalChatMessagesTransformCapture(input, output));
|
|
115
|
+
},
|
|
116
|
+
"experimental.chat.system.transform": async (input, output) => {
|
|
117
|
+
await capture(normalizeExperimentalChatSystemTransformCapture(input, output));
|
|
69
118
|
},
|
|
70
119
|
"tool.execute.before": async (input, output) => {
|
|
71
120
|
await capture(normalizeToolCapture("tool.execute.before", input, output));
|
|
@@ -81,7 +130,7 @@ var rootTui = async (...args) => {
|
|
|
81
130
|
return mod.tui(...args);
|
|
82
131
|
};
|
|
83
132
|
var id = "opencode-insights";
|
|
84
|
-
var src_default = { id, server
|
|
133
|
+
var src_default = { id, server };
|
|
85
134
|
export {
|
|
86
135
|
JsonlCaptureStore,
|
|
87
136
|
OpenCodeInsights,
|
|
@@ -93,6 +142,7 @@ export {
|
|
|
93
142
|
src_default as default,
|
|
94
143
|
defaultDataDir,
|
|
95
144
|
estimateStreamTokens,
|
|
145
|
+
extractEventType,
|
|
96
146
|
getSubagentItems,
|
|
97
147
|
getSubagentSidebarModel,
|
|
98
148
|
id,
|
|
@@ -103,6 +153,7 @@ export {
|
|
|
103
153
|
normalizeExperimentalChatMessagesTransformCapture,
|
|
104
154
|
normalizeExperimentalChatSystemTransformCapture,
|
|
105
155
|
normalizeToolCapture,
|
|
156
|
+
openDatabase,
|
|
106
157
|
pruneStaleSubagents,
|
|
107
158
|
recordAssistantDelta,
|
|
108
159
|
recordAssistantMessage,
|
|
@@ -112,6 +163,7 @@ export {
|
|
|
112
163
|
renderSubagentSidebar,
|
|
113
164
|
renderSubagentStatus,
|
|
114
165
|
resolveCapturePath,
|
|
166
|
+
resolveRetentionDays,
|
|
115
167
|
server,
|
|
116
168
|
rootTui as tui
|
|
117
169
|
};
|
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.
|
|
4
|
+
"version": "0.1.6",
|
|
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
|
}
|