opencode-tbot 0.1.3 → 0.1.4

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/plugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { i as preparePluginConfiguration, s as loadAppConfig } from "./assets/plugin-config-BYsYAzvx.js";
2
2
  import { mkdir, readFile, rename, stat, writeFile } from "node:fs/promises";
3
- import { basename, dirname, extname, join } from "node:path";
3
+ import { basename, dirname, extname, isAbsolute, join } from "node:path";
4
4
  import { parse, printParseErrorCode } from "jsonc-parser";
5
5
  import { z } from "zod";
6
6
  import { OpenRouter } from "@openrouter/sdk";
@@ -1052,11 +1052,11 @@ async function loadWorkspaceStatusResult(chatId, path, listSessionsUseCase, sess
1052
1052
  status: "error"
1053
1053
  };
1054
1054
  const binding = await sessionRepo.getByChatId(chatId);
1055
- let currentProject = path.data.directory;
1055
+ let currentProject = resolveWorkspaceProjectPath(path.data);
1056
1056
  let currentSession = binding?.sessionId ?? null;
1057
1057
  try {
1058
1058
  const sessions = await listSessionsUseCase.execute({ chatId });
1059
- currentProject = sessions.currentDirectory;
1059
+ currentProject = resolveWorkspaceProjectPath(path.data, sessions.currentDirectory);
1060
1060
  currentSession = sessions.currentSessionId ? formatSessionStatusLabel(sessions.sessions.find((session) => session.id === sessions.currentSessionId) ?? null, sessions.currentSessionId) : null;
1061
1061
  } catch {}
1062
1062
  return {
@@ -1072,6 +1072,20 @@ function formatSessionStatusLabel(session, fallbackId) {
1072
1072
  const title = session.title.trim() || session.slug || session.id;
1073
1073
  return title === session.slug ? title : `${title} (${session.slug})`;
1074
1074
  }
1075
+ function resolveWorkspaceProjectPath(path, preferredPath) {
1076
+ const candidates = [
1077
+ preferredPath,
1078
+ path.worktree,
1079
+ path.directory
1080
+ ];
1081
+ for (const candidate of candidates) if (isUsableWorkspacePath(candidate)) return candidate;
1082
+ return preferredPath ?? path.worktree ?? path.directory;
1083
+ }
1084
+ function isUsableWorkspacePath(value) {
1085
+ if (typeof value !== "string") return false;
1086
+ const normalized = value.trim();
1087
+ return normalized.length > 0 && normalized !== "/" && normalized !== "\\" && isAbsolute(normalized);
1088
+ }
1075
1089
  async function resolveOpenCodeConfigFilePath(configPath) {
1076
1090
  try {
1077
1091
  return (await stat(configPath)).isDirectory() ? join(configPath, "opencode.json") : configPath;
@@ -2636,32 +2650,26 @@ var VARIANT_ORDER = [
2636
2650
  ];
2637
2651
  function presentStatusMessage(input, copy = BOT_COPY) {
2638
2652
  const layout = getStatusLayoutCopy(copy);
2639
- const sections = [
2653
+ return presentStatusSections([
2640
2654
  presentStatusPlainSection(layout.overviewTitle, presentStatusPlainOverviewLines(input, copy, layout)),
2641
2655
  presentStatusPlainSection(layout.workspaceTitle, presentStatusPlainWorkspaceLines(input, copy, layout)),
2642
2656
  presentStatusPlainSection(layout.pluginsTitle, presentStatusPlainPluginLines(input, copy, layout)),
2643
2657
  presentStatusPlainSection(layout.mcpTitle, presentStatusPlainMcpLines(input, copy, layout)),
2644
2658
  presentStatusPlainSection(layout.lspTitle, presentStatusPlainLspLines(input, copy, layout))
2645
- ];
2646
- return presentStatusSections(layout.pageTitle, sections);
2659
+ ]);
2647
2660
  }
2648
2661
  function presentStatusMarkdownMessage(input, copy = BOT_COPY) {
2649
2662
  const layout = getStatusLayoutCopy(copy);
2650
- const sections = [
2663
+ return presentStatusSections([
2651
2664
  presentStatusMarkdownSection(layout.overviewTitle, presentStatusMarkdownOverviewLines(input, copy, layout)),
2652
2665
  presentStatusMarkdownSection(layout.workspaceTitle, presentStatusMarkdownWorkspaceLines(input, copy, layout)),
2653
2666
  presentStatusMarkdownSection(layout.pluginsTitle, presentStatusMarkdownPluginLines(input, copy, layout)),
2654
2667
  presentStatusMarkdownSection(layout.mcpTitle, presentStatusMarkdownMcpLines(input, copy, layout)),
2655
2668
  presentStatusMarkdownSection(layout.lspTitle, presentStatusMarkdownLspLines(input, copy, layout))
2656
- ];
2657
- return presentStatusSections(`# ${layout.pageTitle}`, sections);
2669
+ ]);
2658
2670
  }
2659
- function presentStatusSections(title, sections) {
2660
- return [
2661
- title,
2662
- "",
2663
- ...sections.flatMap((section, index) => index === 0 ? [section] : ["", section])
2664
- ].join("\n");
2671
+ function presentStatusSections(sections) {
2672
+ return sections.flatMap((section, index) => index === 0 ? [section] : ["", section]).join("\n");
2665
2673
  }
2666
2674
  function presentStatusPlainSection(title, lines) {
2667
2675
  return [title, ...lines].join("\n");
@@ -2818,7 +2826,7 @@ function getMcpStatusDetailLines(status, copy, layout) {
2818
2826
  }
2819
2827
  function formatMcpStatusNotes(status, copy, layout) {
2820
2828
  switch (status.status) {
2821
- case "connected": return layout.okLabel;
2829
+ case "connected": return null;
2822
2830
  case "disabled": return null;
2823
2831
  case "needs_auth": return copy.mcp.needsAuth;
2824
2832
  case "failed": return status.error;
@@ -2849,9 +2857,7 @@ function getStatusLayoutCopy(copy) {
2849
2857
  noPluginsMessage: "No plugins configured in the OpenCode config.",
2850
2858
  noneStatus: "⚪",
2851
2859
  openCodeVersionLabel: "OpenCode Version",
2852
- okLabel: "OK",
2853
2860
  overviewTitle: "🖥️ Overview",
2854
- pageTitle: "📊 Service Status",
2855
2861
  pluginsTitle: "🧩 Plugins",
2856
2862
  rootLabel: "Root",
2857
2863
  statusLabel: "Status",
@@ -2874,9 +2880,7 @@ function getStatusLayoutCopy(copy) {
2874
2880
  noPluginsMessage: "当前 OpenCode 配置中未配置插件。",
2875
2881
  noneStatus: "⚪",
2876
2882
  openCodeVersionLabel: "OpenCode版本",
2877
- okLabel: "正常",
2878
2883
  overviewTitle: "🖥️ 概览",
2879
- pageTitle: "📊 服务状态",
2880
2884
  pluginsTitle: "🧩 插件",
2881
2885
  rootLabel: "根目录",
2882
2886
  statusLabel: "状态",