@rejacky/opencode-insights 0.1.2 → 0.1.3

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 CHANGED
@@ -4,49 +4,13 @@ Local OpenCode observability for live TPS, subagent status, and full-fidelity re
4
4
 
5
5
  ## Install
6
6
 
7
- Install from your OpenCode config/package directory:
7
+ Install globally with OpenCode's plugin manager:
8
8
 
9
9
  ```bash
10
- cd ~/.config/opencode
11
- npm i @rejacky/opencode-insights
12
- npx opencode-insights configure
13
- ```
14
-
15
- Restart OpenCode after configuring the plugin.
16
-
17
- `opencode-insights configure` updates two config files because OpenCode loads server plugins and TUI plugins separately:
18
-
19
- ```json
20
- // ~/.config/opencode/opencode.json or opencode.jsonc
21
- {
22
- "plugin": ["@rejacky/opencode-insights"]
23
- }
10
+ opencode plugin @rejacky/opencode-insights --global
24
11
  ```
25
12
 
26
- ```json
27
- // ~/.config/opencode/tui.json
28
- {
29
- "plugin": ["@rejacky/opencode-insights/tui"]
30
- }
31
- ```
32
-
33
- Preview config changes without writing files:
34
-
35
- ```bash
36
- npx opencode-insights configure --dry-run
37
- ```
38
-
39
- OpenCode 1.17.14 loads `tui.json` for TUI plugins. It does not load `tui.jsonc`, so `configure` always writes the TUI plugin entry to `tui.json`.
40
-
41
- The TUI plugin value is the package export `@rejacky/opencode-insights/tui`, not an absolute `dist/tui.js` path.
42
-
43
- OpenCode resolves TUI plugin entries through module resolution, so this works after installing the package in your OpenCode config/package directory.
44
-
45
- Use a custom OpenCode config directory:
46
-
47
- ```bash
48
- npx opencode-insights configure --config-dir ~/.config/opencode
49
- ```
13
+ Restart OpenCode after installing the plugin.
50
14
 
51
15
  ## Uninstall
52
16
 
