@koriit/opencode-claude-bridge 0.1.7 → 0.1.10

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.10",
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,10 @@ 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
+ // TEMPORARY DIAGNOSTIC remove before next release
55
+ process.stderr.write(`[ocb-debug] process.argv=${JSON.stringify(process.argv)}\n`)
56
+ process.stderr.write(`[ocb-debug] has --print-logs: ${process.argv.includes("--print-logs")}\n`)
57
+ const logger = createLogger(bridge.strict)
55
58
  try {
56
59
  // Replay parse-time validation warnings (strict-promotable).
57
60
  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,13 @@ 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: `LEVEL ISO-timestamp +Xms service=opencode-claude-bridge <message>`
30
+ *
31
+ * Gated on --print-logs to match OpenCode's own log-visibility behaviour.
38
32
  */
39
- const fallbackLog = (() => {
33
+ const log = (() => {
40
34
  const enabled = process.argv.includes("--print-logs")
41
35
  let last = Date.now()
42
36
 
@@ -56,43 +50,21 @@ const fallbackLog = (() => {
56
50
  })()
57
51
 
58
52
  /**
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`.
53
+ * Create a logger bound to the resolved `strict` flag. The hook itself is
54
+ * responsible for catching {@link BridgeError} in non-strict paths; in strict
55
+ * mode the error propagates so OpenCode surfaces a hard failure.
67
56
  */
68
- export function createLogger(strict: boolean, client?: LoggingClient): Logger {
57
+ export function createLogger(strict: boolean): Logger {
69
58
  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
59
  return {
88
60
  info(msg) {
89
- logInfo(msg)
61
+ log.info(msg)
90
62
  },
91
63
  warn(msg, opts) {
92
64
  const fatalInStrict = opts?.fatalInStrict ?? true
93
65
  warningCount++
94
66
  if (strict && fatalInStrict) throw new BridgeError(msg)
95
- logWarn(msg)
67
+ log.warn(msg)
96
68
  },
97
69
  hadWarnings() {
98
70
  return warningCount > 0