소스 검색

feat: unwrap BusEvent namespace to flat exports + barrel

Kit Langton 4 일 전
부모
커밋
c454c4acc5
32개의 변경된 파일54개의 추가작업 그리고 55개의 파일을 삭제
  1. 23 25
      packages/opencode/src/bus/bus-event.ts
  2. 1 1
      packages/opencode/src/bus/bus.ts
  3. 1 0
      packages/opencode/src/bus/index.ts
  4. 1 1
      packages/opencode/src/cli/cmd/tui/event.ts
  5. 1 1
      packages/opencode/src/command/command.ts
  6. 1 1
      packages/opencode/src/control-plane/workspace.ts
  7. 1 1
      packages/opencode/src/file/file.ts
  8. 1 1
      packages/opencode/src/file/watcher.ts
  9. 1 1
      packages/opencode/src/ide/ide.ts
  10. 1 1
      packages/opencode/src/installation/installation.ts
  11. 1 1
      packages/opencode/src/lsp/client.ts
  12. 1 1
      packages/opencode/src/lsp/lsp.ts
  13. 1 1
      packages/opencode/src/mcp/mcp.ts
  14. 1 1
      packages/opencode/src/permission/permission.ts
  15. 1 1
      packages/opencode/src/project/project.ts
  16. 1 1
      packages/opencode/src/project/vcs.ts
  17. 1 1
      packages/opencode/src/pty/service.ts
  18. 1 1
      packages/opencode/src/question/index.ts
  19. 1 1
      packages/opencode/src/server/event.ts
  20. 1 1
      packages/opencode/src/server/instance/event.ts
  21. 1 1
      packages/opencode/src/server/instance/global.ts
  22. 1 1
      packages/opencode/src/session/compaction.ts
  23. 1 1
      packages/opencode/src/session/message-v2.ts
  24. 1 1
      packages/opencode/src/session/session.ts
  25. 1 1
      packages/opencode/src/session/status.ts
  26. 1 1
      packages/opencode/src/session/todo.ts
  27. 1 1
      packages/opencode/src/sync/sync-event.ts
  28. 1 1
      packages/opencode/src/worktree/worktree.ts
  29. 1 1
      packages/opencode/test/bus/bus-effect.test.ts
  30. 1 1
      packages/opencode/test/bus/bus-integration.test.ts
  31. 1 1
      packages/opencode/test/bus/bus.test.ts
  32. 1 1
      packages/opencode/test/tool/edit.test.ts

+ 23 - 25
packages/opencode/src/bus/bus-event.ts

@@ -1,33 +1,31 @@
 import z from "zod"
 import type { ZodType } from "zod"
 
-export namespace BusEvent {
-  export type Definition = ReturnType<typeof define>
+export type Definition = ReturnType<typeof define>
 
-  const registry = new Map<string, Definition>()
+const registry = new Map<string, Definition>()
 
-  export function define<Type extends string, Properties extends ZodType>(type: Type, properties: Properties) {
-    const result = {
-      type,
-      properties,
-    }
-    registry.set(type, result)
-    return result
+export function define<Type extends string, Properties extends ZodType>(type: Type, properties: Properties) {
+  const result = {
+    type,
+    properties,
   }
+  registry.set(type, result)
+  return result
+}
 
-  export function payloads() {
-    return registry
-      .entries()
-      .map(([type, def]) => {
-        return z
-          .object({
-            type: z.literal(type),
-            properties: def.properties,
-          })
-          .meta({
-            ref: `Event.${def.type}`,
-          })
-      })
-      .toArray()
-  }
+export function payloads() {
+  return registry
+    .entries()
+    .map(([type, def]) => {
+      return z
+        .object({
+          type: z.literal(type),
+          properties: def.properties,
+        })
+        .meta({
+          ref: `Event.${def.type}`,
+        })
+    })
+    .toArray()
 }

+ 1 - 1
packages/opencode/src/bus/bus.ts

@@ -2,7 +2,7 @@ import z from "zod"
 import { Effect, Exit, Layer, PubSub, Scope, Context, Stream } from "effect"
 import { EffectBridge } from "@/effect"
 import { Log } from "../util"
-import { BusEvent } from "./bus-event"
+import * as BusEvent from "./bus-event"
 import { GlobalBus } from "./global"
 import { InstanceState } from "@/effect"
 import { makeRuntime } from "@/effect/run-service"

+ 1 - 0
packages/opencode/src/bus/index.ts

@@ -1 +1,2 @@
 export * as Bus from "./bus"
+export * as BusEvent from "./bus-event"

+ 1 - 1
packages/opencode/src/cli/cmd/tui/event.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { SessionID } from "@/session/schema"
 import z from "zod"
 

+ 1 - 1
packages/opencode/src/command/command.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { InstanceState } from "@/effect"
 import { EffectBridge } from "@/effect"
 import type { InstanceContext } from "@/project/instance"

+ 1 - 1
packages/opencode/src/control-plane/workspace.ts

@@ -3,7 +3,7 @@ import { setTimeout as sleep } from "node:timers/promises"
 import { fn } from "@/util/fn"
 import { Database, asc, eq, inArray } from "@/storage"
 import { Project } from "@/project"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { GlobalBus } from "@/bus/global"
 import { SyncEvent } from "@/sync"
 import { EventTable } from "@/sync/event.sql"

+ 1 - 1
packages/opencode/src/file/file.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { InstanceState } from "@/effect"
 
 import { AppFileSystem } from "@opencode-ai/shared/filesystem"

+ 1 - 1
packages/opencode/src/file/watcher.ts

@@ -6,7 +6,7 @@ import { readdir } from "fs/promises"
 import path from "path"
 import z from "zod"
 import { Bus } from "@/bus"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { InstanceState } from "@/effect"
 import { Flag } from "@/flag/flag"
 import { Git } from "@/git"

+ 1 - 1
packages/opencode/src/ide/ide.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import z from "zod"
 import { NamedError } from "@opencode-ai/shared/util/error"
 import { Log } from "../util"

+ 1 - 1
packages/opencode/src/installation/installation.ts

@@ -5,7 +5,7 @@ import { withTransientReadRetry } from "@/util/effect-http-client"
 import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
 import path from "path"
 import z from "zod"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Flag } from "../flag/flag"
 import { Log } from "../util"
 

+ 1 - 1
packages/opencode/src/lsp/client.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Bus } from "@/bus"
 import path from "path"
 import { pathToFileURL, fileURLToPath } from "url"

