| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent be88cd5 commit af9fdf0
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,10 +18,9 @@ import type { | |||
| 18 | 18 | } from "@octokit/webhooks-types" | |
| 19 | 19 | import { UI } from "../ui" | |
| 20 | 20 | import { cmd } from "./cmd" | |
| 21 | + import { effectCmd } from "../effect-cmd" | ||
| 21 | 22 | import { ModelsDev } from "@/provider/models" | |
| 22 | - import { Instance } from "@/project/instance" | ||
| 23 | - import { WithInstance } from "@/project/with-instance" | ||
| 24 | - import { bootstrap } from "../bootstrap" | ||
| 23 | + import { InstanceRef } from "@/effect/instance-ref" | ||
| 25 | 24 | import { SessionShare } from "@/share/session" | |
| 26 | 25 | import { Session } from "@/session/session" | |
| 27 | 26 | import type { SessionID } from "../../session/schema" | |
@@ -200,13 +199,14 @@ export const GithubCommand = cmd({ | |||
| 200 | 199 | async handler() {}, | |
| 201 | 200 | }) | |
| 202 | 201 | ||
| 203 | - export const GithubInstallCommand = cmd({ | ||
| 202 | + export const GithubInstallCommand = effectCmd({ | ||
| 204 | 203 | command: "install", | |
| 205 | 204 | describe: "install the GitHub agent", | |
| 206 | - async handler() { | ||
| 207 | - await WithInstance.provide({ | ||
| 208 | - directory: process.cwd(), | ||
| 209 | - async fn() { | ||
| 205 | + handler: Effect.fn("Cli.github.install")(function* () { | ||
| 206 | + const maybeCtx = yield* InstanceRef | ||
| 207 | + if (!maybeCtx) return yield* Effect.die("InstanceRef not provided") | ||
| 208 | + const ctx = maybeCtx | ||
| 209 | + yield* Effect.promise(async () => { | ||
| 210 | 210 | { | |
| 211 | 211 | UI.empty() | |
| 212 | 212 | prompts.intro("Install GitHub agent") | |
@@ -254,22 +254,22 @@ export const GithubInstallCommand = cmd({ | |||
| 254 | 254 | } | |
| 255 | 255 | ||
| 256 | 256 | async function getAppInfo() { | |
| 257 | - const project = Instance.project | ||
| 257 | + const project = ctx.project | ||
| 258 | 258 | if (project.vcs !== "git") { | |
| 259 | 259 | prompts.log.error(`Could not find git repository. Please run this command from a git repository.`) | |
| 260 | 260 | throw new UI.CancelledError() | |
| 261 | 261 | } | |
| 262 | 262 | ||
| 263 | 263 | // Get repo info | |
| 264 | 264 | const info = await AppRuntime.runPromise( | |
| 265 | - Git.Service.use((git) => git.run(["remote", "get-url", "origin"], { cwd: Instance.worktree })), | ||
| 265 | + Git.Service.use((git) => git.run(["remote", "get-url", "origin"], { cwd: ctx.worktree })), | ||
| 266 | 266 | ).then((x) => x.text().trim()) | |
| 267 | 267 | const parsed = parseGitHubRemote(info) | |
| 268 | 268 | if (!parsed) { | |
| 269 | 269 | prompts.log.error(`Could not find git repository. Please run this command from a git repository.`) | |
| 270 | 270 | throw new UI.CancelledError() | |
| 271 | 271 | } | |
| 272 | - return { owner: parsed.owner, repo: parsed.repo, root: Instance.worktree } | ||
| 272 | + return { owner: parsed.owner, repo: parsed.repo, root: ctx.worktree } | ||
| 273 | 273 | } | |
| 274 | 274 | ||
| 275 | 275 | async function promptProvider() { | |
@@ -420,12 +420,11 @@ jobs: | |||
| 420 | 420 | prompts.log.success(`Added workflow file: "${WORKFLOW_FILE}"`) | |
| 421 | 421 | } | |
| 422 | 422 | } | |
| 423 | - }, | ||
| 424 | 423 | }) | |
| 425 | - }, | ||
| 424 | + }), | ||
| 426 | 425 | }) | |
| 427 | 426 | ||
| 428 | - export const GithubRunCommand = cmd({ | ||
| 427 | + export const GithubRunCommand = effectCmd({ | ||
| 429 | 428 | command: "run", | |
| 430 | 429 | describe: "run the GitHub agent", | |
| 431 | 430 | builder: (yargs) => | |
@@ -438,8 +437,10 @@ export const GithubRunCommand = cmd({ | |||
| 438 | 437 | type: "string", | |
| 439 | 438 | describe: "GitHub personal access token (github_pat_********)", | |
| 440 | 439 | }), | |
| 441 | - async handler(args) { | ||
| 442 | - await bootstrap(process.cwd(), async () => { | ||
| 440 | + handler: Effect.fn("Cli.github.run")(function* (args) { | ||
| 441 | + const ctx = yield* InstanceRef | ||
| 442 | + if (!ctx) return yield* Effect.die("InstanceRef not provided") | ||
| 443 | + yield* Effect.promise(async () => { | ||
| 443 | 444 | const isMock = args.token || args.event | |
| 444 | 445 | ||
| 445 | 446 | const context = isMock ? (JSON.parse(args.event!) as Context) : github.context | |
@@ -502,21 +503,21 @@ export const GithubRunCommand = cmd({ | |||
| 502 | 503 | : "issue" | |
| 503 | 504 | : undefined | |
| 504 | 505 | const gitText = async (args: string[]) => { | |
| 505 | - const result = await AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: Instance.worktree }))) | ||
| 506 | + const result = await AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: ctx.worktree }))) | ||
| 506 | 507 | if (result.exitCode !== 0) { | |
| 507 | 508 | throw new Process.RunFailedError(["git", ...args], result.exitCode, result.stdout, result.stderr) | |
| 508 | 509 | } | |
| 509 | 510 | return result.text().trim() | |
| 510 | 511 | } | |
| 511 | 512 | const gitRun = async (args: string[]) => { | |
| 512 | - const result = await AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: Instance.worktree }))) | ||
| 513 | + const result = await AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: ctx.worktree }))) | ||
| 513 | 514 | if (result.exitCode !== 0) { | |
| 514 | 515 | throw new Process.RunFailedError(["git", ...args], result.exitCode, result.stdout, result.stderr) | |
| 515 | 516 | } | |
| 516 | 517 | return result | |
| 517 | 518 | } | |
| 518 | 519 | const gitStatus = (args: string[]) => | |
| 519 | - AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: Instance.worktree }))) | ||
| 520 | + AppRuntime.runPromise(Git.Service.use((git) => git.run(args, { cwd: ctx.worktree }))) | ||
| 520 | 521 | const commitChanges = async (summary: string, actor?: string) => { | |
| 521 | 522 | const args = ["commit", "-m", summary] | |
| 522 | 523 | if (actor) args.push("-m", `Co-authored-by: ${actor} <${actor}@users.noreply.github.com>`) | |
@@ -1646,5 +1647,5 @@ query($owner: String!, $repo: String!, $number: Int!) { | |||
| 1646 | 1647 | }) | |
| 1647 | 1648 | } | |
| 1648 | 1649 | }) | |
| 1649 | - }, | ||
| 1650 | + }), | ||
| 1650 | 1651 | }) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments