@@ -29,7 +29,6 @@ import { Provider } from "@/provider/provider" |
29 | 29 | import { Bus } from "../../bus" |
30 | 30 | import { MessageV2 } from "../../session/message-v2" |
31 | 31 | import { SessionPrompt } from "@/session/prompt" |
32 | | -import { AppRuntime } from "@/effect/app-runtime" |
33 | 32 | import { Git } from "@/git" |
34 | 33 | import { setTimeout as sleep } from "node:timers/promises" |
35 | 34 | import { Process } from "@/util/process" |
@@ -206,14 +205,16 @@ export const GithubInstallCommand = effectCmd({ |
206 | 205 | const maybeCtx = yield* InstanceRef |
207 | 206 | if (!maybeCtx) return yield* Effect.die("InstanceRef not provided") |
208 | 207 | const ctx = maybeCtx |
| 208 | + const modelsDev = yield* ModelsDev.Service |
| 209 | + const gitSvc = yield* Git.Service |
209 | 210 | yield* Effect.promise(async () => { |
210 | 211 | { |
211 | 212 | UI.empty() |
212 | 213 | prompts.intro("Install GitHub agent") |
213 | 214 | const app = await getAppInfo() |
214 | 215 | await installGitHubApp() |
215 | 216 |
|
216 | | - const providers = await AppRuntime.runPromise(ModelsDev.Service.use((s) => s.get())).then((p) => { |
| 217 | + const providers = await Effect.runPromise(modelsDev.get()).then((p) => { |
217 | 218 | // TODO: add guide for copilot, for now just hide it |
218 | 219 | delete p["github-copilot"] |
219 | 220 | return p |
@@ -261,9 +262,9 @@ export const GithubInstallCommand = effectCmd({ |
261 | 262 | } |
262 | 263 |
|
263 | 264 | // Get repo info |
264 | | - const info = await AppRuntime.runPromise( |
265 | | - Git.Service.use((git) => git.run(["remote", "get-url", "origin"], { cwd: ctx.worktree })), |
266 | | - ).then((x) => x.text().trim()) |
| 265 | + const info = await Effect.runPromise(gitSvc.run(["remote", "get-url", "origin"], { cwd: ctx.worktree })).then( |
| 266 | + (x) => x.text().trim(), |
| 267 | + ) |
267 | 268 | const parsed = parseGitHubRemote(info) |
268 | 269 | if (!parsed) { |
269 | 270 | prompts.log.error(`Could not find git repository. Please run this command from a git repository.`) |
@@ -440,6 +441,10 @@ export const GithubRunCommand = effectCmd({ |
440 | 441 | handler: Effect.fn("Cli.github.run")(function* (args) { |
441 | 442 | const ctx = yield* InstanceRef |
442 | 443 | if (!ctx) return yield* Effect.die("InstanceRef not provided") |
| 444 | + const gitSvc = yield* Git.Service |
| 445 | + const sessionSvc = yield* Session.Service |
| 446 | + const sessionShare = yield* SessionShare.Service |
| 447 | + const sessionPrompt = yield* SessionPrompt.Service |
443 | 448 | yield* Effect.promise(async () => { |
444 | 449 | const isMock = args.token || args.event |
445 | 450 |
|
@@ -503,21 +508,20 @@ export const GithubRunCommand = effectCmd({ |
503 | 508 | : "issue" |
504 | 509 | : undefined |
505 | 510 | const gitText = async (args: string[]) => { |
506 | | - const result = await AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: ctx.worktree }))) |
| 511 | + const result = await Effect.runPromise(gitSvc.run(args, { cwd: ctx.worktree })) |
507 | 512 | if (result.exitCode !== 0) { |
508 | 513 | throw new Process.RunFailedError(["git", ...args], result.exitCode, result.stdout, result.stderr) |
509 | 514 | } |
510 | 515 | return result.text().trim() |
511 | 516 | } |
512 | 517 | const gitRun = async (args: string[]) => { |
513 | | - const result = await AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: ctx.worktree }))) |
| 518 | + const result = await Effect.runPromise(gitSvc.run(args, { cwd: ctx.worktree })) |
514 | 519 | if (result.exitCode !== 0) { |
515 | 520 | throw new Process.RunFailedError(["git", ...args], result.exitCode, result.stdout, result.stderr) |
516 | 521 | } |
517 | 522 | return result |
518 | 523 | } |
519 | | - const gitStatus = (args: string[]) => |
520 | | - AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: ctx.worktree }))) |
| 524 | + const gitStatus = (args: string[]) => Effect.runPromise(gitSvc.run(args, { cwd: ctx.worktree })) |
521 | 525 | const commitChanges = async (summary: string, actor?: string) => { |
522 | 526 | const args = ["commit", "-m", summary] |
523 | 527 | if (actor) args.push("-m", `Co-authored-by: ${actor} <${actor}@users.noreply.github.com>`) |
@@ -554,24 +558,22 @@ export const GithubRunCommand = effectCmd({ |
554 | 558 |
|
555 | 559 | // Setup opencode session |
556 | 560 | const repoData = await fetchRepo() |
557 | | - session = await AppRuntime.runPromise( |
558 | | - Session.Service.use((svc) => |
559 | | - svc.create({ |
560 | | - permission: [ |
561 | | - { |
562 | | - permission: "question", |
563 | | - action: "deny", |
564 | | - pattern: "*", |
565 | | - }, |
566 | | - ], |
567 | | - }), |
568 | | - ), |
| 561 | + session = await Effect.runPromise( |
| 562 | + sessionSvc.create({ |
| 563 | + permission: [ |
| 564 | + { |
| 565 | + permission: "question", |
| 566 | + action: "deny", |
| 567 | + pattern: "*", |
| 568 | + }, |
| 569 | + ], |
| 570 | + }), |
569 | 571 | ) |
570 | 572 | subscribeSessionEvents() |
571 | 573 | shareId = await (async () => { |
572 | 574 | if (share === false) return |
573 | 575 | if (!share && repoData.data.private) return |
574 | | - await AppRuntime.runPromise(SessionShare.Service.use((svc) => svc.share(session.id))) |
| 576 | + await Effect.runPromise(sessionShare.share(session.id)) |
575 | 577 | return session.id.slice(-8) |
576 | 578 | })() |
577 | 579 | console.log("opencode session", session.id) |
@@ -944,9 +946,9 @@ export const GithubRunCommand = effectCmd({ |
944 | 946 | async function chat(message: string, files: PromptFiles = []) { |
945 | 947 | console.log("Sending message to opencode...") |
946 | 948 |
|
947 | | - return AppRuntime.runPromise( |
| 949 | + return Effect.runPromise( |
948 | 950 | Effect.gen(function* () { |
949 | | - const prompt = yield* SessionPrompt.Service |
| 951 | + const prompt = sessionPrompt |
950 | 952 | const result = yield* prompt.prompt({ |
951 | 953 | sessionID: session.id, |
952 | 954 | messageID: MessageID.ascending(), |
|