+ 1 - 1
packages/opencode/src/lsp/lsp.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Bus } from "@/bus"
 import { Log } from "../util"
 import * as LSPClient from "./client"

+ 1 - 1
packages/opencode/src/mcp/mcp.ts

@@ -21,7 +21,7 @@ import { AppFileSystem } from "@opencode-ai/shared/filesystem"
 import { McpOAuthProvider } from "./oauth-provider"
 import { McpOAuthCallback } from "./oauth-callback"
 import { McpAuth } from "./auth"
-import { BusEvent } from "../bus/bus-event"
+import { BusEvent } from "../bus"
 import { Bus } from "@/bus"
 import { TuiEvent } from "@/cli/cmd/tui/event"
 import open from "open"

+ 1 - 1
packages/opencode/src/permission/permission.ts

@@ -1,5 +1,5 @@
 import { Bus } from "@/bus"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Config } from "@/config"
 import { InstanceState } from "@/effect"
 import { ProjectID } from "@/project/schema"

+ 1 - 1
packages/opencode/src/project/project.ts

@@ -4,7 +4,7 @@ import { ProjectTable } from "./project.sql"
 import { SessionTable } from "../session/session.sql"
 import { Log } from "../util"
 import { Flag } from "@/flag/flag"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { GlobalBus } from "@/bus/global"
 import { which } from "../util/which"
 import { ProjectID } from "./schema"

+ 1 - 1
packages/opencode/src/project/vcs.ts

@@ -2,7 +2,7 @@ import { Effect, Layer, Context, Stream, Scope } from "effect"
 import { formatPatch, structuredPatch } from "diff"
 import path from "path"
 import { Bus } from "@/bus"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { InstanceState } from "@/effect"
 import { AppFileSystem } from "@opencode-ai/shared/filesystem"
 import { FileWatcher } from "@/file/watcher"

+ 1 - 1
packages/opencode/src/pty/service.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Bus } from "@/bus"
 import { InstanceState } from "@/effect"
 import { Instance } from "@/project/instance"

+ 1 - 1
packages/opencode/src/question/index.ts

@@ -1,6 +1,6 @@
 import { Deferred, Effect, Layer, Schema, Context } from "effect"
 import { Bus } from "@/bus"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { InstanceState } from "@/effect"
 import { SessionID, MessageID } from "@/session/schema"
 import { zod } from "@/util/effect-zod"

+ 1 - 1
packages/opencode/src/server/event.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import z from "zod"
 
 export const Event = {

+ 1 - 1
packages/opencode/src/server/instance/event.ts

@@ -3,7 +3,7 @@ import { Hono } from "hono"
 import { describeRoute, resolver } from "hono-openapi"
 import { streamSSE } from "hono/streaming"
 import { Log } from "@/util"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Bus } from "@/bus"
 import { AsyncQueue } from "../../util/queue"
 

