@koriit/opencode-claude-bridge 0.1.7 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koriit/opencode-claude-bridge",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "An OpenCode plugin that bridges enabled Claude Code plugins (commands, agents, skills, MCP, LSP) into OpenCode at runtime, namespaced so they never shadow your existing items.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@ import { injectCommandsAndAgents } from "./inject.js"
5
5
  import { injectSkills } from "./skill-inject.js"
6
6
  import { injectMcp } from "./mcp-inject.js"
7
7
  import { injectLsp } from "./lsp-inject.js"
8
- import { createLogger, type LoggingClient } from "./logger.js"
8
+ import { createLogger } from "./logger.js"
9
9
  import { listClaudePlugins, selectEnabledPlugins } from "./selection.js"
10
10
  import { collectExistingSkillNames } from "./skill-scan.js"
11
11
 
@@ -51,7 +51,7 @@ export const server: Plugin = async (_input, options) => {
51
51
 
52
52
  return {
53
53
  config: async (cfg) => {
54
- const logger = createLogger(bridge.strict, _input.client as unknown as LoggingClient)
54
+ const logger = createLogger(bridge.strict)
55
55
  try {
56
56
  // Replay parse-time validation warnings (strict-promotable).
57
57
  for (const w of warnings) logger.warn(w)
package/src/logger.ts CHANGED
@@ -1,8 +1,3 @@
1
- /** Minimal duck-type for the OpenCode client — only the log() method we use. */
2
- export interface LoggingClient {
3
- log(params: { service?: string; level?: "debug" | "info" | "warn" | "error"; message?: string }): unknown
4
- }
5
-
6
1
  /** Thrown when a soft warning is promoted to a hard error under `strict` mode. */
7
2
  export class BridgeError extends Error {
8
3
  override name = "BridgeError"
@@ -29,14 +24,16 @@ export interface Logger {
29
24
  hadWarnings(): boolean
30
25
  }
31
26
 
32
-
33
27
  /**
34
- * Fallback output logger used when no real OpenCode client is available (tests,
35
- * edge-case early errors). Writes to process.stderr in OpenCode's structured
36
- * format and only when --print-logs is in argv — matching OpenCode's own
37
- * log-visibility behaviour.
28
+ * Internal output logger. Writes to process.stderr in OpenCode's structured
29
+ * log format, gated on --print-logs to match OpenCode's own log-visibility
30
+ * behaviour.
31
+ *
32
+ * Note: client.log() (HTTP POST to /log) was tried but is unreliable during
33
+ * the config hook because it fires during server bootstrap before the /log
34
+ * endpoint is ready. Direct stderr write is the safe, synchronous alternative.
38
35
  */
39
- const fallbackLog = (() => {
36
+ const log = (() => {
40
37
  const enabled = process.argv.includes("--print-logs")
41
38
  let last = Date.now()
42
39
 
@@ -56,43 +53,21 @@ const fallbackLog = (() => {
56
53
  })()
57
54
 
58
55
  /**
59
- * Create a logger bound to the resolved `strict` flag and the OpenCode client.
60
- *
61
- * When a client is provided, log entries are posted to the server via
62
- * `client.log()` — they flow through OpenCode's own log pipeline, appear in
63
- * the log file, and respect `--print-logs` automatically.
64
- *
65
- * When no client is provided (tests, early-startup errors) the fallback logger
66
- * writes to process.stderr in the same format, gated on `--print-logs`.
56
+ * Create a logger bound to the resolved `strict` flag. The hook itself is
57
+ * responsible for catching {@link BridgeError} in non-strict paths; in strict
58
+ * mode the error propagates so OpenCode surfaces a hard failure.
67
59
  */
68
- export function createLogger(strict: boolean, client?: LoggingClient): Logger {
60
+ export function createLogger(strict: boolean): Logger {
69
61
  let warningCount = 0
70
-
71
- function logInfo(msg: string): void {
72
- if (typeof client?.log === "function") {
73
- void client.log({ service: "opencode-claude-bridge", level: "info", message: msg })
74
- } else {
75
- fallbackLog.info(msg)
76
- }
77
- }
78
-
79
- function logWarn(msg: string): void {
80
- if (typeof client?.log === "function") {
81
- void client.log({ service: "opencode-claude-bridge", level: "warn", message: msg })
82
- } else {
83
- fallbackLog.warn(msg)
84
- }
85
- }
86
-
87
62
  return {
88
63
  info(msg) {
89
- logInfo(msg)
64
+ log.info(msg)
90
65
  },
91
66
  warn(msg, opts) {
92
67
  const fatalInStrict = opts?.fatalInStrict ?? true
93
68
  warningCount++
94
69
  if (strict && fatalInStrict) throw new BridgeError(msg)
95
- logWarn(msg)
70
+ log.warn(msg)
96
71
  },
97
72
  hadWarnings() {
98
73
  return warningCount > 0