@@ -299,10 +299,9 @@ function extractSubagent(event) {
299
299
  const completedMs = numberFromPath(info.time, "completed");
300
300
  const explicitUpdatedMs = numberFromPath(info.time, "updated");
301
301
  const updatedMs = completedMs ?? explicitUpdatedMs ?? startedMs;
302
- const infoStatus = asString(info.status);
303
- const hasError = info.error !== void 0 || infoStatus === "error";
304
- const status = hasError ? "error" : typeof completedMs === "number" || infoStatus === "idle" ? "done" : "running";
305
- const terminalMs = typeof completedMs === "number" || infoStatus === "idle" ? updatedMs : status === "error" && typeof explicitUpdatedMs === "number" ? explicitUpdatedMs : void 0;
302
+ const hasError = info.error !== void 0 || asString(info.status) === "error";
303
+ const status = hasError ? "error" : typeof completedMs === "number" ? "done" : "running";
304
+ const terminalMs = typeof completedMs === "number" ? updatedMs : status === "error" && typeof explicitUpdatedMs === "number" ? explicitUpdatedMs : void 0;
306
305
  const endedAt = typeof terminalMs === "number" ? new Date(terminalMs).toISOString() : void 0;
307
306
  return {
308
307
  id,
@@ -324,11 +323,8 @@ function updateExistingSubagent(state, event) {
324
323
  const previous = state.children[sessionID];
325
324
  if (!previous) return void 0;
326
325
  const info = isRecord(evt.properties?.info) ? evt.properties.info : void 0;
327
- const completedMs = numberFromPath(info?.time, "completed");
328
- const messageCompleted = evt.type === "message.updated" && asString(info?.role) === "assistant" && typeof completedMs === "number";
329
- const messageFailed = messageCompleted && info?.error !== void 0;
330
- const status = messageFailed ? "error" : messageCompleted ? "done" : statusFromEvent(event) ?? previous.status;
331
- const timestamp = messageCompleted ? new Date(completedMs).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
326
+ const status = statusFromEvent(event) ?? previous.status;
327
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
332
328
  const done = status === "done" || status === "error";
333
329
  return {
334
330
  ...previous,
@@ -342,11 +338,9 @@ function statusFromEvent(event) {
342
338
  if (!isRecord(event)) return void 0;
343
339
  const evt = event;
344
340
  if (evt.type === "session.error") return "error";
345
- if (evt.type === "session.idle") return "done";
346
341
  if (evt.type === "session.status" && isRecord(evt.properties?.status)) {
347
342
  const statusType = asString(evt.properties.status.type);
348
343
  if (statusType === "busy" || statusType === "running") return "running";
349
- if (statusType === "idle") return "done";
350
344
  if (statusType === "error") return "error";
351
345
  }
352
346
  return void 0;
package/dist/cli.d.ts CHANGED
@@ -81,7 +81,7 @@ declare function summarizeSessions(sessions: ReturnType<typeof buildRequestHisto
81
81
  }[];
82
82
  declare function formatSessionSummary(rows: ReturnType<typeof summarizeSessions>): string;
83
83
  type JsonObject = Record<string, unknown>;
84
- declare function configureOpenCode(options: CliOptions): Promise<string>;
84
+ declare function configureOpenCodeDebug(options: CliOptions): Promise<string>;
85
85
  declare function defaultOpenCodeConfigDir(): string;
86
86
  declare function resolveOpenCodeConfigPath(configDir: string): string;
87
87
  declare function stripJsonCommentsAndTrailingCommas(input: string): string;
@@ -89,4 +89,4 @@ declare function addUniquePlugin(config: JsonObject, plugin: string): boolean;
89
89
  declare function removePlugin(config: JsonObject, plugin: string): boolean;
90
90
  declare function uninstallOpenCode(options: CliOptions): Promise<string>;
91
91
 
92
- export { addUniquePlugin, configureOpenCode, defaultOpenCodeConfigDir, formatSessionSummary, parseOptions, removePlugin, resolveOpenCodeConfigPath, stripJsonCommentsAndTrailingCommas, summarizeSessions, uninstallOpenCode };
92
+ export { addUniquePlugin, configureOpenCodeDebug, defaultOpenCodeConfigDir, formatSessionSummary, parseOptions, removePlugin, resolveOpenCodeConfigPath, stripJsonCommentsAndTrailingCommas, summarizeSessions, uninstallOpenCode };
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  import { execFile as execFile2 } from "child_process";
8
8
  import { existsSync as existsSync2, realpathSync } from "fs";
9
9
  import { mkdir, readFile as readFile2, rm, writeFile } from "fs/promises";
10
- import { dirname, join } from "path";
10
+ import { dirname, join, resolve } from "path";
11
11
  import { homedir } from "os";
12
12
  import { pathToFileURL } from "url";
13
13
  import { promisify as promisify2 } from "util";
@@ -398,16 +398,16 @@ async function serveViewer(options = {}) {
398
398
  response.writeHead(404, { "content-type": "text/plain; charset=utf-8" });
399
399
  response.end("Not found");
400
400
  });
401
- await new Promise((resolve, reject) => {
401
+ await new Promise((resolve2, reject) => {
402
402
  server.once("error", reject);
403
403
  server.listen(port, host, () => {
404
404
  server.off("error", reject);
405
- resolve();
405
+ resolve2();
406
406
  });
407
407
  });
408
408
  return {
409
409
  url: `http://${host}:${port}`,
410
- close: () => new Promise((resolve) => server.close(() => resolve()))
410
+ close: () => new Promise((resolve2) => server.close(() => resolve2()))
411
411
  };
412
412
  }
413
413
  async function readHistory(options = {}) {
@@ -954,7 +954,8 @@ var execFileAsync2 = promisify2(execFile2);
954
954
  var DEFAULT_RECENT_LIMIT = 20;
955
955
  var DEFAULT_HISTORY_LIMIT = 5e3;
956
956
  var SERVER_PLUGIN_SPEC = "@rejacky/opencode-insights";
957
- var TUI_PLUGIN_SPEC = "@rejacky/opencode-insights";
957
+ var TUI_PLUGIN_SPEC = SERVER_PLUGIN_SPEC;
958
+ var SUBPATH_TUI_PLUGIN_SPEC = "@rejacky/opencode-insights/tui";
958
959
  async function main(argv) {
959
960
  const command = argv[2] ?? "recent";
960
961
  const options = parseOptions(argv.slice(3));
@@ -1034,8 +1035,8 @@ async function main(argv) {
1034
1035
  `);
1035
1036
  return;
1036
1037
  }
1037
- if (command === "configure") {
1038
- process.stdout.write(`${await configureOpenCode(options)}
1038
+ if (command === "debug") {
1039
+ process.stdout.write(`${await configureOpenCodeDebug(options)}
1039
1040
  `);
1040
1041
  return;
1041
1042
  }
@@ -1222,28 +1223,36 @@ async function vacuumDatabase(options) {
1222
1223
  await execFileAsync2("sqlite3", [dbPath, "vacuum;"]);
1223
1224
  return `Vacuumed ${dbPath}`;
1224
1225
  }
1225
- async function configureOpenCode(options) {
1226
+ async function configureOpenCodeDebug(options) {
1226
1227
  const configDir = options.configDir ?? defaultOpenCodeConfigDir();
1227
1228
  const opencodePath = resolveOpenCodeConfigPath(configDir);
1228
1229
  const tuiPath = join(configDir, "tui.json");
1230
+ const localServerEntry = resolve("dist/index.js");
1231
+ const localTuiEntry = resolve("dist/tui.js");
1232
+ if (!existsSync2(localServerEntry) || !existsSync2(localTuiEntry)) {
1233
+ throw new Error("Missing dist output. Run npm run build before opencode-insights debug.");
1234
+ }
1229
1235
  const opencodeConfig = await readJsonConfig(opencodePath, { plugin: [] });
1230
1236
  const tuiConfig = await readJsonConfig(tuiPath, { plugin: [] });
1231
- const opencodeChanged = addUniquePlugin(opencodeConfig, SERVER_PLUGIN_SPEC);
1232
- const tuiChanged = addUniquePlugin(tuiConfig, TUI_PLUGIN_SPEC);
1237
+ setSinglePluginSpec(opencodeConfig, SERVER_PLUGIN_SPEC, localServerEntry);
1238
+ setSinglePluginSpec(tuiConfig, TUI_PLUGIN_SPEC, localTuiEntry);
1239
+ removePlugin(tuiConfig, SUBPATH_TUI_PLUGIN_SPEC);
1233
1240
  const lines = [
1234
1241
  `OpenCode config: ${opencodePath}`,
1235
1242
  `TUI config: ${tuiPath}`,
1236
- `Server plugin: ${opencodeChanged ? "added" : "already present"} (${SERVER_PLUGIN_SPEC})`,
1237
- `TUI plugin: ${tuiChanged ? "added" : "already present"} (${TUI_PLUGIN_SPEC})`
1243
+ `Local server plugin: ${localServerEntry}`,
1244
+ `Local TUI plugin: ${localTuiEntry}`,
1245
+ `Server plugin: set local build output`,
1246
+ `TUI plugin: set local build output`
1238
1247
  ];
1239
1248
  if (options.dryRun) {
1240
1249
  lines.push("Dry run: no files written.");
1241
1250
  return lines.join("\n");
1242
1251
  }
1243
1252
  await mkdir(configDir, { recursive: true });
1244
- if (opencodeChanged || !existsSync2(opencodePath)) await writeJsonConfig(opencodePath, opencodeConfig);
1245
- if (tuiChanged || !existsSync2(tuiPath)) await writeJsonConfig(tuiPath, tuiConfig);
1246
- lines.push("Configuration written. Restart OpenCode to load the plugin.");
1253
+ await writeJsonConfig(opencodePath, opencodeConfig);
1254
+ await writeJsonConfig(tuiPath, tuiConfig);
1255
+ lines.push("Debug configuration written. Restart OpenCode to load the local build.");
1247
1256
  return lines.join("\n");
1248
1257
  }
1249
1258
  function defaultOpenCodeConfigDir() {
@@ -1332,6 +1341,19 @@ function removePlugin(config, plugin) {
1332
1341
  function isPluginEntry(entry, plugin) {
1333
1342
  return entry === plugin || Array.isArray(entry) && entry[0] === plugin;
1334
1343
  }
1344
+ function setSinglePluginSpec(config, previousPlugin, nextPlugin) {
1345
+ const current = Array.isArray(config.plugin) ? config.plugin : [];
1346
+ const next = current.filter((entry) => !isInsightsPluginEntry(entry, previousPlugin, nextPlugin));
1347
+ config.plugin = [...next, nextPlugin];
1348
+ }
1349
+ function isInsightsPluginEntry(entry, packagePlugin, localPlugin) {
1350
+ if (isPluginEntry(entry, packagePlugin) || isPluginEntry(entry, localPlugin) || isPluginEntry(entry, SUBPATH_TUI_PLUGIN_SPEC)) {
1351
+ return true;
1352
+ }
1353
+ const spec = Array.isArray(entry) ? entry[0] : entry;
1354
+ if (typeof spec !== "string") return false;
1355
+ return /(?:^|[/@-])opencode-insights.*\.tgz$/u.test(spec) || /\/opencode-insights\/dist\/(?:index|tui)\.js$/u.test(spec);
1356
+ }
1335
1357
  async function uninstallOpenCode(options) {
1336
1358
  const configDir = options.configDir ?? defaultOpenCodeConfigDir();
1337
1359
  const opencodePath = resolveOpenCodeConfigPath(configDir);
@@ -1346,8 +1368,10 @@ async function uninstallOpenCode(options) {
1346
1368
  ];
1347
1369
  const opencodeResult = await removePluginFromConfig(opencodePath, SERVER_PLUGIN_SPEC, options);
1348
1370
  const tuiResult = await removePluginFromConfig(tuiPath, TUI_PLUGIN_SPEC, options);
1371
+ const subpathTuiResult = await removePluginFromConfig(tuiPath, SUBPATH_TUI_PLUGIN_SPEC, options);
1349
1372
  lines.push(`Server plugin: ${opencodeResult}`);
1350
1373
  lines.push(`TUI plugin: ${tuiResult}`);
1374
+ lines.push(`Subpath TUI plugin: ${subpathTuiResult}`);
1351
1375
  if (options.keepData) {
1352
1376
  lines.push("Data cleanup: skipped (--keep-data).");
1353
1377
  } else {
@@ -1387,7 +1411,7 @@ async function writeJsonConfig(path, config) {
1387
1411
  function usage() {
1388
1412
  return [
1389
1413
  "Usage:",
1390
- " opencode-insights configure [--config-dir DIR] [--dry-run]",
1414
+ " opencode-insights debug [--config-dir DIR] [--dry-run]",
1391
1415
  " opencode-insights uninstall [--config-dir DIR] [--db PATH] [--data-dir DIR] [--keep-data] [--dry-run]",
1392
1416
  " opencode-insights recent [--db PATH] [--data-dir DIR] [--limit N] [--json]",
1393
1417
  " opencode-insights sessions [--db PATH] [--data-dir DIR] [--limit N] [--json]",
@@ -1418,7 +1442,7 @@ if (isDirectRun()) {
1418
1442
  }
1419
1443
  export {
1420
1444
  addUniquePlugin,
1421
- configureOpenCode,
1445
+ configureOpenCodeDebug,
1422
1446
  defaultOpenCodeConfigDir,
1423
1447
  formatSessionSummary,
1424
1448
  parseOptions,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Plugin } from '@opencode-ai/plugin';
2
+ import { TuiPlugin } from '@opencode-ai/plugin/tui';
2
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
4
 
4
5
  type StreamSample = {
@@ -102,10 +103,13 @@ declare function renderSubagentFooter(state: SubagentState, parentID: string, op
102
103
 
103
104
  declare const OpenCodeInsights: Plugin;
104
105
  declare const server: Plugin;
106
+ declare const rootTui: TuiPlugin;
105
107
  declare const id = "opencode-insights";
108
+
106
109
  declare const _default: {
107
110
  id: string;
108
111
  server: Plugin;
112
+ tui: TuiPlugin;
109
113
  };
110
114
 
111
- 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 };
115
+ 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
@@ -13,7 +13,7 @@ import {
13
13
  renderSubagentFooter,
14
14
  renderSubagentSidebar,
15
15
  renderSubagentStatus
16
- } from "./chunk-N3MIWWYE.js";
16
+ } from "./chunk-36ZNCLI3.js";
17
17
  import {
18
18
  JsonlCaptureStore,
19
19
  SqliteCaptureStore,
@@ -73,8 +73,12 @@ var OpenCodeInsights = async (_input, options) => {
73
73
  };
74
74
  };
75
75
  var server = OpenCodeInsights;
76
+ var rootTui = async (...args) => {
77
+ const mod = await import("./tui.js");
78
+ return mod.tui(...args);
79
+ };
76
80
  var id = "opencode-insights";
77
- var src_default = { id, server };
81
+ var src_default = { id, server, tui: rootTui };
78
82
  export {
79
83
  JsonlCaptureStore,
80
84
  OpenCodeInsights,
@@ -105,5 +109,6 @@ export {
105
109
  renderSubagentSidebar,
106
110
  renderSubagentStatus,
107
111
  resolveCapturePath,
108
- server
112
+ server,
113
+ rootTui as tui
109
114
  };
package/dist/tui.js CHANGED
@@ -8,11 +8,11 @@ import {
8
8
  recordToolActivity,
9
9
  renderMetricsText,
10
10
  renderSubagentFooter
11
- } from "./chunk-N3MIWWYE.js";
11
+ } from "./chunk-36ZNCLI3.js";
12
12
 
13
13
  // src/tui.tsx
14
14
  import { createTextAttributes, StyledText } from "@opentui/core";
15
- import { onCleanup } from "solid-js";
15
+ import { createSignal, onCleanup } from "solid-js";
16
16
  import { jsx } from "@opentui/solid/jsx-runtime";
17
17
  function isSessionID(value) {
18
18
  return typeof value === "string" && value.startsWith("ses");
@@ -21,7 +21,10 @@ function PromptRight(props) {
21
21
  let text;
22
22
  const sync = () => {
23
23
  if (!text) return;
24
- text.content = props.text();
24
+ const content = props.text();
25
+ text.content = content;
26
+ text.visible = content.length > 0;
27
+ text.height = content.length > 0 ? "auto" : 0;
25
28
  props.api.renderer.requestRender();
26
29
  };
27
30
  const unsubscribe = props.subscribe(sync);
@@ -61,10 +64,18 @@ function ReactiveText(props) {
61
64
  }
62
65
  function SubagentSidebar(props) {
63
66
  let text;
67
+ const [collapsed, setCollapsed] = createSignal(false);
64
68
  const titleAttributes = createTextAttributes({ bold: true });
69
+ const toggle = () => {
70
+ setCollapsed((prev) => !prev);
71
+ props.api.renderer.requestRender();
72
+ };
65
73
  const sync = () => {
66
74
  if (!text) return;
67
- text.content = renderSubagentStyledSidebar(props.state, props.sessionID, props.api, titleAttributes);
75
+ const model = getSubagentSidebarModel(props.state, props.sessionID);
76
+ text.visible = !!model;
77
+ text.height = model ? "auto" : 0;
78
+ text.content = model ? renderSubagentStyledSidebar(props.state, props.sessionID, props.api, titleAttributes, collapsed()) : "";
68
79
  props.api.renderer.requestRender();
69
80
  };
70
81
  const unsubscribe = props.subscribe(sync);
@@ -80,25 +91,31 @@ function SubagentSidebar(props) {
80
91
  text = ref;
81
92
  sync();
82
93
  },
94
+ onMouseDown: toggle,
83
95
  fg: props.api.theme.current.textMuted,
84
96
  children: ""
85
97
  }
86
98
  );
87
99
  }
88
- function renderSubagentStyledSidebar(state, sessionID, api, titleAttributes) {
100
+ function renderSubagentStyledSidebar(state, sessionID, api, titleAttributes, collapsed) {
89
101
  const model = getSubagentSidebarModel(state, sessionID);
90
102
  if (!model) return "";
103
+ const indicator = collapsed ? "\u25B6 " : "\u25BC ";
91
104
  const chunks = [
92
- textChunk(`${model.title}
105
+ textChunk(`${indicator}${model.title}
93
106
  `, api.theme.current.text, titleAttributes),
94
107
  textChunk(`${model.summary}
95
108
  `, api.theme.current.textMuted)
96
109
  ];
97
- for (const [index, row] of model.rows.entries()) {
98
- if (index > 0) chunks.push(textChunk("\n", api.theme.current.textMuted));
99
- chunks.push(textChunk(`${row.title}
110
+ if (!collapsed) {
111
+ for (const [index, row] of model.rows.entries()) {
112
+ if (index > 0) chunks.push(textChunk("\n"));
113
+ const dotColor = row.status === "running" ? api.theme.current.success : row.status === "error" ? api.theme.current.error : api.theme.current.textMuted;
114
+ chunks.push(textChunk("\u2022 ", dotColor));
115
+ chunks.push(textChunk(`${row.title}
100
116
  `, api.theme.current.text));
101
- chunks.push(textChunk(row.subtitle, api.theme.current.textMuted));
117
+ chunks.push(textChunk(row.subtitle, api.theme.current.textMuted));
118
+ }
102
119
  }
103
120
  return new StyledText(chunks);
104
121
  }
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.2",
4
+ "version": "0.1.3",
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",
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsup",
49
+ "debug": "npm run build && node dist/cli.js debug",
49
50
  "test": "vitest run",
50
51
  "typecheck": "tsc --noEmit",
51
52
  "verify": "npm run typecheck && npm run test && npm run build",
package/DEVELOPMENT.md DELETED
@@ -1,124 +0,0 @@
1
- # Development
2
-
3
- Notes for maintaining and publishing `opencode-insights`.
4
-
5
- ## Local Testing
6
-
7
- From this repo:
8
-
9
- ```bash
10
- cd /Users/zyao/Desktop/opencode-insights
11
- npm install
12
- npm run verify
13
- npm pack
14
- ```
15
-
16
- Install the packed plugin from your OpenCode config/package directory:
17
-
18
- ```bash
19
- cd ~/.config/opencode
20
- npm i /Users/zyao/Desktop/opencode-insights/rejacky-opencode-insights-*.tgz
21
- npx opencode-insights configure
22
- ```
23
-
24
- For local repo development without relying on the installed package binary:
25
-
26
- ```bash
27
- node /Users/zyao/Desktop/opencode-insights/dist/cli.js configure --config-dir ~/.config/opencode
28
- ```
29
-
30
- Restart OpenCode after reinstalling or rebuilding. Existing sessions will not gain missing events retroactively, so create a new session to test capture changes.
31
-
32
- ## Faster Local Iteration
33
-
34
- Link instead of packing each time:
35
-
36
- ```bash
37
- cd /Users/zyao/Desktop/opencode-insights
38
- npm link
39
-
40
- cd ~/.config/opencode
41
- npm link @rejacky/opencode-insights
42
- ```
43
-
44
- After code changes:
45
-
46
- ```bash
47
- cd /Users/zyao/Desktop/opencode-insights
48
- npm run build
49
- node /Users/zyao/Desktop/opencode-insights/dist/cli.js configure --config-dir ~/.config/opencode
50
- ```
51
-
52
- ## Verification
53
-
54
- Run all checks:
55
-
56
- ```bash
57
- npm run verify
58
- ```
59
-
60
- Individual commands:
61
-
62
- ```bash
63
- npm run typecheck
64
- npm test
65
- npm run build
66
- ```
67
-
68
- ## Automated npm Publishing
69
-
70
- The repo publishes from GitHub Actions when `package.json` is pushed to `main` or `master` with a version that is not already on npm.
71
-
72
- One-time npm setup:
73
-
74
- 1. Go to npm package settings for `@rejacky/opencode-insights`.
75
- 2. Open the package publishing / trusted publishing settings.
76
- 3. Add a trusted publisher for repository `Re-Jacky/opencode-insights`.
77
- 4. Use workflow file `.github/workflows/publish.yml`.
78
- 5. Keep the package public.
79
-
80
- No `NPM_TOKEN` secret is needed when npm trusted publishing is configured. The workflow uses GitHub OIDC plus `npm publish --provenance`.
81
-
82
- If GitHub Actions fails with `404 Not Found - PUT https://registry.npmjs.org/@rejacky%2fopencode-insights`, npm found the registry but rejected package write access. Check that the npm package's trusted publisher entry exactly matches the GitHub owner, repo, and workflow file path above. Also confirm the npm account configuring trusted publishing owns or has publish access to `@rejacky/opencode-insights`.
83
-
84
- Release flow:
85
-
86
- ```bash
87
- git status
88
- npm version patch
89
- git push --follow-tags
90
- ```
91
-
92
- Use `npm version minor` or `npm version major` for larger releases. The workflow will run verification first, skip publishing if that exact version already exists, and publish only unpublished versions.
93
-
94
- Manual fallback:
95
-
96
- ```bash
97
- npm run verify
98
- npm pack --dry-run
99
- npm publish --access public --provenance
100
- ```
101
-
102
- ## Manual Publish Checklist
103
-
104
- Review package contents:
105
-
106
- ```bash
107
- npm pack
108
- tar -tf rejacky-opencode-insights-0.1.1.tgz
109
- ```
110
-
111
- Publish manually if GitHub Actions is unavailable:
112
-
113
- ```bash
114
- npm login
115
- npm publish --access public --provenance
116
- ```
117
-
118
- After publishing, users should be able to install from their OpenCode config/package directory with:
119
-
120
- ```bash
121
- cd ~/.config/opencode
122
- npm i @rejacky/opencode-insights
123
- npx opencode-insights configure
124
- ```