+ 1 - 1
packages/opencode/src/server/instance/global.ts

@@ -3,7 +3,7 @@ import { describeRoute, resolver, validator } from "hono-openapi"
 import { streamSSE } from "hono/streaming"
 import { Effect } from "effect"
 import z from "zod"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { SyncEvent } from "@/sync"
 import { GlobalBus } from "@/bus/global"
 import { AppRuntime } from "@/effect/app-runtime"

+ 1 - 1
packages/opencode/src/session/compaction.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Bus } from "@/bus"
 import * as Session from "./session"
 import { SessionID, MessageID, PartID } from "./schema"

+ 1 - 1
packages/opencode/src/session/message-v2.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { SessionID, MessageID, PartID } from "./schema"
 import z from "zod"
 import { NamedError } from "@opencode-ai/shared/util/error"

+ 1 - 1
packages/opencode/src/session/session.ts

@@ -1,6 +1,6 @@
 import { Slug } from "@opencode-ai/shared/util/slug"
 import path from "path"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Bus } from "@/bus"
 import { Decimal } from "decimal.js"
 import z from "zod"

+ 1 - 1
packages/opencode/src/session/status.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Bus } from "@/bus"
 import { InstanceState } from "@/effect"
 import { SessionID } from "./schema"

+ 1 - 1
packages/opencode/src/session/todo.ts

@@ -1,4 +1,4 @@
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Bus } from "@/bus"
 import { SessionID } from "./schema"
 import { Effect, Layer, Context } from "effect"

+ 1 - 1
packages/opencode/src/sync/sync-event.ts

@@ -3,7 +3,7 @@ import type { ZodObject } from "zod"
 import { Database, eq } from "@/storage"
 import { GlobalBus } from "@/bus/global"
 import { Bus as ProjectBus } from "@/bus"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { Instance } from "@/project/instance"
 import { EventSequenceTable, EventTable } from "./event.sql"
 import { WorkspaceContext } from "@/control-plane/workspace-context"

+ 1 - 1
packages/opencode/src/worktree/worktree.ts

@@ -10,7 +10,7 @@ import type { ProjectID } from "../project/schema"
 import { Log } from "../util"
 import { Slug } from "@opencode-ai/shared/util/slug"
 import { errorMessage } from "../util/error"
-import { BusEvent } from "@/bus/bus-event"
+import { BusEvent } from "@/bus"
 import { GlobalBus } from "@/bus/global"
 import { Git } from "@/git"
 import { Effect, Layer, Path, Scope, Context, Stream } from "effect"

+ 1 - 1
packages/opencode/test/bus/bus-effect.test.ts

@@ -2,7 +2,7 @@ import { describe, expect } from "bun:test"
 import { Deferred, Effect, Layer, Stream } from "effect"
 import z from "zod"
 import { Bus } from "../../src/bus"
-import { BusEvent } from "../../src/bus/bus-event"
+import { BusEvent } from "../../src/bus"
 import { Instance } from "../../src/project/instance"
 import * as CrossSpawnSpawner from "../../src/effect/cross-spawn-spawner"
 import { provideInstance, provideTmpdirInstance, tmpdirScoped } from "../fixture/fixture"

+ 1 - 1
packages/opencode/test/bus/bus-integration.test.ts

@@ -1,7 +1,7 @@
 import { afterEach, describe, expect, test } from "bun:test"
 import z from "zod"
 import { Bus } from "../../src/bus"
-import { BusEvent } from "../../src/bus/bus-event"
+import { BusEvent } from "../../src/bus"
 import { Instance } from "../../src/project/instance"
 import { tmpdir } from "../fixture/fixture"
 

+ 1 - 1
packages/opencode/test/bus/bus.test.ts

@@ -1,7 +1,7 @@
 import { afterEach, describe, expect, test } from "bun:test"
 import z from "zod"
 import { Bus } from "../../src/bus"
-import { BusEvent } from "../../src/bus/bus-event"
+import { BusEvent } from "../../src/bus"
 import { Instance } from "../../src/project/instance"
 import { tmpdir } from "../fixture/fixture"
 

+ 1 - 1
packages/opencode/test/tool/edit.test.ts

@@ -11,7 +11,7 @@ import { AppFileSystem } from "@opencode-ai/shared/filesystem"
 import { Format } from "../../src/format"
 import { Agent } from "../../src/agent/agent"
 import { Bus } from "../../src/bus"
-import { BusEvent } from "../../src/bus/bus-event"
+import { BusEvent } from "../../src/bus"
 import { Truncate } from "../../src/tool"
 import { SessionID, MessageID } from "../../src/session/schema"